added better sign in the sign columns for lsp diagnostics

This commit is contained in:
aminnairi
2023-12-06 04:50:06 +01:00
parent 6e1cdbc1d4
commit 81761dc344
+219 -215
View File
@@ -1,232 +1,236 @@
return { return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
event = "VeryLazy", event = "VeryLazy",
dependencies = { dependencies = {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
}, },
init = function() init = function()
local whichKey = require("which-key") local whichKey = require("which-key")
local conform = require("conform")
-- Use LspAttach autocommand to only map the following keys -- Use LspAttach autocommand to only map the following keys
-- after the language server attaches to the current buffer -- after the language server attaches to the current buffer
vim.api.nvim_create_autocmd("LspAttach", { vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}), group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev) callback = function(ev)
-- Enable completion triggered by <c-x><c-o> -- Enable completion triggered by <c-x><c-o>
vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc" vim.bo[ev.buf].omnifunc = "v:lua.vim.lsp.omnifunc"
whichKey.register({ whichKey.register({
["<leader>l"] = { ["<leader>l"] = {
name = "LSP", name = "LSP",
d = { d = {
name = "LSP Diagnostic", name = "LSP Diagnostic",
o = { o = {
function() function()
vim.diagnostic.open_float() vim.diagnostic.open_float()
end, end,
"Open LSP diagnostic", "Open LSP diagnostic",
}, },
p = { p = {
function() function()
vim.diagnostic.goto_prev() vim.diagnostic.goto_prev()
end, end,
"Previous LSP diagnostic", "Previous LSP diagnostic",
}, },
n = { n = {
function() function()
vim.diagnostic.goto_next() vim.diagnostic.goto_next()
end, end,
"Next LSP diagnostic", "Next LSP diagnostic",
}, },
}, },
b = { b = {
name = "LSP Buffer", name = "LSP Buffer",
D = { D = {
function() function()
vim.lsp.buf.declaration() vim.lsp.buf.declaration()
end, end,
"Go to symbol declaration", "Go to symbol declaration",
buffer = ev.buf, buffer = ev.buf,
}, },
d = { d = {
function() function()
vim.lsp.buf.definition() vim.lsp.buf.definition()
end, end,
"Go to symbol definition", "Go to symbol definition",
buffer = ev.buf, buffer = ev.buf,
}, },
h = { h = {
function() function()
vim.lsp.buf.hover() vim.lsp.buf.hover()
end, end,
"Hover symbol documentation", "Hover symbol documentation",
buffer = ev.buf, buffer = ev.buf,
}, },
i = { i = {
function() function()
vim.lsp.buf.implementation() vim.lsp.buf.implementation()
end, end,
"Go to symbol implementation", "Go to symbol implementation",
buffer = ev.buf, buffer = ev.buf,
}, },
s = { s = {
function() function()
vim.lsp.buf.signature_help() vim.lsp.buf.signature_help()
end, end,
"Go to symbol signature", "Go to symbol signature",
buffer = ev.buf, buffer = ev.buf,
}, },
t = { t = {
function() function()
vim.lsp.buf.type_definition() vim.lsp.buf.type_definition()
end, end,
"Go to symbol type definition", "Go to symbol type definition",
buffer = ev.buf, buffer = ev.buf,
}, },
r = { r = {
function() function()
vim.lsp.buf.rename() vim.lsp.buf.rename()
end, end,
"Rename symbol", "Rename symbol",
buffer = ev.buf, buffer = ev.buf,
}, },
c = { c = {
function() function()
vim.lsp.buf.code_action() vim.lsp.buf.code_action()
end, end,
"LSP code action", "LSP code action",
buffer = ev.buf, buffer = ev.buf,
}, },
R = { R = {
function() function()
vim.lsp.buf.references() vim.lsp.buf.references()
end, end,
"Go to symbol deferences", "Go to symbol deferences",
buffer = ev.buf, buffer = ev.buf,
}, },
f = { f = {
function() function()
vim.lsp.buf.format({ vim.lsp.buf.format({
async = true, async = true,
}) })
end,
"Format file",
buffer = ev.buf,
},
},
},
})
end,
})
conform.format({ buffnr = ev.buff }) local signs = { Error = "󰅚 ", Warn = "󰀪 ", Hint = "󰌶 ", Info = "" }
end,
"Format file",
buffer = ev.buf,
},
},
},
})
end,
})
end,
config = function()
local lspconfig = require("lspconfig")
local capabilities = require("cmp_nvim_lsp").default_capabilities()
local on_attach = function() end
lspconfig.lua_ls.setup({ for type, icon in pairs(signs) do
capabilities = capabilities, local hl = "DiagnosticSign" .. type
on_attach = on_attach, vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
settings = { end
Lua = { end,
runtime = { config = function()
-- Tell the language server which version of Lua you"re using (most likely LuaJIT in the case of Neovim) local lspconfig = require("lspconfig")
version = "LuaJIT", local capabilities = require("cmp_nvim_lsp").default_capabilities()
}, local on_attach = function() end
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
})
lspconfig.tsserver.setup({ lspconfig.lua_ls.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach on_attach = on_attach,
}) settings = {
Lua = {
runtime = {
-- Tell the language server which version of Lua you"re using (most likely LuaJIT in the case of Neovim)
version = "LuaJIT",
},
diagnostics = {
-- Get the language server to recognize the `vim` global
globals = { "vim" },
},
workspace = {
-- Make the server aware of Neovim runtime files
library = vim.api.nvim_get_runtime_file("", true),
},
-- Do not send telemetry data containing a randomized but unique identifier
telemetry = {
enable = false,
},
},
},
})
lspconfig.volar.setup({ lspconfig.tsserver.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
filetypes = { })
"vue"
},
})
lspconfig.cssls.setup({ lspconfig.volar.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
filetypes = { filetypes = {
"css", "vue",
"scss", },
"sass", })
"less",
},
})
lspconfig.cssmodules_ls.setup({ lspconfig.cssls.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach, on_attach = on_attach,
filetypes = { filetypes = {
"javascript", "css",
"javascriptreact", "scss",
"typescript", "sass",
"typescriptreact", "less",
}, },
}) })
lspconfig.prismals.setup({ lspconfig.cssmodules_ls.setup({
on_attach = on_attach, capabilities = capabilities,
filetypes = { on_attach = on_attach,
"prisma" filetypes = {
}, "javascript",
capabilities = capabilities "javascriptreact",
}) "typescript",
"typescriptreact",
},
})
lspconfig.yamlls.setup({ lspconfig.prismals.setup({
capabilities = capabilities, on_attach = on_attach,
filetypes = { filetypes = {
"yaml" "prisma",
}, },
}) capabilities = capabilities,
})
lspconfig.marksman.setup({ lspconfig.yamlls.setup({
capabilities = capabilities, capabilities = capabilities,
filetypes = { filetypes = {
"markdown" "yaml",
} },
}) })
lspconfig.eslint.setup({ lspconfig.marksman.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach filetypes = {
}) "markdown",
},
})
lspconfig.dockerls.setup({ lspconfig.eslint.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach on_attach = on_attach,
}) })
lspconfig.rust_analyzer.setup({ lspconfig.dockerls.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach on_attach = on_attach,
}) })
lspconfig.intelephense.setup({ lspconfig.rust_analyzer.setup({
capabilities = capabilities, capabilities = capabilities,
on_attach = on_attach on_attach = on_attach,
}) })
end,
lspconfig.intelephense.setup({
capabilities = capabilities,
on_attach = on_attach,
})
end,
} }