Files
.dotfiles/.config/nvim/lua/plugin/nvim-treesitter.lua
Quinn 5b63e518b3 Include markdown and markdown_inline in pre-installed, since those are very likely unavoidable.
I use Markdown rendering for comment strings, or something like that,
hence this is probably good to have pre-emptively.
2026-01-27 00:57:27 +01:00

39 lines
1.0 KiB
Lua

---@module 'lazy'
---@type LazySpec
return { {
'nvim-treesitter/nvim-treesitter', -- highlight, edit, and navigate code
build = ':TSUpdate',
lazy = false,
config = function()
-- Pre-install a few languages we're (very) likely going to use
local ts = require('nvim-treesitter')
ts.install({
'c', 'make',
'bash', 'gitignore', 'editorconfig',
'ini', 'json', 'yaml',
'markdown', 'markdown_inline',
})
-- Define aliases for entries that lack an entry, but should have one.
local alias = {
{ 'sh', 'bash' },
}
local pat = vim.iter(alias):map(function(a) return a[1] end):totable()
vim.list_extend(pat, ts.get_available())
Autocmd('FileType', {
pattern = pat,
callback = function(arg)
local a = vim.iter(alias)
:find(function(a) return arg.match == a[1] end)
if not a then -- Ensure we only install if an alias was found
require('nvim-treesitter').install(vim.bo.ft)
pcall(vim.treesitter.start)
return
end
vim.bo.ft = a[2] -- Retriggers function
end
})
end,
} }