summary refs log tree commit diff
path: root/.config/nvim/lua/plugins/treesitter.lua
blob: e064a8b10b30a88b4a9e069fa49fb9048e5cfd07 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
return {
  {
    'nvim-treesitter/nvim-treesitter',
    branch = 'master',
    lazy = false,
    dependencies = {
      { 'nvim-treesitter/nvim-treesitter-refactor', lazy = false },
      { 'nvim-treesitter/nvim-treesitter-textobjects', lazy = false },
      -- { 'nvim-treesitter/playground', cmd = { 'TSPlayground' } },
    },
    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',
          },
        },
      },
    },
  },
}