|
1 | 1 | return { |
2 | 2 | "nvim-treesitter/nvim-treesitter", |
3 | | - -- TODO: master is deprecated but treesitter-endwise does not work with main branch |
4 | | - branch = "master", |
| 3 | + branch = "main", |
5 | 4 | build = ":TSUpdate", |
6 | 5 | event = { "BufReadPost", "BufNewFile" }, |
| 6 | + cmd = { "TSUpdate", "TSInstall", "TSLog", "TSUninstall" }, |
7 | 7 | opts = { |
| 8 | + indent = { enable = true }, |
| 9 | + highlight = { enable = true }, |
| 10 | + folds = { enable = true }, |
| 11 | + endwise = { enable = true }, |
8 | 12 | ensure_installed = { |
9 | 13 | "bash", |
10 | 14 | "bicep", |
@@ -35,23 +39,19 @@ return { |
35 | 39 | }, |
36 | 40 | dependencies = { |
37 | 41 | "RRethy/nvim-treesitter-endwise", -- mainly for Lua 'closing end' insertion |
38 | | - { "nvim-mini/mini.ai", event = { "BufReadPre", "BufNewFile" }, opts = {} }, |
39 | | - -- "windwp/nvim-ts-autotag", |
| 42 | + { "nvim-mini/mini.ai", event = { "BufReadPre", "BufNewFile" }, opts = {} }, -- for q (quotes), b (brackets), t (tags) |
40 | 43 | }, |
41 | 44 | config = function(_, opts) |
42 | | - ---@diagnostic disable-next-line: missing-fields |
43 | | - require("nvim-treesitter.configs").setup({ |
44 | | - ensure_installed = opts.ensure_installed, |
45 | | - highlight = { |
46 | | - enable = true, |
47 | | - }, |
48 | | - endwise = { |
49 | | - enable = true, |
50 | | - }, |
51 | | - indent = { enable = true }, |
52 | | - autopairs = { enable = true }, |
53 | | - }) |
| 45 | + local ts = require("nvim-treesitter") |
| 46 | + |
| 47 | + for _, parser in ipairs(opts.ensure_installed) do |
| 48 | + pcall(ts.install, parser) |
| 49 | + end |
54 | 50 |
|
55 | | - -- require("nvim-ts-autotag").setup() |
| 51 | + vim.api.nvim_create_autocmd("FileType", { |
| 52 | + callback = function() |
| 53 | + pcall(vim.treesitter.start) |
| 54 | + end, |
| 55 | + }) |
56 | 56 | end, |
57 | 57 | } |
0 commit comments