Rewrite nvim-treesitter config for new main-branch API

The nvim-treesitter rewrite removed nvim-treesitter.configs entirely.
Now uses require('nvim-treesitter').install() and a FileType autocmd
for dynamic attach, mirroring current kickstart.nvim.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-22 10:55:14 -04:00
parent fe673c846d
commit 4896eb8f60

View File

@@ -257,17 +257,36 @@ require('lazy').setup({
-------------------------------------------------------------------------- --------------------------------------------------------------------------
{ {
'nvim-treesitter/nvim-treesitter', 'nvim-treesitter/nvim-treesitter',
build = ':TSUpdate', lazy = false,
build = ':TSUpdate',
branch = 'main',
config = function() config = function()
require('nvim-treesitter.configs').setup({ local parsers = { 'bash', 'json', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'vim', 'vimdoc', 'yaml' }
ensure_installed = (function() vim.list_extend(parsers, _lang.parsers or {})
local t = { 'bash', 'json', 'lua', 'luadoc', 'markdown', 'markdown_inline', 'vim', 'vimdoc', 'yaml' } require('nvim-treesitter').install(parsers)
vim.list_extend(t, _lang.parsers or {})
return t local function try_attach(buf, lang)
end)(), if not vim.treesitter.language.add(lang) then return end
auto_install = true, vim.treesitter.start(buf, lang)
highlight = { enable = true }, if vim.treesitter.query.get(lang, 'indents') then
indent = { enable = true }, vim.bo.indentexpr = "v:lua.require'nvim-treesitter'.indentexpr()"
end
end
local available = require('nvim-treesitter').get_available()
vim.api.nvim_create_autocmd('FileType', {
callback = function(args)
local lang = vim.treesitter.language.get_lang(args.match)
if not lang then return end
local installed = require('nvim-treesitter').get_installed 'parsers'
if vim.tbl_contains(installed, lang) then
try_attach(args.buf, lang)
elseif vim.tbl_contains(available, lang) then
require('nvim-treesitter').install(lang):await(function() try_attach(args.buf, lang) end)
else
try_attach(args.buf, lang)
end
end,
}) })
end, end,
}, },