diff options
Diffstat (limited to 'lua/talha/plugins/treesitter.lua')
| -rw-r--r-- | lua/talha/plugins/treesitter.lua | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/lua/talha/plugins/treesitter.lua b/lua/talha/plugins/treesitter.lua index 53d3ca0..7cf6c38 100644 --- a/lua/talha/plugins/treesitter.lua +++ b/lua/talha/plugins/treesitter.lua @@ -1,22 +1,28 @@ return { { "nvim-treesitter/nvim-treesitter", + branch = "main", lazy = false, build = ":TSUpdate", config = function () - local configs = require("nvim-treesitter.configs") + local ts = require("nvim-treesitter") - configs.setup({ - ensure_installed = { - "c", "cpp", "python", - "vim", "vimdoc", "query", - }, - sync_install = false, - highlight = { - enable = true, - additional_vim_regex_highlighting = false, - }, - indent = { enable = true }, + -- 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 } |
