--[ -- It's treesitter, I should check how it works ! -- -- The goal of nvim-treesitter is both to provide a simple and easy way to use the interface for tree-sitter in Neovim and to provide some basic functionality such as highlighting based on it: -- -- -- Treesitter uses a different parser for every language, which needs to be generated via tree-sitter-cli from a grammar.js file, then compiled to a .so library that needs to be placed in neovim's runtimepath (typically under parser/{language}.so). To simplify this, nvim-treesitter provides commands to automate this process. If the language is already supported by nvim-treesitter, you can install it with :TSinstall --] return { "nvim-treesitter/nvim-treesitter", enabled = true, event = { "BufReadPre", "BufNewFile" }, build = ":TSUpdate", -- dependencies = { -- "windwp/nvim-ts-autotag", -- }, config = function() local treesitter = require("nvim-treesitter.configs") treesitter.setup({ modules = {}, ignore_install = { "" }, sync_install = false, highlight = { enable = true, additional_vim_regex_highlighting = false, -- disable = {"rust", "python", "lua", "markdown"}, }, indent = { enable = true, disable = {}, }, -- TODO: Install nvim-ts-autotag -- autotag = { -- With nvim-ts-autotag plugin -- enable = true, -- }, --[[ rainbow = { enable = true, extended_mode = true, max_file_lines = nil, }, --]] ensure_installed = { "rust", "go", "html", "python", "ocaml", "json", "javascript", "svelte", "typescript", "tsx", "yaml", "css", "lua", -- "mchat", -- { "mchat", "gsuuon/tree-sitter-mchat" }, "toml", }, auto_install = true, incremental_selection = { enable = true, keymaps = { init_selection = "", node_incremental = "", scope_incremental = false, node_decremental = "", }, }, }) -- require("nvim-ts-autotag").setup({ -- opts = { -- -- Defaults -- enable_close = true, -- Auto close tags -- enable_rename = true, -- Auto rename pairs of tags -- enable_close_on_slash = false, -- Auto close on trailing z", function() vim.cmd([[set foldexpr=nvim_treesitter#foldexpr()]]) end, { desc = "Refresh folding from Treesitter" }) -- Use treesitter for auto-fold -- Create an autocommand for "BufRead" events vim.api.nvim_create_autocmd("FileType", { -- This autocommand will only trigger if the buffer name matches the following patterns -- pattern = { "*.yaml", "*.yml" }, -- The autocommand will trigger the following lua function callback = function() local parsers = require("nvim-treesitter.parsers") if parsers.has_parser() then vim.wo.foldmethod = "expr" vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" vim.wo.foldlevel = 9 else vim.wo.foldmethod = "syntax" end end, }) end, }