| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- -- 1. Use the configs module if it exists, otherwise use the new core
- local ok, configs = pcall(require, "nvim-treesitter.configs")
- if ok then
- -- If you are on a version that still has configs
- configs.setup({
- ensure_installed = {
- "c",
- "lua",
- "java",
- "python",
- "bash",
- "html",
- "css",
- "javascript",
- "bibtex",
- "cmake",
- "cpp",
- "latex",
- "perl",
- "regex",
- "toml",
- "yaml"
- },
- highlight = { enable = true },
- })
- else
- -- THE NEW WAY: If configs is missing, use the internal install module
- local install = require('nvim-treesitter.install')
-
- -- This replaces ensure_installed
- install.prefer_git = true
- -- To install specific parsers via code:
- -- require('nvim-treesitter.command').smart_install({ "lua", "python" })
-
- -- Enable highlighting globally the new Neovim way
- vim.api.nvim_create_autocmd('FileType', {
- callback = function()
- local lang = vim.treesitter.language.get_lang(vim.bo.filetype)
- if lang then
- pcall(vim.treesitter.start)
- end
- end,
- })
- end
- -- local ts = require('nvim-treesitter')
- -- -- 1. Manually install parsers (replaces ensure_installed)
- -- ts.install({
- -- "c",
- -- "lua",
- -- "java",
- -- "python",
- -- "bash",
- -- "html",
- -- "css",
- -- "javascript",
- -- "bibtex",
- -- "cmake",
- -- "cpp",
- -- "latex",
- -- "perl",
- -- "regex",
- -- "toml",
- -- "yaml"
- -- })
- -- -- 2. Enable Highlighting (Now done via Neovim API, not Treesitter setup)
- -- vim.api.nvim_create_autocmd('FileType', {
- -- callback = function()
- -- pcall(vim.treesitter.start)
- -- end,
- -- })
- -- require'nvim-treesitter.configs'.setup {
- -- ensure_installed = {
- -- "c",
- -- "lua",
- -- "java",
- -- "python",
- -- "bash",
- -- "html",
- -- "css",
- -- "javascript",
- -- "bibtex",
- -- "cmake",
- -- "cpp",
- -- "latex",
- -- "perl",
- -- "regex",
- -- "toml",
- -- "yaml"
- -- },
- -- -- Install parsers synchronously (only applied to `ensure_installed`)
- -- sync_install = false,
- -- highlight = {
- -- enable = true,
- -- disable = {"rust"},
- -- -- Set this to `true` if you depend on 'syntax' being enabled (like for indentation).
- -- -- Using this option may slow down your editor, and you may see some duplicate highlights.
- -- additional_vim_regex_highlighting = false,
- -- },
- -- refactor = {
- -- highlight_definitions = {
- -- enable = true,
- -- -- Set to false if you have an `updatetime` of ~100.
- -- clear_on_cursor_move = false,
- -- },
- -- highlight_current_scope = {
- -- -- very annonying per default, maybe has its use when its unclear
- -- enable = false
- -- },
- -- smart_rename = {
- -- enable = true,
- -- keymaps = {
- -- smart_rename = "grr",
- -- },
- -- },
- -- navigation = {
- -- enable = true,
- -- keymaps = {
- -- goto_definition = "gnd",
- -- list_definitions = "gnD",
- -- list_definitions_toc = "gO",
- -- goto_next_usage = "<A-n>",
- -- goto_previous_usage = "<A-p>",
- -- },
- -- },
- -- },
- -- }
|