75 lines
3.2 KiB
Lua
75 lines
3.2 KiB
Lua
local lspKeys = function(client, bufnr)
|
|
local options = { noremap = true, silent = false, buffer = bufnr }
|
|
vim.keymap.set('n', '<space>,', vim.diagnostic.goto_prev, vim.tbl_extend('error', options, { desc = 'Diag prev' }))
|
|
vim.keymap.set('n', '<space>;', vim.diagnostic.goto_next, vim.tbl_extend('error', options, { desc = 'Diag next' }))
|
|
vim.keymap.set({ 'n', 'x' }, '<space>a', vim.lsp.buf.code_action, vim.tbl_extend('error', options, { desc = 'Code action' }))
|
|
vim.keymap.set('n', '<space>e', vim.lsp.buf.declaration, vim.tbl_extend('error', options, { desc = 'Declaration' }))
|
|
vim.keymap.set('n', '<space>h', function()
|
|
vim.lsp.buf.hover({ border = 'none' })
|
|
end, vim.tbl_extend('error', options, { desc = 'Hover' }))
|
|
vim.keymap.set('n', '<space>c', vim.lsp.buf.outgoing_calls, vim.tbl_extend('error', options, { desc = 'Outgoing calls' }))
|
|
vim.keymap.set('n', '<space>C', vim.lsp.buf.incoming_calls, vim.tbl_extend('error', options, { desc = 'Incoming calls' }))
|
|
vim.keymap.set('n', '<space>m', vim.lsp.buf.rename, vim.tbl_extend('error', options, { desc = 'Rename' }))
|
|
vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, vim.tbl_extend('error', options, { desc = 'Type definition' }))
|
|
vim.keymap.set({ 'n', 'i', 'x' }, '<C-k>', vim.lsp.buf.signature_help, vim.tbl_extend('error', options, { desc = 'Signature help' }))
|
|
vim.keymap.set('n', '<space>v', function()
|
|
vim.diagnostic.open_float({ border = 'rounded' })
|
|
end, vim.tbl_extend('error', options, { desc = 'Diagnostics Float' }))
|
|
vim.keymap.set('n', '<A-o>', '<cmd>ClangdSwitchSourceHeader<CR>', vim.tbl_extend('error', options, { desc = 'Switch Source/Header' }))
|
|
|
|
if client.supports_method('inlayHintProvider') then
|
|
vim.keymap.set('n', '<space>i', function()
|
|
vim.lsp.inlay_hint.enable(not vim.lsp.inlay_hint.is_enabled({ bufnr = bufnr }), { bufnr = bufnr })
|
|
end, {
|
|
noremap = true,
|
|
silent = false,
|
|
desc = 'Toggle inlay hints',
|
|
buffer = bufnr,
|
|
})
|
|
end
|
|
end
|
|
|
|
local on_attach = function(client, bufnr)
|
|
vim.api.nvim_set_option_value('omnifunc', 'v:lua.vim.lsp.omnifunc', { buf = 0 })
|
|
vim.api.nvim_set_option_value('formatexpr', 'v:lua.vim.lsp.formatexpr()', { buf = 0 })
|
|
|
|
lspKeys(client, bufnr)
|
|
|
|
if client.server_capabilities.documentSymbolProvider then
|
|
local navic = require('nvim-navic')
|
|
navic.attach(client, bufnr)
|
|
end
|
|
end
|
|
|
|
return {
|
|
'neovim/nvim-lspconfig',
|
|
dependencies = {
|
|
'williamboman/mason.nvim',
|
|
'p00f/clangd_extensions.nvim',
|
|
'Fildo7525/pretty_hover',
|
|
{
|
|
'creativenull/efmls-configs-nvim',
|
|
branch = 'main',
|
|
},
|
|
'SmiteshP/nvim-navic',
|
|
},
|
|
version = nil,
|
|
branch = 'master',
|
|
config = function()
|
|
local lspconfig = require('lspconfig')
|
|
require('nvim-navic').setup({})
|
|
|
|
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
|
capabilities = require('cmp_nvim_lsp').default_capabilities(capabilities)
|
|
-- capabilities = require('blink.cmp').get_lsp_capabilities(capabilities)
|
|
capabilities.workspace = {
|
|
didChangeWatchedFiles = {
|
|
dynamicRegistration = true,
|
|
},
|
|
}
|
|
|
|
require('plugins.lsp.server').setup_server(lspconfig, capabilities, on_attach)
|
|
end,
|
|
event = 'VeryLazy',
|
|
}
|