diff options
| author | Eugene Triguba <hello@eugenetriguba.com> | 2025-12-20 10:53:14 -0500 |
|---|---|---|
| committer | Eugene Triguba <hello@eugenetriguba.com> | 2025-12-20 10:54:02 -0500 |
| commit | 7b6dbb921650e2a52929f025b67be57609fda6d4 (patch) | |
| tree | 895416312698cfe4ac61d4eed0f071d7743c0214 /.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua | |
| parent | Remove openbsd conditional in zsh (diff) | |
| download | dotfiles-7b6dbb921650e2a52929f025b67be57609fda6d4.zip | |
Rework dotfiles to *only* contain dotfiles
Diffstat (limited to '.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua')
| -rw-r--r-- | .config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua b/.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua new file mode 100644 index 0000000..322f475 --- /dev/null +++ b/.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua @@ -0,0 +1,45 @@ +-- Treesitter adds understanding of the source code text (e.g. fields, methods, +-- classes) +vim.pack.add { + { + name = 'nvim-treesitter', + src = 'https://github.com/nvim-treesitter/nvim-treesitter', + version = 'main', + }, + { + name = 'nvim-treesitter-context', + src = 'https://github.com/nvim-treesitter/nvim-treesitter-context', + }, +} + +-- Install parsers +require('nvim-treesitter').setup { + ensure_installed = 'all', + auto_install = true, + ignore_install = { 'norg', 'org', 'ipkg', 'verilog' }, +} + +-- Enable treesitter highlighting for all buffers +vim.api.nvim_create_autocmd('FileType', { + callback = function(args) + -- Start treesitter highlighting if a parser is available + pcall(vim.treesitter.start, args.buf) + end, +}) + +require('treesitter-context').setup { + multiline_threshold = 10, +} + +vim.api.nvim_create_autocmd('PackChanged', { + callback = function(event) + local name, kind = event.data.spec.name, event.data.kind + if name == 'nvim-treesitter' and (kind == 'update' or kind == 'install') then + vim.schedule(function() + -- If nvim-treesitter was updated, run ':TSUpdate' to + -- ensure the installed parsers are also updated. + vim.cmd 'TSUpdate all' + end) + end + end, +}) |