first commit
This commit is contained in:
commit
2a3ea31491
52 changed files with 2991 additions and 0 deletions
101
apps/neovim/lsp.lua
Normal file
101
apps/neovim/lsp.lua
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
local lspconfig = require('lspconfig')
|
||||
|
||||
vim.lsp.config('lua_ls', { cmd = { 'lua-language-server' },
|
||||
settings = {
|
||||
Lua = {
|
||||
runtime = {
|
||||
version = 'LuaJIT',
|
||||
path = vim.split(package.path, ';'),
|
||||
},
|
||||
diagnostics = {
|
||||
globals = { 'vim' },
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
vim.lsp.config('rust_analyzer', {
|
||||
settings = {
|
||||
['rust-analyzer'] = {
|
||||
diagnostics = {
|
||||
enable = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
|
||||
local languages = {
|
||||
'rust_analyzer',
|
||||
'r_language_server',
|
||||
'lua_ls',
|
||||
'quarto',
|
||||
'nil_ls',
|
||||
'pyright'
|
||||
}
|
||||
|
||||
for _, language in ipairs(languages) do
|
||||
vim.lsp.enable(language)
|
||||
end
|
||||
|
||||
vim.diagnostic.config {
|
||||
severity_sort = true,
|
||||
float = { border = 'rounded', source = 'if_many' },
|
||||
underline = { severity = vim.diagnostic.severity.ERROR },
|
||||
signs = vim.g.have_nerd_font and {
|
||||
text = {
|
||||
[vim.diagnostic.severity.ERROR] = ' ',
|
||||
[vim.diagnostic.severity.WARN] = ' ',
|
||||
[vim.diagnostic.severity.INFO] = ' ',
|
||||
[vim.diagnostic.severity.HINT] = ' ',
|
||||
},
|
||||
} or {},
|
||||
virtual_text = {
|
||||
source = 'if_many',
|
||||
spacing = 2,
|
||||
format = function(diagnostic)
|
||||
local diagnostic_message = {
|
||||
[vim.diagnostic.severity.ERROR] = diagnostic.message,
|
||||
[vim.diagnostic.severity.WARN] = diagnostic.message,
|
||||
[vim.diagnostic.severity.INFO] = diagnostic.message,
|
||||
[vim.diagnostic.severity.HINT] = diagnostic.message,
|
||||
}
|
||||
return diagnostic_message[diagnostic.severity]
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(event)
|
||||
local buf = event.buf
|
||||
local opts = function(desc)
|
||||
return { buffer = buf, desc = desc }
|
||||
end
|
||||
|
||||
-- Jumping + finding
|
||||
vim.keymap.set("n", "gd", vim.lsp.buf.definition, opts("[G]oto Definition"))
|
||||
vim.keymap.set("n", "gD", vim.lsp.buf.declaration, opts("Goto [D]eclaration"))
|
||||
vim.keymap.set("n", "gi", vim.lsp.buf.implementation, opts("[G]oto [I]mplementation"))
|
||||
vim.keymap.set("n", "gr", vim.lsp.buf.references, opts("[G]oto [R]eferences"))
|
||||
|
||||
-- Info + documentation
|
||||
vim.keymap.set("n", "K", vim.lsp.buf.hover, opts("Hover Documentation"))
|
||||
vim.keymap.set("n", "<C-k>", vim.lsp.buf.signature_help, opts("Signature Help"))
|
||||
|
||||
-- Actions + rename
|
||||
vim.keymap.set("n", "<leader>rn", vim.lsp.buf.rename, opts("[R]e[n]ame"))
|
||||
vim.keymap.set({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts("[C]ode [A]ction"))
|
||||
|
||||
-- Diagnostics navigation
|
||||
vim.keymap.set("n", "[d", vim.diagnostic.goto_prev, opts("Prev Diagnostic"))
|
||||
vim.keymap.set("n", "]d", vim.diagnostic.goto_next, opts("Next Diagnostic"))
|
||||
vim.keymap.set("n", "<leader>e", vim.diagnostic.open_float, opts("Show Error"))
|
||||
vim.keymap.set("n", "<leader>q", vim.diagnostic.setloclist, opts("Diagnostic Quickfix"))
|
||||
|
||||
-- Formatting
|
||||
vim.keymap.set("n", "<leader>f", function()
|
||||
vim.lsp.buf.format({ async = true })
|
||||
end, opts("[F]ormat Buffer"))
|
||||
end,
|
||||
})
|
||||
Loading…
Add table
Add a link
Reference in a new issue