Iron out bugs and document completions plugin setup
This commit is contained in:
parent
d30de16dca
commit
2d22ea836f
@ -1,44 +1,62 @@
|
|||||||
return {
|
return {
|
||||||
'neovim/nvim-lspconfig',
|
'neovim/nvim-lspconfig',
|
||||||
|
|
||||||
dependencies = {
|
dependencies = {
|
||||||
|
-- Language server management plugins
|
||||||
'williamboman/mason.nvim',
|
'williamboman/mason.nvim',
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'williamboman/mason-lspconfig.nvim',
|
||||||
|
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
-- Completion plugins
|
||||||
'hrsh7th/cmp-buffer',
|
'hrsh7th/cmp-nvim-lsp', -- Source for built-in language server client
|
||||||
'hrsh7th/cmp-path',
|
'hrsh7th/cmp-buffer', -- Source for buffer words
|
||||||
'hrsh7th/cmp-cmdline',
|
'hrsh7th/cmp-path', -- Source for filesystem paths
|
||||||
'hrsh7th/nvim-cmp',
|
'hrsh7th/cmp-cmdline', -- Source for command-line
|
||||||
|
'hrsh7th/nvim-cmp', -- Completion engine combines and use the above
|
||||||
|
|
||||||
|
-- Lue vim module support in lua language server
|
||||||
'folke/neodev.nvim',
|
'folke/neodev.nvim',
|
||||||
|
|
||||||
|
-- Snippet pluggins
|
||||||
|
'L3MON4D3/LuaSnip',
|
||||||
|
'saadparwaiz1/cmp_luasnip',
|
||||||
|
|
||||||
-- TODO: https://github.com/j-hui/fidget.nvim
|
-- TODO: https://github.com/j-hui/fidget.nvim
|
||||||
|
|
||||||
-- TODO: https://github.com/nvimtools/none-ls.nvim
|
-- TODO: https://github.com/nvimtools/none-ls.nvim
|
||||||
|
|
||||||
-- TODO: https://github.com/mfussenegger/nvim-dap
|
-- TODO: https://github.com/mfussenegger/nvim-dap
|
||||||
-- TODO: https://github.com/rcarriga/nvim-dap-ui
|
-- TODO: https://github.com/rcarriga/nvim-dap-ui
|
||||||
},
|
},
|
||||||
config = function()
|
|
||||||
require('neodev').setup()
|
|
||||||
|
|
||||||
|
config = function()
|
||||||
require('mason').setup()
|
require('mason').setup()
|
||||||
require('mason-lspconfig').setup({
|
require('mason-lspconfig').setup({
|
||||||
ensure_installed = {
|
ensure_installed = {
|
||||||
'clangd',
|
'clangd',
|
||||||
'cmake',
|
'cmake',
|
||||||
|
'jsonls',
|
||||||
'lua_ls',
|
'lua_ls',
|
||||||
|
'lemminx',
|
||||||
|
'vimls',
|
||||||
|
'yamlls',
|
||||||
},
|
},
|
||||||
automatic_installation = false,
|
automatic_installation = false,
|
||||||
handlers = {
|
handlers = {
|
||||||
|
-- Default handler, sets up everything unless a custom language server
|
||||||
|
-- setup handler is defined below
|
||||||
function(server_name)
|
function(server_name)
|
||||||
require('lspconfig')[server_name].setup({})
|
require('lspconfig')[server_name].setup({})
|
||||||
end,
|
end,
|
||||||
|
|
||||||
['lua_ls'] = function()
|
['lua_ls'] = function()
|
||||||
|
require('neodev').setup()
|
||||||
local lspconfig = require('lspconfig')
|
local lspconfig = require('lspconfig')
|
||||||
lspconfig.lua_ls.setup({
|
lspconfig.lua_ls.setup({
|
||||||
settings = {
|
settings = {
|
||||||
Lua = {
|
Lua = {
|
||||||
diagnostics = {
|
diagnostics = {
|
||||||
disable = { "missing-fields" },
|
disable = { 'missing-fields', },
|
||||||
|
globals = { 'vim', },
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,17 +65,29 @@ return {
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
require('cmp').setup({
|
local cmp = require('cmp')
|
||||||
|
cmp.setup({
|
||||||
|
snippet = {
|
||||||
|
expand = function(args)
|
||||||
|
require('luasnip').lsp_expand(args.body)
|
||||||
|
end
|
||||||
|
},
|
||||||
|
mapping = cmp.mapping.preset.insert({
|
||||||
|
['<C-p>'] = cmp.mapping.select_prev_item(),
|
||||||
|
['<C-n>'] = cmp.mapping.select_next_item(),
|
||||||
|
['<C-y>'] = cmp.mapping.confirm({ select = true }),
|
||||||
|
}),
|
||||||
sources = {
|
sources = {
|
||||||
{ name = 'nvim_lsp' },
|
{ name = 'nvim_lsp' },
|
||||||
-- TODO: snippets
|
{ name = 'luasnip' },
|
||||||
|
{ name = 'buffer' },
|
||||||
|
{ name = 'path' },
|
||||||
|
{ name = 'cmdline' },
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
-- Disable displaying diagnostics as virtual text
|
-- Disable displaying diagnostics as virtual text
|
||||||
vim.diagnostic.config({
|
vim.diagnostic.config({ virtual_text = false })
|
||||||
virtual_text = false,
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Diagnostic mappings
|
-- Diagnostic mappings
|
||||||
-- TODO: trouble.nvim mappings instead? https://youtu.be/MuUrCcvE-Yw?t=631
|
-- TODO: trouble.nvim mappings instead? https://youtu.be/MuUrCcvE-Yw?t=631
|
||||||
@ -73,27 +103,26 @@ return {
|
|||||||
callback = function(ev)
|
callback = function(ev)
|
||||||
local opts = { noremap = true, buffer = ev.buf }
|
local opts = { noremap = true, buffer = ev.buf }
|
||||||
|
|
||||||
-- FIXME: Should I drop this? It's only for expanding snippets because
|
-- TODO: Should I drop this? It's only for expanding snippets because
|
||||||
-- coc.nvim was being weird about it
|
-- coc.nvim was being weird about it
|
||||||
-- inoremap <silent><expr> <TAB> coc#pum#visible() ? coc#pum#confirm() : "\<TAB>"
|
-- inoremap <silent><expr> <TAB> coc#pum#visible() ? coc#pum#confirm() : "\<TAB>"
|
||||||
|
|
||||||
vim.keymap.set('n', '<leader>fi', function()
|
-- Fixit mapping, or close enough, actually any code action
|
||||||
-- FIXME: This doesn't stop the prompt to select the code action when
|
vim.keymap.set('n', '<leader>fi', vim.lsp.buf.code_action, opts)
|
||||||
-- there is only one. Also not sure if its actually filtering
|
|
||||||
vim.lsp.buf.code_action({ context = { only = { 'quickfix' } } })
|
|
||||||
end, opts)
|
|
||||||
|
|
||||||
|
-- Goto definition mapping
|
||||||
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
vim.keymap.set('n', 'gd', vim.lsp.buf.definition, opts)
|
||||||
|
-- TODO: nnoremap <silent> <leader>gt <Plug>(coc-type-definition)
|
||||||
-- 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)
|
-- nnoremap <silent> <leader>gu <Plug>(coc-references-used)
|
||||||
|
|
||||||
|
-- Get references to symbol under cursor, store in quickfix window
|
||||||
|
vim.keymap.set('n', '<leader>gr', vim.lsp.buf.references, opts)
|
||||||
|
|
||||||
-- Refactoring mappings
|
-- Refactoring mappings
|
||||||
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
vim.keymap.set('n', '<leader>rn', vim.lsp.buf.rename, opts)
|
||||||
-- TODO: vim.lsp.buf.format
|
|
||||||
|
-- Format whole buffer mapping
|
||||||
|
vim.keymap.set('n', '<leader>gq', vim.lsp.buf.format, opts)
|
||||||
|
|
||||||
-- Help mappings
|
-- Help mappings
|
||||||
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
vim.keymap.set('n', 'K', vim.lsp.buf.hover, opts)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user