update lsp config to use vim.lsp

This commit is contained in:
2025-04-13 00:30:16 -07:00
parent ebbe37bece
commit 8a151a6430
6 changed files with 77 additions and 88 deletions

View File

@@ -20,27 +20,34 @@ return {
"ansiblels",
"docker_compose_language_service",
}
-- Define the highlight color for float border
vim.api.nvim_set_hl(0, "FloatBorder", { fg = "#89b4fa", bold = true })
local border = {
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
{ "", "FloatBorder" },
}
for _, lsp in ipairs(servers) do
if lsp == "lua_ls" then
lspconfig[lsp].setup({
-- on_attach = require("lsp-format").on_attach,
on_attach = function()
vim.notify("Lua LSP attached", nil, { title = "LSP" })
end,
vim.lsp.enable(lsp)
vim.lsp.config("lua_ls", {
on_init = function(client)
if client.workspace_folders then
local path = client.workspace_folders[1].name
if
path ~= vim.fn.stdpath("config")
and (
vim.loop.fs_stat(path .. "/.luarc.json")
or vim.loop.fs_stat(path .. "/.luarc.jsonc")
)
and (vim.uv.fs_stat(path .. "/.luarc.json") or vim.uv.fs_stat(path .. "/.luarc.jsonc"))
then
return
end
end
client.config.settings.Lua = vim.tbl_deep_extend("force", client.config.settings.Lua, {
runtime = {
-- Tell the language server which version of Lua you're using
@@ -53,7 +60,7 @@ return {
library = {
vim.env.VIMRUNTIME,
-- Depending on the usage, you might want to add additional paths here.
-- "${3rd}/luv/library"
-- "${3rd}/luv/library",
-- "${3rd}/busted/library",
},
-- or pull in all of 'runtimepath'. NOTE: this is a lot slower and will cause issues when working on your own configuration (see https://github.com/neovim/nvim-lspconfig/issues/3189)
@@ -61,23 +68,22 @@ return {
},
})
end,
callSnippet = "Replace",
settings = {
Lua = {},
},
})
elseif lsp == "docker_compose_language_service" then
lspconfig[lsp].setup({
filetypes = { "dockerfile", "docker-compose", "yaml", "yml" },
on_attach = function()
vim.notify("Docker Compose LSP attached", nil, { title = "LSP" })
end,
handlers = {},
})
else
lspconfig[lsp].setup({
on_attach = function()
vim.notify(lsp .. " LSP attached", nil, { title = "LSP" })
end,
vim.lsp.enable(lsp)
-- vim.lsp.config(lsp, {
-- handlers = {
-- UNNSUUPPORTED
-- ["textDocument/signatureHelp"] = vim.lsp.with(
-- vim.lsp.handlers.signature_help,
-- { border = border }
-- ),
-- ["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, { border = border }),
},
})
end
end