172 lines
6.2 KiB
Lua
172 lines
6.2 KiB
Lua
return {
|
|
{ -- lsp configurations
|
|
"https://github.com/neovim/nvim-lspconfig",
|
|
event = "BufReadPre",
|
|
dependencies = {
|
|
"https://github.com/williamboman/mason.nvim",
|
|
"https://github.com/williamboman/mason-lspconfig.nvim",
|
|
},
|
|
config = function()
|
|
local lspconfig = require("lspconfig")
|
|
vim.diagnostic.config({
|
|
float = {
|
|
border = "rounded",
|
|
},
|
|
virtual_text = false,
|
|
virtual_lines = {
|
|
only_current_line = true,
|
|
},
|
|
})
|
|
local opts = { noremap = true, silent = true }
|
|
vim.keymap.set("n", "<space>e", vim.diagnostic.open_float, opts)
|
|
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts)
|
|
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts)
|
|
-- vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)
|
|
|
|
local on_attach = function(_, bufnr)
|
|
-- Enable completion triggered by <c-x><c-o>
|
|
vim.api.nvim_buf_set_option(bufnr, "omnifunc", "v:lua.vim.lsp.omnifunc")
|
|
|
|
local function bufopts(desc)
|
|
return { buffer = bufnr, noremap = true, silent = true, desc = desc }
|
|
end
|
|
|
|
vim.keymap.set("n", "gd", vim.lsp.buf.definition, bufopts("go to definition"))
|
|
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, bufopts("go to declaration"))
|
|
vim.keymap.set("n", "K", vim.lsp.buf.hover, bufopts("hover"))
|
|
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, bufopts("go to implementation"))
|
|
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, bufopts("help signature"))
|
|
vim.keymap.set("n", "gr", vim.lsp.buf.references, bufopts("references"))
|
|
vim.keymap.set("n", "<space>D", vim.lsp.buf.type_definition, bufopts("type definition"))
|
|
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, bufopts("rename"))
|
|
vim.keymap.set("n", "<leader>ca", vim.lsp.buf.code_action, bufopts("code action"))
|
|
vim.keymap.set("n", "<leader>ff", function()
|
|
vim.lsp.buf.format({ async = true })
|
|
end, bufopts("format code"))
|
|
end
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
|
|
capabilities.textDocument.foldingRange = {
|
|
dynamicRegistration = false,
|
|
lineFoldingOnly = true,
|
|
}
|
|
|
|
lspconfig.bashls.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
lspconfig.texlab.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
-- lspconfig.typst_lsp.setup({
|
|
-- -- on_attach = on_attach,
|
|
-- -- capabilities = capabilities,
|
|
-- })
|
|
|
|
lspconfig.elixirls.setup({
|
|
cmd = { "/usr/lib/elixir-ls/language_server.sh" },
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
lspconfig.pyright.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
lspconfig.rust_analyzer.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
["rust-analyzer"] = {
|
|
diagnostics = {
|
|
enable = true,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
-- Trzeba stworzyć odpowiedniego enva i zainstalować paczki
|
|
lspconfig.julials.setup({
|
|
-- This just adds dirname(fname) as a fallback (see nvim-lspconfig#1768).
|
|
on_new_config = function(new_config, _)
|
|
-- https://discourse.julialang.org/t/neovim-languageserver-jl/37286/83
|
|
local julia = vim.fn.expand("~/.local/share/julia/environments/nvim-lspconfig/bin/julia")
|
|
if require("lspconfig").util.path.is_file(julia) then
|
|
new_config.cmd[1] = julia
|
|
end
|
|
end,
|
|
root_dir = function(fname)
|
|
local util = require("lspconfig.util")
|
|
return util.root_pattern("Project.toml")(fname)
|
|
or util.find_git_ancestor(fname)
|
|
or util.path.dirname(fname)
|
|
end,
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
julia = {
|
|
lint = {
|
|
call = false,
|
|
},
|
|
},
|
|
}
|
|
})
|
|
|
|
lspconfig.clangd.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
})
|
|
|
|
lspconfig.lua_ls.setup({
|
|
on_attach = on_attach,
|
|
capabilities = capabilities,
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {
|
|
globals = { "vim" },
|
|
},
|
|
telemetry = {
|
|
enable = false,
|
|
},
|
|
},
|
|
},
|
|
})
|
|
|
|
lspconfig.cssls.setup {
|
|
capabilities = capabilities,
|
|
}
|
|
|
|
lspconfig.html.setup {
|
|
capabilities = capabilities,
|
|
}
|
|
end,
|
|
},
|
|
|
|
{
|
|
"https://github.com/williamboman/mason-lspconfig.nvim",
|
|
lazy = true,
|
|
},
|
|
|
|
{ -- portable package manager
|
|
"https://github.com/williamboman/mason.nvim",
|
|
cmd = "Mason",
|
|
keys = {
|
|
{ "<leader>pm", "<cmd>Mason<CR>", desc = "Mason" },
|
|
},
|
|
opts = {
|
|
ui = {
|
|
border = "double",
|
|
icons = {
|
|
package_installed = "✓",
|
|
package_pending = "➜",
|
|
package_uninstalled = "✗",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|