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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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