From 28ea0e3cbe1c0f980a05d6fb13a428bcab2ea1c5 Mon Sep 17 00:00:00 2001 From: Vikas Kushwaha Date: Fri, 13 Jun 2025 08:37:31 +0530 Subject: neovim updates --- .config/nvim/plugins.conf.d/coc-onload.vim | 147 ++++++++++++++++++++++++++ .config/nvim/plugins.conf.d/coc-settings.json | 10 ++ .config/nvim/plugins.conf.d/fzf.vim | 23 ++++ .config/nvim/plugins.conf.d/onedark.vim | 38 +++++++ .config/nvim/plugins.conf.d/out.vim | 36 +++++++ .config/nvim/plugins.conf.d/vimspector.vim | 21 ++++ .config/nvim/plugins.conf.d/zeal.vim | 7 ++ 7 files changed, 282 insertions(+) create mode 100644 .config/nvim/plugins.conf.d/coc-onload.vim create mode 100644 .config/nvim/plugins.conf.d/coc-settings.json create mode 100644 .config/nvim/plugins.conf.d/fzf.vim create mode 100644 .config/nvim/plugins.conf.d/onedark.vim create mode 100644 .config/nvim/plugins.conf.d/out.vim create mode 100644 .config/nvim/plugins.conf.d/vimspector.vim create mode 100644 .config/nvim/plugins.conf.d/zeal.vim (limited to '.config/nvim/plugins.conf.d') diff --git a/.config/nvim/plugins.conf.d/coc-onload.vim b/.config/nvim/plugins.conf.d/coc-onload.vim new file mode 100644 index 0000000..b3db607 --- /dev/null +++ b/.config/nvim/plugins.conf.d/coc-onload.vim @@ -0,0 +1,147 @@ + +" May need for Vim (not Neovim) since coc.nvim calculates byte offset by count +" utf-8 byte sequence +set encoding=utf-8 +" Some servers have issues with backup files, see #649 +set nobackup +set nowritebackup + +" Having longer updatetime (default is 4000 ms = 4s) leads to noticeable +" delays and poor user experience +set updatetime=1000 + +" Always show the signcolumn, otherwise it would shift the text each time +" diagnostics appear/become resolved +set signcolumn=yes + +" Use tab for trigger completion with characters ahead and navigate +" NOTE: There's always complete item selected by default, you may want to enable +" no select by `"suggest.noselect": true` in your configuration file +" NOTE: Use command ':verbose imap ' to make sure tab is not mapped by +" other plugin before putting this into your config + inoremap + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\" : + \ coc#refresh() + inoremap coc#pum#visible() ? coc#pum#prev(1) : "\" + +" Make to accept selected completion item or notify coc.nvim to format +" u breaks current undo, please make your own choice +inoremap coc#pum#visible() ? coc#pum#confirm() + \: "\u\\=coc#on_enter()\" + +function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +" Use to trigger completion +if has('nvim') + inoremap coc#refresh() +else + inoremap coc#refresh() +endif + +" Use `[g` and `]g` to navigate diagnostics +" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list +nmap [g (coc-diagnostic-prev) +nmap ]g (coc-diagnostic-next) + +" GoTo code navigation +nmap gd (coc-definition) +nmap gy (coc-type-definition) +nmap gi (coc-implementation) +nmap gr (coc-references) + +" Override neovim's builtin referencing +nmap grr (coc-references) + +" Use K to show documentation in preview window +nnoremap :call ShowDocumentation() + +function! ShowDocumentation() + if CocAction('hasProvider', 'hover') + call CocActionAsync('doHover') + else + call feedkeys('K', 'in') + endif +endfunction + +" Highlight the symbol and its references when holding the cursor +autocmd CursorHold * silent call CocActionAsync('highlight') + +" Symbol renaming +nmap rn (coc-rename) + +" Formatting selected code +xmap cf (coc-format-selected) +nmap cf (coc-format-selected) + +augroup mygroup + autocmd! + " Setup formatexpr specified filetype(s) + autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') + " Update signature help on jump placeholder + autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') +augroup end + +" Applying code actions to the selected code block +" Example: `aap` for current paragraph +xmap aa (coc-codeaction-selected) +nmap aa (coc-codeaction-selected) + +" Remap keys for applying code actions at the cursor position +nmap ac (coc-codeaction-cursor) +" Remap keys for apply code actions affect whole buffer +nmap as (coc-codeaction-source) +" Apply the most preferred quickfix action to fix diagnostic on the current line +nmap aq (coc-fix-current) + +" Remap keys for applying refactor code actions +nmap re (coc-codeaction-refactor) +xmap r (coc-codeaction-refactor-selected) +nmap r (coc-codeaction-refactor-selected) + +" Run the Code Lens action on the current line +nmap cl (coc-codelens-action) + +" Map function and class text objects +" NOTE: Requires 'textDocument.documentSymbol' support from the language server +xmap if (coc-funcobj-i) +omap if (coc-funcobj-i) +xmap af (coc-funcobj-a) +omap af (coc-funcobj-a) +xmap ic (coc-classobj-i) +omap ic (coc-classobj-i) +xmap ac (coc-classobj-a) +omap ac (coc-classobj-a) + +" Remap and to scroll float windows/popups +if has('nvim-0.4.0') || has('patch-8.2.0750') + nnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + nnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(1)\" : "\" + inoremap coc#float#has_scroll() ? "\=coc#float#scroll(0)\" : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(1) : "\" + vnoremap coc#float#has_scroll() ? coc#float#scroll(0) : "\" +endif + +" Use CTRL-S for selections ranges +" Requires 'textDocument/selectionRange' support of language server +nmap (coc-range-select) +xmap (coc-range-select) + +" Add `:Format` command to format current buffer +command! -nargs=0 Format :call CocActionAsync('format') + +" Add `:Fold` command to fold current buffer +command! -nargs=? Fold :call CocAction('fold', ) + +" Add `:OR` command for organize imports of the current buffer +command! -nargs=0 OR :call CocActionAsync('runCommand', 'editor.action.organizeImport') + +" 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 +set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} + diff --git a/.config/nvim/plugins.conf.d/coc-settings.json b/.config/nvim/plugins.conf.d/coc-settings.json new file mode 100644 index 0000000..437572d --- /dev/null +++ b/.config/nvim/plugins.conf.d/coc-settings.json @@ -0,0 +1,10 @@ +{ + "suggest.autoTrigger": "always", + "diagnostic.enable": true, + "python.linting.pycodestyleEnabled": true, + "html.autoCreateQuotes": false, + "coc.preferences.formatOnType": true, + "copilot.showRemainingText": true, + "copilot.enable": false, + "typescript.autoClosingTags": false +} diff --git a/.config/nvim/plugins.conf.d/fzf.vim b/.config/nvim/plugins.conf.d/fzf.vim new file mode 100644 index 0000000..49fec8d --- /dev/null +++ b/.config/nvim/plugins.conf.d/fzf.vim @@ -0,0 +1,23 @@ +" --> Fzf + +let g:fzf_history_dir = system('echo "${XDG_STATE_HOME:-$HOME/.local/state}/fzf/fzf_vim_history') + +let g:fzf_layout = { 'window': { 'width': 1, 'height': 1 } } +command! -bang -nargs=? -complete=dir Files + \ call fzf#vim#files(, {'options': ['--info=inline', '--preview', 'preview {}']}, 0) + +" Mapping selecting mappings +nmap (fzf-maps-n) +xmap (fzf-maps-x) +omap (fzf-maps-o) + +" Insert mode completion +imap (fzf-complete-word) +imap (fzf-complete-path) +imap (fzf-complete-line) + +" Fzf keybindings +nnoremap fh :History +nnoremap ff :Files +nnoremap f. :Files %:p:h + diff --git a/.config/nvim/plugins.conf.d/onedark.vim b/.config/nvim/plugins.conf.d/onedark.vim new file mode 100644 index 0000000..6f526bd --- /dev/null +++ b/.config/nvim/plugins.conf.d/onedark.vim @@ -0,0 +1,38 @@ +" --> Onedark Theme +if exists('+termguicolors') + let g:airline_theme = 'onedark' + let g:onedark_terminal_italics = 1 + let g:onedark_color_overrides = { + \ "foreground": { "gui": "#BBC2CF", "cterm": "145", "cterm16": "NONE" }, + \ "background": { "gui": "#181C24", "cterm": "235", "cterm16": "NONE" }, + \ "comment_grey": { "gui": "#6C7380", "cterm": "59", "cterm16": "7" }, + \ "gutter_fg_grey": { "gui": "#6272A4", "cterm": "238", "cterm16": "8" }, + \ "special_grey": { "gui": "#5Ba078", "cterm": "238", "cterm16": "7" }, + \ } + " \ "background": { "gui": "#202426", "cterm": "235", "cterm16": "NONE" }, + " + " \ "red": { "gui": "#E06C75", "cterm": "204", "cterm16": "1" }, + " \ "dark_red": { "gui": "#BE5046", "cterm": "196", "cterm16": "9" }, + " \ "green": { "gui": "#98C379", "cterm": "114", "cterm16": "2" }, + " \ "yellow": { "gui": "#E5C07B", "cterm": "180", "cterm16": "3" }, + " \ "dark_yellow": { "gui": "#D19A66", "cterm": "173", "cterm16": "11" }, + " \ "blue": { "gui": "#61AFEF", "cterm": "39", "cterm16": "4" }, + " \ "purple": { "gui": "#C678DD", "cterm": "170", "cterm16": "5" }, + " \ "cyan": { "gui": "#56B6C2", "cterm": "38", "cterm16": "6" }, + " \ "black": { "gui": "#282C34", "cterm": "235", "cterm16": "0" }, + " \ "white": { "gui": "#ABB2BF", "cterm": "145", "cterm16": "15" }, + " \ "cursor_grey": { "gui": "#2C323C", "cterm": "236", "cterm16": "0" }, + " \ "visual_grey": { "gui": "#3E4452", "cterm": "237", "cterm16": "8" }, + " \ "menu_grey": { "gui": "#3E4452", "cterm": "237", "cterm16": "7" }, + " \ "vertsplit": { "gui": "#3E4452", "cterm": "59", "cterm16": "7" }, + + " autocmd ColorScheme * call onedark#extend_highlight("LineNr", { + " \ "fg": { "gui": "#6272A4", "cterm": "238", "cterm16": "8" }, + " \ }) + let &t_8f="\[38;2;%lu;%lu;%lum" + let &t_8b="\[48;2;%lu;%lu;%lum" + " set termguicolors noshowmode + colorscheme onedark + " autocmd VimEnter * AirlineTheme +endif + diff --git a/.config/nvim/plugins.conf.d/out.vim b/.config/nvim/plugins.conf.d/out.vim new file mode 100644 index 0000000..6e4e1f1 --- /dev/null +++ b/.config/nvim/plugins.conf.d/out.vim @@ -0,0 +1,36 @@ +" capture (dump) the (somewhat long) ouput of the commands like `:digraph`, `:map', `:highlight`, `:scripnames` etc. + +function! s:dump(cmd) abort + + " Start a new split or maybe a buffer or a tab + " enew | " open a new buffer + 10split | enew | " open a new split (with 10% height (?)) + " tabnew | " open a new tab + + " Make it a scratch buffer ( `:help special-buffers`) + setlocal + \ bufhidden=wipe + \ buftype=nofile + \ nobuflisted + \ nolist + \ noswapfile + \ norelativenumber + \ nonumber + + " Write the cmd output to the buffer + put =execute(a:cmd) + " There are 2 empty line at the beginning of the buffer before the ouput of + " the cmd. Not sure from where they are comning from. Anyhow I will delete + " them. + norm gg2dd + + " No modifications to this buffer + setlocal readonly nomodifiable nomodified + + " Press escape to close when you're done + nnoremap :bd + +endfunction + +" Define a command to use the function easier +command! -nargs=1 Dump execute "call s:dump(" string() ")" diff --git a/.config/nvim/plugins.conf.d/vimspector.vim b/.config/nvim/plugins.conf.d/vimspector.vim new file mode 100644 index 0000000..521e252 --- /dev/null +++ b/.config/nvim/plugins.conf.d/vimspector.vim @@ -0,0 +1,21 @@ +" --> Vimspector +let g:vimspector_base_dir = expand('$HOME/.local/share/nvim/vimspector') +let g:vimspector_enable_mappings = 'HUMAN' +nnoremap dc VimspectorContinue +nnoremap ds VimspectorStop +nnoremap dr VimspectorRestart +nnoremap dp VimspectorPause +nnoremap dl VimspectorBreakpoints +nnoremap dd VimspectorToggleBreakpoint +nnoremap db VimspectorToggleConditionalBreakpoint +nnoremap df VimspectorAddFunctionBreakpoint +nnoremap dg VimspectorGoToCurrentLine +nnoremap dx :call vimspector#ClearBreakpoints() +nnoremap dq :VimspectorReset +nnoremap VimspectorContinue +nnoremap VimspectorStepOver +nnoremap VimspectorStepInto +nnoremap VimspectorStepOut +nnoremap VimspectorToggleBreakpoint +nnoremap VimspectorRunToCursor + diff --git a/.config/nvim/plugins.conf.d/zeal.vim b/.config/nvim/plugins.conf.d/zeal.vim new file mode 100644 index 0000000..1b2734f --- /dev/null +++ b/.config/nvim/plugins.conf.d/zeal.vim @@ -0,0 +1,7 @@ +" --> Zeal docs +let g:zv_disable_mapping = 1 +nmap z Zeavim +vmap z ZVVisSelection +nmap gz ZVOperator +nmap z ZVKeyDocset + -- cgit v1.2.3