dotfiles/dotconfig/nvim/lua/modules/lsp.lua

56 lines
1.4 KiB
Lua
Raw Normal View History

2024-05-28 20:42:24 +02:00
local lsp_zero = require('lsp-zero')
lsp_zero.on_attach(function(client, bufnr)
lsp_zero.default_keymaps({buffer = bufnr})
-- rename symbol
vim.keymap.set('', '<F2>', vim.lsp.buf.rename, {noremap = true})
-- tab completion
lsp_zero.extend_cmp()
local cmp = require('cmp')
cmp.setup({
mapping = cmp.mapping.preset.insert({
['<C-space>'] = cmp.mapping.complete(),
['<Tab>'] = cmp.mapping(
function(fallback)
if cmp.visible() then
if #cmp.get_entries() == 1 then
cmp.confirm({ select = true })
else
cmp.select_next_item()
end
else
fallback()
end
end,
{ 'i', 's' }
),
['<S-Tab>'] = cmp.mapping.select_prev_item(),
['<CR>'] = cmp.mapping.confirm({ select = true }),
-- ['<Esc>'] = cmp.mapping.abort(),
['<C-j>'] = cmp.mapping.scroll_docs(-4),
['<C-k>'] = cmp.mapping.scroll_docs(4),
}),
})
2024-11-15 19:30:02 +01:00
-- inlay hints
vim.lsp.inlay_hint.enable(true)
2024-06-05 14:20:30 +02:00
2024-05-28 20:42:24 +02:00
-- signature help
2024-06-05 14:20:30 +02:00
require('lsp_signature').on_attach({ floating_window_above_cur_line = true }, bufnr)
2024-05-28 20:42:24 +02:00
-- auto-format
-- vim.api.nvim_create_autocmd('BufWritePre', {
-- callback = vim.lsp.buf.format,
-- })
end)
local lsp_config = require('lspconfig')
lsp_config['clangd'].setup({})
lsp_config['rust_analyzer'].setup({})
lsp_config['texlab'].setup({})
lsp_config['pylsp'].setup({})