WIP: Move to vim.lsp

This commit is contained in:
Dennis Schoepf 2025-04-09 18:40:28 +02:00
parent 0b367e1656
commit d3945cc621
9 changed files with 348 additions and 41 deletions

View file

@ -0,0 +1,32 @@
local dnscUtils = require("dnsc.utils")
return {
init_options = { hostInfo = "neovim" },
cmd = { "typescript-language-server", "--stdio" },
filetypes = {
"javascript",
"javascriptreact",
"javascript.jsx",
"typescript",
"typescriptreact",
"typescript.tsx",
},
root_dir = dnscUtils.root_pattern("tsconfig.json", "jsconfig.json", "package.json", ".git"),
init_options = {
preferences = {
importModuleSpecifierPreference = "relative",
importModuleSpecifierEnding = "minimal",
},
},
handlers = {
["textDocument/definition"] = function(err, result, method, ...)
if vim.tbl_islist(result) and #result > 1 then
local filtered_result = dnscUtils.filter(result, dnscUtils.filterReactDTS)
return vim.lsp.handlers["textDocument/definition"](err, filtered_result, method, ...)
end
vim.lsp.handlers["textDocument/definition"](err, result, method, ...)
end,
},
single_file_support = true,
}