Port coc.nvim mappings to native LSP
This commit is contained in:
parent
1d45d47556
commit
97cfaddce8
@ -4,7 +4,6 @@ return {
|
|||||||
'williamboman/mason.nvim',
|
'williamboman/mason.nvim',
|
||||||
'williamboman/mason-lspconfig.nvim',
|
'williamboman/mason-lspconfig.nvim',
|
||||||
|
|
||||||
'neovim/nvim-lspconfig',
|
|
||||||
'hrsh7th/cmp-nvim-lsp',
|
'hrsh7th/cmp-nvim-lsp',
|
||||||
'hrsh7th/cmp-buffer',
|
'hrsh7th/cmp-buffer',
|
||||||
'hrsh7th/cmp-path',
|
'hrsh7th/cmp-path',
|
||||||
@ -42,5 +41,52 @@ return {
|
|||||||
-- TODO: snippets
|
-- TODO: snippets
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
end,
|
|
||||||
|
-- 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
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user