53 lines
1.4 KiB
Lua
53 lines
1.4 KiB
Lua
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),
|
|
}),
|
|
})
|
|
|
|
|
|
-- signature help
|
|
require('lsp_signature').on_attach({ floating_window_above_cur_line = true }, bufnr)
|
|
|
|
-- 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({})
|