2022-08-19 11:14:32 +03:00
|
|
|
-- Smaller updatetime for CursorHold & CursorHoldI
|
|
|
|
vim.opt.updatetime = 300
|
|
|
|
|
2022-08-26 16:55:21 +03:00
|
|
|
-- Coc don't use completeopt
|
|
|
|
vim.opt.completeopt = {}
|
2022-08-19 11:14:32 +03:00
|
|
|
-- don't give |ins-completion-menu| messages.
|
|
|
|
vim.opt.shortmess:append('c')
|
|
|
|
|
|
|
|
-- always show signcolumns
|
|
|
|
vim.opt.signcolumn = 'yes'
|
|
|
|
|
|
|
|
-- Some server have issues with backup files, see coc#649
|
|
|
|
vim.opt.backup = false
|
|
|
|
vim.opt.writebackup = false
|
|
|
|
|
|
|
|
-- Better display for messages
|
|
|
|
vim.opt.cmdheight = 2
|
|
|
|
|
|
|
|
-- Use <c-space> for trigger completion.
|
|
|
|
vim.keymap.set('i', '<C-space>', vim.fn['coc#refresh'], {
|
|
|
|
silent = true,
|
|
|
|
expr = true
|
|
|
|
})
|
|
|
|
|
|
|
|
-- Use <cr> for confirm completion, `<C-g>u` means break undo chain at current
|
|
|
|
-- position. Coc only does snippet and additional edit on confirm.
|
|
|
|
local function confirm_coc_completion()
|
2022-08-26 16:55:21 +03:00
|
|
|
if vim.call'coc#pum#visible' == 1 then
|
|
|
|
vim.call'coc#pum#confirm'
|
|
|
|
return ""
|
|
|
|
else
|
|
|
|
return "<CR>"
|
|
|
|
end
|
2022-08-19 11:14:32 +03:00
|
|
|
end
|
2022-08-26 16:55:21 +03:00
|
|
|
vim.keymap.set('i', '<CR>', confirm_coc_completion, { expr = true, silent = true })
|
2022-08-19 11:14:32 +03:00
|
|
|
|
|
|
|
local sr_opts = { silent = true, remap = true }
|
|
|
|
-- Use `[c` and `]c` for navigate diagnostics
|
|
|
|
vim.keymap.set('n', '[c', '<Plug>(coc-diagnostic-prev)', sr_opts)
|
|
|
|
vim.keymap.set('n', ']c', '<Plug>(coc-diagnostic-next)', sr_opts)
|
|
|
|
|
|
|
|
-- Remap keys for gotos
|
|
|
|
vim.keymap.set('n', 'gd', '<Plug>(coc-definition)', sr_opts)
|
|
|
|
vim.keymap.set('n', 'gy', '<Plug>(coc-type-definition)', sr_opts)
|
|
|
|
vim.keymap.set('n', 'gi', '<Plug>(coc-implementation)', sr_opts)
|
|
|
|
vim.keymap.set('n', 'gr', '<Plug>(coc-references)', sr_opts)
|
|
|
|
|
|
|
|
-- Remap for do code action of current line
|
|
|
|
vim.keymap.set('n', '<localleader>a', '<Plug>(coc-codeaction)')
|
|
|
|
-- Remap for rename current word
|
|
|
|
vim.keymap.set('n', '<localleader>n', '<Plug>(coc-rename)')
|
|
|
|
|
|
|
|
-- Mapping for CocList
|
|
|
|
vim.keymap.set('n', '<localleader>cl', ':CocList<CR>')
|
|
|
|
vim.keymap.set('n', '<localleader>cd', ':CocList diagnostics<CR>')
|
|
|
|
vim.keymap.set('n', '<localleader>cc', ':CocList commands<CR>')
|
|
|
|
vim.keymap.set('n', '<localleader>co', ':CocList outline<CR>')
|
|
|
|
vim.keymap.set('n', '<localleader>cs', ':CocList symbols<CR>')
|