105 lines
3.1 KiB
Lua
105 lines
3.1 KiB
Lua
return {
|
|
'neovim/nvim-lspconfig',
|
|
dependencies = {
|
|
'williamboman/mason.nvim',
|
|
'williamboman/mason-lspconfig.nvim',
|
|
|
|
'hrsh7th/cmp-nvim-lsp',
|
|
'hrsh7th/cmp-buffer',
|
|
'hrsh7th/cmp-path',
|
|
'hrsh7th/cmp-cmdline',
|
|
'hrsh7th/nvim-cmp',
|
|
|
|
'folke/neodev.nvim',
|
|
|
|
-- TODO: https://github.com/j-hui/fidget.nvim
|
|
-- TODO: https://github.com/nvimtools/none-ls.nvim
|
|
-- TODO: https://github.com/mfussenegger/nvim-dap
|
|
-- TODO: https://github.com/rcarriga/nvim-dap-ui
|
|
},
|
|
config = function()
|
|
require('neodev').setup()
|
|
|
|
require('mason').setup()
|
|
require('mason-lspconfig').setup({
|
|
ensure_installed = {
|
|
'clangd',
|
|
'cmake',
|
|
'lua_ls',
|
|
},
|
|
automatic_installation = false,
|
|
handlers = {
|
|
function(server_name)
|
|
require('lspconfig')[server_name].setup({})
|
|
end,
|
|
['lua_ls'] = function()
|
|
local lspconfig = require('lspconfig')
|
|
lspconfig.lua_ls.setup({
|
|
settings = {
|
|
Lua = {
|
|
diagnostics = {
|
|
disable = { "missing-fields" },
|
|
}
|
|
}
|
|
}
|
|
})
|
|
end
|
|
},
|
|
})
|
|
|
|
require('cmp').setup({
|
|
sources = {
|
|
{ name = 'nvim_lsp' },
|
|
-- TODO: snippets
|
|
},
|
|
})
|
|
|
|
-- Disable displaying diagnostics as virtual text
|
|
vim.diagnostic.config({
|
|
virtual_text = false,
|
|
})
|
|
|
|
-- Diagnostic mappings
|
|
-- TODO: trouble.nvim mappings instead? https://youtu.be/MuUrCcvE-Yw?t=631
|
|
vim.keymap.set('n', '<C-n>', vim.diagnostic.goto_next, { noremap = true })
|
|
vim.keymap.set('n', '<C-p>', vim.diagnostic.goto_prev, { noremap = true })
|
|
vim.keymap.set('n', '<leader>sd', vim.diagnostic.open_float, { noremap = true })
|
|
|
|
-- Mappings to create once a language server attaches to a buffer
|
|
local augroup = vim.api.nvim_create_augroup('lsp', { clear = true })
|
|
vim.api.nvim_create_autocmd('LspAttach', {
|
|
pattern = '*',
|
|
group = augroup,
|
|
callback = function(ev)
|
|
local opts = { noremap = true, buffer = ev.buf }
|
|
|
|
-- FIXME: Should I drop this? It's only for expanding snippets because
|
|
-- coc.nvim was being weird about it
|
|
-- inoremap <silent><expr> <TAB> coc#pum#visible() ? coc#pum#confirm() : "\<TAB>"
|
|
|
|
vim.keymap.set('n', '<leader>fi', function()
|
|
-- FIXME: This doesn't stop the prompt to select the code action when
|
|
-- there is only one. Also not sure if its actually filtering
|
|
vim.lsp.buf.code_action({ context = { only = { 'quickfix' } } })
|
|
end, opts)
|
|
|
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
|
|
|
-- nnoremap <silent> <leader>gt <Plug>(coc-type-definition)
|
|
|
|
vim.keymap.set('n', '<leader>gr', vim.lsp.buf.references, opts)
|
|
|
|
-- nnoremap <silent> <leader>gu <Plug>(coc-references-used)
|
|
|
|
-- Refactoring mappings
|
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
|
-- TODO: vim.lsp.buf.format
|
|
|
|
-- Help mappings
|
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
|
vim.keymap.set('i', '<C-h>', vim.lsp.buf.signature_help, opts)
|
|
end
|
|
})
|
|
end
|
|
}
|