aboutsummaryrefslogtreecommitdiffstats
path: root/.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua
diff options
context:
space:
mode:
authorEugene Triguba <hello@eugenetriguba.com>2026-10-17 10:40:11 -0700
committerEugene Triguba <hello@eugenetriguba.com>2026-10-17 10:40:11 -0700
commitea127689e0ae2d39b49004be605e541ff80e2621 (patch)
treeabbe79e5e37792bd8ebea8f9ac788ff5b8aed704 /.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua
downloadopenbsd-dotfiles-ea127689e0ae2d39b49004be605e541ff80e2621.zip
Initial Commit
Diffstat (limited to '.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua')
-rw-r--r--.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua62
1 files changed, 62 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..e01cfa4
--- /dev/null
+++ b/.config/nvim/lua/eugenetriguba/plugins/tree-sitter.lua
@@ -0,0 +1,62 @@
+-- Treesitter adds understanding of the source code text
+-- (e.g. fields, methods, classes). nvim has built-in support
+-- for tree-sitter, however, nvim-treesitter makes it easier
+-- to automatically install tree-sitter parser files for each
+-- language.
+
+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,
+})
+
+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',
+ },
+}
+
+local langs = {
+ 'bash',
+ 'c',
+ 'commonlisp',
+ 'css',
+ 'hcl',
+ 'html',
+ 'javascript',
+ 'json',
+ 'lua',
+ 'make',
+ 'python',
+ 'sh',
+ 'sql',
+ 'tsx',
+ 'typescript',
+ 'yaml',
+}
+
+require 'nvim-treesitter'.install { ensure_installed = langs }
+
+vim.api.nvim_create_autocmd('FileType', {
+ pattern = langs,
+ callback = function()
+ vim.treesitter.start()
+ vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
+ end,
+})
+
+require('treesitter-context').setup { multiline_threshold = 10}
+