summaryrefslogtreecommitdiff
path: root/lua/config/lsp.lua
diff options
context:
space:
mode:
Diffstat (limited to 'lua/config/lsp.lua')
-rw-r--r--lua/config/lsp.lua82
1 files changed, 82 insertions, 0 deletions
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
new file mode 100644
index 0000000..ebb779f
--- /dev/null
+++ b/lua/config/lsp.lua
@@ -0,0 +1,82 @@
+vim.o.completeopt = "menuone,noselect,noinsert,popup,fuzzy"
+
+vim.diagnostic.config({
+ underline = true,
+ virtual_lines = { current_line = true },
+ signs = {
+ text = {
+ [vim.diagnostic.severity.ERROR] = "",
+ [vim.diagnostic.severity.WARN] = "",
+ [vim.diagnostic.severity.INFO] = "",
+ [vim.diagnostic.severity.HINT] = "",
+ },
+ },
+})
+
+vim.lsp.config("*", {
+ capabilities = {
+ textDocument = {
+ semanticTokens = {
+ multilineTokenSupport = true,
+ },
+ completion = {
+ completionItem = {
+ snippetSupport = true,
+ commitCharactersSupport = true,
+ deprecatedSupport = true,
+ preselectSupport = true,
+ insertReplaceSupport = true,
+ labelDetailsSupport = true,
+ resolveSupport = {
+ properties = {
+ "documentation",
+ "detail",
+ "additionalTextEdits",
+ },
+ },
+ },
+ },
+ },
+ },
+
+ on_attach = function(client, bufnr)
+ if client:supports_method('textDocument/completion') then
+ vim.lsp.completion.enable(true, client.id, bufnr, { autotrigger = true })
+ vim.keymap.set("i", "<M-Space>", vim.lsp.completion.get, { buffer = bufnr })
+ end
+
+ if client:supports_method('textDocument/definition') then
+ vim.keymap.set("n", "grd", vim.lsp.buf.definition, { desc = "Jumps to definition", buffer = bufnr })
+ end
+ if client:supports_method('textDocument/declaration') then
+ vim.keymap.set("n", "grD", vim.lsp.buf.declaration, { desc = "Jumps to declaration", buffer = bufnr })
+ end
+
+ if client:supports_method("textDocument/inlayHint") then
+ vim.lsp.inlay_hint.enable(true, { bufnr })
+ end
+
+ if client:supports_method("textDocument/formatting") then
+ local description = "LSP: Formats the current buffer"
+ local format_buffer = function()
+ vim.lsp.buf.format({ async = true, buffer = bufnr })
+ end
+ vim.keymap.set("n", "<Leader>cf", format_buffer, { desc = description })
+ vim.keymap.set("v", "<C-f>", format_buffer, { desc = description })
+ end
+ end,
+})
+
+vim.lsp.enable({
+ "clangd",
+ "css",
+ "go",
+ "html",
+ "javascript",
+ "json",
+ "lua",
+ "markdown",
+ "odin",
+ "ruby",
+ "yaml",
+})