summary refs log tree commit diff
path: root/.config/nvim/lua/plugins/treesitter.lua
diff options
context:
space:
mode:
authorRobert Günzler <r@gnzler.io>2026-02-10 12:32:48 +0100
committerRobert Günzler <r@gnzler.io>2026-02-10 12:41:25 +0100
commit63feeb9f369fc6176e85c1c2d8fcc863caad1946 (patch)
tree41cd5d2d1ec36e74e464caab722cc9b460153f04 /.config/nvim/lua/plugins/treesitter.lua
parent5bd0a4aca65ecb9818ef1285982d160b6b6ff665 (diff)
start new
Signed-off-by: Robert Günzler <r@gnzler.io>
Diffstat (limited to '.config/nvim/lua/plugins/treesitter.lua')
-rw-r--r--.config/nvim/lua/plugins/treesitter.lua93
1 files changed, 93 insertions, 0 deletions
diff --git a/.config/nvim/lua/plugins/treesitter.lua b/.config/nvim/lua/plugins/treesitter.lua
new file mode 100644
index 0000000..93f396d
--- /dev/null
+++ b/.config/nvim/lua/plugins/treesitter.lua
@@ -0,0 +1,93 @@
+return {
+  {
+    'nvim-treesitter/nvim-treesitter',
+    branch = 'master',
+    dependencies = {
+      { 'nvim-treesitter/nvim-treesitter-refactor', lazy = false },
+      { 'nvim-treesitter/nvim-treesitter-textobjects', lazy = false },
+      -- { 'nvim-treesitter/playground', cmd = { 'TSPlayground' } },
+    },
+    lazy = false,
+    build = ':TSUpdate',
+    config = function(_, opts)
+      require('nvim-treesitter.configs').setup(opts)
+
+      -- use bash parser for gentoo ebuilds
+      vim.treesitter.language.register('bash', 'ebuild')
+    end,
+    opts = {
+      ensure_installed = {
+        'bash',
+        'c',
+        'cmake',
+        'comment',
+        'cpp',
+        'css',
+        'dockerfile',
+        'go',
+        'gomod',
+        'gotmpl',
+        'gowork',
+        'html',
+        'javascript',
+        'json',
+        'jsonc',
+        'lua',
+        'make',
+        'markdown',
+        'markdown_inline',
+        'ninja',
+        'python',
+        'regex',
+        'rust',
+        'scss',
+        'sql',
+        'todotxt',
+        'toml',
+        'typescript',
+        'typst',
+        'vim',
+        'vimdoc',
+        'yaml',
+        'zig',
+      },
+      highlight = {
+        enable = true,
+        additional_vim_regex_highlighting = { 'markdown' },
+      },
+      indent = {
+        enable = true,
+      },
+      refactor = {
+        navigation = {
+          enable = true,
+        },
+        smart_rename = {
+          enable = true,
+        },
+      },
+      textobjects = {
+        select = {
+          enable = true,
+          keymaps = {
+            ['ib'] = '@block.inner',
+            ['ab'] = '@block.outer',
+            -- ['ic'] = '@conditional.inner',
+            -- ['ac'] = '@conditional.outer',
+            ['if'] = '@function.inner',
+            ['af'] = '@function.outer',
+            ['il'] = '@loop.inner',
+            ['al'] = '@loop.outer',
+            ['is'] = '@scopename.inner',
+            ['as'] = '@scopename.outer',
+            ['ic'] = '@comment.inner',
+            ['ac'] = '@comment.outer',
+          },
+          selection_mode = {
+            ['@comment.outer'] = 'V',
+          },
+        },
+      },
+    },
+  },
+}