summaryrefslogtreecommitdiff
path: root/.config/nvim/lua/plugins/nvim-treesitter.lua
blob: 39184cfdd87cd8b2562821d5e68ca8147cee7b95 (plain)
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
return {
    'nvim-treesitter/nvim-treesitter',
    build = ':TSUpdate',
    config = function()
        ---@type userdata
        ---@diagnostic disable-next-line: missing-fields
        require('nvim-treesitter.configs').setup({
            auto_install = true,
            highlight = { enable = true },
            indent = { enable = true },
            rainbow = {
                enable = true,
                extended_mode = true,
                max_file_lines = nil,
            },
        })

        -- HACK: Workaround to have syntax highlighting in zsh until a zsh parser is added
        -- https://github.com/nvim-treesitter/nvim-treesitter/issues/655
        local ft_to_lang = require('nvim-treesitter.parsers').ft_to_lang
        ---@diagnostic disable-next-line: duplicate-set-field
        require('nvim-treesitter.parsers').ft_to_lang = function(ft)
            if ft == 'zsh' then
                return 'bash'
            end
            return ft_to_lang(ft)
        end
    end,
}