" ============================================================================= " URL: https://github.com/sainnhe/dotfiles " Filename: .config/nvim/features/full.vim " Author: Sainnhe Park " Email: sainnhe@gmail.com " License: Anti-996 && MIT " ============================================================================= " {{{Status line " {{{lightline.vim let g:lightline = {} let g:lightline.separator = { 'left': "\ue0b8", 'right': "\ue0be" } let g:lightline.subseparator = { 'left': "\ue0b9", 'right': "\ue0b9" } let g:lightline.tabline_separator = { 'left': "\ue0bc", 'right': "\ue0ba" } let g:lightline.tabline_subseparator = { 'left': "\ue0bb", 'right': "\ue0bb" } let g:lightline#asyncrun#indicator_none = '' let g:lightline#asyncrun#indicator_run = 'Running...' if g:vim_lightline_artify == 0 let g:lightline.active = { \ 'left': [ [ 'mode', 'paste' ], \ [ 'readonly', 'filename', 'modified', 'fileformat', 'devicons_filetype' ] ], \ 'right': [ [ 'lineinfo' ], \ [ 'linter_errors', 'linter_warnings', 'linter_ok', 'pomodoro' ], \ [ 'asyncrun_status', 'coc_status' ] ] \ } let g:lightline.inactive = { \ 'left': [ [ 'filename' , 'modified', 'fileformat', 'devicons_filetype' ]], \ 'right': [ [ 'lineinfo' ] ] \ } let g:lightline.tabline = { \ 'left': [ [ 'vim_logo', 'tabs' ] ], \ 'right': [ [ 'git_global' ], \ [ 'git_buffer' ] ] \ } let g:lightline.tab = { \ 'active': [ 'tabnum', 'filename', 'modified' ], \ 'inactive': [ 'tabnum', 'filename', 'modified' ] } else let g:lightline.active = { \ 'left': [ [ 'artify_mode', 'paste' ], \ [ 'readonly', 'filename', 'modified', 'fileformat', 'devicons_filetype' ] ], \ 'right': [ [ 'artify_lineinfo' ], \ [ 'linter_errors', 'linter_warnings', 'linter_ok', 'pomodoro' ], \ [ 'asyncrun_status', 'coc_status' ] ] \ } let g:lightline.inactive = { \ 'left': [ [ 'filename' , 'modified', 'fileformat', 'devicons_filetype' ]], \ 'right': [ [ 'artify_lineinfo' ] ] \ } let g:lightline.tabline = { \ 'left': [ [ 'vim_logo', 'tabs' ] ], \ 'right': [ [ 'git_global' ], \ [ 'git_buffer' ] ] \ } let g:lightline.tab = { \ 'active': [ 'artify_activetabnum', 'artify_filename', 'modified' ], \ 'inactive': [ 'artify_inactivetabnum', 'filename', 'modified' ] } endif let g:lightline.tab_component_function = { \ 'artify_activetabnum': 'custom#lightline#artify_active_tabnum', \ 'artify_inactivetabnum': 'custom#lightline#artify_inactive_tabnum', \ 'artify_filename': 'custom#lightline#artify_tabname', \ 'tabnum': 'custom#lightline#tabnum', \ 'filename': 'lightline#tab#filename', \ 'modified': 'lightline#tab#modified', \ 'readonly': 'lightline#tab#readonly' \ } let g:lightline.component = { \ 'git_buffer' : '%{get(b:, "coc_git_status", "")}', \ 'git_global' : '%{custom#lightline#git_global()}', \ 'artify_mode': '%{custom#lightline#artify_mode()}', \ 'artify_lineinfo': "%2{custom#lightline#artify_line_percent()}\uf295 %3{custom#lightline#artify_line_num()}:%-2{custom#lightline#artify_column_num()}", \ 'vim_logo': "\ue7c5", \ 'pomodoro': '%{custom#lightline#pomodoro()}', \ 'mode': '%{lightline#mode()}', \ 'filename': '%t', \ 'fileformat': '%{&fenc!=#""?&fenc:&enc}[%{&ff}]', \ 'modified': '%M', \ 'paste': '%{&paste?"PASTE":""}', \ 'readonly': '%R', \ 'lineinfo': '%2p%% %3l:%-2v' \ } let g:lightline.component_function = { \ 'devicons_filetype': 'custom#lightline#devicons', \ 'coc_status': 'custom#lightline#coc_status' \ } let g:lightline.component_expand = { \ 'linter_warnings': 'custom#lightline#coc_diagnostic_warning', \ 'linter_errors': 'custom#lightline#coc_diagnostic_error', \ 'linter_ok': 'custom#lightline#coc_diagnostic_ok', \ 'asyncrun_status': 'lightline#asyncrun#status' \ } let g:lightline.component_type = { \ 'linter_warnings': 'warning', \ 'linter_errors': 'error' \ } " }}} " {{{tmuxline.vim if g:vim_is_in_tmux == 1 && !has('win32') let g:tmuxline_preset = { \'a' : '#S', \'b' : '%R', \'c' : [ '#{sysstat_mem} #[fg=blue]#{sysstat_ntemp} #(~/.tmux/tmuxline/widget-color.sh)\ufa51#{upload_speed}' ], \'win' : [ '#I', '#W' ], \'cwin' : [ '#I', '#W', '#F' ], \'x' : [ "#(~/.tmux/tmuxline/widget-color.sh)#{download_speed} \uf6d9 #[fg=blue]#{sysstat_itemp} #{sysstat_cpu}" ], \'y' : [ '%a' ], \'z' : '#H #{prefix_highlight}' \} let g:tmuxline_separators = { \ 'left' : "\ue0bc", \ 'left_alt': "\ue0bd", \ 'right' : "\ue0ba", \ 'right_alt' : "\ue0bd", \ 'space' : ' '} endif " }}} " }}} " {{{Additional UI components " {{{vim-startify if !exists('g:vim_man_pager') let g:startify_session_dir = fnamemodify(custom#utils#stdpath('data'), ':p') . 'sessions' let g:startify_files_number = 5 let g:startify_update_oldfiles = 1 let g:startify_session_delete_buffers = 1 let g:startify_change_to_dir = 1 let g:startify_fortune_use_unicode = 1 let g:startify_padding_left = 3 let g:startify_session_remove_lines = ['setlocal', 'winheight'] let g:startify_session_sort = 1 let g:startify_custom_indices = ['1', '2', '3', '4', '5', '1', '2', '3', '4', '5'] let g:startify_commands = [ \ {'l': 'CocList'}, \ {'f': 'Clap'}, \ {'g': 'Clap grep'}, \ {'u': 'Update'}, \ ] " figlet -f slant if has('nvim') let g:startify_custom_header = [ \ ' ', \ ' _____ _ __ _ _ __ _ ', \ ' / ___/____ _(_)___ ____ / /_ ___ ( )_____ / | / /__ ____ _ __(_)___ ___ ', \ ' \__ \/ __ `/ / __ \/ __ \/ __ \/ _ \|// ___/ / |/ / _ \/ __ \ | / / / __ `__ \', \ ' ___/ / /_/ / / / / / / / / / / / __/ (__ ) / /| / __/ /_/ / |/ / / / / / / /', \ ' /____/\__,_/_/_/ /_/_/ /_/_/ /_/\___/ /____/ /_/ |_/\___/\____/|___/_/_/ /_/ /_/ ', \ ' ', \ ] else let g:startify_custom_header = [ \ ' ', \ ' _____ _ __ _ _ ___ ', \ ' / ___/____ _(_)___ ____ / /_ ___ ( )_____ | | / (_)___ ___ ', \ ' \__ \/ __ `/ / __ \/ __ \/ __ \/ _ \|// ___/ | | / / / __ `__ \', \ ' ___/ / /_/ / / / / / / / / / / / __/ (__ ) | |/ / / / / / / /', \ ' /____/\__,_/_/_/ /_/_/ /_/_/ /_/\___/ /____/ |___/_/_/ /_/ /_/ ', \ ' ', \ ] endif let g:startify_lists = [ \ { 'type': 'dir', 'header': [" \ufa1eMRU Files in ". getcwd()] }, \ { 'type': 'files', 'header': [" \ufa1eMRU Files"] }, \ { 'type': 'bookmarks', 'header': [" \uf5c2 Bookmarks"] }, \ { 'type': 'sessions', 'header': [" \ue62e Sessions"] }, \ { 'type': 'commands', 'header': [" \ufb32 Commands"] }, \ ] let g:startify_skiplist = [ \ '/mnt/*', \ ] function! s:startify_mappings() abort nmap o nmap h :wincmd h nmap :CocList project endfunction augroup StartifyCustom autocmd! autocmd User CocNvimInit if !argc() | call custom#explorer#startify() | endif autocmd FileType startify call s:startify_mappings() autocmd User Startified nmap (startify-open-buffers):call custom#explorer#toggle() augroup END endif " }}} " }}} " {{{Language features " {{{coc.nvim " {{{coc-init let g:coc_data_home = fnamemodify(custom#utils#stdpath('data'), ':p') . 'coc' let g:coc_global_extensions = [ \ 'coc-calc', \ 'coc-clangd', \ 'coc-cmake', \ 'coc-css', \ 'coc-diagnostic', \ 'coc-dictionary', \ 'coc-docker', \ 'coc-emmet', \ 'coc-emoji', \ 'coc-explorer', \ 'coc-git', \ 'coc-gitignore', \ 'coc-highlight', \ 'coc-html', \ 'coc-htmlhint', \ 'coc-imselect', \ 'coc-json', \ 'coc-julia', \ 'coc-lists', \ 'coc-lua', \ 'coc-markdown-preview-enhanced', \ 'coc-markdownlint', \ 'coc-marketplace', \ 'coc-prettier', \ 'coc-project', \ 'coc-pyright', \ 'coc-rust-analyzer', \ 'coc-sh', \ 'coc-snippets', \ 'coc-spell-checker', \ 'coc-sql', \ 'coc-svg', \ 'coc-syntax', \ 'coc-tag', \ 'coc-terminal', \ 'coc-texlab', \ 'coc-toml', \ 'coc-tsserver', \ 'coc-vimlsp', \ 'coc-webview', \ 'coc-xml', \ 'coc-yaml', \ 'coc-yank', \ ] " }}} " {{{coc-settings augroup CocCustom autocmd! autocmd CursorHold * silent if g:coc_hover_enable == 1 && !coc#float#has_float() | call CocActionAsync('doHover') | endif autocmd CursorHold * silent if &filetype !=# 'markdown' | call CocActionAsync('highlight') | endif autocmd User CocGitStatusChange CocCommand git.refresh autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') autocmd User CocGitStatusChange,CocStatusChange,CocDiagnosticChange call lightline#update() augroup END let g:coc_hover_enable = 0 call coc#config('project', { \ 'dbpath': fnamemodify(g:coc_data_home, ':p') . 'project.json', \ }) call coc#config('xml', { \ 'java': { \ 'home': has('win32') ? 'C:\Users\gaoti\scoop\apps\openjdk\current' : \ has('osxdarwin') ? '/Library/Java/JavaVirtualMachines/openjdk17-oracle/Contents/Home' : \ '/usr/lib/jvm/default' \ } \ }) call coc#config('semanticTokens', { \ 'filetypes': has('nvim') ? [''] : ['*'] \ }) if has('win32') call coc#config('terminal', { \ 'shellPath': 'powershell', \ 'shellArgs': ['-nologo'], \ }) endif " }}} " {{{coc-mappings inoremap \ coc#jumpable() ? "\=coc#rpc#request('snippetNext', [])\" : \ pumvisible() ? coc#_select_confirm() : \ "\" inoremap \ coc#jumpable() ? "\=coc#rpc#request('snippetPrev', [])\" : \ "\" inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : \ custom#utils#check_back_space() ? "\" : \ coc#refresh() inoremap pumvisible() ? "\\\" : "\" inoremap pumvisible() ? "\\\" : "\" inoremap pumvisible() ? "\\\" : "\" inoremap pumvisible() ? "\\\" : "\" inoremap pumvisible() ? "\\\" : "\" 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)\" : "\" nnoremap :CocOutline nnoremap :CocCommand terminal.Toggle tnoremap :CocCommand terminal.Toggle nnoremap :CocCommand terminal.REPL tnoremap :CocCommand terminal.Toggle nmap f :CocList nmap fy :CocList yank nmap fs :CocList symbols nmap jd (coc-definition) nmap jD (coc-declaration) nmap jt (coc-type-definition) nmap jr (coc-references-used) nmap jm (coc-implementation) nmap r (coc-rename) nmap R (coc-refactor) nmap ca (coc-codeaction) nmap cl (coc-codeaction-line) nmap cc (coc-codeaction-cursor) vmap c (coc-codeaction-selected) nmap o (coc-openlink) nmap l (coc-codelens-action) nmap mf :CocCommand prettier.formatFile nmap mp :CocCommand markdown-preview-enhanced.openPreview nmap mi :CocCommand markdown-preview-enhanced.openImageHelper nmap mI :CocCommand markdown-preview-enhanced.showUploadedImages nmap mr :CocCommand markdown-preview-enhanced.runCodeChunk nmap mR :CocCommand markdown-preview-enhanced.runAllCodeChunks nmap (coc-format) vmap (coc-format-selected) nmap gj (coc-git-nextchunk) nmap gk (coc-git-prevchunk) nmap gi (coc-git-chunkinfo) omap ig (coc-git-chunk-inner) xmap ig (coc-git-chunk-inner) omap ag (coc-git-chunk-outer) xmap ag (coc-git-chunk-outer) nmap gD :CocCommand git.diffCached nmap gu :CocCommand git.chunkUndo nmap ga :CocCommand git.chunkStage nmap gf :CocCommand git.foldUnchanged nmap go :CocCommand git.browserOpen nmap gs :CocList gstatus nmap gla :CocList commits nmap glc :CocList bcommits nmap gll (coc-git-commit) nmap dj (coc-diagnostic-next) nmap dk (coc-diagnostic-prev) nmap df (coc-fix-current) nmap dd :CocDiagnostics nmap d :CocList diagnostics if !has('nvim') xmap if (coc-funcobj-i) omap if (coc-funcobj-i) xmap af (coc-funcobj-a) omap af (coc-funcobj-a) endif if !exists('g:which_key_map') let g:which_key_map = { \ 'name': 'Alpha', \ "\": { \ 'name': 'Beta', \ "\": { \ 'name': 'Omega' \ } \ } \ } endif let g:which_key_map['j'] = { \ 'name': 'jump', \ 'd': 'definition', \ 'D': 'declaration', \ 't': 'type definition', \ 'r': 'reference', \ 'm': 'implementation', \ } let g:which_key_map[''] = 'format' let g:which_key_map["\"]['r'] = 'rename' let g:which_key_map["\"]['R'] = 'refactor' let g:which_key_map["\"]['o'] = 'open link' let g:which_key_map["\"]['l'] = 'codeLens action' let g:which_key_map["\"]['c'] = { \ 'name': 'code action', \ 'a': 'full buffer', \ 'l': 'current line', \ 'c': 'current cursor', \ } let g:which_key_map["\"]['m'] = { \ 'name': 'markdown', \ 'f': 'format', \ 'p': 'preview', \ 'i': 'image helper', \ 'I': 'image uploaded', \ 'r': 'run code chunk', \ 'R': 'run all code chunks', \ } let g:which_key_map['g'] = { \ 'name': 'git', \ 'j': 'chunk next', \ 'k': 'chunk prev', \ 'D': 'diff staged', \ 'i': 'chunk info', \ 'u': 'chunk undo', \ 'a': 'chunk stage', \ 's': 'status', \ 'l': {'name': 'logs', 'a': 'log (all)', 'c': 'log (cur buf)', 'l': 'log (cur line)'}, \ 'f': 'toggle fold unchanged', \ 'o': 'open remote url in the browser', \ } let g:which_key_map['f'] = { \ 'name': 'fuzzy finder', \ "\": 'list', \ 's': 'symbols', \ 'y': 'yank', \ } let g:which_key_map['d'] = { \ 'name': 'diagnostics', \ "\": 'list (global)', \ 'd': 'list (current)', \ 'f': 'fix', \ 'j': 'next', \ 'k': 'prev', \ } nnoremap ? :let g:coc_hover_enable = (g:coc_hover_enable == 1 ? 0 : 1) " }}} " {{{coc-explorer nnoremap :execute 'CocCommand explorer --focus ' . getcwd() augroup ExplorerCustom autocmd! autocmd FileType coc-explorer setlocal signcolumn=no autocmd FileType coc-explorer nnoremap q :call custom#explorer#close_startify() autocmd BufEnter * call custom#explorer#close_last() autocmd BufEnter * if stridx(@%, 'term:') != -1 | setlocal nocursorline | endif augroup END " }}} " {{{coc-project nnoremap fp :CocList project let g:which_key_map['f']['p'] = 'projects' " }}} " }}} " {{{vim-doge let g:doge_enable_mappings = 0 let g:doge_mapping_comment_jump_forward = '' let g:doge_mapping_comment_jump_backward = '' let g:doge_doc_standard_python = 'google' nnoremap d :DogeGenerate let g:which_key_map["\"]['d'] = 'generate code doc' " }}} " {{{any-jump.vim let g:any_jump_disable_default_keybindings = 1 nnoremap jj :AnyJump xnoremap jj :AnyJumpVisual let g:which_key_map['j']['j'] = 'any jump' " }}} " {{{vim-dasht if !has('win32') " Search related docsets let g:dasht_filetype_docsets = {} " filetype => list of docset name regexp " When in Elixir, also search Erlang: let g:dasht_filetype_docsets['elixir'] = ['erlang'] " When in C, also search GLib: let g:dasht_filetype_docsets['c'] = ['GLib'] " When in C++, also search C, Boost, OpenGL, Qt_5 and Qt_6: let g:dasht_filetype_docsets['cpp'] = ['^c$', 'boost', 'OpenGL', 'Qt_5', 'Qt_6'] " When in Python, also search NumPy, SciPy, and Pandas: let g:dasht_filetype_docsets['python'] = ['(num|sci)py', 'pandas'] " When in JavaScript, also search NodeJS: let g:dasht_filetype_docsets['javascript'] = ['NodeJS'] " When in HTML, also search CSS, JavaScript, Bootstrap, and jQuery: let g:dasht_filetype_docsets['html'] = ['css', 'js', 'bootstrap'] nnoremap D :call Dasht(dasht#cursor_search_terms()) vnoremap D y:call Dasht(getreg(0)) let g:which_key_map["\"]['D'] = 'dasht' endif " }}} " }}} " {{{Tree-sitter if has('nvim') lua < fl :Clap blines nnoremap fL :Clap lines nnoremap ff :Clap files ++finder=rg --files --follow nnoremap fF :Clap files ++finder=rg --files --follow --hidden --no-ignore nnoremap fb :Clap buffers nnoremap fh :Clap help_tags let g:which_key_map['f']['l'] = 'lines' let g:which_key_map['f']['L'] = 'lines all' let g:which_key_map['f']['f'] = 'files' let g:which_key_map['f']['F'] = 'files all' let g:which_key_map['f']['b'] = 'buffers' let g:which_key_map['f']['h'] = 'help' " {{{providers function s:clap_provider_color_schemes_sink(selected) abort execute 'call custom#colorscheme#' . a:selected . '()' endfunction function s:clap_provider_color_schemes_source() abort return [ \ 'everforest_dark', \ 'everforest_light', \ 'gruvbox_material_dark', \ 'gruvbox_mix_dark', \ 'gruvbox_material_light', \ 'edge_dark', \ 'edge_light', \ 'sonokai', \ 'sonokai_shusia', \ 'sonokai_andromeda', \ 'sonokai_atlantis', \ 'sonokai_maia', \ 'sonokai_espresso', \ 'soft_era' \ ] endfunction let g:clap_provider_color_schemes = {} let g:clap_provider_color_schemes.source = function('s:clap_provider_color_schemes_source') let g:clap_provider_color_schemes.sink = function('s:clap_provider_color_schemes_sink') nnoremap C :Clap color_schemes let g:which_key_map["\"]["\"]['C'] = 'color schemes' " }}} " }}} " {{{vCoolor.vim if !has('win32') && !has('osxdarwin') let g:vcoolor_custom_picker = 'zenity --title "custom" --color-selection --color ' endif let g:vcoolor_disable_mappings = 1 let g:vcoolor_lowercase = 1 nnoremap cc :VCoolor nnoremap cr :VCoolor r nnoremap cH :VCoolor h nnoremap cR :VCoolor ra let g:which_key_map["\"]["\"]['c'] = { \ 'name': 'color picker', \ 'c': 'insert hex', \ 'r': 'insert rgb', \ 'H': 'insert hsl', \ 'R': 'insert rgba' \ } " }}} " }}} " vim: set sw=2 ts=2 sts=2 et tw=80 ft=vim fdm=marker fmr={{{,}}}: