nvim/lua/plugins/treesitter.lua

55 lines
1.7 KiB
Lua
Raw Normal View History

2023-12-04 09:24:43 +01:00
return {
'nvim-treesitter/nvim-treesitter',
-- lazy = false,
dependencies = { 'rush-rs/tree-sitter-asm' },
2023-12-04 09:24:43 +01:00
-- dependencies = 'windwp/nvim-ts-autotag',
event = 'VeryLazy',
keys = {
{ '<leader>v', desc = 'start incremental selection' },
{ '<leader>h', '<cmd>TSBufToggle highlight<cr>', desc = 'toggle TS highlight' },
},
-- init = function(plugin)
-- require('lazy.core.loader').add_to_rtp(plugin)
-- require 'nvim-treesitter.query_predicates'
-- end,
2023-12-04 09:24:43 +01:00
config = function()
require('nvim-treesitter.parsers').get_parser_configs().asm = {
install_info = {
url = 'https://github.com/rush-rs/tree-sitter-asm.git',
files = { 'src/parser.c' },
branch = 'main',
},
}
local configs = require 'nvim-treesitter.configs'
configs.setup {
ignore_install = { 'haskell' },
ensure_installed = { 'c', 'rust', 'lua', 'vim', 'vimdoc', 'cpp', 'go' },
auto_install = true,
2023-12-04 09:24:43 +01:00
highlight = {
enable = true, -- false will disable the whole extension
},
incremental_selection = {
enable = true,
keymaps = {
init_selection = '<leader>s',
node_incremental = '<Space>',
scope_incremental = false,
node_decremental = '<S-Space>',
},
},
-- Or use a function for more flexibility, e.g. to disable slow treesitter highlight for large files
disable = function(_, buf)
local max_filesize = 300 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
2023-12-04 09:24:43 +01:00
-- context_commentstring = { enable = true, config = { css = '// %s' } },
indent = { enable = true },
2023-12-04 09:24:43 +01:00
-- autotag = { enable = true },
}
end,
}