From e777ea62f96b43e63f6ed5d6fedb4177497c3734 Mon Sep 17 00:00:00 2001 From: kj_sh604 Date: Tue, 2 Jun 2026 07:52:44 -0400 Subject: refactor: put nvim config into one file --- .config/nvim/lua/coc.lua | 191 ----------------------------------------------- 1 file changed, 191 deletions(-) delete mode 100644 .config/nvim/lua/coc.lua (limited to '.config/nvim/lua/coc.lua') diff --git a/.config/nvim/lua/coc.lua b/.config/nvim/lua/coc.lua deleted file mode 100644 index 8cc2956..0000000 --- a/.config/nvim/lua/coc.lua +++ /dev/null @@ -1,191 +0,0 @@ --- old coc.nvim config (minimal) --- vim.cmd [[ --- function! CheckBackspace() abort --- let col = col('.') - 1 --- return !col || getline('.')[col - 1] =~# '\s' --- endfunction --- --- inoremap --- \ coc#pum#visible() ? coc#pum#next(1) : --- \ CheckBackspace() ? "\" : --- \ coc#refresh() --- inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" --- ]] - --- 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 = true, 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 snippets -keyset("i", "", "(coc-snippets-expand-jump)") --- use to trigger completion -keyset("i", "", "coc#refresh()", {silent = true, expr = true}) - --- use `[g` and `]g` to navigate diagnostics --- use `:cocdiagnostics` to get all diagnostics of current buffer in location list -keyset("n", "[g", "(coc-diagnostic-prev)", {silent = true}) -keyset("n", "]g", "(coc-diagnostic-next)", {silent = true}) - --- goto code navigation -keyset("n", "gd", "(coc-definition)", {silent = true}) -keyset("n", "gy", "(coc-type-definition)", {silent = true}) -keyset("n", "gi", "(coc-implementation)", {silent = true}) -keyset("n", "gr", "(coc-references)", {silent = true}) - --- use k to show documentation in preview window -function _G.show_docs() - local cw = vim.fn.expand('') - 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", 'lua _G.show_docs()', {silent = true}) - --- highlight the symbol and its references on a cursorhold event(cursor is idle) -vim.api.nvim_create_augroup("CocGroup", {}) -vim.api.nvim_create_autocmd("CursorHold", { - group = "CocGroup", - command = "silent call CocActionAsync('highlight')", - desc = "Highlight symbol under cursor on CursorHold" -}) - --- symbol renaming -keyset("n", "rn", "(coc-rename)", {silent = true}) - --- formatting selected code -keyset("x", "F", "(coc-format-selected)", {silent = true}) -keyset("n", "F", "(coc-format-selected)", {silent = true}) - --- setup formatexpr specified filetype(s) -vim.api.nvim_create_autocmd("FileType", { - group = "CocGroup", - pattern = "typescript,json", - command = "setl formatexpr=CocAction('formatSelected')", - desc = "Setup formatexpr specified filetype(s)." -}) - --- update signature help on jump placeholder -vim.api.nvim_create_autocmd("User", { - group = "CocGroup", - pattern = "CocJumpPlaceholder", - command = "call CocActionAsync('showSignatureHelp')", - desc = "Update signature help on jump placeholder" -}) - --- apply codeaction to the selected region --- example: `aap` for current paragraph -local opts = {silent = true, nowait = true} -keyset("x", "a", "(coc-codeaction-selected)", opts) -keyset("n", "a", "(coc-codeaction-selected)", opts) - --- remap keys for apply code actions at the cursor position. -keyset("n", "ac", "(coc-codeaction-cursor)", opts) --- remap keys for apply source code actions for current file. -keyset("n", "as", "(coc-codeaction-source)", opts) --- apply the most preferred quickfix action on the current line. -keyset("n", "qf", "(coc-fix-current)", opts) - --- remap keys for apply refactor code actions. -keyset("n", "re", "(coc-codeaction-refactor)", { silent = true }) -keyset("x", "r", "(coc-codeaction-refactor-selected)", { silent = true }) -keyset("n", "r", "(coc-codeaction-refactor-selected)", { silent = true }) - --- run the code lens actions on the current line -keyset("n", "cl", "(coc-codelens-action)", opts) - - --- map function and class text objects --- note: requires 'textdocument.documentsymbol' support from the language server -keyset("x", "if", "(coc-funcobj-i)", opts) -keyset("o", "if", "(coc-funcobj-i)", opts) -keyset("x", "af", "(coc-funcobj-a)", opts) -keyset("o", "af", "(coc-funcobj-a)", opts) -keyset("x", "ic", "(coc-classobj-i)", opts) -keyset("o", "ic", "(coc-classobj-i)", opts) -keyset("x", "ac", "(coc-classobj-a)", opts) -keyset("o", "ac", "(coc-classobj-a)", opts) - - --- remap and to scroll float windows/popups ----@diagnostic disable-next-line: redefined-local -local opts = {silent = true, nowait = true, expr = true} -keyset("n", "", 'coc#float#has_scroll() ? coc#float#scroll(1) : ""', opts) -keyset("n", "", 'coc#float#has_scroll() ? coc#float#scroll(0) : ""', opts) -keyset("i", "", - 'coc#float#has_scroll() ? "=coc#float#scroll(1)" : ""', opts) -keyset("i", "", - 'coc#float#has_scroll() ? "=coc#float#scroll(0)" : ""', opts) -keyset("v", "", 'coc#float#has_scroll() ? coc#float#scroll(1) : ""', opts) -keyset("v", "", 'coc#float#has_scroll() ? coc#float#scroll(0) : ""', opts) - --- use ctrl-s for selections ranges --- requires 'textdocument/selectionrange' support of language server -keyset("n", "", "(coc-range-select)", {silent = true}) -keyset("x", "", "(coc-range-select)", {silent = true}) - --- add `:format` command to format current buffer -vim.api.nvim_create_user_command("Format", "call CocAction('format')", {}) - --- " add `:fold` command to fold current buffer -vim.api.nvim_create_user_command("Fold", "call CocAction('fold', )", {nargs = '?'}) - --- add `:or` command for organize imports of the current buffer -vim.api.nvim_create_user_command("OR", "call CocActionAsync('runCommand', 'editor.action.organizeImport')", {}) - --- mappings for coclist --- code actions and coc stuff ----@diagnostic disable-next-line: redefined-local -local opts = {silent = true, nowait = true} --- show all diagnostics -keyset("n", "a", ":CocList diagnostics", opts) --- manage extensions -keyset("n", "e", ":CocList extensions", opts) --- show commands -keyset("n", "c", ":CocList commands", opts) --- find symbol of current document -keyset("n", "o", ":CocList outline", opts) --- search workspace symbols -keyset("n", "s", ":CocList -I symbols", opts) --- do default action for next item -keyset("n", "j", ":CocNext", opts) --- do default action for previous item -keyset("n", "k", ":CocPrev", opts) --- resume latest coc list -keyset("n", "p", ":CocListResume", opts) - --- add (neo)vim's native statusline support --- note: please see `:h coc-status` for integrations with external plugins that --- provide custom statusline: lightline.vim, vim-airline --- vim.opt.statusline:prepend("%{coc#status()}%{get(b:,'coc_current_function','')}") -- cgit v1.2.3