vim.cmd([[ let g:coc_global_extensions = [ \ 'coc-clangd', \ 'coc-lua', \ 'coc-python', \ 'coc-json', \ \ 'coc-translator', \ 'coc-yank', \ 'coc-pairs', \ 'coc-explorer', \ 'coc-lists', \ ] ]]) local map = vim.api.nvim_set_keymap -- coc 设置 -- 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 = true, noremap = true, expr = true, replace_keycodes = false} map("i", "", [[ coc#pum#visible() ? coc#pum#next(1) : v:lua.check_back_space() ? "" : coc#refresh() ]] , opts) map("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 map("i", "", [[ coc#pum#visible() ? coc#pum#confirm() : "\u\\=coc#on_enter()\" ]], opts)