- commit
- fd73e54
- parent
- 61e6b09
- author
- Eric bower
- date
- 2025-07-17 10:11:34 -0400 EDT
refactor(nvim): fix `main` nvim-treesitter config
1 files changed,
+49,
-50
+49,
-50
1@@ -57,54 +57,6 @@ if not (vim.uv or vim.loop).fs_stat(lazypath) then
2 end
3 vim.opt.rtp:prepend(lazypath)
4
5-function setup_treesitter()
6- ft_opts = {
7- "bash",
8- "c",
9- "dockerfile",
10- "fish",
11- "git_config",
12- "git_rebase",
13- "gitattributes",
14- "gitcommit",
15- "gitignore",
16- "go",
17- "gomod",
18- "gosum",
19- "html",
20- "javascript",
21- "json",
22- "lua",
23- "make",
24- "markdown",
25- "python",
26- "rust",
27- "sql",
28- "toml",
29- "tsx",
30- "typescript",
31- "typst",
32- "vim",
33- "yaml",
34- "zig",
35- }
36- require'nvim-treesitter'.install(ft_opts)
37-
38- autocmd("FileType", {
39- desc = "enable tree-sitter syntax highlighting",
40- pattern = ft_opts,
41- callback = function() vim.treesitter.start() end,
42- })
43-
44- autocmd("FileType", {
45- desc = "enable tree-sitter indentation",
46- pattern = ft_opts,
47- callback = function(event)
48- vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
49- end,
50- })
51-end
52-
53 function setup_lsp()
54 map('n', '<leader>e', vim.diagnostic.open_float, opts)
55 map('n', '<leader>q', vim.diagnostic.setloclist, opts)
56@@ -164,6 +116,37 @@ function setup_lsp()
57 handler("zls")
58 end
59
60+local ts_parsers = {
61+ "bash",
62+ "c",
63+ "dockerfile",
64+ "fish",
65+ "git_config",
66+ "git_rebase",
67+ "gitattributes",
68+ "gitcommit",
69+ "gitignore",
70+ "go",
71+ "gomod",
72+ "gosum",
73+ "html",
74+ "javascript",
75+ "json",
76+ "lua",
77+ "make",
78+ "markdown",
79+ "python",
80+ "rust",
81+ "sql",
82+ "toml",
83+ "tsx",
84+ "typescript",
85+ "typst",
86+ "vim",
87+ "yaml",
88+ "zig",
89+}
90+
91 require("lazy").setup({
92 rocks = { enabled = false },
93 performance = {
94@@ -180,8 +163,24 @@ require("lazy").setup({
95 'nvim-treesitter/nvim-treesitter',
96 branch = 'main',
97 lazy = false,
98- build = ':TSUpdate',
99- config = setup_treesitter,
100+ -- https://github.com/nvim-treesitter/nvim-treesitter/discussions/7894#discussioncomment-13296403
101+ build = function()
102+ require("nvim-treesitter").install(ts_parsers)
103+ require("nvim-treesitter").update()
104+ end,
105+ init = function()
106+ vim.api.nvim_create_autocmd("FileType", {
107+ callback = function(args)
108+ local filetype = args.match
109+ local lang = vim.treesitter.language.get_lang(filetype)
110+ if vim.treesitter.language.add(lang) then
111+ -- vim.wo.foldexpr = 'v:lua.vim.treesitter.foldexpr()'
112+ vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
113+ vim.treesitter.start()
114+ end
115+ end
116+ })
117+ end,
118 },
119 {
120 "nvim-treesitter/nvim-treesitter-context",