123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- local keyset = vim.keymap.set
- 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
- local opts = { silent = true, noremap = true, expr = true, replace_keycodes = false }
- keyset("i", "<S-TAB>", [[coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"]], opts)
- keyset("i", "<TAB>", [[coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"]], opts)
- keyset("i", "<c-j>", "<Plug>(coc-snippets-expand-jump)")
- keyset("i", "<c-space>", "coc#refresh()", {silent = true, expr = true})
- keyset("n", "[g", "<Plug>(coc-diagnostic-prev)", {silent = true})
- keyset("n", "]g", "<Plug>(coc-diagnostic-next)", {silent = true})
- keyset("n", "gd", "<Plug>(coc-definition)", {silent = true})
- keyset("n", "gy", "<Plug>(coc-type-definition)", {silent = true})
- keyset("n", "gi", "<Plug>(coc-implementation)", {silent = true})
- keyset("n", "gr", "<Plug>(coc-references)", {silent = true})
- function _G.show_docs()
- local cw = vim.fn.expand('<cword>')
- if vim.fn.index({'vim', 'help'}, vim.bo.filetype) >= 0 then
- vim.api.nvim_command('h ' .. cw)
- elseif vim.api.nvim_eval('coc#rpc#ready()') then
- vim.fn.CocActionAsync('doHover')
- else
- vim.api.nvim_command('!' .. vim.o.keywordprg .. ' ' .. cw)
- end
- end
- keyset("n", "K", '<CMD>lua _G.show_docs()<CR>', {silent = true})
|