summaryrefslogtreecommitdiff
path: root/lua/talha/plugins/treesitter.lua
blob: 7cf6c38fff1ad7787d5474f0641fae4b9be12125 (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", 
        branch = "main",
        lazy = false,
        build = ":TSUpdate",
        config = function ()
            local ts = require("nvim-treesitter")

            -- Automatically install your specified parsers
            ts.install({
              "c", "cpp", "python",
              "vim", "vimdoc", "query"
            })

            -- Enable highlighting and indentation using Neovim's built-in APIs
            vim.api.nvim_create_autocmd("FileType", {
              pattern = { "*.yml", "*.sql", "Dockerfile*", "CMakeLists*", "*.py", "*.c", "*.cpp", "*.h", "*.hpp" },
              callback = function()
                -- Replaces highlight = { enable = true }
                vim.treesitter.start()

                -- Replaces indent = { enable = true }
                vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
              end,
            })
        end
    }
}