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.
|
2022-08-29 15:40:41 +03:00
|
|
|
vim.opt.shortmess:append("c")
|
2022-08-19 11:14:32 +03:00
|
|
|
|
|
|
|
-- always show signcolumns
|
2022-08-29 15:40:41 +03:00
|
|
|
vim.opt.signcolumn = "yes"
|
2022-08-19 11:14:32 +03:00
|
|
|
|
|
|
|
-- 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.
|
2022-08-29 15:40:41 +03:00
|
|
|
vim.keymap.set("i", "<C-space>", vim.fn["coc#refresh"], {
|
|
|
|
silent = true,
|
|
|
|
expr = true,
|
2022-08-19 11:14:32 +03:00
|
|
|
})
|
|
|
|
|
|
|
|
-- 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-29 15:40:41 +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-29 15:40:41 +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
|
2022-08-29 15:40:41 +03:00
|
|
|
vim.keymap.set("n", "[c", "<Plug>(coc-diagnostic-prev)", sr_opts)
|
|
|
|
vim.keymap.set("n", "]c", "<Plug>(coc-diagnostic-next)", sr_opts)
|
2022-08-19 11:14:32 +03:00
|
|
|
|
|
|
|
-- Remap keys for gotos
|
2022-08-29 15:40:41 +03:00
|
|
|
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)
|
2022-08-19 11:14:32 +03:00
|
|
|
|
|
|
|
-- Remap for do code action of current line
|
2022-08-29 15:40:41 +03:00
|
|
|
vim.keymap.set("n", "<localleader>a", "<Plug>(coc-codeaction)")
|
2022-08-19 11:14:32 +03:00
|
|
|
-- Remap for rename current word
|
2022-08-29 15:40:41 +03:00
|
|
|
vim.keymap.set("n", "<localleader>n", "<Plug>(coc-rename)")
|
2022-08-19 11:14:32 +03:00
|
|
|
|
|
|
|
-- Mapping for CocList
|
2022-08-29 15:40:41 +03:00
|
|
|
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>")
|