diff options
Diffstat (limited to '.config/nvim/lua/plugins/lsp.lua')
| -rw-r--r-- | .config/nvim/lua/plugins/lsp.lua | 72 |
1 files changed, 36 insertions, 36 deletions
diff --git a/.config/nvim/lua/plugins/lsp.lua b/.config/nvim/lua/plugins/lsp.lua index e710fd7..b10aa58 100644 --- a/.config/nvim/lua/plugins/lsp.lua +++ b/.config/nvim/lua/plugins/lsp.lua | |||
| @@ -12,37 +12,38 @@ return { | |||
| 12 | local map = require("helpers.keys").map | 12 | local map = require("helpers.keys").map |
| 13 | 13 | ||
| 14 | map('n', '<leader>e', vim.diagnostic.open_float, "lsp: open diagnostics float") | 14 | map('n', '<leader>e', vim.diagnostic.open_float, "lsp: open diagnostics float") |
| 15 | map('n', '[d', vim.diagnostic.goto_prev, "lsp: goto previous diagnostic") | 15 | map('n', '[d', function() vim.diagnostic.jump({ count = -1, float = true }) end, |
| 16 | map('n', ']d', vim.diagnostic.goto_next, "lsp: goto next diagnostic") | 16 | "lsp: goto previous diagnostic") |
| 17 | map('n', ']d', function() vim.diagnostic.jump({ count = 1, float = true }) end, "lsp: goto next diagnostic") | ||
| 17 | 18 | ||
| 18 | -- set up cool signs for diagnostics | 19 | vim.diagnostic.config({ |
| 19 | local signs = { Error = " ", Warn = "", Hint = "", Info = "" } | 20 | underline = true, |
| 20 | for type, icon in pairs(signs) do | ||
| 21 | local hl = "DiagnosticSign" .. type | ||
| 22 | vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" }) | ||
| 23 | end | ||
| 24 | |||
| 25 | -- Diagnostic config | ||
| 26 | local config = { | ||
| 27 | virtual_text = false, | ||
| 28 | signs = { | 21 | signs = { |
| 29 | active = signs, | 22 | active = true, |
| 23 | text = { | ||
| 24 | [vim.diagnostic.severity.ERROR] = "", | ||
| 25 | [vim.diagnostic.severity.WARN] = "", | ||
| 26 | [vim.diagnostic.severity.HINT] = "", | ||
| 27 | [vim.diagnostic.severity.INFO] = "", | ||
| 28 | }, | ||
| 30 | }, | 29 | }, |
| 31 | update_in_insert = true, | 30 | virtual_text = false, |
| 32 | underline = true, | ||
| 33 | severity_sort = true, | ||
| 34 | float = { | 31 | float = { |
| 35 | focusable = true, | ||
| 36 | style = "minimal", | ||
| 37 | border = "rounded", | ||
| 38 | source = "always", | ||
| 39 | header = "", | 32 | header = "", |
| 40 | prefix = "", | 33 | border = "rounded", |
| 34 | format = function(diagnostic) | ||
| 35 | return string.format( | ||
| 36 | "%s (%s) [%s]", | ||
| 37 | diagnostic.message, | ||
| 38 | diagnostic.source, | ||
| 39 | diagnostic.code or diagnostic.user_data.lsp.code | ||
| 40 | ) | ||
| 41 | end, | ||
| 41 | }, | 42 | }, |
| 42 | } | ||
| 43 | vim.diagnostic.config(config) | ||
| 44 | 43 | ||
| 45 | -- this function gets run when an lsp connects to a particular buffer. | 44 | }) |
| 45 | |||
| 46 | -- This function gets run when an LSP connects to a particular buffer. | ||
| 46 | local on_attach = function(_, bufnr) | 47 | local on_attach = function(_, bufnr) |
| 47 | map = require("helpers.keys").lsp_map | 48 | map = require("helpers.keys").lsp_map |
| 48 | 49 | ||
| @@ -71,17 +72,16 @@ return { | |||
| 71 | capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) | 72 | capabilities = require("cmp_nvim_lsp").default_capabilities(capabilities) |
| 72 | 73 | ||
| 73 | -- misc. | 74 | -- misc. |
| 74 | local lspconfig = require('lspconfig') | 75 | local servers = { 'ts_ls', 'jsonls', 'eslint', 'cssls', 'html', 'vala_ls', 'gopls', 'clangd' } |
| 75 | local servers = { 'ts_ls', 'jsonls', 'eslint', 'cssls', 'html', 'vala_ls', 'gopls' } | ||
| 76 | for _, lsp in pairs(servers) do | 76 | for _, lsp in pairs(servers) do |
| 77 | lspconfig[lsp].setup { | 77 | vim.lsp.config(lsp, { |
| 78 | on_attach = on_attach, | 78 | on_attach = on_attach, |
| 79 | capabilites = capabilities, | 79 | capabilites = capabilities, |
| 80 | } | 80 | }) |
| 81 | end | 81 | end |
| 82 | 82 | ||
| 83 | -- typst/tinymist | 83 | -- typst/tinymist |
| 84 | require("lspconfig")["tinymist"].setup({ | 84 | vim.lsp.config("tinymist", { |
| 85 | on_attach = on_attach, | 85 | on_attach = on_attach, |
| 86 | capabilities = capabilities, | 86 | capabilities = capabilities, |
| 87 | single_file_support = true, | 87 | single_file_support = true, |
| @@ -94,7 +94,7 @@ return { | |||
| 94 | }) | 94 | }) |
| 95 | 95 | ||
| 96 | -- lua | 96 | -- lua |
| 97 | require("lspconfig")["lua_ls"].setup({ | 97 | vim.lsp.config("lua_ls", { |
| 98 | on_attach = on_attach, | 98 | on_attach = on_attach, |
| 99 | capabilities = capabilities, | 99 | capabilities = capabilities, |
| 100 | settings = { | 100 | settings = { |
| @@ -116,7 +116,7 @@ return { | |||
| 116 | }) | 116 | }) |
| 117 | 117 | ||
| 118 | -- python | 118 | -- python |
| 119 | require("lspconfig")["pylsp"].setup({ | 119 | vim.lsp.config("pylsp", { |
| 120 | on_attach = on_attach, | 120 | on_attach = on_attach, |
| 121 | capabilities = capabilities, | 121 | capabilities = capabilities, |
| 122 | settings = { | 122 | settings = { |
| @@ -139,7 +139,7 @@ return { | |||
| 139 | }) | 139 | }) |
| 140 | 140 | ||
| 141 | -- efm | 141 | -- efm |
| 142 | require("lspconfig")["efm"].setup({ | 142 | vim.lsp.config("efm", { |
| 143 | on_attach = on_attach, | 143 | on_attach = on_attach, |
| 144 | settings = { | 144 | settings = { |
| 145 | initializationOptions = { | 145 | initializationOptions = { |
| @@ -155,7 +155,7 @@ return { | |||
| 155 | filetypes = { 'sh', 'tex' }, | 155 | filetypes = { 'sh', 'tex' }, |
| 156 | }) | 156 | }) |
| 157 | 157 | ||
| 158 | require("lspconfig")["harper_ls"].setup { | 158 | vim.lsp.config("harper_ls", { |
| 159 | on_attach = on_attach, | 159 | on_attach = on_attach, |
| 160 | capabilities = capabilities, | 160 | capabilities = capabilities, |
| 161 | settings = { | 161 | settings = { |
| @@ -185,17 +185,17 @@ return { | |||
| 185 | root_dir = function(fname) | 185 | root_dir = function(fname) |
| 186 | return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) | 186 | return vim.fs.dirname(vim.fs.find('.git', { path = fname, upward = true })[1]) |
| 187 | end, | 187 | end, |
| 188 | } | 188 | }) |
| 189 | 189 | ||
| 190 | -- ltex | 190 | -- ltex |
| 191 | require("lspconfig")["ltex"].setup({ | 191 | vim.lsp.config("ltex", { |
| 192 | capabilities = capabilities, | 192 | capabilities = capabilities, |
| 193 | on_attach = function(client, bufnr) | 193 | on_attach = function(client, bufnr) |
| 194 | on_attach(client, bufnr) | 194 | on_attach(client, bufnr) |
| 195 | require("ltex_extra").setup { | 195 | require("ltex_extra").setup { |
| 196 | load_langs = { "en-GB" }, | 196 | load_langs = { "en-GB" }, |
| 197 | init_check = true, | 197 | init_check = true, |
| 198 | log_level = "none", | 198 | log_level = "warn", |
| 199 | } | 199 | } |
| 200 | end, | 200 | end, |
| 201 | filetypes = { "bib", "gitcommit", "markdown", "org", "plaintex", "rst", "rnoweb", "tex", "pandoc", "quarto", "rmd", "context", "mail", "text" }, | 201 | filetypes = { "bib", "gitcommit", "markdown", "org", "plaintex", "rst", "rnoweb", "tex", "pandoc", "quarto", "rmd", "context", "mail", "text" }, |
