55 lines
1.7 KiB
Lua
55 lines
1.7 KiB
Lua
return {
|
|
'nvim-treesitter/nvim-treesitter',
|
|
-- lazy = false,
|
|
dependencies = { 'rush-rs/tree-sitter-asm' },
|
|
-- dependencies = 'windwp/nvim-ts-autotag',
|
|
event = 'VeryLazy',
|
|
keys = {
|
|
{ '<leader>s', 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,
|
|
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,
|
|
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,
|
|
-- context_commentstring = { enable = true, config = { css = '// %s' } },
|
|
indent = { enable = true },
|
|
-- autotag = { enable = true },
|
|
}
|
|
end,
|
|
}
|