Files
dots/files/nvim/.config/nvim/lua/plugins/nvim-lspconfig-conf.lua
2023-03-23 23:30:20 +01:00

84 lines
2.0 KiB
Lua

local util = require 'lspconfig.util'
-- Custom warning symbols
local signs = { Error = "", Warn = "", Hint = "", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = hl })
end
-- Easily install LSPs with `:LSPInstall`
require("nvim-lsp-installer").setup({
automatic_installation = true,
ui = {
icons = {
server_installed = "",
server_pending = "",
server_uninstalled = "",
},
},
})
local lsp = require('lspconfig')
-- own custom attach, gets called in every client
function my_attach (client, bufnr)
end
-- Normal LSPs
-- Install with `:LSPInstall`
local servers = { "pylsp", "clangd", "gopls" }
for _, i in ipairs(servers) do
lsp[i].setup({
on_attach = function(client, bufnr)
my_attach(client, bufnr)
end
})
end
-- LaTeX (build with `:TexlabBuild`)
-- Extra config for autocompile
-- https://github.com/neovim/nvim-lspconfig/blob/master/lua/lspconfig/server_configurations/texlab.lua
lsp.texlab.setup({
on_attach = function(client, bufnr)
my_attach(client, bufnr)
end,
settings = {
cmd = { 'texlab' },
texlab = {
build = {
executable = 'latexmk',
args = { '-xelatex', '-interaction=nonstopmode', '-synctex=1', '-shell-escape', '%f' },
onSave = true,
}
}
}
})
-- Rust (use rust-tools to setup lsp, because it has more features)
local opts = {
tools = {
autoSetHints = true,
inlay_hints = {
show_parameter_hints = false,
parameter_hints_prefix = "",
other_hints_prefix = "",
},
},
server = { -- these settings go directly to lsp
on_attach = function(client, bufnr)
my_attach(client, bufnr)
end,
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy"
},
}
}
},
}
-- actually setup rust-tools with the opts from above
require('rust-tools').setup(opts)