diff --git a/home/.config/nvim/plugin/treesitter.lua b/home/.config/nvim/plugin/treesitter.lua index 37971ec84..8b51aa8bf 100644 --- a/home/.config/nvim/plugin/treesitter.lua +++ b/home/.config/nvim/plugin/treesitter.lua @@ -1,7 +1,15 @@ -vim.opt.foldmethod = "expr" -vim.opt.foldexpr = "nvim_treesitter#foldexpr()" --- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file -vim.opt.foldlevelstart = 99 +vim.api.nvim_create_autocmd("FileType", { + -- TODO: in nvim-treesitter 1.0 this is require("nvim-treesitter.config") + pattern = require("nvim-treesitter.info").installed_parsers(), + callback = function() + vim.treesitter.start() + vim.wo.foldexpr = "v:lua.vim.treesitter.foldexpr()" + vim.bo.foldmethod = "expr" + -- https://stackoverflow.com/questions/8316139/how-to-set-the-default-to-unfolded-when-you-open-a-file + vim.bo.foldlevelstart = 99 + vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()" + end, +}) -- https://alpha2phi.medium.com/neovim-101-tree-sitter-usage-fa3e8bed921a local swap_next, swap_prev = (function() @@ -23,32 +31,12 @@ end)() require("nvim-treesitter.configs").setup({ -- ensure_installed = "maintained", -- one of "all", "maintained" (parsers with maintainers), or a list of languages -- This is handled by the Makefile - -- ensure_installed = require('treesitter').langs, - highlight = { - enable = true, -- false will disable the whole extension - }, matchup = { enable = true, -- mandatory, false will disable the whole extension }, endwise = { enable = true, }, - incremental_selection = { - enable = true, - keymaps = { - -- this is also done by treeclimber - init_selection = "", -- alternatives: , , currently: (treeclimber) - scope_incremental = "", -- alternatives: , - node_incremental = "", -- alternatives: , , currently: (treeclimber) - node_decremental = "", -- alternatives: , , currently: (treeclimber) - }, - }, - indent = { enable = true }, - playground = { - enable = true, - updatetime = 25, -- Debounced time for highlighting nodes in the playground from source code - persist_queries = false, -- Whether the query persists across vim sessions - }, textobjects = { select = { enable = true, @@ -100,5 +88,4 @@ require("nvim-treesitter.configs").setup({ }, }, }, - context_commentstring = { enable = true }, })