63 lines
1.6 KiB
Lua
63 lines
1.6 KiB
Lua
local on_attach = require("plugins.configs.lspconfig").on_attach
|
|
local capabilities = require("plugins.configs.lspconfig").capabilities
|
|
|
|
local lspconfig = require "lspconfig"
|
|
local servers = { "vtsls", "tailwindcss", "cssls", "prismals", "gopls", "yamlls", "hls", "metals", "zls" }
|
|
|
|
for _, lsp in ipairs(servers) do
|
|
lspconfig[lsp].setup {
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
}
|
|
end
|
|
|
|
require("lspconfig").eslint.setup {
|
|
-- Copied from nvim-lspconfig/lua/lspconfig/server_conigurations/eslint.js
|
|
root_dir = lspconfig.util.root_pattern(
|
|
".eslintrc",
|
|
".eslintrc.js",
|
|
".eslintrc.cjs",
|
|
".eslintrc.yaml",
|
|
".eslintrc.yml",
|
|
".eslintrc.json"
|
|
-- Disabled to prevent "No ESLint configuration found" exceptions
|
|
-- 'package.json',
|
|
),
|
|
}
|
|
|
|
--[[
|
|
|
|
local function filter(arr, fn)
|
|
if type(arr) ~= "table" then
|
|
return arr
|
|
end
|
|
|
|
local filtered = {}
|
|
for k, v in pairs(arr) do
|
|
if fn(v, k, arr) then
|
|
table.insert(filtered, v)
|
|
end
|
|
end
|
|
|
|
return filtered
|
|
end
|
|
|
|
local function filterReactDTS(value)
|
|
return string.match(value.targetUri, 'node_modules/@types/react/ts5.0/index.d.ts') == nil
|
|
end
|
|
|
|
lspconfig.vtsls.setup {
|
|
-- other options
|
|
handlers = {
|
|
['textDocument/definition'] = function(err, result, method, ...)
|
|
if vim.tbl_islist(result) and #result > 1 then
|
|
local filtered_result = filter(result, filterReactDTS)
|
|
return vim.lsp.handlers['textDocument/definition'](err, filtered_result, method, ...)
|
|
end
|
|
|
|
vim.lsp.handlers['textDocument/definition'](err, result, method, ...)
|
|
end
|
|
}
|
|
}
|
|
]]--
|