Skip to content

Commit

Permalink
fix(neovim): deprecated treesitter features
Browse files Browse the repository at this point in the history
  • Loading branch information
perrin4869 committed Nov 20, 2023
1 parent 0cd9d60 commit bdff3ad
Showing 1 changed file with 12 additions and 25 deletions.
37 changes: 12 additions & 25 deletions home/.config/nvim/plugin/treesitter.lua
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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 = "<M-w>", -- alternatives: <M-w>, <CR>, currently: <M-j> (treeclimber)
scope_incremental = "<M-e>", -- alternatives: <M-e>, <CR>
node_incremental = "<M-w>", -- alternatives: <M-w>, <TAB>, currently: <M-j> (treeclimber)
node_decremental = "<M-C-w>", -- alternatives: <M-C-w>, <S-TAB>, currently: <M-k> (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,
Expand Down Expand Up @@ -100,5 +88,4 @@ require("nvim-treesitter.configs").setup({
},
},
},
context_commentstring = { enable = true },
})

0 comments on commit bdff3ad

Please sign in to comment.