-- https://raw.githubusercontent.com/neoclide/coc.nvim/master/doc/coc-example-config.lua -- Some servers have issues with backup files, see #649 vim.opt.backup = false vim.opt.writebackup = false -- Having longer updatetime (default is 4000 ms = 4s) leads to noticeable -- delays and poor user experience vim.opt.updatetime = 300 -- Always show the signcolumn, otherwise it would shift the text each time -- diagnostics appeared/became resolved vim.opt.signcolumn = "yes" local keyset = vim.keymap.set -- Autocomplete function _G.check_back_space() local col = vim.fn.col('.') - 1 return col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') ~= nil end -- Use Tab for trigger completion with characters ahead and navigate -- NOTE: There's always a completion item selected by default, you may want to enable -- no select by setting `"suggest.noselect": true` in your configuration file -- NOTE: Use command ':verbose imap ' to make sure Tab is not mapped by -- other plugins before putting this into your config local opts = {silent = false, noremap = true, expr = true, replace_keycodes = false} keyset("i", "", 'coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "" : coc#refresh()', opts) keyset("i", "", [[coc#pum#visible() ? coc#pum#prev(1) : "\"]], opts) -- Make to accept selected completion item or notify coc.nvim to format -- u breaks current undo, please make your own choice keyset("i", "", [[coc#pum#visible() ? coc#pum#confirm() : "\u\\=coc#on_enter()\"]], opts) -- Use to trigger completion keyset("i", "", "coc#refresh()", {silent = true, expr = true})