Compare commits
3 Commits
fcd5cfbd54
...
b146971918
Author | SHA1 | Date | |
---|---|---|---|
b146971918 | |||
a365bcb6b5 | |||
6affd78df7 |
@ -72,57 +72,48 @@ return {
|
||||
},
|
||||
|
||||
config = function()
|
||||
local capabilities = vim.lsp.protocol.make_client_capabilities()
|
||||
capabilities = vim.tbl_deep_extend(
|
||||
'force', capabilities, require('cmp_nvim_lsp').default_capabilities())
|
||||
local lspconfig_default_opts = {
|
||||
-- Broadcast full client capabilities to language servers
|
||||
capabilities = vim.tbl_deep_extend(
|
||||
'force', vim.lsp.protocol.make_client_capabilities(),
|
||||
require('cmp_nvim_lsp').default_capabilities()),
|
||||
}
|
||||
|
||||
local lspconfig_custom_opts = {
|
||||
clangd = {
|
||||
cmd = { 'clangd', '--completion-style=detailed' },
|
||||
},
|
||||
|
||||
lua_ls = {
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
disable = { 'missing-fields', },
|
||||
globals = { 'vim', },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
pyright = {
|
||||
settings = {
|
||||
pyright = {
|
||||
disableOrganizeImports = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
require('mason').setup()
|
||||
require('mason-lspconfig').setup({
|
||||
automatic_installation = false,
|
||||
ensure_installed = ensure_installed,
|
||||
|
||||
handlers = {
|
||||
-- Default handler, sets up everything unless a custom language server
|
||||
-- setup handler is defined below
|
||||
function(server_name)
|
||||
require('lspconfig')[server_name].setup({
|
||||
capabilities = capabilities,
|
||||
})
|
||||
local opts = vim.tbl_deep_extend("force",
|
||||
lspconfig_default_opts, lspconfig_custom_opts[server_name] or {})
|
||||
require('lspconfig')[server_name].setup(opts)
|
||||
end,
|
||||
|
||||
['clangd'] = function()
|
||||
require('lspconfig').clangd.setup({
|
||||
capabilities = capabilities,
|
||||
cmd = { 'clangd', '--completion-style=detailed' }
|
||||
})
|
||||
end,
|
||||
|
||||
['lua_ls'] = function()
|
||||
require('neodev').setup()
|
||||
require('lspconfig').lua_ls.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
Lua = {
|
||||
diagnostics = {
|
||||
disable = { 'missing-fields', },
|
||||
globals = { 'vim', },
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
end,
|
||||
|
||||
['pyright'] = function()
|
||||
require('lspconfig').pyright.setup({
|
||||
capabilities = capabilities,
|
||||
settings = {
|
||||
pyright = {
|
||||
disableOrganizeImports = true, -- Use ruff import sorter instead
|
||||
},
|
||||
}
|
||||
})
|
||||
end,
|
||||
|
||||
},
|
||||
})
|
||||
|
||||
@ -180,11 +171,12 @@ return {
|
||||
vim.api.nvim_create_autocmd('LspAttach', {
|
||||
pattern = '*',
|
||||
group = augroup,
|
||||
callback = function(ev)
|
||||
local opts = { noremap = true, buffer = ev.buf }
|
||||
callback = function(event)
|
||||
local opts = { noremap = true, buffer = event.buf }
|
||||
|
||||
-- Fixit mapping, or close enough, actually any code action
|
||||
vim.keymap.set('n', '<leader>fi', require('actions-preview').code_actions, opts)
|
||||
vim.keymap.set('n', '<leader>fi',
|
||||
require('actions-preview').code_actions, opts)
|
||||
|
||||
-- Goto mappings
|
||||
local tb = require('telescope.builtin')
|
||||
@ -195,7 +187,7 @@ return {
|
||||
vim.keymap.set('n', 'gr', tb.lsp_references, opts)
|
||||
vim.keymap.set('n', '<leader>ic', tb.lsp_incoming_calls, opts)
|
||||
vim.keymap.set('n', '<leader>oc', tb.lsp_outgoing_calls, opts)
|
||||
vim.keymap.set('n', '<leader>ss', tb.lsp_document_symbols, opts)
|
||||
vim.keymap.set('n', '<leader>sd', tb.lsp_document_symbols, opts)
|
||||
vim.keymap.set('n', '<leader>sw', tb.lsp_workspace_symbols, opts)
|
||||
|
||||
-- Refactoring mappings
|
||||
@ -212,7 +204,8 @@ return {
|
||||
|
||||
-- Swtich file using clangd extension
|
||||
-- TODO: limit this to only filetypes supported by clangd
|
||||
vim.keymap.set('n', '<leader>sf', ':ClangdSwitchSourceHeader<CR>', { silent = true })
|
||||
vim.keymap.set('n', '<leader>sf',
|
||||
':ClangdSwitchSourceHeader<CR>', { silent = true })
|
||||
end
|
||||
})
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user