mirror of
https://github.com/pnx/dotfiles
synced 2026-06-16 03:14:55 +02:00
nvim: update lsp config to nvim 0.12
This commit is contained in:
parent
0423818458
commit
d21bef893e
21 changed files with 91 additions and 87 deletions
|
|
@ -1,5 +1,7 @@
|
|||
return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
commit = "4916d6592ede8c07973490d9322f187e07dfefac",
|
||||
pin = true,
|
||||
dependencies = {
|
||||
'windwp/nvim-ts-autotag',
|
||||
'nvim-treesitter/nvim-treesitter-textobjects'
|
||||
|
|
@ -7,10 +9,10 @@ return {
|
|||
build = function()
|
||||
require("nvim-treesitter.install").update({ with_sync = true })
|
||||
end,
|
||||
opts_extend = { "ensure_installed" },
|
||||
opts_extend = { "install" },
|
||||
opts = {
|
||||
-- Default parsers.
|
||||
ensure_installed = {
|
||||
install = {
|
||||
-- VIM stuff
|
||||
"vim",
|
||||
"vimdoc",
|
||||
|
|
@ -18,7 +20,6 @@ return {
|
|||
|
||||
-- Common config languages
|
||||
"json",
|
||||
"jsonc",
|
||||
"yaml",
|
||||
"toml",
|
||||
"xml",
|
||||
|
|
@ -35,37 +36,47 @@ return {
|
|||
"printf",
|
||||
"nginx",
|
||||
},
|
||||
|
||||
auto_install = true,
|
||||
|
||||
highlight = {
|
||||
enable = true,
|
||||
additional_vim_regex_highlighting = false,
|
||||
},
|
||||
|
||||
indent = {
|
||||
enable = true,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
local parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
||||
|
||||
parser_config.dotenv = {
|
||||
install_info = {
|
||||
url = "https://github.com/pnx/tree-sitter-dotenv",
|
||||
branch = "main",
|
||||
files = { "src/parser.c", "src/scanner.c" },
|
||||
},
|
||||
filetype = "dotenv",
|
||||
}
|
||||
|
||||
vim.filetype.add({
|
||||
pattern = {
|
||||
['%.env'] = 'dotenv',
|
||||
['%.env%..+'] = 'dotenv',
|
||||
local ts = require("nvim-treesitter")
|
||||
vim.api.nvim_create_autocmd('User', { pattern = 'TSUpdate', callback = function ()
|
||||
require("nvim-treesitter.parsers").dotenv = {
|
||||
install_info = {
|
||||
url = "https://github.com/pnx/tree-sitter-dotenv",
|
||||
branch = "main",
|
||||
files = { "src/parser.c", "src/scanner.c" },
|
||||
}
|
||||
}
|
||||
end})
|
||||
|
||||
-- vim.filetype.add({
|
||||
-- pattern = {
|
||||
-- ['%.env'] = 'dotenv',
|
||||
-- ['%.env%..+'] = 'dotenv',
|
||||
-- }
|
||||
-- })
|
||||
vim.treesitter.language.register('dotenv', { 'env' })
|
||||
|
||||
for _, value in pairs(opts.install) do
|
||||
vim.treesitter.language.register(value, value)
|
||||
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
|
||||
-- local all_langs = vim.treesitter.language._complete()
|
||||
-- local lang = vim.treesitter.language.get_lang(ev.match)
|
||||
-- vim.print(ev.match, all_langs, vim.tbl_contains(all_langs, lang))
|
||||
-- if vim.tbl_contains(all_langs, lang) then
|
||||
-- vim.treesitter.start(ev.buf)
|
||||
-- end
|
||||
end,
|
||||
})
|
||||
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
end,
|
||||
ts.install(opts.install)
|
||||
ts.setup(opts)
|
||||
end
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,15 +63,15 @@ local config = function(_, opts)
|
|||
client.server_capabilities,
|
||||
server_opts.server_capabilities or {})
|
||||
|
||||
if server_opts.inlay_hints.enabled and client.supports_method("textDocument/inlayHint") then
|
||||
if server_opts.inlay_hints.enabled and client:supports_method("textDocument/inlayHint") then
|
||||
vim.lsp.inlay_hint.enable(true, { bufnr = bufnr })
|
||||
end
|
||||
|
||||
if server_opts.codelens.enabled and client.supports_method("textDocument/codeLens") then
|
||||
utils.codelens(augroup, bufnr)
|
||||
if server_opts.codelens.enabled and client:supports_method("textDocument/codeLens") then
|
||||
vim.lsp.codelens.enable(true, { bufnr = bufnr })
|
||||
end
|
||||
|
||||
if server_opts.document_highlight.enabled and client.supports_method("textDocument/documentHighlight") then
|
||||
if server_opts.document_highlight.enabled and client:supports_method("textDocument/documentHighlight") then
|
||||
utils.document_highlight(bufnr)
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "bash" }
|
||||
install = { "bash" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "c", "cpp" }
|
||||
install = { "c", "cpp" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "cmake" }
|
||||
install = { "cmake" }
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "css", "scss" }
|
||||
install = { "css", "scss" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "dockerfile" }
|
||||
install = { "dockerfile" }
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "go", "gomod", "gowork", "gosum" }
|
||||
install = { "go", "gomod", "gowork", "gosum" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "html" }
|
||||
install = { "html" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "javascript", "javadoc" }
|
||||
install = { "javascript", "javadoc" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "lua" }
|
||||
install = { "lua" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "markdown" }
|
||||
install = { "markdown" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "ninja" }
|
||||
install = { "ninja" }
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "php", "blade", "php_only", "phpdoc", "sql", "csv" }
|
||||
install = { "php", "blade", "php_only", "phpdoc", "sql", "csv" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "qmljs" }
|
||||
install = { "qmljs" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "rust", "toml" }
|
||||
install = { "rust", "toml" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "sql" }
|
||||
install = { "sql" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "typescript" }
|
||||
install = { "typescript" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ return {
|
|||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = {
|
||||
ensure_installed = { "vue" }
|
||||
install = { "vue" }
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue