1
0
Fork 0
mirror of https://github.com/pnx/dotfiles synced 2026-08-15 16:38:13 +02:00

nvim/lua/user/plugins/editor/treesitter.lua: switch to tree-sitter-manager

This commit is contained in:
Henrik Hautakoski 2026-07-03 17:24:58 +02:00
parent 665fb375b0
commit e4b7184d75
19 changed files with 88 additions and 140 deletions

View file

@ -1,27 +1,23 @@
return {
"nvim-treesitter/nvim-treesitter",
commit = "4916d6592ede8c07973490d9322f187e07dfefac",
pin = true,
"romus204/tree-sitter-manager.nvim",
dependencies = {
'windwp/nvim-ts-autotag',
'nvim-treesitter/nvim-treesitter-textobjects'
},
build = function()
require("nvim-treesitter.install").update({ with_sync = true })
end,
opts_extend = { "install", "alias" },
opts_extend = { "ensure_installed", "alias" },
opts = {
-- Default parsers.
install = {
ensure_installed = {
-- VIM stuff
"vim",
"vimdoc",
"query",
-- Common config languages
-- Common data formats
"json",
"yaml",
"toml",
"dtd",
"xml",
"kdl",
@ -37,45 +33,26 @@ return {
"re2c",
"xresources",
"sql",
"tsv",
"csv",
"ssh_config",
"printf",
"nginx",
},
alias = {
dotenv = "env"
}
},
config = function(_, opts)
local ts = require("nvim-treesitter")
vim.api.nvim_create_autocmd('User', { pattern = 'TSUpdate', callback = function ()
require("nvim-treesitter.parsers").dotenv = {
languages = {
dotenv = {
install_info = {
url = "https://github.com/pnx/tree-sitter-dotenv",
branch = "main",
files = { "src/parser.c", "src/scanner.c" },
files = { "src/parser.c", "src/scanner.c" }
}
}
end})
for _, value in pairs(opts.install) do
vim.treesitter.language.register(value, value)
end
for k, v in pairs(opts.alias) do
},
},
config = function(_, opts)
for k, v in pairs(opts.alias or {}) do
vim.treesitter.language.register(v, k)
end
vim.api.nvim_create_autocmd('FileType', {
callback = function(ev)
local lang = vim.treesitter.language.get_lang(ev.match)
if vim.list_contains(ts.get_installed(), lang) then
vim.treesitter.start(ev.buf)
end
end,
})
ts.install(opts.install)
ts.setup(opts)
require("tree-sitter-manager").setup(opts)
end
}

View file

@ -1,10 +1,7 @@
local spec = require('user.utils.lang_spec')
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "bash" }
}
},
spec.treesitter("bash"),
{
"neovim/nvim-lspconfig",
opts = {

View file

@ -1,10 +1,7 @@
local spec = require('user.utils.lang_spec')
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "c", "cpp" }
}
},
spec.treesitter("c", "cpp"),
{
"neovim/nvim-lspconfig",
opts = {

View file

@ -1,8 +1,5 @@
local spec = require('user.utils.lang_spec')
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "cmake" }
}
},
spec.treesitter("cmake"),
}

View file

@ -1,10 +1,7 @@
local spec = require('user.utils.lang_spec')
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "css", "scss" }
}
},
spec.treesitter("css", "scss"),
{
"neovim/nvim-lspconfig",
opts = {

View file

@ -1,8 +1,5 @@
local spec = require('user.utils.lang_spec')
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "dockerfile" }
}
},
spec.treesitter("dockerfile"),
}

View file

@ -1,3 +1,5 @@
local spec = require('user.utils.lang_spec')
local lspservers = {
gopls = {
codelens = {
@ -49,12 +51,7 @@ local lspservers = {
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "go", "gomod", "gowork", "gosum", "gotmpl" }
}
},
spec.treesitter("go", "gomod", "gowork", "gosum", "gotmpl"),
{
"neovim/nvim-lspconfig",
opts = {

View file

@ -1,10 +1,7 @@
local spec = require('user.utils.lang_spec')
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "html" }
}
},
spec.treesitter("html"),
{
"neovim/nvim-lspconfig",
opts = {

View file

@ -1,8 +1,5 @@
local spec = require('user.utils.lang_spec')
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "javascript", "javadoc" }
}
}
spec.treesitter("javascript", "javadoc"),
}

View file

@ -1,3 +1,5 @@
local spec = require('user.utils.lang_spec')
local lspservers = {
lua_ls = {
settings = {
@ -18,12 +20,7 @@ local lspservers = {
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "lua" }
}
},
spec.treesitter("lua"),
{
"neovim/nvim-lspconfig",
opts = {

View file

@ -1,14 +1,11 @@
local spec = require('user.utils.lang_spec')
return {
'MeanderingProgrammer/render-markdown.nvim',
ft = { "markdown" },
dependencies = {
'nvim-tree/nvim-web-devicons',
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "markdown" }
}
},
spec.treesitter("markdown"),
{
"windwp/nvim-ts-autotag",
optional = true,

View file

@ -1,8 +1,5 @@
local spec = require('user.utils.lang_spec')
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "ninja" }
}
},
spec.treesitter("ninja"),
}

View file

@ -1,11 +1,8 @@
local spec = require('user.utils.lang_spec')
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "php", "blade", "php_only", "phpdoc", "sql", "csv" },
alias = { phpx = "php_only" }
}
},
spec.treesitter("php", "blade", "php_only", "phpdoc", "sql", "csv"),
spec.treesitter_alias({ phpx = "php_only" }),
{
"windwp/nvim-ts-autotag",
optional = true,

View file

@ -1,14 +1,11 @@
local spec = require('user.utils.lang_spec')
local lspservers = {
qmlls = {}
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "qmljs" }
}
},
spec.treesitter("qmljs"),
{
"neovim/nvim-lspconfig",
opts = {

View file

@ -1,3 +1,5 @@
local spec = require('user.utils.lang_spec')
local lspservers = {
rust_analyzer = {
-- settings = {
@ -22,12 +24,7 @@ local lspservers = {
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "rust", "toml" }
}
},
spec.treesitter("rust", "toml"),
{
"neovim/nvim-lspconfig",
opts = {

View file

@ -1,14 +1,11 @@
local spec = require('user.utils.lang_spec')
local lspservers = {
sqlls = {}
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "sql" }
}
},
spec.treesitter("sql"),
{
"neovim/nvim-lspconfig",
opts = {

View file

@ -1,3 +1,5 @@
local spec = require('user.utils.lang_spec')
local lspservers = {
ts_ls = function()
local vue_language_server_path = vim.fn.expand '$MASON/packages' .. '/vue-language-server' .. '/node_modules/@vue/language-server'
@ -20,12 +22,7 @@ local lspservers = {
}
return {
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "typescript", "tsx" }
}
},
spec.treesitter("typescript", "tsx"),
{
"windwp/nvim-ts-autotag",
optional = true,

View file

@ -1,3 +1,5 @@
local spec = require('user.utils.lang_spec')
local lspservers = {
vue_ls = {
init_options = {
@ -10,16 +12,11 @@ local lspservers = {
return {
spec.treesitter("vue"),
-- Vue needs typescript
{ import = "user.plugins.lang.typescript" },
-- And most likely css/scss aswell.
{ import = "user.plugins.lang.css" },
{
"nvim-treesitter/nvim-treesitter",
opts = {
install = { "vue" }
}
},
{
"windwp/nvim-ts-autotag",
optional = true,

View file

@ -0,0 +1,22 @@
local M = {}
M.treesitter = function (...)
return {
"romus204/tree-sitter-manager.nvim",
opts = {
ensure_installed = {...},
}
}
end
M.treesitter_alias = function (value)
return {
"romus204/tree-sitter-manager.nvim",
opts = {
alias = value,
}
}
end
return M