Created
July 24, 2021 13:17
-
-
Save leoluyi/59ee2ea7d408f94e57a418db96067c0a to your computer and use it in GitHub Desktop.
Example init.vim from https://github.com/phongnh/dotfiles/blob/master/init.vim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if has('vim_starting') | |
set encoding=utf-8 | |
endif | |
scriptencoding utf-8 | |
if &shell =~# 'fish$' " && (v:version < 704 || v:version == 704 && !has('patch276')) | |
if executable('zsh') | |
let &shell = exepath('zsh') | |
elseif executable('bash') | |
let &shell = exepath('bash') | |
endif | |
endif | |
" Python 3 | |
if executable('python3') | |
let g:python3_host_prog = exepath('python3') | |
endif | |
if has('pythonx') | |
set pyxversion=3 | |
endif | |
" Disable Python 2 support | |
let g:loaded_python_provider = 0 | |
" Disable Ruby support | |
let g:loaded_ruby_provider = 0 | |
" Disable Perl support | |
let g:loaded_perl_provider = 0 | |
" Disable system plugins | |
let g:loaded_getscript = 1 | |
let g:loaded_getscriptPlugin = 1 | |
let g:loaded_gzip = 1 | |
let g:loaded_logiPat = 1 | |
let g:loaded_tar = 1 | |
let g:loaded_tarPlugin = 1 | |
let g:loaded_2html_plugin = 1 | |
let g:loaded_vimball = 1 | |
let g:loaded_vimballPlugin = 1 | |
let g:loaded_zip = 1 | |
let g:loaded_zipPlugin = 1 | |
let g:loaded_rrhelper = 1 | |
let g:myscriptsfile = 1 | |
let g:loaded_less = 1 | |
" Disable highlighting matching parens in 'matchpairs' option like (), {}, and [] | |
let g:loaded_matchparen = 1 | |
" Disable Netrw plugin | |
let g:loaded_netrwPlugin = 1 | |
let g:loaded_netrwSettings = 1 | |
let g:loaded_netrwFileHandlers = 1 | |
" Disable sql completion and mappings | |
let g:loaded_sql_completion = 1 | |
let g:omni_sql_no_default_maps = 1 | |
let g:ftplugin_sql_omni_key = '' | |
" Disable syntax completion | |
let g:loaded_syntax_completion = 1 | |
" Ruby speedup | |
let g:rubycomplete_buffer_loading = 0 | |
let g:rubycomplete_classes_in_global = 0 | |
let g:rubycomplete_rails = 0 | |
" Disable custom rails syntax highlighting | |
" let g:rails_syntax = 0 | |
" Opererator syntax highlighting | |
" let g:ruby_operators = 1 | |
" Set augroup | |
augroup MyAutoCmd | |
autocmd! | |
" Disable syntax and sql completions | |
autocmd BufEnter * if &omnifunc ==# 'syntaxcomplete#Complete' || &omnifunc ==# 'sqlcomplete#Complete' | set omnifunc= | endif | |
" Share the histories | |
autocmd CursorHold * rshada | wshada | |
" " Start insert when entering in term buffer | |
" autocmd BufWinEnter,WinEnter term://* startinsert | |
" " Stop insert when leaving in term buffer | |
" autocmd BufLeave term://* stopinsert | |
augroup END | |
" Helpers | |
" Find and source vimrc from root to current folder | |
" ~/projects/hello $ | |
" . | |
" └── /home/phong | |
" ├── vimrc | |
" └── projects | |
" ├── vimrc | |
" └── hello | |
" ├── vimrc | |
" └── ... | |
" | |
" Files are sourced in order for the call s:Source('vimrc'): | |
" /home/phong/vimrc | |
" /home/phong/projects/vimrc | |
" /home/phong/projects/hello/vimrc | |
function! s:Source(vimrc) abort | |
let vimrcs = findfile(a:vimrc, ';', -1) | |
for vimrc in reverse(vimrcs) | |
execute 'source ' . fnamemodify(vimrc, ':p') | |
endfor | |
endfunction | |
" Check if plugin group is used or not | |
function! s:Use(group) abort | |
return index(g:zero_vim_groups, a:group) > -1 | |
endfunction | |
" Check if a plugin is plugged in plug section or not | |
function! s:IsPlugged(plugin) abort | |
return has_key(g:plugs, a:plugin) | |
endfunction | |
" Plugin Dir | |
function! s:PlugDir(plugin) abort | |
return g:plugs[a:plugin]['dir'] | |
endfunction | |
" Setup custom mapping to open specific folder | |
function! OpenFolderWithMapping(folder, mapping) abort | |
if exists(':CtrlP') == 2 | |
let l:cmd = 'CtrlP' | |
elseif exists(':LeaderfFile') == 2 | |
let l:cmd = 'LeaderfFile' | |
elseif exists(':ClapFiles') == 2 | |
let cmd = 'ClapFiles' | |
else | |
let l:cmd = 'Files' | |
endif | |
execute printf('nnoremap <silent> %s :%s %s<CR>', a:mapping, l:cmd, a:folder) | |
endfunction | |
" Check if LSP is enabled | |
function! s:IsLSPEnabled() abort | |
return s:IsPlugged('coc.nvim') || s:IsPlugged('nvim-lspconfig') || s:IsPlugged('vim-lsp') || s:IsPlugged('vim-lsc') || s:IsPlugged('LanguageClient-neovim-dev') || s:IsPlugged('LanguageClient-neovim') || s:IsPlugged('vim-lamp') | |
endfunction | |
" Check if Quickfix is loclist | |
function! s:IsLocationList() abort | |
return getwininfo(win_getid())[0]['loclist'] | |
endfunction | |
function! s:Warn(message) abort | |
echohl WarningMsg | |
echomsg a:message | |
echohl None | |
endfunction | |
" Find and source .init.vim.before from root to current folder | |
call s:Source('.init.vim.before') | |
" Default zero settings | |
let g:zero_vim_groups = get(g:, 'zero_vim_groups', []) | |
let g:zero_vim_devicons = get(g:, 'zero_vim_devicons', 0) | |
let g:zero_vim_nerdfont = get(g:, 'zero_vim_nerdfont', 0) | |
let g:zero_vim_glyph_palette = get(g:, 'zero_vim_glyph_palette', 0) | |
let g:zero_vim_true_color = get(g:, 'zero_vim_true_color', $COLORTERM =~# '^\(truecolor\|24bit\)$') | |
let g:zero_vim_powerline = get(g:, 'zero_vim_powerline', 0) | |
let g:zero_vim_powerline_style = get(g:, 'zero_vim_powerline_style', 'default') | |
let g:zero_vim_powerline_spaces = get(g:, 'zero_vim_powerline_spaces', {}) | |
let g:zero_vim_solarized = get(g:, 'zero_vim_solarized', 0) | |
let g:zero_vim_transparent = get(g:, 'zero_vim_transparent', 0) | |
let g:zero_vim_extra_hi_groups = get(g:, 'zero_vim_extra_hi_groups', 0) | |
let g:zero_vim_lsp_diagnostics = get(g:, 'zero_vim_lsp_diagnostics', 0) | |
let g:zero_vim_lsp_highlight_references = get(g:, 'zero_vim_lsp_highlight_references', 0) | |
let g:zero_vim_autolint = get(g:, 'zero_vim_autolint', 0) | |
let g:zero_vim_autofix = get(g:, 'zero_vim_autofix', 0) | |
let g:zero_vim_git_gutter = get(g:, 'zero_vim_git_gutter', 1) | |
let g:zero_vim_git_branch = get(g:, 'zero_vim_git_branch', 1) | |
let g:zero_vim_use_simple_grep = get(g:, 'zero_vim_use_simple_grep', 0) | |
let g:zero_vim_use_git_grep = get(g:, 'zero_vim_use_git_grep', 0) | |
let g:zero_vim_grep_ignore_vcs = get(g:, 'zero_vim_grep_ignore_vcs', 0) | |
let g:zero_vim_find_tool = get(g:, 'zero_vim_find_tool', 'rg') | |
let g:zero_vim_follow_links = get(g:, 'zero_vim_follow_links', 0) | |
let g:zero_vim_indent_char = get(g:, 'zero_vim_indent_char', '┊') | |
let g:zero_vim_indent_first_char = get(g:, 'zero_vim_indent_first_char', '│') | |
let g:zero_vim_ctags_bin = get(g:, 'zero_vim_ctags_bin', executable('ctags-universal') ? 'ctags-universal' : 'ctags') | |
let g:zero_vim_ctags_ignore = get(g:, 'zero_vim_ctags_ignore', expand('~/.ctagsignore')) | |
let g:zero_vim_gtags_cscope = get(g:, 'zero_vim_gtags_cscope', 0) | |
try | |
let g:zero_vim_universal_ctags = system(printf('%s --version', g:zero_vim_ctags_bin)) =~# 'Universal Ctags' | |
catch | |
let g:zero_vim_universal_ctags = 0 | |
endtry | |
" Default signs | |
let g:zero_vim_signs = extend({ | |
\ 'error': '🅔', | |
\ 'style_error': 'ⓔ', | |
\ 'warning': '🅦', | |
\ 'style_warning': 'ⓦ', | |
\ 'information': '🅘', | |
\ 'hint': '🅗', | |
\ 'virtual_text': '🅥', | |
\ }, get(g:, 'zero_vim_signs', {})) | |
let g:zero_vim_lsp_signs = extend({ | |
\ 'error': 'E', | |
\ 'style_error': 'e', | |
\ 'warning': 'W', | |
\ 'style_warning': 'w', | |
\ 'information': 'I', | |
\ 'hint': 'H', | |
\ 'virtual_text': '<!>', | |
\ }, get(g:, 'zero_vim_lsp_signs', {})) | |
" True Color settings | |
if g:zero_vim_true_color && has('termguicolors') | |
set termguicolors | |
endif | |
" Plugins | |
call plug#begin() | |
" Core { | |
if s:Use('sleuth') || !s:Use('polyglot') | |
" sleuth.vim: Heuristically set buffer options | |
Plug 'tpope/vim-sleuth' | |
endif | |
if exists("$TMUX") | |
" Vim plugin for handling tmux panes. | |
Plug 'jebaum/vim-tmuxify' | |
endif | |
" Asynchronous build and test dispatcher | |
Plug 'tpope/vim-dispatch' | |
" Interactive command execution | |
Plug 'Shougo/vimproc.vim', { 'do': 'make' } | |
" rsi.vim: Readline style insertion | |
Plug 'tpope/vim-rsi' | |
" My vim helpers | |
Plug 'phongnh/vim-helpers' | |
" Helpers for UNIX | |
Plug 'tpope/vim-eunuch' | |
" Better whitespace highlighting for vim | |
Plug 'ntpeters/vim-better-whitespace' | |
" Enable repeating supported plugin maps with "." | |
Plug 'tpope/vim-repeat' | |
" Pairs of handy bracket mappings | |
Plug 'tpope/vim-unimpaired' | |
" Toggle useful settings | |
Plug 'phongnh/vim-toggler' | |
" Maximize current buffer | |
Plug 'phongnh/ZoomWin' | |
" Sane buffer/window deletion. | |
Plug 'mhinz/vim-sayonara' | |
" A Narrow Region Plugin for vim (like Emacs Narrow Region) | |
Plug 'chrisbra/NrrwRgn' | |
if s:Use('quickfix-enhanced') | |
" Tame the quickfix window | |
Plug 'romainl/vim-qf' | |
else | |
" Open a Quickfix item in a window you choose. (Vim plugin) | |
Plug 'yssl/QFEnter' | |
endif | |
" } | |
" Search { | |
" Helps you win at grep. | |
Plug 'mhinz/vim-grepper' | |
" An ack.vim alternative mimics Ctrl-Shift-F on Sublime Text 2 | |
Plug 'dyng/ctrlsf.vim' | |
if s:Use('any-jump') && has('nvim-0.4') && executable('rg') | |
" Jump to any definition and references IDE madness without overhead | |
Plug 'pechorin/any-jump.vim' | |
endif | |
" } | |
" Editing { | |
if s:Use('nerdcommenter') | |
" Vim plugin for intensely orgasmic commenting | |
Plug 'scrooloose/nerdcommenter' | |
endif | |
" commentary.vim: comment stuff out | |
Plug 'tpope/vim-commentary' | |
" A Vim alignment plugin | |
Plug 'junegunn/vim-easy-align' | |
if s:Use('tabular') | |
" Vim script for text filtering and alignment | |
Plug 'godlygeek/tabular' | |
endif | |
" quoting/parenthesizing made simple | |
Plug 'tpope/vim-surround' | |
" easily search for, substitute, and abbreviate multiple variants of a word | |
Plug 'tpope/vim-abolish' | |
" Easy text exchange operator for Vim | |
Plug 'tommcdo/vim-exchange' | |
" use CTRL-A/CTRL-X to increment dates, times, and more | |
Plug 'tpope/vim-speeddating' | |
if s:Use('auto-pairs') | |
" insert or delete brackets, parens, quotes in pair | |
Plug 'jiangmiao/auto-pairs' | |
elseif s:Use('lexima') | |
" Auto close parentheses and repeat by dot dot dot... | |
Plug 'cohama/lexima.vim' | |
endif | |
if s:Use('multiple-cursors') | |
" True Sublime Text style multiple selections for Vim | |
Plug 'terryma/vim-multiple-cursors' | |
else | |
" Multiple cursors plugin for vim/neovim | |
Plug 'mg979/vim-visual-multi' | |
endif | |
" emmet for vim: http://emmet.io | |
Plug 'mattn/emmet-vim' | |
" ragtag.vim: ghetto HTML/XML mappings | |
Plug 'tpope/vim-ragtag' | |
" A vim plugin that simplifies the transition between multiline and single-line code | |
Plug 'AndrewRadev/splitjoin.vim' | |
" A Vim plugin to move function arguments (and other delimited-by-something items) left and right. | |
Plug 'AndrewRadev/sideways.vim' " a | |
" } | |
" Text Objects { | |
if s:Use('text-objects') | |
Plug 'kana/vim-textobj-user' | |
Plug 'kana/vim-textobj-entire' " e | |
Plug 'kana/vim-textobj-line' " l | |
Plug 'kana/vim-textobj-indent' " i | |
Plug 'glts/vim-textobj-comment' " c | |
Plug 'mattn/vim-textobj-url' " u | |
Plug 'rhysd/vim-textobj-conflict' " =, remapped to C | |
Plug 'rhysd/vim-textobj-word-column' " v | |
Plug 'inside/vim-textobj-jsxattr' " x | |
Plug 'rhysd/vim-textobj-ruby' " r: any block | ro: definitions, rl: loop, rc: control, rd: do, rr: any block | |
Plug 'whatyouhide/vim-textobj-erb' " E | |
Plug 'edkolev/erlang-motions.vim' " m: function clause, M: function declaration | |
Plug 'andyl/vim-textobj-elixir' " e, remapped to r | |
endif | |
if s:Use('targets') | |
" Vim plugin that provides additional text objects | |
Plug 'wellle/targets.vim' | |
endif | |
" } | |
" Appearance { | |
if s:Use('airline') | |
" My airline settings | |
let g:airline_powerline = g:zero_vim_powerline | |
let g:airline_powerline_style = get(g:, 'airline_powerline_style', g:zero_vim_powerline_style) | |
let g:airline_powerline_spaces = g:zero_vim_powerline_spaces | |
let g:airline_show_git_branch = g:zero_vim_git_branch | |
Plug 'phongnh/airline-settings.vim' | |
" lean & mean status/tabline for vim that's light as air | |
Plug 'vim-airline/vim-airline' | |
" A collection of themes for vim-airline | |
Plug 'vim-airline/vim-airline-themes' | |
elseif s:Use('lightline') | |
" My lightline settings | |
let g:lightline_powerline = g:zero_vim_powerline | |
let g:lightline_powerline_style = get(g:, 'lightline_powerline_style', g:zero_vim_powerline_style) | |
let g:lightline_powerline_spaces = g:zero_vim_powerline_spaces | |
let g:lightline_show_git_branch = g:zero_vim_git_branch | |
Plug 'phongnh/lightline-settings.vim' | |
" A light and configurable statusline/tabline plugin for Vim | |
Plug 'itchyny/lightline.vim' | |
else | |
" My vim statusline | |
let g:statusline_show_git_branch = g:zero_vim_git_branch | |
Plug 'phongnh/vim-statusline' | |
endif | |
" Show "Match 123 of 456 /search term/" in Vim searches | |
Plug 'henrik/vim-indexed-search' | |
" Rainbow Parentheses Improved, shorter code, no level limit, smooth and fast, powerful configuration. | |
Plug 'luochen1990/rainbow' | |
" Vim Fold Text | |
Plug 'phongnh/vim-fold-text' | |
" } | |
" Indent { | |
if s:Use('indent') | |
if has('conceal') | |
" A vim plugin to display the indention levels with thin vertical lines | |
Plug 'Yggdroot/indentLine' | |
else | |
" A Vim plugin for visually displaying indent levels in code | |
Plug 'nathanaelkane/vim-indent-guides' | |
endif | |
endif | |
" } | |
" Startify { | |
if s:Use('startify') | |
" A fancy start screen | |
Plug 'mhinz/vim-startify' | |
endif | |
" } | |
" Distraction-free { | |
if s:Use('distraction-free') | |
" Distraction-free writing | |
Plug 'junegunn/goyo.vim' | |
" Hyperfocus-writing | |
Plug 'junegunn/limelight.vim' | |
endif | |
" } | |
" Undo history { | |
if s:Use('undo') | |
if has('python3') | |
" Visualize your Vim undo tree | |
Plug 'sjl/gundo.vim' | |
else | |
" The ultimate undo history visualizer for VIM | |
Plug 'mbbill/undotree' | |
endif | |
elseif s:Use('mundo') | |
if has('python3') | |
" Vim undo tree visualizer | |
Plug 'simnalamburt/vim-mundo' | |
else | |
" The ultimate undo history visualizer for VIM | |
Plug 'mbbill/undotree' | |
endif | |
endif | |
" } | |
" Explorer { | |
if s:Use('bufexplorer') | |
" BufExplorer Plugin for Vim | |
Plug 'jlanzarotta/bufexplorer' | |
endif | |
if s:Use('fern') && has('nvim-0.4.2') | |
" General purpose asynchrnonous tree viewer written in Pure Vim script | |
Plug 'lambdalisue/fern.vim' | |
Plug 'hrsh7th/fern-mapping-collapse-or-leave.vim' | |
if g:zero_vim_nerdfont | |
Plug 'lambdalisue/fern-renderer-nerdfont.vim' | |
elseif g:zero_vim_devicons | |
Plug 'phongnh/fern-renderer-nerdfont.vim', { 'as': 'phongnh-fern-renderer-nerdfont.vim' } | |
endif | |
elseif s:Use('vaffle') | |
Plug 'cocopon/vaffle.vim' | |
elseif s:Use('nerdtree') | |
" A tree explorer plugin for vim | |
Plug 'scrooloose/nerdtree' | |
endif | |
" } | |
" Project Configuration { | |
" Find out which project a file belongs to, easy to use in scripts/mappings | |
Plug 'dbakker/vim-projectroot' | |
" projectionist.vim: Granular project configuration | |
Plug 'tpope/vim-projectionist' | |
" } | |
" Fuzzy finder { | |
if s:Use('ctrlp') | |
if s:Use('fruzzy') && has('python3') | |
Plug 'raghur/fruzzy', { 'do': { -> fruzzy#install() } } | |
endif | |
if has('python3') && executable('cmake') | |
Plug 'nixprime/cpsm', { 'do': 'env PY3=ON ./install.sh' } | |
endif | |
" Full path fuzzy file, buffer, mru, tag, ... finder for Vim. | |
Plug 'ctrlpvim/ctrlp.vim' | |
Plug 'DavidEGx/ctrlp-smarttabs' | |
Plug 'tacahiroy/ctrlp-funky' | |
Plug 'mattn/ctrlp-register' | |
Plug 'LeafCage/yankround.vim' | |
Plug 'fisadev/vim-ctrlp-cmdpalette' | |
Plug 'ompugao/ctrlp-history' | |
Plug 'https://bitbucket.org/slimane/ctrlp-locationlist' | |
Plug 'phongnh/ctrlp-settings.vim' | |
elseif s:Use('leaderf') && has('python3') | |
" An asynchronous fuzzy finder which is used to quickly locate files, buffers, mrus, tags, etc. in large project. | |
Plug 'Yggdroot/LeaderF', { 'do': ':LeaderfInstallCExtension' } | |
Plug 'phongnh/leaderf-settings.vim' | |
elseif s:Use('clap') && has('nvim-0.4.2') | |
" Viewer & Finder for LSP symbols and tags | |
Plug 'liuchengxu/vista.vim' | |
" Modern performant generic finder and dispatcher for Vim and NeoVim | |
Plug 'liuchengxu/vim-clap', { 'do': { -> clap#installer#build_all() } } | |
Plug 'phongnh/clap-settings.vim' | |
else | |
" A command-line fuzzy finder written in Go | |
Plug 'junegunn/fzf', { 'do': { -> fzf#install() } } | |
Plug 'junegunn/fzf.vim' | |
Plug 'phongnh/fzf-settings.vim' | |
endif | |
" } | |
" Format { | |
if s:Use('format') | |
if has('python3') | |
" Provide easy code formatting in Vim by integrating existing code formatters. | |
Plug 'Chiel92/vim-autoformat' | |
endif | |
if executable('yarn') | |
" A Vim plugin for Prettier | |
Plug 'prettier/vim-prettier', { 'do': 'yarn install' } | |
endif | |
endif | |
" } | |
" Syntax Checking/Linting { | |
if s:Use('lint') | |
" Asynchronous Lint Engine | |
Plug 'dense-analysis/ale' | |
elseif s:Use('neomake') | |
" Asynchronous linting and make framework for Neovim/Vim | |
Plug 'neomake/neomake' | |
elseif s:Use('syntastic') | |
" Syntax checking hacks for vim | |
Plug 'vim-syntastic/syntastic' | |
endif | |
" } | |
" Snippets and Autocomplete { | |
if s:Use('ultisnips') && has('python3') | |
Plug 'honza/vim-snippets' | |
Plug 'SirVer/ultisnips' | |
elseif s:Use('neosnippet') | |
Plug 'honza/vim-snippets' | |
Plug 'Shougo/neosnippet-snippets' | |
Plug 'Shougo/neosnippet.vim' | |
endif | |
if s:Use('coc') | |
" coc.nvim plugin has both autocomplete and lsp functions | |
elseif s:Use('nvim-lsp') && has('nvim-0.5-nightly') | |
Plug 'neovim/nvim-lspconfig' | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
elseif s:Use('lsp') | |
Plug 'prabirshrestha/vim-lsp' | |
Plug 'mattn/vim-lsp-settings' | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
elseif s:Use('lsc') | |
Plug 'natebosch/vim-lsc' | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
elseif s:Use('LanguageClient-dev') | |
Plug 'autozimu/LanguageClient-neovim', { 'as': 'LanguageClient-neovim-dev', 'branch': 'dev', 'do': 'bash install.sh' } | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
elseif s:Use('LanguageClient') | |
Plug 'autozimu/LanguageClient-neovim', { 'branch': 'next', 'do': 'bash install.sh' } | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
elseif s:Use('lamp') | |
Plug 'hrsh7th/vim-lamp' | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
endif | |
if s:Use('completion-nvim') && has('nvim-0.5-nightly') | |
Plug 'nvim-lua/completion-nvim' | |
Plug 'steelsojka/completion-buffers' | |
Plug 'kristijanhusak/completion-tags' | |
if s:Use('treesitter') | |
Plug 'nvim-treesitter/completion-treesitter' | |
endif | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
elseif s:Use('compe') && has('nvim-0.5-nightly') | |
Plug 'hrsh7th/nvim-compe' | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
if s:IsPlugged('vim-lamp') | |
Plug 'hrsh7th/compe-lamp' | |
endif | |
elseif s:Use('deoplete') && has('python3') | |
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | |
if s:IsPlugged('nvim-lspconfig') | |
Plug 'deoplete-plugins/deoplete-lsp' | |
elseif s:IsPlugged('vim-lsp') | |
Plug 'lighttiger2505/deoplete-vim-lsp' | |
elseif s:IsPlugged('vim-lsc') | |
Plug 'hrsh7th/deoplete-vim-lsc' | |
elseif s:IsPlugged('vim-lamp') | |
Plug 'hrsh7th/deoplete-lamp' | |
endif | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
elseif s:Use('coc') && executable('yarn') | |
Plug 'neoclide/coc.nvim', { 'do': 'yarn install --frozen-lockfile' } | |
elseif s:Use('YouCompleteMe') && has('python3') && executable('cmake') | |
function! BuildYCM(info) abort | |
if a:info.status == 'unchanged' && !a:info.force | |
return | |
endif | |
let l:cmd = '!./install.py' | |
if !executable('clangd') | |
let l:cmd .= ' --clangd-completer' | |
endif | |
if !executable('gopls') | |
let l:cmd .= ' --go-completer' | |
endif | |
if !executable('rustc') | |
let l:cmd .= ' --rust-completer' | |
endif | |
if !executable('tsserver') | |
let l:cmd .= ' --ts-completer' | |
endif | |
call s:Warn('[vim-plug] YouCompleteMe: ' . l:cmd) | |
execute l:cmd | |
endfunction | |
Plug 'ycm-core/YouCompleteMe', { 'do': function('BuildYCM') } | |
elseif s:Use('asyncomplete') | |
Plug 'prabirshrestha/asyncomplete.vim' | |
Plug 'prabirshrestha/asyncomplete-buffer.vim' | |
Plug 'prabirshrestha/asyncomplete-file.vim' | |
Plug 'yami-beta/asyncomplete-omni.vim' | |
if s:IsPlugged('ultisnips') | |
Plug 'prabirshrestha/asyncomplete-ultisnips.vim' | |
elseif s:IsPlugged('neosnippet.vim') | |
Plug 'prabirshrestha/asyncomplete-neosnippet.vim' | |
endif | |
if s:IsPlugged('vim-lsp') | |
Plug 'prabirshrestha/asyncomplete-lsp.vim' | |
elseif s:IsPlugged('vim-lamp') | |
Plug 'hrsh7th/asyncomplete-lamp' | |
endif | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
elseif s:Use('ncm2') && has('python3') | |
Plug 'roxma/nvim-yarp' | |
Plug 'ncm2/ncm2' | |
Plug 'ncm2/ncm2-bufword' | |
Plug 'ncm2/ncm2-path' | |
if s:IsPlugged('ultisnips') | |
Plug 'ncm2/ncm2-ultisnips' | |
elseif s:IsPlugged('neosnippet.vim') | |
Plug 'ncm2/ncm2-neosnippet' | |
endif | |
if s:IsPlugged('vim-lsp') | |
Plug 'ncm2/ncm2-vim-lsp' | |
endif | |
elseif s:Use('completor') && has('python3') | |
Plug 'maralla/completor.vim' | |
if s:IsPlugged('neosnippet') | |
Plug 'maralla/completor-neosnippet' | |
endif | |
elseif s:Use('mucomplete') | |
Plug 'lifepillar/vim-mucomplete' | |
Plug 'hrsh7th/vim-vsnip' | |
Plug 'hrsh7th/vim-vsnip-integ' | |
else | |
Plug 'ackyshake/VimCompletesMe' | |
endif | |
" } | |
" Ctags { | |
if executable(g:zero_vim_ctags_bin) | |
if s:Use('ctags') | |
" A Vim plugin that manages your tag files | |
Plug 'ludovicchabant/vim-gutentags' | |
elseif s:Use('gen_tags') | |
" Async plugin for vim and neovim to ease the use of ctags/gtags | |
Plug 'jsfaint/gen_tags.vim' | |
endif | |
if s:Use('tagbar') | |
" A class outline viewer for Vim | |
Plug 'majutsushi/tagbar' | |
Plug 'phongnh/vim-tagbar-settings' | |
endif | |
if s:Use('vista') && g:zero_vim_universal_ctags | |
" Viewer & Finder for LSP symbols and tags | |
Plug 'liuchengxu/vista.vim' | |
endif | |
endif | |
" } | |
" Git { | |
if s:Use('git') | |
" An awesome Git wrapper so awesome | |
Plug 'tpope/vim-fugitive' | |
" rhubarb.vim: GitHub extension for fugitive.vim | |
Plug 'tpope/vim-rhubarb' | |
" A git commit browser in Vim | |
Plug 'junegunn/gv.vim' | |
endif | |
if s:Use('git-messenger') | |
" Vim and Neovim plugin to reveal the commit messages under the cursor | |
Plug 'rhysd/git-messenger.vim' | |
endif | |
if s:Use('git-gutter') || s:Use('gitgutter') | |
" A Vim plugin which shows a git diff in the gutter (sign column) and stages/undoes hunks. | |
Plug 'airblade/vim-gitgutter' | |
elseif s:Use('signify') | |
" Show a diff via Vim sign column | |
Plug 'mhinz/vim-signify' | |
endif | |
if s:Use('github') | |
" Open URI with your favorite browser from your most favorite editor | |
Plug 'tyru/open-browser.vim' | |
" Open GitHub URL of current file, etc. from Vim editor (supported GitHub Enterprise) | |
Plug 'tyru/open-browser-github.vim' | |
endif | |
if s:Use('committia') | |
" A Vim plugin for more pleasant editing on commit messages | |
Plug 'rhysd/committia.vim' | |
endif | |
if s:Use('diff-enhanced') && &diff | |
" Better Diff options for Vim | |
Plug 'chrisbra/vim-diff-enhanced' | |
endif | |
" } | |
" Tasks { | |
if s:Use('tasks') | |
" An implementation of Sublime's PlainTasks plugin for Vim | |
Plug 'elentok/plaintasks.vim' | |
endif | |
" } | |
" Hard Time { | |
if s:Use('hardtime') | |
" Plugin to help you stop repeating the basic movement keys | |
Plug 'takac/vim-hardtime' | |
endif | |
" } | |
" Syntax { | |
let g:polyglot_disabled = ['sensible'] | |
if s:IsPlugged('vim-sleuth') | |
call add(g:polyglot_disabled, 'autoindent') | |
endif | |
if s:Use('web') | |
Plug 'hail2u/vim-css3-syntax' | |
Plug 'HerringtonDarkholme/yats.vim' | |
Plug 'pangloss/vim-javascript' | |
Plug 'MaxMEllon/vim-jsx-pretty' | |
Plug 'jparise/vim-graphql' | |
Plug 'tpope/vim-jdaddy' | |
Plug 'heavenshell/vim-jsdoc' | |
if s:Use('coloresque') | |
Plug 'gko/vim-coloresque' | |
else | |
Plug 'ap/vim-css-color' | |
endif | |
call extend(g:polyglot_disabled, ['typescript', 'javascript', 'jsx', 'graphql']) | |
endif | |
if s:Use('coffee-script') | |
Plug 'kchmck/vim-coffee-script' | |
Plug 'joukevandermaas/vim-ember-hbs' | |
call add(g:polyglot_disabled, 'coffee-script') | |
endif | |
if s:Use('ruby') | |
Plug 'stephpy/vim-yaml' | |
Plug 'noprompt/vim-yardoc' | |
Plug 'keith/rspec.vim' | |
Plug 'tpope/vim-rake' | |
Plug 'tpope/vim-rails' | |
Plug 'phongnh/vim-rubocop' | |
Plug 'phongnh/vim-reek' | |
call extend(g:polyglot_disabled, ['yaml', 'yard', 'rspec']) | |
endif | |
if s:Use('crystal') | |
Plug 'vim-crystal/vim-crystal' | |
Plug 'elorest/vim-slang' | |
call add(g:polyglot_disabled, 'crystal') | |
endif | |
if s:Use('python') | |
Plug 'vim-python/python-syntax' | |
Plug 'nvie/vim-flake8' | |
Plug 'fisadev/vim-isort' | |
Plug 'google/yapf', { 'rtp': 'plugins/vim' } | |
call add(g:polyglot_disabled, 'python') | |
endif | |
if s:Use('go') | |
Plug 'fatih/vim-go' | |
Plug 'zchee/vim-go-stdlib' " go standard library syntax highlighting | |
Plug 'phongnh/go-explorer' " go get github.com/phongnh/go-explorer/src/getool | |
Plug 'tweekmonster/hl-goimport.vim' " Highlights imported packages in Go | |
call add(g:polyglot_disabled, 'go') | |
endif | |
if s:Use('rust') | |
Plug 'rust-lang/rust.vim' | |
call add(g:polyglot_disabled, 'rust') | |
endif | |
if s:Use('erlang') | |
Plug 'vim-erlang/vim-erlang-runtime' | |
Plug 'vim-erlang/vim-erlang-compiler' | |
call add(g:polyglot_disabled, 'erlang') | |
endif | |
if s:Use('elixir') | |
Plug 'elixir-editors/vim-elixir' | |
Plug 'mhinz/vim-mix-format' | |
call add(g:polyglot_disabled, 'elixir') | |
endif | |
if s:Use('terraform') | |
Plug 'hashivim/vim-terraform' | |
call add(g:polyglot_disabled, 'terraform') | |
endif | |
if s:Use('polyglot') | |
" A solid language pack for Vim | |
Plug 'sheerun/vim-polyglot' | |
else | |
Plug 'georgewitteman/vim-fish' | |
endif | |
" } | |
" Run your tests at the speed of thought | |
Plug 'vim-test/vim-test' | |
" Nvim Treesitter configurations and abstraction layer | |
if s:Use('treesitter') && has('nvim-0.5-nightly') | |
Plug 'nvim-treesitter/nvim-treesitter' | |
Plug 'nvim-treesitter/nvim-treesitter-refactor' | |
Plug 'nvim-treesitter/nvim-treesitter-textobjects' | |
if s:Use('treesitter-context') | |
Plug 'romgrk/nvim-treesitter-context' | |
endif | |
endif | |
" Color schemes { | |
" Default | |
Plug 'altercation/vim-colors-solarized' | |
Plug 'gruvbox-community/gruvbox' | |
" True Color | |
Plug 'lifepillar/vim-solarized8' | |
Plug 'lifepillar/vim-gruvbox8' | |
" Collection of awesome color schemes for Neo/vim, merged for quick use. | |
Plug 'rafi/awesome-vim-colorschemes' | |
" } | |
" DevIcons { | |
if g:zero_vim_devicons | |
" Adds file type glyphs/icons to popular Vim plugins: NERDTree, vim-airline, Powerline, Unite, vim-startify and more | |
Plug 'ryanoasis/vim-devicons' | |
endif | |
if g:zero_vim_nerdfont | |
" Fundemental plugin to handle Nerd Fonts in Vim | |
Plug 'lambdalisue/nerdfont.vim' | |
endif | |
if (g:zero_vim_devicons || g:zero_vim_nerdfont) && g:zero_vim_glyph_palette | |
" An universal palette for Nerd Fonts | |
Plug 'lambdalisue/glyph-palette.vim' | |
endif | |
" } | |
if s:Use('which-key') | |
" Vim plugin that shows keybindings in popup | |
Plug 'liuchengxu/vim-which-key' | |
endif | |
" My default filetype settings | |
Plug 'phongnh/filetype-settings.vim' | |
" Fix CursorHold Performance | |
" https://github.com/neovim/neovim/issues/12587 | |
Plug 'antoinemadec/FixCursorHold.nvim' | |
call plug#end() | |
" Make ESC respond faster | |
set ttimeout | |
set ttimeoutlen=50 | |
set timeoutlen=500 " Mapping delay | |
set visualbell " Use visual bell instead of beeping | |
set t_vb= " Disable screen flash | |
set nomodeline " Don't parse modelines because of vim modeline vulnerability | |
set lazyredraw " Do not redraw while macro executing | |
set mouse=a " Enable mouse in every mode | |
set mousehide " Hide mouse pointer while typing | |
set mousemodel=popup " Right mouse button pops up a menu | |
set encoding=utf-8 " Default encoding for saving and reading file | |
set fileformat=unix " Default fileformat | |
set fileformats=unix,dos,mac | |
" Don't try to highlight lines longer than 500 characters | |
set synmaxcol=500 | |
" Enable virtualedit in visual block mode | |
set virtualedit=block | |
set hidden " Allow buffer switching without saving | |
set showmatch " Automatically highlight matching braces/brackets/etc | |
set cpoptions-=m " Highlight when CursorMoved | |
set matchpairs+=<:> " Highlight <> | |
set matchtime=1 | |
set infercase " Ignore case on insert completion | |
set ignorecase " Ignore case search for normal letters | |
set smartcase " Do case-sensitive search if pattern contains upper case letters | |
" Default indent settings | |
set tabstop=4 shiftwidth=4 | |
set smartindent | |
set shiftround " Round indent by shiftwidth | |
set expandtab " Expand tab to space | |
set foldopen=block,hor,insert,jump,mark,percent,quickfix,search,tag,undo | |
set foldmethod=indent " Fold by indent | |
set foldlevel=1 " Starting fold at level 1 | |
set foldlevelstart=10 " Open all folds by default | |
set foldnestmax=10 " Deepest fold is 10 levels | |
set nofoldenable " Disable fold by default | |
set fillchars=diff:⣿,vert:│ | |
set grepformat=%f:%l:%c:%m,%f:%l:%m | |
" Turn off swapfile and backup | |
set noswapfile nobackup nowritebackup | |
set directory=~/.cache/swap | |
set backupdir=~/.cache/backup | |
if has('persistent_undo') | |
set undofile | |
" Use different undodir for NeoVim Nightly because it is incompatible | |
if has('nvim-0.5-nightly') | |
set undodir=~/.cache/nvim-undo | |
else | |
set undodir=~/.cache/undo | |
endif | |
endif | |
set updatetime=100 " 100ms | |
set scrolloff=0 " Minimal number of screen lines to keep above and below the cursor | |
set scrolljump=1 " Lines to scroll when cursor leaves screen | |
set sidescroll=0 " The minimal number of columns to scroll horizontally | |
set sidescrolloff=0 " The minimal number of screen columns to keep to the left and to the right of the cursor | |
" Display tabs and trailing spaces | |
set listchars+=extends:>,precedes:< | |
if has('conceal') | |
set listchars+=conceal:^ | |
set conceallevel=2 concealcursor=i | |
endif | |
set shortmess=aiToOc " Print current file name, cursor position and file status (press C-g) | |
" Wrap conditions | |
set whichwrap=b,s,h,l,<,>,[,] " Backspace and cursor keys wrap too | |
set iskeyword-=. " '.' is an end of word designator | |
set iskeyword-=# " '#' is an end of word designator | |
set iskeyword-=- " '-' is an end of word designator | |
if has('linebreak') | |
set linebreak " Wrap lines at convenient point | |
let &showbreak='↪ ' | |
set breakat=\ \ ;:,!? | |
if exists('+breakindent') | |
set breakindent | |
endif | |
endif | |
set formatoptions+=1 " Don't break a line after a one-letter word | |
if v:version > 703 || v:version == 703 && has('patch541') | |
set formatoptions+=j " Delete comment character when joining commented lines | |
endif | |
" set showcmd " Show (partial) command in the last line of the screen | |
set noshowcmd | |
set cmdheight=2 " Height of command-line (easy-readable) | |
set undolevels=1000 " Maximum number of changes that can be undone | |
" Completion settings | |
set completeopt=menuone,noinsert,noselect | |
set complete=.,w,b,u,t,k | |
set complete-=t | |
set pumheight=20 " Set popup menu max height | |
set wildmode=list:longest,full | |
" Ingore the following stuff when tab completing | |
set wildignore+=*/.built/*,*/node_modules/*,*/cache/*,*/.sass-cache/* | |
set wildignore+=*/vendor/gems/*,*/vendor/cache/* | |
set wildignore+=*/tmp/cache/assets/*/sprockets/*,*/tmp/cache/assets/*/sass/* | |
set wildignore+=*.o,*.obj,*.pyc,*.rbc,*.rbo,*.luac,*.jpg,*.jpeg,*.png,*.gif,*.bmp,*.pdf,*.class,*.gem | |
set wildignore+=*.zip,*.rar,*.7z,*.tar.gz,*.tar.bz2,*.tar.xz | |
set wildignore+=*.DS_Store,*.dmg,*.pkg,*dll,*.exe,*.lnk,*.ini,*.dat | |
set wildignore+=*.swp,*~,._* | |
" Adjust window size of preview and help | |
set previewheight=12 | |
set helpheight=12 | |
set nostartofline " The cursor is kept in the same column (if possible) | |
set splitbelow " Splitting a window will put the new window below the current one | |
set splitright " Splitting a window will put the new window right the current one | |
if has('path_extra') | |
setglobal tags-=./tags tags-=./tags; tags^=./tags; | |
endif | |
" Map leader | |
let g:mapleader = ' ' | |
let g:maplocalleader = '\' | |
" F1: Help | |
nnoremap <F1> :help<Space> | |
imap <F1> <Esc><F1> | |
" F2: Paste Toggle | |
set pastetoggle=<F2> | |
" CTRL-Space: Show history | |
cnoremap <C-@> <C-f> | |
" CTRL-V: Paste from clipboard | |
cnoremap <C-v> <C-r>+ | |
" Reset Esc | |
inoremap <Esc> <Esc> | |
" Enable undo for CTRL-W (Delete word) and CTRL-U (Delete line) | |
inoremap <C-w> <C-g>u<C-w> | |
inoremap <C-u> <C-g>u<C-u> | |
" CTRL-T: Insert tab | |
inoremap <silent> <C-t> <C-v><Tab> | |
" CTRL-L: Redraw | |
if has('diff') && &diff | |
nnoremap <silent> <C-l> :nohlsearch <Bar> diffupdate<CR><C-l> | |
else | |
nnoremap <silent> <C-l> :nohlsearch<CR><C-l> | |
endif | |
" Q: Disable Ex-mode. qq to record, Q to replay (remapped) | |
nmap Q @q | |
" gQ: Q (remapped) | |
nnoremap gQ Q | |
" .: repeats the last command on every line | |
xnoremap . :normal .<CR> | |
" @: repeats macro on every line | |
xnoremap @ :normal @ | |
" After indenting code, does not exit Visual mode | |
xnoremap > >gv | |
xnoremap < <gv | |
xmap <Tab> > | |
xmap <S-Tab> < | |
" Indent whole file | |
nnoremap g= gg=G`` | |
" gi already moves to "last place you exited insert mode" | |
" gI: Move to last change (remapped) | |
nnoremap gI `.` | |
" gV: Select the text that was last edited/pasted (remapped) | |
" http://vimcasts.org/episodes/bubbling-text/ | |
nmap gV `[v`] | |
" U: Redo (remapped) | |
nnoremap U :redo<CR> | |
" Y: Yank to end line (remapped) | |
nnoremap Y y$ | |
" Copy / cut to clipboard | |
nmap cy "+y | |
nmap cd "+d | |
xmap gy "+y | |
xmap gd "+d | |
" Copy yanked text to clipboard | |
nnoremap <silent> cY :let [@+, @*] = [@", @"]<CR> | |
" Paste from clipboard | |
nnoremap <silent> cp "+p | |
nnoremap <silent> cP "+P | |
nnoremap <silent> cgp "+gp | |
nnoremap <silent> cgP "+gP | |
nnoremap <silent> c=p o<Esc>"+pm``[=`]``^ | |
nnoremap <silent> c=P O<Esc>"+Pm``[=`]``^ | |
nnoremap <silent> c=v :set paste<CR>"+p:set nopaste<CR> | |
nnoremap <silent> c=V :set paste<CR>"+P:set nopaste<CR> | |
inoremap <silent> <C-v> <C-g>u<C-\><C-o>"+gP | |
" Folding | |
nnoremap <silent> zr zr:<C-u>setlocal foldlevel?<CR> | |
nnoremap <silent> zm zm:<C-u>setlocal foldlevel?<CR> | |
nnoremap <silent> zR zR:<C-u>setlocal foldlevel?<CR> | |
nnoremap <silent> zM zM:<C-u>setlocal foldlevel?<CR> | |
nnoremap <silent> z] :let &foldcolumn = &foldcolumn + 1<CR>:<C-u>setlocal foldcolumn?<CR> | |
nnoremap <silent> z[ :let &foldcolumn = &foldcolumn - 1<CR>:<C-u>setlocal foldcolumn?<CR> | |
" Search and Replace | |
nnoremap <Leader>R :%s//gc<Left><Left><Left> | |
nnoremap <Leader>sr :%s/<C-r>=vim_helpers#CwordForSubstitute()<CR>//gc<Left><Left><Left> | |
nmap <Leader>rr <Leader>sr | |
nnoremap <Leader>.r :%s/<C-r>=vim_helpers#WordForSubstitute()<CR>//gc<Left><Left><Left> | |
xnoremap <Leader>R :s/\%V/gc<Left><Left><Left> | |
xnoremap <Leader>sr <Esc>:%s/<C-r>=vim_helpers#VwordForSubstitute()<CR>//gc<Left><Left><Left> | |
xmap <Leader>rr <Leader>sr | |
" Search and Replace entries with same mappings in quickfix/locationlist with :cdo and :ldo | |
function! s:SetupQuickfixMapping() abort | |
let l:cmd = s:IsLocationList() ? 'ldo' : 'cdo' | |
execute printf('nnoremap <buffer> <Leader>R :%s s//<Left>', l:cmd) | |
execute printf('nnoremap <buffer> <Leader>sr :%s s/<C-r>=vim_helpers#CwordForSubstitute()<CR>//<Left>', l:cmd) | |
execute printf('xnoremap <buffer> <Leader>sr <Esc>:%s s/<C-r>=vim_helpers#VwordForSubstitute()<CR>//<Left>', l:cmd) | |
execute printf('nnoremap <buffer> <Leader>.r :%s s/<C-r>=vim_helpers#WordForSubstitute()<CR>//<Left>', l:cmd) | |
endfunction | |
augroup MyAutoCmd | |
autocmd FileType qf call <SID>SetupQuickfixMapping() | |
augroup END | |
" Buffer-related mappings | |
" gl: Go to Last buffer | |
nnoremap <silent> gl :buffer#<CR> | |
" Edit file from buffer folder | |
nnoremap <C-w><C-e> :edit <C-r>=fnameescape(expand('%:p:~:.:h')) . '/'<CR> | |
" Edit buffer | |
nnoremap <C-w>e :edit<Space> | |
" Yank whole buffer to clipboard | |
nnoremap <silent> <Leader>by :%y+<CR> | |
" Reload buffer | |
nnoremap <silent> <Leader>be :confirm edit<CR> | |
" Save/Write buffer | |
nnoremap <silent> <Leader>w :update<CR> | |
vnoremap <silent> <Leader>w <Esc><Leader>wgv | |
nnoremap <silent> <Leader>bw :update<CR> | |
vmap <Leader>bw <Esc><Leader>bwgv | |
nnoremap <silent> <Leader>bu :update<CR> | |
vmap <Leader>bu <Esc><Leader>bugv | |
nnoremap <silent> <C-s> :update<CR> | |
vmap <C-s> <Esc><C-s>gv | |
imap <C-s> <Esc><C-s> | |
" Save and Quit buffer | |
nnoremap <silent> <Leader>x :xit<CR> | |
vmap <Leader>x <Esc><Leader>x | |
nnoremap <silent> <Leader>bx :xit<CR> | |
vmap <Leader>bx <Esc><Leader>bx | |
" Unload buffer and delete it from the buffer list | |
nnoremap <silent> <Leader>bk :confirm bdelete<CR> | |
" Exit Vim. Bring up a prompt when some buffers have been changed | |
nnoremap <silent> ZE :confirm qall<CR> | |
" Insert date/time | |
nnoremap <silent> <Leader>id a<C-r>=strftime('%Y-%m-%d')<CR><Esc> | |
nnoremap <silent> <Leader>ic a<C-r>=strftime('%c')<CR><Esc> | |
" RFC822 Format | |
nnoremap <silent> <Leader>ir a<C-r>=strftime('%a, %d %b %Y %H:%M:%S %z')<CR><Esc> | |
" ISO8601 / W3C Format | |
nnoremap <silent> <Leader>it a<C-r>=strftime('%Y-%m-%dT%T%z')<CR><Esc> | |
" junegunn/vim-plug | |
nnoremap <silent> <Leader>vv :PlugUpdate<CR> | |
if s:IsPlugged('vim-tmuxify') | |
" jebaum/vim-tmuxify | |
let g:tmuxify_custom_command = 'tmux split-window -d -p 30' | |
" Disable default mappings | |
let g:tmuxify_map_prefix = '' | |
let g:tmuxify_global_maps = 1 | |
function! s:SetupTmuxifyMappings(prefix, suffix) abort | |
execute 'nnoremap <silent> ' . a:prefix . 'b :TxSigInt' . a:suffix . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'c :TxClear' . a:suffix . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'C :TxSendClear' . a:suffix . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'f :TxSendClear' . a:suffix . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'n :TxCreate' . a:suffix . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'p :TxSetPane' . a:suffix . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'q :TxKill' . a:suffix . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'r :TxRun' . a:suffix . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 't :TxSetRunCmd' . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'i :TxSend' . a:suffix . '<CR>' | |
execute 'xnoremap <silent> ' . a:prefix . 's "my:TxSend' . a:suffix . '(@m)<CR>' | |
execute 'nmap <silent> ' . a:prefix . 's mmvip' . a:prefix . 's`m' | |
execute 'nmap <silent> ' . a:prefix . 'S mmggVG' . a:prefix . 's`m' | |
execute 'nmap <silent> ' . a:prefix . 'l mmV' . a:prefix . 's`m' | |
execute 'nmap <silent> ' . a:prefix . 'w mmviw' . a:prefix . 's`m' | |
execute 'nnoremap <silent> ' . a:prefix . 'a :TxSend' . a:suffix . '(@m)<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'k :TxSendKey' . a:suffix . '<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'e :TxSendKey' . a:suffix . ' C-u q C-u<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'x :TxSendKey' . a:suffix . ' C-u q C-u<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'm :TxSendKey' . a:suffix . ' Enter<CR>' | |
execute 'nnoremap <silent> ' . a:prefix . 'd :TxSendKey' . a:suffix . ' C-d<CR>' | |
endfunction | |
" Global mappings | |
call s:SetupTmuxifyMappings('<Leader>m', '!') | |
" Local mappings | |
call s:SetupTmuxifyMappings('<Leader>v', '') | |
function! TmuxifySendKeys(keys, bang) | |
let keys = empty(a:keys) ? input('TxSendKeys> ') : a:keys | |
for key in split(keys) | |
call tmuxify#pane_send_raw(key, a:bang) | |
endfor | |
endfunction | |
function! s:SetupTmuxifyCommands() abort | |
" Overwrite TxClear and TxSendKey commands | |
command! -bar -bang TxClear call TmuxifySendKeys('C-u C-l C-u', <q-bang>) | |
command! -nargs=? -bar -bang TxSendKey call TmuxifySendKeys(<q-args>, <q-bang>) | |
command! -bar -bang TxSendClear call tmuxify#pane_run(<q-bang>, 'clear') | |
endfunction | |
augroup MyAutoCmd | |
autocmd VimEnter * call <SID>SetupTmuxifyCommands() | |
augroup END | |
endif | |
" tpope/vim-dispatch | |
let g:dispatch_quickfix_height = 10 | |
let g:dispatch_tmux_height = 1 | |
" phongnh/vim-helpers | |
let g:grep_ignore_vcs = g:zero_vim_grep_ignore_vcs | |
function! s:IsSubstituteCommand(cmd) abort | |
return a:cmd =~# '^%\?\(s\|substitute\|S\|Subvert\)/' || | |
\ a:cmd =~# '^\(c\|l\)do \(s\|substitute\|S\|Subvert\)/' || | |
\ a:cmd =~# '^\(c\|l\)fdo %\(s\|substitute\|S\|Subvert\)/' | |
endfunction | |
function! s:IsGrepCommand(cmd) abort | |
return a:cmd =~# '^\(Grep\|LGrep\|BGrep\|grep\|lgrep\)\s' || | |
\ a:cmd =~# '^\(Ggrep!\?\|Gcgrep!\?\|Glgrep!\?\)\s' || | |
\ a:cmd =~# '^\(Git!\?\s\+grep\)\s' | |
endfunction | |
function! s:IsCtrlSFCommand(cmd) abort | |
return a:cmd =~# '^CtrlSF' || | |
\ a:cmd =~# '^PCtrlSF' || | |
\ a:cmd =~# '^HCtrlSF' | |
endfunction | |
function! s:InsertWord() abort | |
let l:cmd = getcmdline() | |
if s:IsSubstituteCommand(l:cmd) | |
return vim_helpers#WordForSubstitute() | |
elseif s:IsGrepCommand(l:cmd) | |
return vim_helpers#WordForGrep() | |
elseif s:IsCtrlSFCommand(l:cmd) | |
return vim_helpers#Word() | |
else | |
return vim_helpers#WordForShell() | |
endif | |
endfunction | |
function! s:InsertCCword() abort | |
let l:cmd = getcmdline() | |
if s:IsSubstituteCommand(l:cmd) | |
return vim_helpers#CCwordForSubstitute() | |
elseif s:IsGrepCommand(l:cmd) | |
return vim_helpers#CCwordForGrep() | |
elseif s:IsCtrlSFCommand(l:cmd) | |
return '-R ' . vim_helpers#CCword() | |
else | |
return vim_helpers#CCwordForShell() | |
endif | |
endfunction | |
function! s:InsertPword() abort | |
let l:cmd = getcmdline() | |
if s:IsSubstituteCommand(l:cmd) | |
return vim_helpers#PwordForSubstitute() | |
elseif s:IsGrepCommand(l:cmd) | |
return vim_helpers#PwordForGrep() | |
elseif s:IsCtrlSFCommand(l:cmd) | |
let l:pword = vim_helpers#Pword() | |
return (stridx(l:pword, '\b') == 0 ? '-R ' : '') . l:pword | |
else | |
return vim_helpers#PwordForShell() | |
endif | |
endfunction | |
cnoremap <C-r><C-t> <C-r>=<SID>InsertWord()<CR> | |
cnoremap <C-r><C-b> <C-r>=<SID>InsertCCword()<CR> | |
cnoremap <C-r><C-_> <C-r>=<SID>InsertPword()<CR> | |
cnoremap <C-r><C-d> <C-r>=expand("%:p:h")<CR> | |
cnoremap <C-r><C-h> <C-r>=projectroot#get()<CR> | |
" Tig Status | |
nnoremap <silent> <Leader>gt :TigStatus<CR> | |
" Grep | |
function! s:SetupGrepMappings() abort | |
nnoremap <Leader>S :Grep<Space> | |
xnoremap <Leader>S :GrepVword<Space> | |
nnoremap <silent> <Leader>ss :GrepCCword<CR> | |
xnoremap <silent> <Leader>ss :GrepVword<CR> | |
nnoremap <silent> <Leader>sc :GrepWord<CR> | |
nnoremap <silent> <Leader>sp :GrepCCword <C-r>=projectroot#get()<CR><CR> | |
xnoremap <silent> <Leader>sp :GrepVword <C-r>=projectroot#get()<CR><CR> | |
nnoremap <silent> <Leader>sd :GrepCCword <C-r>=expand("%:p:h")<CR><CR> | |
xnoremap <silent> <Leader>sd :GrepVword <C-r>=expand("%:p:h")<CR><CR> | |
nnoremap <silent> <Leader>s/ :GrepPword<CR> | |
nnoremap <Leader>s? :GrepPword<Space> | |
nnoremap <Leader>B :LGrep<Space> | |
xnoremap <Leader>B :LGrepVword<Space> | |
nnoremap <silent> <Leader>bs :LGrepCCword<CR> | |
xnoremap <silent> <Leader>bs :LGrepVword<CR> | |
nnoremap <silent> <Leader>bc :LGrepWord<CR> | |
nnoremap <silent> <Leader>b/ :LGrepPword<CR> | |
nnoremap <Leader>b? :LGrepPword<Space> | |
nnoremap <silent> <Leader>.s :GrepWord<CR> | |
nnoremap <Leader>.S :GrepWord<Space> | |
nnoremap <silent> <Leader>.p :GrepWord <C-r>=projectroot#get()<CR><CR> | |
nnoremap <silent> <Leader>.d :GrepWord <C-r>=expand("%:p:h")<CR><CR> | |
nnoremap <silent> <Leader>.b :LGrepWord<CR> | |
nnoremap <Leader>.B :LGrepWord<Space> | |
endfunction | |
if g:zero_vim_use_simple_grep | |
augroup MyAutoCmd | |
autocmd VimEnter * call <SID>SetupGrepMappings() | |
augroup END | |
endif | |
" ntpeters/vim-better-whitespace | |
let g:better_whitespace_enabled = 1 | |
let g:strip_whitespace_on_save = 0 | |
let g:better_whitespace_filetypes_blacklist = [ | |
\ 'terminal', | |
\ 'diff', | |
\ 'git', | |
\ 'gitcommit', | |
\ 'fugitiveblame', | |
\ 'ctrlsf', | |
\ 'unite', | |
\ 'qf', | |
\ 'help', | |
\ 'markdown', | |
\ ] | |
nnoremap <silent> <Leader>bw :StripWhitespace<CR>:update<CR> | |
vnoremap <silent> <Leader>bw :StripWhitespace<CR>:update<CR>gv | |
nnoremap <silent> yo<Space> :ToggleWhitespace<CR> | |
" phongnh/ZoomWin | |
nmap <silent> <C-w>m <Plug>ZoomWin | |
vmap <C-w>m <Esc><C-w>mgv | |
nmap <Leader>bm <C-w>m | |
vmap <Leader>bm <C-w>m | |
" mhinz/vim-sayonara | |
let g:sayonara_confirm_quit = 1 | |
let g:sayonara_filetypes = { | |
\ 'fern': 'close', | |
\ 'nerdtree': 'NERDTreeClose', | |
\ 'vaffle': 'call VaffleQuit()', | |
\ 'bufexplorer': 'ToggleBufExplorer', | |
\ 'undotree': 'UndotreeHide', | |
\ 'gundo': 'GundoHide', | |
\ 'Mundo': 'MundoHide', | |
\ } | |
nnoremap <silent> <C-w>c :Sayonara<CR> | |
nnoremap <silent> <C-w>C :Sayonara!<CR> | |
nnoremap <silent> <Leader>bk :Sayonara!<CR> | |
" chrisbra/NrrwRgn | |
let g:nrrw_topbot_leftright = 'belowright' | |
let g:nrrw_rgn_nomap_nr = 1 | |
let g:nrrw_rgn_nomap_Nr = 1 | |
let g:nrrw_rgn_resize_window = 'relative' | |
let g:nrrw_rgn_rel_min = 50 | |
let g:nrrw_rgn_rel_max = 50 | |
nmap <Leader>bn <Plug>NrrwrgnDo | |
xmap <Leader>bn <Plug>NrrwrgnDo | |
nmap <Leader>n <Leader>bn | |
xmap <Leader>n <Leader>bn | |
augroup MyAutoCmd | |
" TODO: Find a better way to setup NrrwRgn buffer mapping | |
autocmd FileType * let b:nrrw_aucmd_create = 'nnoremap <buffer> <silent> <Leader>bn :WidenRegion!<CR>' | |
augroup END | |
if s:IsPlugged('vim-qf') | |
" romainl/vim-qf | |
let g:qf_auto_open_quickfix = 0 | |
let g:qf_auto_open_loclist = 0 | |
let g:qf_mapping_ack_style = 1 | |
function! s:RemapQuickfixMappings() abort | |
execute 'nnoremap <buffer> <silent> <expr> <C-v> ' . maparg('v', 'n') | |
execute 'nnoremap <buffer> <silent> <C-s> ' . maparg('s', 'n') | |
execute 'nnoremap <buffer> <silent> <C-x> ' . maparg('s', 'n') | |
execute 'nnoremap <buffer> <silent> <C-t> ' . maparg('t', 'n') | |
nnoremap <buffer> v v | |
nnoremap <buffer> t t | |
endfunction | |
augroup MyAutoCmd | |
autocmd FileType qf call <SID>RemapQuickfixMappings() | |
augroup end | |
endif | |
if s:IsPlugged('QFEnter') | |
" yssl/QFEnter | |
let g:qfenter_enable_autoquickfix = 0 | |
let g:qfenter_keymap = {} | |
let g:qfenter_keymap.vopen = ['<C-v>'] | |
let g:qfenter_keymap.hopen = ['<C-CR>', '<C-s>', '<C-x>'] | |
let g:qfenter_keymap.topen = ['<C-t>'] | |
endif | |
" mhinz/vim-grepper | |
let s:grepper_tools = ['rg', 'git', 'findstr'] | |
let g:grepper = { | |
\ 'open': 1, | |
\ 'switch': 1, | |
\ 'jump': 0, | |
\ 'prompt': 1, | |
\ 'prompt_mapping_tool': '<C-\>', | |
\ 'tools': copy(s:grepper_tools), | |
\ 'stop': 2000, | |
\ } | |
function! s:SetupGrepper() abort | |
if empty(g:grepper.tools) | |
for l:tool in s:grepper_tools | |
if executable(l:tool) | |
call add(g:grepper.tools, l:tool) | |
endif | |
endfor | |
endif | |
if index(g:grepper.tools, 'rg') > -1 | |
let g:grepper.rg.grepprg = 'rg -H --no-heading --line-number --column --hidden --smart-case' | |
if g:zero_vim_follow_links | |
let g:grepper.rg.grepprg .= ' --follow' | |
endif | |
if g:zero_vim_grep_ignore_vcs | |
let g:grepper.rg.grepprg .= ' --no-ignore-vcs' | |
endif | |
endif | |
endfunction | |
augroup MyAutoCmd | |
autocmd VimEnter * call <SID>SetupGrepper() | |
augroup END | |
command! -nargs=* -complete=customlist,grepper#complete PGrepper Grepper -dir repo,cwd <args> | |
command! -nargs=* -complete=customlist,grepper#complete DGrepper Grepper -dir file,cwd <args> | |
command! -nargs=* -complete=customlist,grepper#complete LGrepper Grepper -noquickfix <args> | |
command! -nargs=* -complete=customlist,grepper#complete BGrepper LGrepper -buffer <args> | |
command! -nargs=* -complete=customlist,grepper#complete GrepperCCword Grepper -cword <args> | |
command! -nargs=* -complete=customlist,grepper#complete GrepperCword execute 'Grepper ' . <q-args> . ' -query' vim_helpers#CwordForShell() | |
command! -nargs=* -complete=customlist,grepper#complete GrepperWord execute 'Grepper ' . <q-args> . ' -query' vim_helpers#WordForShell() | |
command! -nargs=* -complete=customlist,grepper#complete -range GrepperVword execute 'Grepper ' . <q-args> . ' -query' vim_helpers#VwordForShell() | |
command! -nargs=* -complete=customlist,grepper#complete GrepperPword execute 'Grepper ' . <q-args> . ' -query' vim_helpers#PwordForShell() | |
command! -nargs=* -complete=customlist,grepper#complete LGrepperCCword LGrepper -cword <args> | |
command! -nargs=* -complete=customlist,grepper#complete LGrepperCword execute 'LGrepper ' . <q-args> . ' -query' vim_helpers#CwordForShell() | |
command! -nargs=* -complete=customlist,grepper#complete LGrepperWord execute 'LGrepper ' . <q-args> . ' -query' vim_helpers#WordForShell() | |
command! -nargs=* -complete=customlist,grepper#complete -range LGrepperVword execute 'LGrepper ' . <q-args> . ' -query' vim_helpers#VwordForShell() | |
command! -nargs=* -complete=customlist,grepper#complete LGrepperPword execute 'LGrepper ' . <q-args> . ' -query' vim_helpers#PwordForShell() | |
nmap gs <Plug>(GrepperOperator) | |
xmap gs <Plug>(GrepperOperator) | |
nnoremap <silent> <Leader>S :Grepper<CR> | |
xnoremap <silent> <Leader>S :GrepperVword<CR> | |
nnoremap <silent> <Leader>ss :GrepperCCword -noprompt<CR> | |
xnoremap <silent> <Leader>ss :GrepperVword -noprompt<CR> | |
nnoremap <silent> <Leader>sc :GrepperWord -noprompt<CR> | |
" Grepper with current buffer project / repo | |
nnoremap <silent> <Leader>sp :GrepperCCword -dir repo,cwd -noprompt<CR> | |
xnoremap <silent> <Leader>sp :GrepperVword -dir repo,cwd -noprompt<CR> | |
" Grepper with current buffer dir | |
nnoremap <silent> <Leader>sd :GrepperCCword -dir file,cwd -noprompt<CR> | |
xnoremap <silent> <Leader>sd :GrepperVword -dir file,cwd -noprompt<CR> | |
" Grepper with current search pattern | |
nnoremap <silent> <Leader>s/ :GrepperPword -noprompt<CR> | |
nnoremap <silent> <Leader>s? :GrepperPword<CR> | |
nnoremap <silent> <Leader>B :LGrepper<CR> | |
xnoremap <silent> <Leader>B :LGrepperVword<CR> | |
nnoremap <silent> <Leader>bs :LGrepperCCword -noprompt<CR> | |
xnoremap <silent> <Leader>bs :LGrepperVword -noprompt<CR> | |
nnoremap <silent> <Leader>bc :LGrepperWord -noprompt<CR> | |
nnoremap <silent> <Leader>b/ :LGrepperPword -noprompt<CR> | |
nnoremap <silent> <Leader>b? :LGrepperPword<CR> | |
nnoremap <silent> <Leader>.s :GrepperWord -noprompt<CR> | |
nnoremap <silent> <Leader>.S :GrepperWord<CR> | |
nnoremap <silent> <Leader>.p :GrepperWord -dir repo,cwd -noprompt<CR> | |
nnoremap <silent> <Leader>.d :GrepperWord -dir file,cwd -noprompt<CR> | |
nnoremap <silent> <Leader>.b :LGrepperWord -noprompt<CR> | |
nnoremap <silent> <Leader>.B :LGrepperWord<CR> | |
" Grepper Git | |
command! -nargs=* -complete=customlist,grepper#complete GitGrepper Grepper -tool git <args> | |
command! -nargs=* -complete=customlist,grepper#complete LGitGrepper LGrepper -tool git <args> | |
nnoremap <silent> <Leader>G :Grepper -tool git<CR> | |
xnoremap <silent> <Leader>G :GrepperVword -tool git<CR> | |
nnoremap <silent> <Leader>sg :GrepperCCword -tool git -noprompt<CR> | |
xnoremap <silent> <Leader>sg :GrepperVword -tool git -noprompt<CR> | |
nnoremap <silent> <Leader>bg :LGrepperCCword -tool git -noprompt<CR> | |
xnoremap <silent> <Leader>bg :LGrepperVword -tool git -noprompt<CR> | |
nnoremap <silent> <Leader>.g :GrepperWord -tool git -noprompt <CR> | |
" dyng/ctrlsf.vim | |
let g:ctrlsf_default_root = 'cwd' | |
let g:ctrlsf_extra_root_markers = ['.git', '.hg', '.svn', '.bzr', '_darcs', 'Gemfile', 'rebar.config', 'mix.exs', 'Cargo.toml', 'shard.yml', 'go.mod'] | |
let g:ctrlsf_follow_symlinks = g:zero_vim_follow_links | |
let g:ctrlsf_populate_qflist = 0 | |
let g:ctrlsf_auto_focus = { | |
\ 'at': 'start' | |
\ } | |
" Prefer rg | |
if executable('rg') | |
let g:ctrlsf_backend = 'rg' | |
if g:zero_vim_grep_ignore_vcs | |
let g:ctrlsf_extra_backend_args = { | |
\ 'rg': '--no-ignore-vcs', | |
\ } | |
endif | |
endif | |
function! s:PCtrlSF(...) abort | |
let l:current_default_root = g:ctrlsf_default_root | |
try | |
let g:ctrlsf_default_root = 'project+fw' | |
execute vim_helpers#strip('CtrlSF' . ' ' . join(a:000, ' ')) | |
finally | |
let g:ctrlsf_default_root = l:current_default_root | |
endtry | |
endfunction | |
function! s:HCtrlSF(...) abort | |
let l:current_position = g:ctrlsf_position | |
try | |
let g:ctrlsf_position = 'top' | |
execute vim_helpers#strip('CtrlSF' . ' ' . join(a:000, ' ')) | |
finally | |
let g:ctrlsf_position = l:current_position | |
endtry | |
endfunction | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion CtrlSFWord execute 'CtrlSF' vim_helpers#Word() <args> | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion PCtrlSF call <SID>PCtrlSF(<f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion PCtrlSFCCword call <SID>PCtrlSF(get(g:, ctrlsf_backend, '') ==# 'rg' ? '-R ' . vim_helpers#CCword() : vim_helpers#Cword(), <f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion PCtrlSFCword call <SID>PCtrlSF(vim_helpers#Cword(), <f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion PCtrlSFWord call <SID>PCtrlSF(vim_helpers#Word(), <f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion -range PCtrlSFVword call <SID>PCtrlSF(vim_helpers#VwordForShell(), <f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion PCtrlSFPword call <SID>PCtrlSF(vim_helpers#PwordForShell(), <f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion HCtrlSF call <SID>HCtrlSF(<f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion HCtrlSFCCword call <SID>HCtrlSF(get(g:, ctrlsf_backend, '') ==# 'rg' ? '-R ' . vim_helpers#CCword() : vim_helpers#Cword(), <f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion HCtrlSFCword call <SID>HCtrlSF(vim_helpers#Cword(), <f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion HCtrlSFWord call <SID>HCtrlSF(vim_helpers#Word(), <f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion -range HCtrlSFVword call <SID>HCtrlSF(vim_helpers#VwordForShell(), <f-args>) | |
command! -nargs=* -complete=customlist,ctrlsf#comp#Completion HCtrlSFPword call <SID>HCtrlSF(vim_helpers#PwordForShell(), <f-args>) | |
nnoremap <expr> <Plug>CtrlSFWordExec ":\<C-u>CtrlSF " . vim_helpers#Word() . ' ' . "\<CR>" | |
nnoremap <expr> <Plug>CtrlSFWordPath ":\<C-u>CtrlSF " . vim_helpers#Word() . ' ' | |
nmap <Leader>F <Plug>CtrlSFPrompt | |
vmap <Leader>F <Plug>CtrlSFVwordPath | |
nmap <Leader>sf <Plug>CtrlSFCCwordExec | |
vmap <Leader>sf <Plug>CtrlSFVwordExec | |
nmap <Leader>sw <Plug>CtrlSFWordExec | |
nnoremap <silent> <Leader>sh :HCtrlSFCCword<CR> | |
xnoremap <silent> <Leader>sh :HCtrlSFVword<CR> | |
" CtrlSF with current buffer project / repo | |
nnoremap <silent> <Leader>so :PCtrlSFCCword<CR> | |
xnoremap <silent> <Leader>so :PCtrlSFVword<CR> | |
nnoremap <silent> <Leader>su :CtrlSFUpdate<CR> | |
nnoremap <silent> <Leader>st :CtrlSFToggle<CR> | |
nmap <silent> <Leader>.f <Plug>CtrlSFWordExec | |
nmap <silent> <Leader>.F <Plug>CtrlSFWordPath | |
nnoremap <silent> <Leader>.h :HCtrlSFWord<CR> | |
nnoremap <silent> <Leader>.o :PCtrlSFWord<CR> | |
function! s:ToggleCtrlSFPopulateQuickfix() abort | |
let g:ctrlsf_populate_qflist = !g:ctrlsf_populate_qflist | |
echo printf('CtrlSF: %s populating quickfix!', g:ctrlsf_populate_qflist ? 'Enabled' : 'Disabled') | |
endfunction | |
command! ToogleCtrlSFQuickfix call <SID>ToggleCtrlSFPopulateQuickfix() | |
nnoremap <silent> yoq :ToogleCtrlSFQuickfix<CR> | |
if s:IsPlugged('any-jump.vim') | |
" pechorin/any-jump.vim | |
" Disable default any-jump keybindings (default: 0) | |
let g:any_jump_disable_default_keybindings = 1 | |
" Show line numbers in search rusults | |
let g:any_jump_list_numbers = 0 | |
" Auto search references | |
let g:any_jump_references_enabled = 1 | |
" Auto group results by filename | |
let g:any_jump_grouping_enabled = 0 | |
" Amount of preview lines for each search result | |
let g:any_jump_preview_lines_count = 5 | |
" Max search results, other results can be opened via [a] | |
let g:any_jump_max_search_results = 10 | |
" Prefered search engine: rg or ag | |
let g:any_jump_search_prefered_engine = 'rg' | |
" Search results list styles: | |
" - 'filename_first' | |
" - 'filename_last' | |
let g:any_jump_results_ui_style = 'filename_first' | |
" Any-jump window size & position options | |
let g:any_jump_window_width_ratio = 0.6 | |
let g:any_jump_window_height_ratio = 0.6 | |
let g:any_jump_window_top_offset = 4 | |
" Remove comments line from search results (default: 1) | |
let g:any_jump_remove_comments_from_results = 1 | |
" Custom ignore files | |
" default is: ['*.tmp', '*.temp'] | |
let g:any_jump_ignored_files = ['*.tmp', '*.temp'] | |
" Search references only for current file type | |
" (default: false, so will find keyword in all filetypes) | |
let g:any_jump_references_only_for_current_filetype = 0 | |
" Disable search engine ignore vcs untracked files | |
" (default: false, search engine will ignore vcs untracked files) | |
let g:any_jump_disable_vcs_ignore = 0 | |
" Normal mode: Jump to definition under cursore | |
nnoremap <silent> <Leader>sa :AnyJump<CR> | |
nnoremap <silent> <Leader>sj :AnyJump<CR> | |
" Visual mode: jump to selected text in visual mode | |
xnoremap <silent> <Leader>sa :AnyJumpVisual<CR> | |
xnoremap <silent> <Leader>sj :AnyJumpVisual<CR> | |
" Normal mode: open last closed search window again | |
nnoremap <silent> <Leader>sl :AnyJumpLastResults<CR> | |
nnoremap <silent> <Leader>sk :AnyJumpLastResults<CR> | |
" Normal mode: open previous opened file (after jump) | |
nnoremap <silent> <Leader>sb :AnyJumpBack<CR> | |
endif | |
if s:IsPlugged('nerdcommenter') | |
" scrooloose/nerdcommenter | |
" Add spaces after comment delimiters by default | |
let g:NERDSpaceDelims = 1 | |
" Enable trimming of trailing whitespace when uncommenting | |
let g:NERDTrimTrailingWhitespace = 1 | |
" Use compact syntax for prettified multi-line comments | |
let g:NERDCompactSexyComs = 1 | |
" Allow commenting and inverting empty lines (useful when commenting a region) | |
" let g:NERDCommentEmptyLines = 1 | |
endif | |
" junegunn/vim-easy-align | |
vmap <Enter> <Plug>(EasyAlign) | |
if s:IsPlugged('tabular') | |
" godlygeek/tabular | |
" Overwrite ga behavior - call :ascii instead | |
nnoremap ga :Tabularize<Space>/ | |
xnoremap ga :Tabularize<Space>/ | |
endif | |
" tpope/vim-surround | |
let g:surround_indent = 1 | |
let g:surround_no_insert_mappings = 1 | |
" tpope/vim-abolish | |
nnoremap <Leader>V :%Subvert//gc<Left><Left><Left> | |
nnoremap <Leader>sv :%Subvert/<C-r>=vim_helpers#CwordForSubstitute()<CR>//gc<Left><Left><Left> | |
nmap <Leader>rv <Leader>sv | |
nnoremap <Leader>.v :%Subvert/<C-r>=vim_helpers#WordForSubstitute()<CR>//gc<Left><Left><Left> | |
xnoremap <Leader>V :Subvert//gc<Left><Left><Left> | |
xnoremap <Leader>sv <Esc>:%Subvert/<C-r>=vim_helpers#VwordForSubstitute()<CR>//gc<Left><Left><Left> | |
xmap <Leader>rv <Leader>sv | |
" Search and Replace entries with same mappings in quickfix/locationlist with :cdo and :ldo | |
function! s:SetupQuickfixMappingForSubvert() abort | |
let l:cmd = s:IsLocationList() ? 'ldo' : 'cdo' | |
execute printf('nnoremap <buffer> <Leader>V :%s Subvert//<Left>', l:cmd) | |
execute printf('nnoremap <buffer> <Leader>sv :%s Subvert/<C-r>=vim_helpers#CwordForSubstitute()<CR>//<Left>', l:cmd) | |
execute printf('xnoremap <buffer> <Leader>sv <Esc>:%s Subvert/<C-r>=vim_helpers#VwordForSubstitute()<CR>//<Left>', l:cmd) | |
execute printf('nnoremap <buffer> <Leader>.v :%s Subvert/<C-r>=vim_helpers#WordForSubstitute()<CR>//<Left>', l:cmd) | |
endfunction | |
augroup MyAutoCmd | |
autocmd FileType qf call <SID>SetupQuickfixMappingForSubvert() | |
augroup END | |
if s:IsPlugged('auto-pairs') | |
" jiangmiao/auto-pairs | |
let g:AutoPairsFlyMode = 0 | |
let g:AutoPairsShortcutToggle = '<M-p>' | |
let g:AutoPairsShortcutFastWrap = '' | |
let g:AutoPairsShortcutJump = '<M-n>' | |
let g:AutoPairsShortcutBackInsert = '' | |
let g:AutoPairsMoveCharacter = '' | |
endif | |
if s:IsPlugged('lexima.vim') | |
" cohama/lexima.vim | |
let g:lexima_enable_basic_rules = 1 | |
let g:lexima_enable_newline_rules = 1 | |
let g:lexima_enable_space_rules = 1 | |
let g:lexima_enable_endwise_rules = 0 | |
let g:lexima_accept_pum_with_enter = 0 " Always insert new line regardless if popup menu is visible | |
let g:lexima_ctrlh_as_backspace = 1 | |
let g:lexima_map_escape = '' " Disabled Esc mapping | |
endif | |
" Autocompletion plugins should define these functions to | |
" integrate with vim-visual-multi / vim-multiple-cursors plugin | |
function! Disable_Completion_Hook() abort | |
endfunction | |
function! Enable_Completion_Hook() abort | |
endfunction | |
if s:IsPlugged('vim-multiple-cursors') | |
" terryma/vim-multiple-cursors | |
function! Multiple_cursors_before() abort | |
let b:autopairs_enabled = 0 | |
let b:lexima_disabled = 1 | |
call Disable_Completion_Hook() | |
endfunction | |
function! Multiple_cursors_after() abort | |
let b:autopairs_enabled = 1 | |
let b:lexima_disabled = 0 | |
call Enable_Completion_Hook() | |
endfunction | |
endif | |
if s:IsPlugged('vim-visual-multi') | |
" mg979/vim-visual-multi | |
let g:VM_custom_remaps = { | |
\ '<C-p>': 'N', | |
\ '<C-x>': 'q', | |
\ '<C-c>': '<Esc>', | |
\ } | |
function! VM_Start() abort | |
let b:autopairs_enabled = 0 | |
let b:lexima_disabled = 1 | |
call Disable_Completion_Hook() | |
endfunction | |
function! VM_Exit() abort | |
let b:autopairs_enabled = 1 | |
let b:lexima_disabled = 0 | |
call Enable_Completion_Hook() | |
endfunction | |
function! VM_Mappings() abort | |
imap <nowait> <buffer> <C-c> <Esc><Esc> | |
endfunction | |
augroup MyAutoCmd | |
autocmd User visual_multi_start call VM_Start() | |
autocmd User visual_multi_exit call VM_Exit() | |
autocmd User visual_multi_mappings call VM_Mappings() | |
augroup end | |
endif | |
" mattn/emmet-vim | |
let g:user_emmet_leader_key = '<C-y>' | |
let g:user_emmet_settings = { | |
\ 'javascript.jsx': { | |
\ 'extends': 'jsx', | |
\ }, | |
\ } | |
" AndrewRadev/sideways.vim | |
let g:sideways_search_timeout = 50 | |
omap <silent> aa <Plug>SidewaysArgumentTextobjA | |
xmap <silent> aa <Plug>SidewaysArgumentTextobjA | |
omap <silent> ia <Plug>SidewaysArgumentTextobjI | |
xmap <silent> ia <Plug>SidewaysArgumentTextobjI | |
nmap <silent> si <Plug>SidewaysArgumentInsertBefore | |
nmap <silent> sa <Plug>SidewaysArgumentAppendAfter | |
nmap <silent> sI <Plug>SidewaysArgumentInsertFirst | |
nmap <silent> sA <Plug>SidewaysArgumentAppendLast | |
nnoremap <silent> s[ :SidewaysJumpLeft<CR> | |
nnoremap <silent> s] :SidewaysJumpRight<CR> | |
nmap s< <Plug>SidewaysLeft | |
nmap s> <Plug>SidewaysRight | |
if s:IsPlugged('vim-textobj-conflict') | |
" rhysd/vim-textobj-conflict | |
let g:textobj_conflict_no_default_key_mappings = 1 | |
" Remap from '=' to 'C' | |
omap aC <Plug>(textobj-conflict-_-a) | |
xmap aC <Plug>(textobj-conflict-_-a) | |
omap iC <Plug>(textobj-conflict-_-i) | |
xmap iC <Plug>(textobj-conflict-_-i) | |
endif | |
if s:IsPlugged('vim-textobj-ruby') | |
" rhysd/vim-textobj-ruby | |
let g:textobj_ruby_more_mappings = 0 | |
let g:textobj_ruby_no_default_key_mappings = 1 | |
augroup MyAutoCmd | |
autocmd FileType ruby | |
\ omap <buffer> ar <Plug>(textobj-ruby-any-a)| | |
\ xmap <buffer> ar <Plug>(textobj-ruby-any-a)| | |
\ omap <buffer> ir <Plug>(textobj-ruby-any-i)| | |
\ xmap <buffer> ir <Plug>(textobj-ruby-any-i) | |
augroup END | |
endif | |
if s:IsPlugged('vim-textobj-erb') | |
" whatyouhide/vim-textobj-erb | |
let g:textobj_erb_no_default_key_mappings = 1 | |
augroup MyAutoCmd | |
autocmd FileType rhtml,eruby,eruby.yaml,eruby.html,html.eruby | |
\ omap <buffer> aE <Plug>(textobj-erb-a)| | |
\ xmap <buffer> aE <Plug>(textobj-erb-a)| | |
\ omap <buffer> iE <Plug>(textobj-erb-i)| | |
\ xmap <buffer> iE <Plug>(textobj-erb-i) | |
augroup END | |
endif | |
if s:IsPlugged('vim-textobj-elixir') | |
" andyl/vim-textobj-elixir | |
let g:textobj_elixir_no_default_key_mappings = 1 | |
" Remap from 'e' to 'r' | |
augroup MyAutoCmd | |
autocmd FileType elixir | |
\ omap <buffer> ar <Plug>(textobj-elixir-any-a)| | |
\ xmap <buffer> ar <Plug>(textobj-elixir-any-a)| | |
\ omap <buffer> ir <Plug>(textobj-elixir-any-i)| | |
\ xmap <buffer> ir <Plug>(textobj-elixir-any-i) | |
augroup END | |
endif | |
if s:IsPlugged('targets.vim') | |
" wellle/targets.vim | |
let g:targets_nl = 'nN' | |
" Prefer multiline targets around cursor over distant targets within cursor line: | |
" let g:targets_seekRanges = 'cc cr cb cB lc ac Ac lr lb ar ab lB Ar aB Ab AB rr ll rb al rB Al bb aa bB Aa BB AA' | |
" Never seek backwards: | |
" let g:targets_seekRanges = 'cc cr cb cB lc ac Ac lr rr lb ar ab lB Ar aB Ab AB rb rB bb bB BB' | |
" Only seek if next/last targets touch current line: | |
" let g:targets_seekRanges = 'cc cr cb cB lc ac Ac lr rr ll lb ar ab lB Ar aB Ab AB rb rB al Al' | |
" Only consider targets fully visible on screen: | |
" let g:targets_seekRanges = 'cc cr cb cB lc ac Ac lr lb ar ab rr rb bb ll al aa' | |
" Only consider targets around cursor: | |
" let g:targets_seekRanges = 'cc cr cb cB lc ac Ac lr lb ar ab lB Ar aB Ab AB' | |
" Only consider targets fully contained in current line: | |
" let g:targets_seekRanges = 'cc cr cb cB lc ac Ac lr rr ll' | |
augroup MyAutoCmd | |
autocmd User targets#mappings#user call targets#mappings#extend({ | |
\ 'a': {}, | |
\ }) | |
augroup END | |
endif | |
" luochen1990/rainbow | |
let g:rainbow_active = 0 | |
nnoremap <silent> <Leader>bh :RainbowToggle<CR> | |
if s:IsPlugged('indentLine') | |
" Yggdroot/indentLine | |
let g:indentLine_enabled = 0 | |
let g:indentLine_char = g:zero_vim_indent_char | |
let g:indentLine_first_char = g:zero_vim_indent_first_char | |
let g:indentLine_showFirstIndentLevel = 1 | |
let g:indentLine_noConcealCursor = 1 | |
let g:indentLine_color_term = 239 | |
" let g:indentLine_color_gui = '#A4E57E' | |
nnoremap <silent> <Leader>bi :IndentLinesToggle<CR> | |
vmap <Leader>bi <Esc><Leader>bigv | |
endif | |
if s:IsPlugged('vim-indent-guides') | |
" nathanaelkane/vim-indent-guides | |
let g:indent_guides_enable_on_vim_startup = 0 | |
let g:indent_guides_start_level = 1 | |
let g:indent_guides_guide_size = 1 | |
let g:indent_guides_color_change_percent = 3 | |
nnoremap <silent> <Leader>bi :IndentGuidesToggle<CR> | |
vmap <Leader>bi <Esc><Leader>bigv | |
endif | |
if s:IsPlugged('vim-startify') | |
" mhinz/vim-startify | |
let g:startify_skiplist = [ | |
\ '.git/index', | |
\ '.git/config', | |
\ 'fugitiveblame', | |
\ 'COMMIT_EDITMSG', | |
\ 'git-rebase-todo', | |
\ escape(fnamemodify($VIMRUNTIME, ':p'), '\') . 'doc', | |
\ ] | |
let g:startify_enable_special = 0 | |
let g:startify_change_to_dir = 0 | |
let g:startify_change_to_vcs_root = 0 | |
let g:startify_relative_path = 1 | |
let g:startify_update_oldfiles = 1 | |
let g:startify_show_sessions = 1 | |
let g:startify_custom_header = [] " Disable random quotes header | |
nnoremap <silent> <Leader>H :Startify<CR> | |
augroup MyAutoCmd | |
autocmd User Startified setlocal buftype= nofoldenable foldcolumn=0 | |
augroup END | |
endif | |
if s:IsPlugged('goyo.vim') | |
" junegunn/goyo.vim | |
let g:goyo_width = '70%' | |
let g:goyo_height = '85%' | |
let g:goyo_linenr = 0 | |
let s:goyo_current_mode = 0 | |
let s:goyo_modes = [ | |
\ [ g:goyo_width, g:goyo_height ], | |
\ [ '120', g:goyo_height ], | |
\ [ '100', g:goyo_height ], | |
\ [ '80', g:goyo_height ], | |
\ ] | |
function! CycleGoyoMode(direction) abort | |
if !exists('#goyo') | |
return | |
endif | |
let s:goyo_current_mode += a:direction | |
if s:goyo_current_mode >= len(s:goyo_modes) | |
let s:goyo_current_mode = 0 | |
elseif s:goyo_current_mode < 0 | |
let s:goyo_current_mode = len(s:goyo_modes) - 1 | |
endif | |
let l:goyo_mode = s:goyo_modes[s:goyo_current_mode] | |
let g:goyo_width = l:goyo_mode[0] | |
let g:goyo_height = l:goyo_mode[1] | |
let l:cmd = printf('Goyo %s', join(l:goyo_mode, 'x')) | |
echo l:cmd | |
execute l:cmd | |
endfunction | |
function! RefreshGoyoMode(...) abort | |
if !exists('#goyo') | |
return | |
endif | |
if get(a:, 1, 0) | |
silent! cclose | lclose | pclose | helpclose | |
endif | |
execute 'Goyo ' join([ g:goyo_width, g:goyo_height ], 'x') | |
redraw | |
endfunction | |
function! s:OnGoyoEnter() abort | |
augroup GoyoRefreshHooks | |
autocmd! | |
autocmd BufHidden * if &filetype ==# 'qf' && exists('*timer_start') | call timer_start(100, 'RefreshGoyoMode') | endif | |
autocmd VimResized * call RefreshGoyoMode() | |
augroup END | |
let s:goyo_maps = { | |
\ '<C-w>r': maparg('<C-w>r', 'n', 0, 1), | |
\ '<C-w><C-r>': maparg('<C-w><C-r>', 'n', 0, 1), | |
\ '<C-w>o': maparg('<C-w>o', 'n', 0, 1), | |
\ '<C-w><C-o>': maparg('<C-w><C-o>', 'n', 0, 1), | |
\ '<C-w>m': maparg('<C-w>m', 'n', 0, 1), | |
\ '<C-w>M': maparg('<C-w>M', 'n', 0, 1), | |
\ } | |
nnoremap <silent> <C-w>r :call RefreshGoyoMode()<CR> | |
vmap <C-w>r <Esc><C-w>rgv | |
nmap <C-w><C-r> <C-w>r | |
vmap <C-w><C-r> <C-w>r | |
nnoremap <silent> <C-w>o :call RefreshGoyoMode(1)<CR> | |
vmap <C-w>o <Esc><C-w>ogv | |
nmap <C-w><C-o> <C-w>o | |
vmap <C-w><C-o> <C-w>o | |
nnoremap <silent> <C-w>m :call CycleGoyoMode(1)<CR> | |
vmap <C-w>m <Esc><C-w>mgv | |
nnoremap <silent> <C-w>M :call CycleGoyoMode(-1)<CR> | |
vmap <C-w>M <Esc><C-w>Mgv | |
let s:goyo_settings = { | |
\ 'showmode': &showmode, | |
\ 'scrolloff': &scrolloff, | |
\ } | |
set showmode | |
set scrolloff=999 | |
highlight StatusLineNC cterm=bold | |
highlight StatusLine cterm=NONE | |
endfunction | |
function! s:OnGoyoLeave() abort | |
autocmd! GoyoRefreshHooks * | |
augroup! GoyoRefreshHooks | |
for [k, v] in items(s:goyo_maps) | |
if !empty(v) | |
call mapset('n', 0, v) | |
else | |
execute printf('silent! nunmap %s', k) | |
endif | |
if strlen(mapcheck(k, 'v')) | |
execute printf('silent! vunmap %s', k) | |
endif | |
endfor | |
for [k, v] in items(s:goyo_settings) | |
execute printf('let &%s = %s', k, string(v)) | |
endfor | |
for [k, v] in items(s:goyo_settings) | |
execute printf('let &%s = %s', k, string(v)) | |
endfor | |
endfunction | |
augroup MyAutoCmd | |
autocmd! User GoyoEnter nested call <SID>OnGoyoEnter() | |
autocmd! User GoyoLeave nested call <SID>OnGoyoLeave() | |
augroup END | |
nnoremap <silent> <Leader><Enter> :Goyo<CR> | |
vmap <Leader><Enter> <Esc><Leader><Enter>gv | |
" <C-w><C-m> | |
nnoremap <silent> <C-w><Enter> :Goyo<CR> | |
vmap <C-w><Enter> <Esc><C-w><Enter>gv | |
endif | |
if s:IsPlugged('limelight.vim') | |
" junegunn/limelight.vim | |
let g:limelight_conceal_ctermfg = 240 | |
let g:limelight_conceal_guifg = '#777777' | |
let g:limelight_default_coefficient = 0.75 | |
let g:limelight_priority = -1 | |
nnoremap <silent> <Leader>L :Limelight!!<CR> | |
xmap <Leader>L <Plug>(Limelight) | |
endif | |
if s:IsPlugged('gundo.vim') | |
" sjl/gundo.vim | |
let g:gundo_prefer_python3 = 1 | |
let g:gundo_right = 1 | |
let g:gundo_width = 30 | |
let g:gundo_preview_bottom = 1 | |
let g:gundo_preview_height = 18 | |
let g:gundo_auto_preview = 1 | |
nnoremap <silent> <Leader>U :GundoToggle<CR> | |
endif | |
if s:IsPlugged('undotree') | |
" mbbill/undotree | |
let g:undotree_WindowLayout = 'botright' | |
let g:undotree_SetFocusWhenToggle = 1 | |
nnoremap <silent> <Leader>U :UndotreeToggle<CR> | |
endif | |
if s:IsPlugged('vim-mundo') | |
" simnalamburt/vim-mundo | |
let g:mundo_prefer_python3 = 1 | |
let g:mundo_right = 1 | |
let g:mundo_width = 30 | |
let g:mundo_preview_bottom = 1 | |
let g:mundo_preview_height = 18 | |
let g:mundo_auto_preview = 1 | |
nnoremap <silent> <Leader>U :MundoToggle<CR> | |
endif | |
if s:IsPlugged('bufexplorer') | |
" jlanzarotta/bufexplorer | |
let g:bufExplorerDisableDefaultKeyMapping = 1 | |
let g:bufExplorerShowDirectories = 0 | |
let g:bufExplorerShowRelativePath = 1 | |
nnoremap <silent> gb :ToggleBufExplorer<CR> | |
endif | |
if s:IsPlugged('fern.vim') | |
" lambdalisue/fern.vim | |
let g:fern#drawer_width = 35 | |
if s:IsPlugged('fern-renderer-nerdfont.vim') || s:IsPlugged('phongnh-fern-renderer-nerdfont.vim') | |
let g:fern#renderer = 'nerdfont' | |
let g:fern#renderer#nerdfont#leading = ' ' | |
else | |
let g:fern#renderer#default#root_symbol = "\u2302\u00a0" | |
let g:fern#renderer#default#leading = ' ' | |
let g:fern#renderer#default#leaf_symbol = ' ' | |
let g:fern#renderer#default#collapsed_symbol = '+ ' | |
let g:fern#renderer#default#expanded_symbol = '~ ' | |
endif | |
command! -nargs=? -complete=customlist,fern#internal#command#fern#complete FernReveal Fern %:h <args> -reveal=%:t | |
command! -nargs=? -complete=customlist,fern#internal#command#fern#complete FernCWD execute printf('Fern %s <args>', escape(getcwd(), ' ')) | |
command! -nargs=? -complete=customlist,fern#internal#command#fern#complete FernDrawerToggle Fern <args> -drawer -toggle | |
command! FernDrawerReveal FernReveal -drawer | |
command! FernDrawerCWD FernCWD -drawer | |
function! s:InitFern() abort | |
nnoremap <buffer> <silent> <Plug>(fern-action-quit) :<C-u>quit<CR> | |
nmap <buffer> <Plug>(fern-action-smart-quit) | |
\ <Plug>(fern-action-zoom:reset)<Plug>(fern-action-quit) | |
nmap <buffer> <Plug>(fern-action-zoom:half) 5<Plug>(fern-action-zoom) | |
nmap <buffer> <Plug>(fern-action-zoom:full) 10<Plug>(fern-action-zoom) | |
nmap <buffer> <Plug>(fern-action-reload-and-redraw) | |
\ <Plug>(fern-action-reload:all)<Plug>(fern-action-redraw) | |
nmap <buffer> o <Plug>(fern-action-open-or-expand) | |
nmap <buffer> p <Plug>(fern-action-leave) | |
nmap <buffer> u <Plug>(fern-action-leave) | |
nmap <buffer> r <Plug>(fern-action-reload-and-redraw) | |
nmap <buffer> I <Plug>(fern-action-hidden:toggle) | |
nmap <buffer> cd <Plug>(fern-action-cd) | |
nmap <buffer> <nowait> H <Plug>(fern-action-zoom:half) | |
nmap <buffer> <nowait> F <Plug>(fern-action-zoom:full) | |
nmap <buffer> <nowait> ff <Plug>(fern-action-zoom:full) | |
nmap <buffer> <nowait> q <Plug>(fern-action-smart-quit) | |
endfunction | |
augroup MyAutoCmd | |
autocmd FileType fern call <SID>InitFern() | |
augroup END | |
nnoremap <silent> <Leader>e :FernDrawerToggle .<CR> | |
nnoremap <silent> <Leader>E :FernDrawerCWD<CR> | |
nnoremap <silent> <Leader>bf :FernDrawerReveal<CR> | |
endif | |
if s:IsPlugged('vaffle.vim') | |
" cocopon/vaffle.vim | |
" Hack for vaffle.vim with vim-projectionist | |
let g:projectionist_ignore_vaffle = 1 | |
if s:IsPlugged('nerdfont.vim') | |
function! VaffleRenderCustomIcon(item) abort | |
return nerdfont#find(a:item.basename, a:item.is_dir) | |
endfunction | |
let g:vaffle_render_custom_icon = 'VaffleRenderCustomIcon' | |
elseif s:IsPlugged('vim-devicons') | |
function! VaffleRenderCustomIcon(item) abort | |
return WebDevIconsGetFileTypeSymbol(a:item.basename, a:item.is_dir) | |
endfunction | |
let g:vaffle_render_custom_icon = 'VaffleRenderCustomIcon' | |
endif | |
command! VaffleCWD execute 'Vaffle' escape(getcwd(), ' ') | |
function! VaffleQuit() abort | |
try | |
:buffer # | |
catch | |
call vaffle#quit() | |
endtry | |
endfunction | |
function! s:InitVaffle() abort | |
setlocal cursorline | |
nmap <buffer> <silent> cd <Plug>(vaffle-chdir-here) | |
nmap <buffer> <silent> P <Plug>(vaffle-open-root) | |
nmap <buffer> <silent> K <Plug>(vaffle-mkdir) | |
nmap <buffer> <silent> N <Plug>(vaffle-new-file) | |
nmap <buffer> <silent> s <Plug>(vaffle-toggle-current) | |
nmap <buffer> <silent> Q <Plug>(vaffle-quit) | |
nmap <buffer> <silent> q :<C-u>call VaffleQuit()<CR> | |
endfunction | |
augroup MyAutoCmd | |
autocmd FileType vaffle call s:InitVaffle() | |
augroup END | |
nnoremap <silent> <Leader>e :Vaffle<CR> | |
nnoremap <silent> <Leader>E :VaffleCWD<CR> | |
nnoremap <silent> <Leader>bf :Vaffle %<CR> | |
endif | |
if s:IsPlugged('nerdtree') | |
" scrooloose/nerdtree | |
let g:NERDTreeWinSize = 35 | |
let g:NERDTreeMouseMode = 2 | |
let g:NERDTreeMapChangeRoot = '.' " Map . for changing root in NERDTree | |
let g:NERDTreeQuitOnOpen = 0 | |
let g:NERDTreeChDirMode = 0 | |
let g:NERDTreeShowBookmarks = 1 | |
if g:zero_vim_devicons | |
let g:NERDTreeDirArrowExpandable = "\u00a0" | |
let g:NERDTreeDirArrowCollapsible = "\u00a0" | |
else | |
let g:NERDTreeDirArrowExpandable = '+' | |
let g:NERDTreeDirArrowCollapsible = '~' | |
endif | |
nnoremap <silent> <Leader>e :NERDTreeToggle<CR> | |
noremap <silent> <Leader>E :NERDTreeCWD<CR> | |
nnoremap <silent> <Leader>bf :NERDTreeFind<CR> | |
endif | |
if s:IsPlugged('ctrlp.vim') | |
" ctrlpvim/ctrlp.vim | |
let g:ctrlp_find_tool = g:zero_vim_find_tool | |
let g:ctrlp_follow_symlinks = g:zero_vim_follow_links | |
let g:ctrlp_buftag_ctags_bin = g:zero_vim_ctags_bin | |
let g:ctrlp_cmd = 'CtrlPRoot' | |
if s:IsPlugged('fruzzy') | |
" raghur/fruzzy | |
let g:fruzzy#usenative = 1 | |
let g:fruzzy#sortonempty = 1 | |
let g:ctrlp_match_func = { 'match': 'fruzzy#ctrlp#matcher' } | |
elseif s:IsPlugged('cpsm') && filereadable(s:PlugDir('cpsm') . 'autoload/cpsm_py.so') | |
" nixprime/cpsm | |
let g:cpsm_match_empty_query = 0 | |
let g:cpsm_highlight_mode = 'basic' | |
let g:ctrlp_match_func = { 'match': 'cpsm#CtrlPMatch' } | |
" Disable webdevicons because highlight does not work | |
let g:webdevicons_enable_ctrlp = 0 | |
endif | |
nnoremap <silent> yof :ToggleCtrlPFollowSymlinks<CR> | |
nnoremap <silent> yok :ChangeCtrlPUserCommand<CR> | |
nmap <Leader><Leader> <Leader>f | |
nnoremap <silent> <Leader>f :CtrlP<CR> | |
nnoremap <silent> <Leader>a :CtrlPAll<CR> | |
nnoremap <silent> <Leader>p :CtrlPRoot<CR> | |
nnoremap <silent> <Leader>o :CtrlPBuffer<CR> | |
nnoremap <silent> <Leader>O :CtrlPMRUFiles<CR> | |
nnoremap <silent> <Leader>d :CtrlPCurFile<CR> | |
nnoremap <silent> <Leader>\ :CtrlPTag<CR> | |
nnoremap <silent> <Leader>q :cclose<CR>:CtrlPQuickfix<CR> | |
" Buffer-related mappings | |
nnoremap <silent> <Leader>bb :CtrlPBuffer<CR> | |
nmap <Leader>bd <Leader>d | |
nmap <Leader>bp <Leader>p | |
nnoremap <silent> <Leader>bl :CtrlPLine %<CR> | |
nnoremap <silent> <Leader>bt :CtrlPBufTag<CR> | |
" DavidEGx/ctrlp-smarttabs | |
nnoremap <silent> <Leader>W :CtrlPSmartTabs<CR> | |
" tacahiroy/ctrlp-funky | |
nnoremap <silent> <Leader>bo :CtrlPFunky<CR> | |
" mattn/ctrlp-register | |
nnoremap <silent> <Leader>Y :CtrlPRegister<CR> | |
" LeafCage/yankround.vim | |
let g:yankround_max_history = 100 | |
nnoremap <silent> <Leader>y :CtrlPYankRound<CR> | |
" fisadev/vim-ctrlp-cmdpalette | |
nnoremap <silent> <Leader>; :CtrlPCmdPalette<CR> | |
" ompugao/ctrlp-history | |
nnoremap <silent> <Leader>: :CtrlPCmdHistory<CR> | |
nnoremap <silent> <Leader>/ :CtrlPSearchHistory<CR> | |
" slimane/ctrlp-locationlist | |
nnoremap <silent> <Leader>l :lclose<CR>:CtrlPLocationlist<CR> | |
endif | |
if s:IsPlugged('LeaderF') | |
" Yggdroot/LeaderF | |
let g:Lf_SolarizedTheme = g:zero_vim_solarized | |
let g:Lf_Powerline = g:zero_vim_powerline | |
let g:Lf_Powerline_Style = get(g:, 'Lf_Powerline_Style', g:zero_vim_powerline_style) | |
let g:Lf_ShowDevIcons = g:zero_vim_devicons | |
let g:Lf_FindTool = g:zero_vim_find_tool | |
let g:Lf_FollowLinks = g:zero_vim_follow_links | |
let g:Lf_GrepIgnoreVCS = g:zero_vim_grep_ignore_vcs | |
let g:Lf_Ctags = g:zero_vim_ctags_bin | |
let g:Lf_ShortcutF = '<Leader>f' | |
let g:Lf_ShortcutB = '<Leader>bb' | |
nnoremap <silent> yof :ToggleLeaderfFollowLinks<CR> | |
nnoremap <silent> yok :ChangeLeaderfExternalCommand<CR> | |
nmap <Leader><Leader> <Leader>f | |
nnoremap <silent> <Leader>a :LeaderfFileAll<CR> | |
nnoremap <silent> <C-p> :LeaderfFileRoot<CR> | |
nnoremap <silent> <Leader>p :LeaderfFileRoot<CR> | |
nnoremap <silent> <Leader>o :LeaderfBuffer<CR> | |
nnoremap <silent> <Leader>O :LeaderfMru<CR> | |
nnoremap <silent> <Leader>d :LeaderfFile <C-r>=expand("%:h")<CR><CR> | |
nnoremap <silent> <Leader>\ :LeaderfTag<CR> | |
" Buffer-related mappings | |
nmap <Leader>bd <Leader>d | |
nmap <Leader>bp <Leader>p | |
nnoremap <silent> <Leader>bl :LeaderfLine<CR> | |
nnoremap <silent> <Leader>bt :LeaderfBufTag<CR> | |
nnoremap <silent> <Leader>W :LeaderfWindow<CR> | |
nnoremap <silent> <Leader>bo :LeaderfFunction<CR> | |
nnoremap <silent> <Leader>; :LeaderfCommand<CR> | |
nnoremap <silent> <Leader>: :LeaderfHistoryCmd<CR> | |
nnoremap <silent> <Leader>/ :LeaderfHistorySearch<CR> | |
nnoremap <silent> <Leader>q :cclose<CR>:LeaderfQuickFix<CR> | |
nnoremap <silent> <Leader>l :lclose<CR>:LeaderfLocList<CR> | |
nmap <Leader>se <Plug>LeaderfRgCwordLiteralBoundary<CR> | |
vmap <Leader>se <Plug>LeaderfRgVisualLiteralNoBoundary<CR> | |
nnoremap <silent> <Leader>sE :LeaderfRgRecall<CR> | |
endif | |
if s:IsPlugged('vim-clap') | |
" liuchengxu/vim-clap | |
let g:clap_solarized_theme = g:zero_vim_solarized | |
let g:clap_find_tool = g:zero_vim_find_tool | |
let g:clap_follow_links = g:zero_vim_follow_links | |
let g:clap_grep_ignore_vcs = g:zero_vim_grep_ignore_vcs | |
let g:clap_force_python = has('python3') | |
let g:clap_enable_icon = s:IsPlugged('vim-devicons') || s:IsPlugged('nerdfont.vim') | |
nnoremap <silent> yof :ToggleClapFollowLinks<CR> | |
nnoremap <silent> yok :ChangeClapFinder<CR> | |
nmap <Leader><Leader> <Leader>f | |
nnoremap <silent> <Leader>f :ClapFiles<CR> | |
nnoremap <silent> <Leader>a :ClapFilesAll<CR> | |
nnoremap <silent> <C-p> :ClapRoot<CR> | |
nnoremap <silent> <Leader>p :ClapRoot<CR> | |
nnoremap <silent> <Leader>o :Clap buflist<CR> | |
nnoremap <silent> <Leader>O :Clap history<CR> | |
nnoremap <silent> <Leader>d :ClapFiles <C-r>=expand("%:h")<CR><CR> | |
nnoremap <silent> <Leader>\ :Clap proj_tags<CR> | |
" Ivy-like file explorer | |
nnoremap <silent> <C-w>e :Clap filer<CR> | |
" Buffer-related mappings | |
nnoremap <silent> <Leader>bb :Clap buffers<CR> | |
nmap <Leader>bd <Leader>d | |
nmap <Leader>bp <Leader>p | |
nnoremap <silent> <Leader>bl :Clap blines<CR> | |
nnoremap <silent> <Leader>bt :Clap tags<CR> | |
nnoremap <silent> <Leader>W :Clap windows<CR> | |
nnoremap <silent> <Leader>bo :Clap tags<CR> | |
nnoremap <silent> <Leader>; :Clap command<CR> | |
nnoremap <silent> <Leader>: :Clap command_history<CR> | |
nnoremap <silent> <Leader>/ :Clap search_history<CR> | |
nnoremap <silent> <Leader>' :Clap marks<CR> | |
nnoremap <silent> <Leader>y :Clap yanks<CR> | |
nnoremap <silent> <Leader>Y :Clap registers<CR> | |
nnoremap <silent> <Leader>q :cclose<CR>:Clap quickfix<CR> | |
nnoremap <silent> <Leader>l :lclose<CR>:Clap loclist<CR> | |
nnoremap <silent> <Leader>se :Clap grep ++query=<cword><CR> | |
xnoremap <silent> <Leader>se :Clap grep ++query=@visual<CR> | |
nnoremap <silent> <Leader>si :Clap grep2 ++query=<cword><CR> | |
xnoremap <silent> <Leader>si :Clap grep2 ++query=@visual<CR> | |
endif | |
if s:IsPlugged('fzf') | |
" junegunn/fzf and junegunn/fzf.vim | |
let g:fzf_find_tool = g:zero_vim_find_tool | |
let g:fzf_follow_links = g:zero_vim_follow_links | |
let g:fzf_grep_ignore_vcs = g:zero_vim_grep_ignore_vcs | |
let g:fzf_ctags = g:zero_vim_ctags_bin | |
let g:fzf_ctags_ignore = g:zero_vim_ctags_ignore | |
let g:fzf_universal_ctags = g:zero_vim_universal_ctags | |
nnoremap <silent> yof :ToggleFzfFollowLinks<CR> | |
nnoremap <silent> yok :ChangeFzfFilesCommands<CR> | |
nmap <Leader><Leader> <Leader>f | |
nnoremap <silent> <Leader>f :Files<CR> | |
nnoremap <silent> <Leader>a :AFiles<CR> | |
nnoremap <silent> <C-p> :PFiles<CR> | |
nnoremap <silent> <Leader>p :PFiles<CR> | |
nnoremap <silent> <Leader>o :Buffers<CR> | |
nnoremap <silent> <Leader>O :History<CR> | |
nnoremap <silent> <Leader>d :Files <C-r>=expand("%:h")<CR><CR> | |
nnoremap <silent> <Leader>\ :Tags!<CR> | |
" Buffer-related mappings | |
nnoremap <silent> <Leader>bb :Buffers<CR> | |
nmap <Leader>bd <Leader>d | |
nmap <Leader>bp <Leader>p | |
nnoremap <silent> <Leader>bl :BLines<CR> | |
nnoremap <silent> <Leader>bt :BTags<CR> | |
nnoremap <silent> <Leader>bo :BOutline<CR> | |
nnoremap <silent> <Leader>W :Windows<CR> | |
nnoremap <silent> <Leader>; :Commands<CR> | |
nnoremap <silent> <Leader>: :History:<CR> | |
nnoremap <silent> <Leader>/ :History/<CR> | |
nnoremap <silent> <Leader>q :cclose<CR>:Quickfix<CR> | |
nnoremap <silent> <Leader>l :lclose<CR>:LocationList<CR> | |
nnoremap <silent> <Leader>se :Rg! <C-r><C-w><CR> | |
xnoremap <silent> <Leader>se <Esc>:FRg! <C-r>=vim_helpers#Vword()<CR><CR> | |
endif | |
if s:IsPlugged('vim-autoformat') | |
" Chiel92/vim-autoformat | |
let g:autoformat_autoindent = 0 | |
let g:autoformat_retab = 0 | |
let g:autoformat_remove_trailing_spaces = 0 | |
let g:autoformat_verbosemode = 0 | |
" Terraform | |
let g:formatdef_terraform_fmt = '"terraform fmt -no-color -"' | |
let g:formatters_terraform = ['terraform_fmt'] | |
nnoremap <silent> <Leader>A :Autoformat <Bar> update<CR> | |
xnoremap <silent> <Leader>A :Autoformat <Bar> update<CR> | |
nmap <silent> <Leader>= <Leader>A | |
xmap <silent> <Leader>= <Leader>A | |
nmap <silent> <Leader>b= <Leader>A | |
xmap <silent> <Leader>b= <Leader>A | |
nmap <silent> <Leader>bu <Leader>A | |
xmap <silent> <Leader>bu <Leader>A | |
endif | |
if s:IsPlugged('vim-prettier') | |
" prettier/vim-prettier | |
let g:prettier#autoformat = 0 | |
nmap <Leader>P <Plug>(Prettier) | |
augroup MyAutoCmd | |
autocmd FileType javascript,typescript,css,less,scss,json,graphql,markdown,vue,yaml,html | |
\ nmap <buffer> <Leader>bu <Plug>(PrettierAsync) | |
augroup END | |
endif | |
if s:IsPlugged('ale') | |
" dense-analysis/ale | |
let g:ale_disable_lsp = 0 | |
let g:ale_lint_on_text_changed = 0 | |
let g:ale_lint_on_insert_leave = 0 | |
let g:ale_lint_on_enter = g:zero_vim_autolint | |
let g:ale_lint_on_save = g:zero_vim_autolint | |
let g:ale_lint_on_filetype_changed = g:zero_vim_autolint | |
let g:ale_set_loclist = 1 | |
let g:ale_set_quickfix = 0 | |
let g:ale_list_window_size = 5 | |
let g:ale_keep_list_window_open = 0 | |
let g:ale_open_list = 0 | |
let g:ale_fix_on_save = g:zero_vim_autofix | |
let g:ale_sign_error = g:zero_vim_signs.error | |
let g:ale_sign_warning = g:zero_vim_signs.warning | |
let g:ale_sign_style_error = g:zero_vim_signs.style_error | |
let g:ale_sign_style_warning = g:zero_vim_signs.style_warning | |
let g:ale_sign_info = g:zero_vim_signs.information | |
let g:ale_virtualtext_prefix = g:zero_vim_signs.virtual_text . ' ' | |
let g:ale_echo_cursor = 1 | |
let g:ale_virtualtext_cursor = 1 | |
let g:ale_linter_aliases = { | |
\ 'jsx': 'javascript', | |
\ 'javascript.jsx': 'javascript', | |
\ } | |
let g:ale_linters = { | |
\ 'javascript': ['eslint'], | |
\ 'typescript': ['eslint'], | |
\ 'yaml': ['yamllint'], | |
\ 'ruby': ['standardrb', 'rubocop', 'solargraph', 'sorbet'], | |
\ 'python': ['flake8', 'pylint'], | |
\ 'go': ['golint', 'govet', 'errcheck'], | |
\ 'elixir': ['credo', 'elixir-ls'], | |
\ } | |
let g:ale_fixers = { | |
\ '*': ['remove_trailing_lines', 'trim_whitespace'], | |
\ 'sh': ['shellcheck', 'shfmt'], | |
\ 'bash': ['shellcheck', 'shfmt'], | |
\ 'html': ['prettier', 'tidy'], | |
\ 'css': ['prettier'], | |
\ 'scss': ['prettier'], | |
\ 'markdown': ['prettier'], | |
\ 'json': ['prettier', 'jq'], | |
\ 'javascript': ['prettier', 'eslint'], | |
\ 'typescript': ['prettier', 'eslint'], | |
\ 'graphql': ['prettier'], | |
\ 'yaml': ['prettier'], | |
\ 'ruby': ['standardrb', 'rubocop'], | |
\ 'python': ['black', 'autopep8', 'yapf'], | |
\ 'go': ['gofmt'], | |
\ 'rust': ['rustfmt'], | |
\ 'elixir': ['mix_format', 'elixir-ls'], | |
\ } | |
" Don't auto-format files inside `node_modules`, minified files and jquery | |
let g:ale_pattern_options_enabled = 1 | |
let g:ale_pattern_options = { | |
\ '\.min\.(js\|css)$': { | |
\ 'ale_linters': [], | |
\ 'ale_fixers': [] | |
\ }, | |
\ 'jquery.*': { | |
\ 'ale_linters': [], | |
\ 'ale_fixers': [] | |
\ }, | |
\ 'node_modules/.*': { | |
\ 'ale_linters': [], | |
\ 'ale_fixers': [] | |
\ }, | |
\ 'package.json': { | |
\ 'ale_fixers': g:ale_fixers['*'] | |
\ }, | |
\} | |
nnoremap <silent> <Leader>bv :ALELint<CR> | |
nnoremap <silent> <Leader>b= :ALEFix<CR> | |
endif | |
if s:IsPlugged('neomake') | |
" neomake/neomake | |
let g:neomake_open_list = 2 | |
let g:neomake_list_height = 5 | |
let g:neomake_echo_current_error = 1 | |
let g:neomake_error_sign = { 'text': g:zero_vim_signs.error } | |
let g:neomake_warning_sign = { 'text': g:zero_vim_signs.warning } | |
let g:neomake_info_sign = { 'text': g:zero_vim_signs.info } | |
let g:neomake_message_sign = { 'text': g:zero_vim_signs.message } | |
let g:neomake_virtualtext_prefix = g:zero_vim_signs.virtual_text . ' ' | |
if g:zero_vim_autolint | |
call neomake#configure#automake('w') | |
endif | |
nnoremap <silent> <Leader>bv :Neomake<CR>:echo neomake#statusline#LoclistStatus()<CR> | |
endif | |
if s:IsPlugged('syntastic') | |
" vim-syntastic/syntastic | |
let g:syntastic_mode_map = { 'mode': 'passive', } | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = g:zero_vim_autolint | |
let g:syntastic_auto_jump = 1 | |
let g:syntastic_loc_list_height = 5 | |
let g:syntastic_check_on_open = g:zero_vim_autolint | |
let g:syntastic_check_on_wq = g:zero_vim_autolint | |
let g:syntastic_aggregate_errors = 1 | |
let g:syntastic_echo_current_error = 1 | |
let g:syntastic_error_symbol = g:zero_vim_signs.error | |
let g:syntastic_warning_symbol = g:zero_vim_signs.warning | |
let g:syntastic_style_error_symbol = g:zero_vim_signs.style_error | |
let g:syntastic_style_warning_symbol = g:zero_vim_signs.style_warning | |
let g:syntastic_jsx_checkers = ['eslint'] | |
let g:syntastic_jsx_eslint_checkers = 'npm run eslint --' | |
let g:syntastic_javascript_checkers = ['eslint'] | |
let g:syntastic_javascript_eslint_checkers = 'npm run eslint --' | |
let g:syntastic_typescript_checkers = ['eslint'] | |
let g:syntastic_typescript_eslint_checkers = 'npm run eslint --' | |
let g:syntastic_yaml_checkers = ['yamllint'] | |
let g:syntastic_ruby_checkers = ['standardrb', 'rubocop'] | |
let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck'] | |
nnoremap <silent> <Leader>bv :SyntasticCheck<CR>:echo SyntasticStatuslineFlag()<CR> | |
endif | |
if s:IsPlugged('ultisnips') | |
" SirVer/ultisnips | |
let g:UltiSnipsExpandTrigger = '<Plug>(ultisnips_expand)' | |
let g:UltiSnipsJumpForwardTrigger = '<C-j>' | |
let g:UltiSnipsJumpBackwardTrigger = '<C-z>' | |
let g:UltiSnipsListSnippets = '' | |
" Jump Forward result | |
let g:ulti_jump_forwards_res = 0 " (0: fail, 1: success) | |
function! s:IsExpandableUltiSnips() abort | |
return !( | |
\ col('.') <= 1 | |
\ || !empty(matchstr(getline('.'), '\%' . (col('.') - 1) . 'c\s')) | |
\ || empty(UltiSnips#SnippetsInCurrentScope()) | |
\ ) | |
endfunction | |
function! s:UltiSnipsExpand() abort | |
if s:IsExpandableUltiSnips() | |
return "\<Plug>(ultisnips_expand_or_jump)" | |
endif | |
if pumvisible() | |
return "\<C-e>" | |
endif | |
return "\<C-k>" | |
endfunction | |
inoremap <silent> <Plug>(ultisnips_expand_or_jump) <C-r>=UltiSnips#ExpandSnippetOrJump()<CR> | |
snoremap <silent> <Plug>(ultisnips_expand_or_jump) <Esc>:call UltiSnips#ExpandSnippetOrJump()<CR> | |
imap <silent> <expr> <C-k> <SID>UltiSnipsExpand() | |
smap <C-k> <Plug>(ultisnips_expand_or_jump) | |
xmap <C-k> <Plug>(ultisnips_expand) | |
endif | |
if s:IsPlugged('neosnippet.vim') | |
" Shougo/neosnippet.vim | |
let g:neosnippet#enable_snipmate_compatibility = 1 | |
let g:neosnippet#enable_complete_done = 1 | |
let g:neosnippet#expand_word_boundary = 1 | |
let g:neosnippet#scope_aliases = { | |
\ 'ruby': 'ruby,rails', | |
\ 'objc': 'objc,c', | |
\ 'objcpp': 'objc,c', | |
\ } | |
function! s:NeoSnippetExpand() abort | |
if neosnippet#expandable_or_jumpable() | |
return "\<Plug>(neosnippet_expand_or_jump)" | |
endif | |
if pumvisible() | |
return "\<C-e>" | |
endif | |
return "\<C-k>" | |
endfunction | |
imap <silent> <expr> <C-k> <SID>NeoSnippetExpand() | |
smap <C-k> <Plug>(neosnippet_expand_or_jump) | |
xmap <C-k> <Plug>(neosnippet_expand_target) | |
imap <C-j> <Plug>(neosnippet_jump) | |
smap <C-j> <Plug>(neosnippet_jump) | |
smap <Tab> <Plug>(neosnippet_jump) | |
endif | |
" LSP Servers | |
let g:language_servers = extend({ | |
\ 'bash-language-server': { | |
\ 'cmd': ['bash-language-server', 'start'], | |
\ 'filetypes': ['sh'], | |
\ }, | |
\ 'ccls': { | |
\ 'cmd': ['ccls'], | |
\ 'filetypes': ['c', 'cpp'], | |
\ }, | |
\ 'clangd': { | |
\ 'cmd': ['clangd', '--background-index'], | |
\ 'filetypes': ['c', 'cpp'], | |
\ }, | |
\ 'crystalline': { | |
\ 'cmd': ['crystalline'], | |
\ 'filetypes': ['crystal'], | |
\ }, | |
\ 'docker-langserver': { | |
\ 'cmd': ['docker-langserver', '--stdio'], | |
\ 'filetypes': ['dockerfile'], | |
\ }, | |
\ 'graphql-lsp': { | |
\ 'cmd': ['graphql-lsp', 'server', '--method', 'stream'], | |
\ 'filetypes': ['graphql'], | |
\ }, | |
\ 'elixir-ls': { | |
\ 'cmd': ['elixir-ls'], | |
\ 'filetypes': ['elixir'], | |
\ 'root_markers': ['mix.exs'], | |
\ }, | |
\ 'erlang-ls': { | |
\ 'cmd': ['erlang-ls'], | |
\ 'filetypes': ['erlang'], | |
\ 'root_markers': ['rebar.config'], | |
\ }, | |
\ 'flow': { | |
\ 'cmd': ['flow', 'lsp', '--from', 'vim'], | |
\ 'filetypes': ['javascript', 'javascripteact', 'javascript.jsx'], | |
\ }, | |
\ 'gopls': { | |
\ 'cmd': ['gopls', '-mode', 'stdio'], | |
\ 'filetypes': ['go'], | |
\ }, | |
\ 'javascript-typescript-langserver': { | |
\ 'cmd': ['javascript-typescript-langserver'], | |
\ 'filetypes': ['javascript', 'javascriptreact', 'javascript.jsx'], | |
\ }, | |
\ 'pyls': { | |
\ 'cmd': ['pyls'], | |
\ 'filetypes': ['python'], | |
\ }, | |
\ 'pyright': { | |
\ 'cmd': ['pyright-langserver', '--stdio'], | |
\ 'filetypes': ['python'], | |
\ }, | |
\ 'rls': { | |
\ 'cmd': ['rls'], | |
\ 'filetypes': ['rust'], | |
\ }, | |
\ 'rls-nightly': { | |
\ 'cmd': ['~/.cargo/bin/rustup', 'run', 'nightly', 'rls'], | |
\ 'filetypes': ['rust'], | |
\ }, | |
\ 'rust-analyzer': { | |
\ 'cmd': ['rust-analyzer'], | |
\ 'filetypes': ['rust'], | |
\ }, | |
\ 'scry': { | |
\ 'cmd': ['scry'], | |
\ 'filetypes': ['crystal'], | |
\ }, | |
\ 'solargraph': { | |
\ 'cmd': ['solargraph', 'stdio'], | |
\ 'filetypes': ['ruby'], | |
\ 'initialization_options': { 'diagnostics': 'true' }, | |
\ 'root_markers': ['Gemfile'], | |
\ }, | |
\ 'srb': { | |
\ 'cmd': ['srb', 'tc', '--typed', 'true', '--enable-all-experimental-lsp-features', '--lsp', '--disable-watchman', '--dir', '.'], | |
\ 'filetypes': ['ruby'], | |
\ }, | |
\ 'terraform-ls': { | |
\ 'cmd': ['terraform-ls', 'serve'], | |
\ 'filetypes': ['terraform'], | |
\ }, | |
\ 'terraform-lsp': { | |
\ 'cmd': ['terraform-lsp'], | |
\ 'filetypes': ['terraform'], | |
\ }, | |
\ 'typescript-language-server': { | |
\ 'cmd': ['typescript-language-server', '--stdio'], | |
\ 'filetypes': ['javascript', 'javascriptreact', 'javascript.jsx', 'typescript', 'typescriptreact', 'typescript.tsx'], | |
\ }, | |
\ 'vim-language-server': { | |
\ 'cmd': ['vim-language-server', '--stdio'], | |
\ 'filetypes': ['vim'], | |
\ }, | |
\ }, get(g:, 'language_servers', {})) | |
function! s:CheckLanguageServers(server_names) abort | |
let l:valid_language_servers = [] | |
for l:name in a:server_names | |
if !has_key(g:language_servers, l:name) | |
continue | |
endif | |
let cmd = g:language_servers[l:name]['cmd'] | |
if executable(cmd[0]) | |
if !empty(exepath(cmd[0])) | |
let cmd[0] = exepath(cmd[0]) | |
endif | |
call add(l:valid_language_servers, l:name) | |
endif | |
endfor | |
return l:valid_language_servers | |
endfunction | |
" Enabled Language Servers | |
function! s:GetEnabledLanguageServers() abort | |
if exists('s:enabled_language_servers') | |
return s:enabled_language_servers | |
endif | |
let l:server_names = get(g:, 'zero_vim_enabled_language_servers', [ | |
\ 'clangd', | |
\ 'ccls', | |
\ 'solargraph', | |
\ 'crystalline', | |
\ 'scry', | |
\ 'pyls', | |
\ 'pyright', | |
\ 'gopls', | |
\ 'rust-analyzer', | |
\ 'rls', | |
\ 'elixir-ls', | |
\ 'erlang-ls', | |
\ 'typescript-language-server', | |
\ 'docker-langserver', | |
\ 'terraform-ls', | |
\ 'terraform-lsp', | |
\ 'bash-language-server', | |
\ 'vim-language-server', | |
\ ]) | |
let s:enabled_language_servers = s:CheckLanguageServers(l:server_names) | |
return s:enabled_language_servers | |
endfunction | |
if s:IsPlugged('nvim-lspconfig') | |
" neovim/nvim-lspconfig | |
function! s:GetNvimLanguageServers() abort | |
let g:nvim_lsp_servers = {} | |
let g:nvim_lsp_filetypes = {} | |
let l:nvim_language_server_mappings = { | |
\ 'bash-language-server': 'bashls', | |
\ 'ccls': 'cssls', | |
\ 'clangd': 'clangd', | |
\ 'cssls': 'ccs-languageserver', | |
\ 'docker-langserver': 'dockerls', | |
\ 'elixir-ls': 'elixirls', | |
\ 'flow': 'flow', | |
\ 'gopls': 'gopls', | |
\ 'html-languageserver': 'html', | |
\ 'json-languageserver': 'jsonls', | |
\ 'metals': 'metals', | |
\ 'pyls': 'pyls', | |
\ 'pyls-ms': 'pyls_ms', | |
\ 'rls': 'rls', | |
\ 'rust-analyzer': 'rust_analyzer', | |
\ 'scry': 'scry', | |
\ 'solargraph': 'solargraph', | |
\ 'lua-language-server': 'sumneko_lua', | |
\ 'terraform-ls': 'terraformls', | |
\ 'typescript-language-server': 'tsserver', | |
\ 'vim-language-server': 'vimls', | |
\ 'yaml-language-server': 'yamlls', | |
\ } | |
for l:name in s:GetEnabledLanguageServers() | |
let l:nvim_server_name = get(l:nvim_language_server_mappings, l:name, '') | |
if empty(l:nvim_server_name) | |
next | |
endif | |
let l:server = g:language_servers[l:name] | |
for ft in l:server['filetypes'] | |
if !has_key(g:nvim_lsp_filetypes, ft) | |
let g:nvim_lsp_servers[l:nvim_server_name] = l:server | |
let g:nvim_lsp_filetypes[ft] = 1 | |
endif | |
endfor | |
endfor | |
endfunction | |
call s:GetNvimLanguageServers() | |
" Signs | |
call sign_define('LspDiagnosticsSignError', { 'text': g:zero_vim_lsp_signs.error, 'texthl': 'LspDiagnosticsSignError' }) | |
call sign_define('LspDiagnosticsSignWarning', { 'text': g:zero_vim_lsp_signs.warning, 'texthl': 'LspDiagnosticsSignWarning' }) | |
call sign_define('LspDiagnosticsSignInformation', { 'text': g:zero_vim_lsp_signs.information, 'texthl': 'LspDiagnosticsSignInformation' }) | |
call sign_define('LspDiagnosticsSignHint', { 'text': g:zero_vim_lsp_signs.hint, 'texthl': 'LspDiagnosticsSignHint' }) | |
function! s:InitNvimLSP() abort | |
if empty(g:nvim_lsp_servers) | |
return | |
endif | |
try | |
lua << EOF | |
local lspconfig = require('lspconfig') | |
local configs = require('lspconfig/configs') | |
local completion | |
if pcall(require, 'completion') then | |
completion = require('completion') | |
end | |
local ncm2 | |
if pcall(require, 'ncm2') then | |
ncm2 = require('ncm2') | |
end | |
local on_attach = function(client, bufnr) | |
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc') | |
if completion then | |
completion.on_attach(client) | |
end | |
-- Mappings | |
local opts ={ noremap = true, silent = true } | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'H', '<cmd>lua vim.lsp.buf.hover()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gA', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'x', 'gA', '<cmd>lua vim.lsp.buf.range_code_action()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'M', '<cmd>lua vim.lsp.buf.rename()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gF', '<cmd>lua vim.lsp.buf.formating()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'x', 'gF', '<cmd>lua vim.lsp.buf.range_formating()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g[', '<cmd>lua vim.lsp.buf.definition()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gy', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gI', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gm', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'go', '<cmd>lua vim.lsp.buf.document_symbol()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gO', '<cmd>lua vim.lsp.buf.workspace_symbol()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g{', '<cmd>lua vim.lsp.buf.incoming_calls()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'g}', '<cmd>lua vim.lsp.buf.outgoing_calls()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gL', '<cmd>lua vim.lsp.diagnostic.show_line_diagnostics()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'L', '<cmd>lua vim.lsp.diagnostic.set_loclist({ severity_limit = "Warning" })<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[g', '<cmd>lua vim.lsp.diagnostic.goto_prev({ severity_limit = "Warning" })<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']g', '<cmd>lua vim.lsp.diagnostic.goto_next({ severity_limit = "Warning" })<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', '[k', '<cmd>lua vim.lsp.diagnostic.goto_prev()<CR>', opts) | |
vim.api.nvim_buf_set_keymap(bufnr, 'n', ']k', '<cmd>lua vim.lsp.diagnostic.goto_next()<CR>', opts) | |
end | |
for name, server_config in pairs(vim.g.nvim_lsp_servers) do | |
if not lspconfig[name] then | |
configs[server_name] = { | |
default_config = { | |
cmd = server_config.cmd, | |
filetypes = server_config.filetypes, | |
root_dir = function(fname) | |
return nvim_lsp.util.find_git_ancestor(fname) or vim.loop.os_homedir() | |
end, | |
settings = {}, | |
}, | |
} | |
end | |
local setup_config = { | |
cmd = server_config.cmd, | |
filetypes = server_config.filetypes, | |
on_attach = on_attach | |
} | |
if ncm2 then | |
setup_config.on_init = ncm2.register_lsp_source | |
end | |
lspconfig[name].setup(setup_config) | |
end | |
if vim.g.zero_vim_lsp_diagnostics == 1 then | |
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with( | |
vim.lsp.diagnostic.on_publish_diagnostics, { | |
underline = false, | |
virtual_text = { | |
spacing = 4, | |
prefix = vim.g.zero_vim_lsp_signs.virtual_text, | |
severity_limit = "Warning", | |
}, | |
signs = true, | |
update_in_insert = false, | |
} | |
) | |
else | |
vim.lsp.handlers["textDocument/publishDiagnostics"] = vim.lsp.with(function() end, {}) | |
end | |
EOF | |
catch /^Vim(lua):E5108/ | |
call s:Warn('nvim-lsp: ' . v:exception) | |
endtry | |
endfunction | |
call s:InitNvimLSP() | |
function! s:LspReload() abort | |
lua vim.lsp.stop_client(vim.lsp.get_active_clients()) | |
edit | |
endfunction | |
command! LspReload call <SID>LspReload() | |
command! LspInspect lua print(vim.inspect(vim.lsp.buf_get_clients(0))) | |
command! LspInspectAll lua print(vim.inspect(vim.lsp.buf_get_clients())) | |
command! LspServerReady lua print("Server Ready?", vim.lsp.buf.server_ready()) | |
endif | |
if s:IsPlugged('vim-lsp') | |
" prabirshrestha/vim-lsp | |
let g:lsp_async_completion = 1 | |
let g:lsp_fold_enabled = 0 | |
let g:lsp_signs_error = { 'text': g:zero_vim_lsp_signs.error } | |
let g:lsp_signs_warning = { 'text': g:zero_vim_lsp_signs.warning } | |
let g:lsp_signs_information = { 'text': g:zero_vim_lsp_signs.information } | |
let g:lsp_signs_hint = { 'text': g:zero_vim_lsp_signs.hint } | |
let g:lsp_virtual_text_prefix = g:zero_vim_lsp_signs.virtual_text | |
let g:lsp_diagnostics_enabled = g:zero_vim_lsp_diagnostics | |
let g:lsp_diagnostics_echo_cursor = 0 | |
let g:lsp_highlight_references_enabled = g:zero_vim_lsp_highlight_references | |
function! s:OnLspBufferEnabled() abort | |
setlocal omnifunc=lsp#complete | |
" setlocal foldmethod=expr | |
" setlocal foldexpr=lsp#ui#vim#folding#foldexpr() | |
" setlocal foldtext=lsp#ui#vim#folding#foldtext() | |
if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif | |
" Use `[g` and `]g` to navigate diagnostics | |
nmap <buffer> <silent> [g <Plug>(lsp-previous-diagnostic) | |
nmap <buffer> <silent> ]g <Plug>(lsp-next-diagnostic) | |
nmap <buffer> <silent> [k <Plug>(lsp-previous-error) | |
nmap <buffer> <silent> ]k <Plug>(lsp-next-error) | |
" Use `[r` and `]r` to navigate references | |
nmap <buffer> <silent> [r <Plug>(lsp-previous-reference) | |
nmap <buffer> <silent> ]r <Plug>(lsp-next-reference) | |
nmap <buffer> <silent> K <Plug>(lsp-hover) | |
nmap <buffer> <silent> g<CR> <Plug>(lsp-code-action) | |
nmap <buffer> <silent> gr <Plug>(lsp-rename) | |
nmap <buffer> <silent> g= <Plug>(lsp-document-format) | |
vmap <buffer> <silent> g= <Plug>(lsp-document-format) | |
nmap <buffer> <silent> gF <Plug>(lsp-document-range-format) | |
xmap <buffer> <silent> gF <Plug>(lsp-document-range-format) | |
nmap <buffer> <silent> gd <Plug>(lsp-declaration) | |
nmap <buffer> <silent> g] <Plug>(lsp-definition) | |
nmap <buffer> <silent> g[ <Plug>(lsp-type-definition) | |
nmap <buffer> <silent> g{ <Plug>(lsp-type-hierarchy) | |
nmap <buffer> <silent> gI <Plug>(lsp-implementation) | |
nmap <buffer> <silent> gL <Plug>(lsp-document-diagnostics) | |
nmap <buffer> <silent> go <Plug>(lsp-document-symbol) | |
nmap <buffer> <silent> gO <Plug>(lsp-workspace-symbol) | |
nmap <buffer> <silent> gR <Plug>(lsp-references) | |
nmap <buffer> <silent> gm <Plug>(lsp-signature-help) | |
endfunction | |
augroup MyAutoCmd | |
autocmd User lsp_buffer_enabled call <SID>OnLspBufferEnabled() | |
augroup END | |
if s:IsPlugged('vim-lsp-settings') | |
" mattn/vim-lsp-settings | |
let g:lsp_settings = {} | |
function! s:SetupLanguageServers() abort | |
for l:name in keys(g:language_servers) | |
let g:lsp_settings[l:name] = { 'disabled': v:true } | |
endfor | |
for l:name in s:GetEnabledLanguageServers() | |
let l:server = g:language_servers[l:name] | |
let l:server_settings = { | |
\ 'disabled': v:false, | |
\ 'cmd': l:server['cmd'], | |
\ 'allowlist': l:server['filetypes'], | |
\ } | |
if has_key(l:server, 'root_markers') | |
let l:server_settings['root_uri_patterns'] = l:server['root_markers'] | |
endif | |
if has_key(l:server, 'initialization_options') | |
let l:server_settings['initialization_options'] = l:server['initialization_options'] | |
endif | |
let g:lsp_settings[l:name] = l:server_settings | |
endfor | |
endfunction | |
call s:SetupLanguageServers() | |
endif | |
endif | |
if s:IsPlugged('vim-lsc') | |
" natebosch/vim-lsc | |
let g:lsc_autocomplete_length = 2 | |
let g:lsc_complete_timeout = 0.5 " Wait up to a half second | |
let g:lsc_enable_diagnostics = g:zero_vim_lsp_diagnostics ? v:true : v:false | |
let g:lsc_reference_highlights = g:zero_vim_lsp_highlight_references ? v:true : v:false | |
let g:lsc_trace_level = 'off' | |
let g:lsc_server_commands = {} | |
" Default server options | |
let s:lsc_server_default_opts = { | |
\ 'log_level': -1, | |
\ 'suppress_stderr': v:true, | |
\ 'workspace_config': {}, | |
\ } | |
function! s:SetupLanguageServers() abort | |
for l:name in s:GetEnabledLanguageServers() | |
let l:server = g:language_servers[l:name] | |
let l:default = get(s:, 'lsc_server_default_opts', {}) | |
let l:message_hooks = {} | |
if has_key(l:server, 'initialization_options') | |
let l:message_hooks['initialize'] = { | |
\ 'initializationOptions': l:server['initialization_options'], | |
\ } | |
endif | |
let l:server_settings = extend(copy(l:default), { | |
\ 'name': l:name, | |
\ 'command': l:server['cmd'], | |
\ 'message_hooks': l:message_hooks, | |
\ }) | |
for ft in l:server['filetypes'] | |
if !has_key(g:lsc_server_commands, ft) | |
let g:lsc_server_commands[ft] = l:server_settings | |
endif | |
endfor | |
endfor | |
endfunction | |
call s:SetupLanguageServers() | |
let g:lsc_auto_map = { | |
\ 'GoToDefinition': 'g]', | |
\ 'GoToDefinitionSplit': '', | |
\ 'FindReferences': 'gr', | |
\ 'NextReference': '[r', | |
\ 'PreviousReference': ']r', | |
\ 'FindImplementations': 'gI', | |
\ 'FindCodeActions': 'g<CR>', | |
\ 'Rename': 'gr', | |
\ 'ShowHover': 'K', | |
\ 'DocumentSymbol': 'go', | |
\ 'WorkspaceSymbol': 'gO', | |
\ 'SignatureHelp': 'gm', | |
\ 'Completion': 'omnifunc', | |
\ } | |
function! s:PrintLSCServerStatus(...) abort | |
let ft = get(a:, 1, &filetype) | |
let servers = lsc#server#forFileType(ft) | |
if empty(servers) | echo 'No Server!' | return | endif | |
let server = servers[0] | |
echo printf('%s: %s!', get(server, 'config', { 'name': 'Server' })['name'], server['status']) | |
endfunction | |
command! LSClientServerStatus call <SID>PrintLSCServerStatus() | |
function! s:SetupLSC() abort | |
nnoremap <buffer> <silent> gL :LSClientAllDiagnostics<CR> | |
nnoremap <buffer> <silent> gK :LSClientWindowDiagnostics<CR> | |
endfunction | |
augroup MyAutoCmd | |
execute printf('autocmd FileType %s call <SID>SetupLSC()', join(keys(g:lsc_server_commands), ',')) | |
augroup END | |
endif | |
if s:IsPlugged('LanguageClient-neovim') || s:IsPlugged('LanguageClient-neovim-dev') | |
" autozimu/LanguageClient-neovim | |
let g:LanguageClient_serverCommands = {} | |
let g:LanguageClient_rootMarkers = {} | |
let g:LanguageClient_diagnosticsList = 'Location' | |
let g:LanguageClient_diagnosticsEnable = g:zero_vim_lsp_diagnostics | |
let g:LanguageClient_virtualTextPrefix = g:zero_vim_lsp_signs.virtual_text . ' ' | |
let g:LanguageClient_diagnosticsDisplay = { | |
\ 1: { 'signText': g:zero_vim_lsp_signs.error }, | |
\ 2: { 'signText': g:zero_vim_lsp_signs.warning }, | |
\ 3: { 'signText': g:zero_vim_lsp_signs.information }, | |
\ 4: { 'signText': g:zero_vim_lsp_signs.hint }, | |
\ } | |
" Shougo/neosnippet.vim: expand auto completed parameter | |
" let g:neosnippet#enable_complete_done = 1 | |
function! s:SetupLanguageServers() abort | |
for l:name in s:GetEnabledLanguageServers() | |
let l:server = g:language_servers[l:name] | |
for ft in l:server['filetypes'] | |
if !has_key(g:LanguageClient_serverCommands, ft) | |
let g:LanguageClient_serverCommands[ft] = l:server['cmd'] | |
endif | |
if has_key(l:server, 'root_markers') && !has_key(g:LanguageClient_rootMarkers, ft) | |
let g:LanguageClient_rootMarkers[ft] = l:server['root_markers'] | |
endif | |
endfor | |
endfor | |
endfunction | |
call s:SetupLanguageServers() | |
command! LanguageClientServerStatusMessage echo LanguageClient_serverStatusMessage() | |
vnoremap <Plug>(lcn-format) :<C-u>call LanguageClient_textDocument_rangeFormatting()<CR> | |
nnoremap <Plug>(lcn-workspace-symbols) :<C-u>call LanguageClient_workspace_symbol()<CR> | |
nnoremap <Plug>(lcn-clear-highlight) :<C-u>call LanguageClient_clearDocumentHighlight()<CR> | |
function! s:SetupLanguageClient() abort | |
setlocal omnifunc=LanguageClient#complete | |
nmap <buffer> <silent> [g <Plug>(lcn-diagnostics-prev) | |
nmap <buffer> <silent> ]g <Plug>(lcn-diagnostics-next) | |
nmap <buffer> <silent> K <Plug>(lcn-hover) | |
nmap <buffer> gM <Plug>(lcn-menu) | |
nmap <buffer> <silent> g<CR> <Plug>(lcn-code-action) | |
vmap <buffer> <silent> g<CR> <Plug>(lcn-code-action) | |
nmap <buffer> <silent> gC <Plug>(lcn-code-lens-action) | |
nmap <buffer> <silent> gr <Plug>(lcn-rename) | |
nmap <buffer> <silent> g= <Plug>(lcn-format) | |
vmap <buffer> <silent> g= <Plug>(lcn-format) | |
nmap <buffer> <silent> g] <Plug>(lcn-definition) | |
nmap <buffer> <silent> g[ <Plug>(lcn-type-definition) | |
nmap <buffer> <silent> gI <Plug>(lcn-implementation) | |
nmap <buffer> <silent> gR <Plug>(lcn-references) | |
nmap <buffer> <silent> go <Plug>(lcn-symbols) | |
nmap <buffer> <silent> gO <Plug>(lcn-workspace-symbols) | |
nmap <buffer> <silent> sh <Plug>(lcn-highlight) | |
nmap <buffer> <silent> sH <Plug>(lcn-clear-highlight) | |
nmap <buffer> <silent> se <Plug>(lcn-explain-error) | |
endfunction | |
augroup MyAutoCmd | |
autocmd User LanguageClientStarted call <SID>SetupLanguageClient() | |
augroup END | |
endif | |
if s:IsPlugged('vim-lamp') | |
" hrsh7th/vim-lamp | |
" Initialize Servers | |
function! s:OnInitializedLamp() abort | |
" call lamp#config('global.debug', expand("$HOME/.cache/lamp.log")) | |
call lamp#config('global.timeout', 3000) | |
call lamp#config('view.sign.error.text', g:zero_vim_lsp_signs.error) | |
call lamp#config('view.sign.warning.text', g:zero_vim_lsp_signs.warning) | |
call lamp#config('view.sign.information.text', g:zero_vim_lsp_signs.information) | |
call lamp#config('view.sign.hint.text', g:zero_vim_lsp_signs.hint) | |
" built-in setting | |
call lamp#builtin#pyls() | |
call lamp#builtin#gopls() | |
call lamp#builtin#rls() | |
call lamp#builtin#typescript_language_server() | |
call lamp#builtin#vim_language_server() | |
let l:lamp_disabled_language_servers = [ | |
\ 'pyls', | |
\ 'gopls', | |
\ 'rls', | |
\ 'typescript-language-server', | |
\ 'vim-language-server', | |
\ ] | |
" Add some language servers | |
for l:name in s:GetEnabledLanguageServers() | |
if index(l:lamp_disabled_language_servers, l:name) > -1 | |
continue | |
endif | |
let l:server = g:language_servers[l:name] | |
let l:lamp_server = { | |
\ 'command': l:server['cmd'], | |
\ 'filetypes': l:server['filetypes'], | |
\ } | |
if has_key(l:server, 'root_markers') | |
let l:root_markers = copy(l:server['root_markers']) | |
call add(l:root_markers, '.git') | |
let l:lamp_server['root_uri'] = { bufnr -> lamp#findup(l:root_markers, bufname(bufnr)) } | |
endif | |
call lamp#register(l:name, l:lamp_server) | |
endfor | |
endfunction | |
" Initialize Buffers | |
function! s:OnTextDocumentDidOpen() abort | |
setlocal omnifunc=lamp#complete | |
nnoremap <buffer> <silent> [g :<C-u>LampDiagnosticsPrev<CR> | |
nnoremap <buffer> <silent> ]g :<C-u>LampDiagnosticsNext<CR> | |
nnoremap <buffer> <silent> K :<C-u>LampHover<CR> | |
nnoremap <buffer> <silent> g<CR> :<C-u>LampCodeAction<CR> | |
vnoremap <buffer> <silent> g<CR> :LampCodeAction<CR> | |
nnoremap <buffer> <silent> gr :<C-u>LampRename<CR> | |
nnoremap <buffer> <silent> g= :<C-u>LampFormatting<CR> | |
vnoremap <buffer> <silent> g= :LampRangeFormatting<CR> | |
nnoremap <buffer> <silent> gd :<C-u>LampDeclaration edit<CR> | |
nnoremap <buffer> <silent> g] :<C-u>LampDefinition edit<CR> | |
nnoremap <buffer> <silent> g[ :<C-u>LampTypeDefinition edit<CR> | |
nnoremap <buffer> <silent> gI :<C-u>LampImplementation edit<CR> | |
nnoremap <buffer> <silent> gR :<C-u>LampReferences<CR> | |
nnoremap <buffer> <silent> sh :<C-u>LampDocumentHighlight<CR> | |
nnoremap <buffer> <silent> sH :<C-u>LampDocumentHighlightClear<CR> | |
nnoremap <buffer> <silent> s+ :<C-u>LampSelectionRangeExpand<CR> | |
nnoremap <buffer> <silent> s_ :<C-u>LampSelectionRangeCollapse<CR> | |
vnoremap <buffer> <silent> s+ :<C-u>LampSelectionRangeExpand<CR> | |
vnoremap <buffer> <silent> s_ :<C-u>LampSelectionRangeCollapse<CR> | |
endfunction | |
augroup MyAutoCmd | |
autocmd User lamp#initialized call <SID>OnInitializedLamp() | |
autocmd User lamp#text_document_did_open call <SID>OnTextDocumentDidOpen() | |
augroup END | |
endif | |
if s:IsPlugged('vim-vsnip') | |
" hrsh7th/vim-vsnip | |
let g:vsnip_snippet_dir = expand('~/.vim/vsnip') | |
let g:vsnip_snippet_dirs = extend([expand('~/.vsnip')], glob('~/.vsnip/*/', 0, 1)) | |
imap <expr> <C-\> vsnip#available(1) ? "\<Plug>(vsnip-expand-or-jump)" : "\<C-\>" | |
smap <expr> <C-\> vsnip#available(1) ? "\<Plug>(vsnip-expand-or-jump)" : "\<C-\>" | |
if !s:IsPlugged('ultisnips') && !s:IsPlugged('neosnippet.vim') | |
imap <expr> <C-k> vsnip#available(1) ? "\<Plug>(vsnip-expand-or-jump)" : "\<C-k>" | |
smap <expr> <C-k> vsnip#available(1) ? "\<Plug>(vsnip-expand-or-jump)" : "\<C-k>" | |
imap <expr> <C-j> vsnip#jumpable(1) ? "\<Plug>(vsnip-jump-next)" : "\<C-j>" | |
smap <expr> <C-j> vsnip#jumpable(1) ? "\<Plug>(vsnip-jump-next)" : "\<C-j>" | |
imap <expr> <C-z> vsnip#jumpable(-1) ? "\<Plug>(vsnip-jump-prev)" : "\<C-z>" | |
smap <expr> <C-z> vsnip#jumpable(-1) ? "\<Plug>(vsnip-jump-prev)" : "\<C-z>" | |
endif | |
endif | |
if s:IsPlugged('completion-nvim') | |
" nvim-lua/completion-nvim | |
let g:completion_enable_auto_popup = 1 | |
let g:completion_timer_cycle = 100 | |
let g:completion_confirm_key = "\<C-y>" | |
let g:completion_enable_auto_paren = 0 | |
let g:completion_trigger_on_delete = 1 | |
let g:completion_auto_change_source = 1 | |
let g:completion_matching_strategy_list = ['exact', 'fuzzy'] | |
let g:completion_sorting = 'none' | |
if s:IsPlugged('ultisnips') | |
let g:completion_enable_snippet = 'UltiSnips' | |
elseif s:IsPlugged('neosnippet.vim') | |
let g:completion_enable_snippet = 'Neosnippet' | |
" Expand auto completed parameter and snippets | |
let g:neosnippet#enable_completed_snippet = 1 | |
let g:neosnippet#enable_optional_arguments = 1 | |
let g:neosnippet#enable_complete_done = 1 | |
endif | |
let g:completion_chain_complete_list = { | |
\ 'default': [ | |
\ { 'complete_items': ['lsp', 'snippet', 'vim-vsnip'] }, | |
\ { 'complete_items': (s:IsPlugged('completion-treesitter') ? ['ts'] : []) + ['buffers', 'path'] }, | |
\ { 'mode': '<c-p>' }, | |
\ { 'mode': '<c-n>' }, | |
\ ] | |
\ } | |
" steelsojka/completion-buffers | |
let g:completion_word_min_length = 1 | |
" A list of filetypes that should be ignored from caching/gathering words. | |
let g:completion_word_ignored_ft = [] | |
" <Tab>: completion | |
function! s:CheckBackSpace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
function! s:CleverTab() abort | |
if pumvisible() | |
return "\<C-n>" | |
endif | |
if s:CheckBackSpace() | |
return "\<Tab>" | |
endif | |
return "\<Plug>(completion_trigger)" | |
endfunction | |
imap <silent> <expr> <Tab> <SID>CleverTab() | |
" <S-Tab>: completion back | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-h>" | |
" " <Tab>: smart completion | |
" imap <Tab> <Plug>(completion_smart_tab) | |
" " <S-Tab>: smart completion | |
" imap <S-Tab> <Plug>(completion_smart_s_tab) | |
" <CR>: close popup and insert newline (works with auto-pairs) | |
function! s:CleverCR() abort | |
if pumvisible() | |
if complete_info()['selected'] != '-1' | |
return "\<Plug>(completion_confirm_completion)" | |
endif | |
return "\<C-e>\<CR>" | |
endif | |
return "\<CR>" | |
endfunction | |
imap <expr> <CR> <SID>CleverCR() | |
" Switch to previous completion | |
imap <silent> <C-x><C-h> <Plug>(completion_prev_source) | |
" Switch to next completion | |
imap <silent> <C-x><C-j> <Plug>(completion_next_source) | |
" Trigger completion manually | |
imap <silent> <C-x><C-x> <Plug>(completion_trigger) | |
" Integrate with vim-visual-multi / vim-multiple-cursors plugin | |
function! Disable_Completion_Hook() abort | |
let b:completion_enable = 0 | |
let g:completion_enable_auto_popup = 0 | |
endfunction | |
function! Enable_Completion_Hook() abort | |
let b:completion_enable = 1 | |
let g:completion_enable_auto_popup = 1 | |
endfunction | |
let g:completion_disable_filetypes = [ | |
\ 'nerdtree', | |
\ 'fern', | |
\ 'vaffle', | |
\ 'startify', | |
\ 'tagbar', | |
\ 'vista', | |
\ 'vim-plug', | |
\ 'terminal', | |
\ 'help', | |
\ 'qf', | |
\ 'godoc', | |
\ 'gitcommit', | |
\ 'fugitiveblame', | |
\ 'ctrlp', | |
\ 'leaderf', | |
\ 'clap_input', | |
\ ] | |
function! s:InitCompletionNvim() | |
if index(g:completion_disable_filetypes, &filetype) > -1 | |
return | |
endif | |
if exists('g:nvim_lsp_filetypes') && has_key(g:nvim_lsp_filetypes, &filetype) | |
return | |
endif | |
try | |
lua require('completion').on_attach() | |
catch /^Vim(lua):E5108/ | |
call s:Warn('completion-nvim: ' . v:exception) | |
endtry | |
endfunction | |
augroup MyAutoCmd | |
" Use completion-nvim in every buffer | |
autocmd BufEnter * call <SID>InitCompletionNvim() | |
augroup end | |
endif | |
if s:IsPlugged('nvim-compe') | |
" hrsh7th/nvim-compe | |
let g:compe = {} | |
let g:compe.enabled = v:true | |
let g:compe.autocomplete = v:true | |
let g:compe.debug = v:true | |
let g:compe.min_length = 1 | |
let g:compe.preselect = 'always' | |
let g:compe.throttle_time = 80 | |
let g:compe.source_timeout = 200 | |
let g:compe.incomplete_delay = 400 | |
let g:compe.max_abbr_width = 100 | |
let g:compe.max_kind_width = 100 | |
let g:compe.max_menu_width = 100 | |
let g:compe.documentation = v:true | |
let g:compe.source = {} | |
let g:compe.source.path = v:true | |
let g:compe.source.buffer = v:true | |
let g:compe.source.calc = v:false | |
let g:compe.source.spell = v:true | |
let g:compe.source.tags = v:false | |
let g:compe.source.omni = s:IsLSPEnabled() ? v:false : v:true | |
let g:compe.source.treesitter = s:IsPlugged('nvim-treesitter') ? v:true : v:false | |
let g:compe.source.vsnip = v:true | |
let g:compe.source.ultisnips = s:IsPlugged('ultisnips') ? v:true : v:false | |
let g:compe.source.snippets_nvim = v:false | |
let g:compe.source.nvim_lua = v:false | |
let g:compe.source.nvim_lsp = s:IsPlugged('nvim-lspconfig') ? v:true : v:false | |
let g:compe.source.vim_lsp = s:IsPlugged('vim-lsp') ? v:true : v:false | |
let g:compe.source.vim_lsc = s:IsPlugged('vim-lsc') ? v:true : v:false | |
" Manual complete | |
inoremap <silent> <expr> <C-x><C-x> compe#complete() | |
" <C-y>: close popup | |
inoremap <silent> <expr> <C-y> compe#confirm("\<C-y>") | |
" CTRL-E: Cancel popup | |
inoremap <silent> <expr> <C-e> compe#close("\<C-e>") | |
" CTRL-H, <BS>: close popup and delete backword char | |
inoremap <silent> <expr> <C-h> compe#close("\<C-h>") | |
inoremap <silent> <expr> <BS> compe#close("\<C-h>") | |
" <Tab>: completion | |
function! s:CheckBackSpace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
function! s:CleverTab() abort | |
if pumvisible() | |
return "\<C-n>" | |
endif | |
if s:CheckBackSpace() | |
return "\<Tab>" | |
endif | |
return compe#complete() | |
endfunction | |
imap <silent> <expr> <Tab> <SID>CleverTab() | |
" <S-Tab>: completion back | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-h>" | |
" <CR>: close popup and insert newline | |
if s:IsPlugged('auto-pairs') | |
inoremap <silent> <expr> <CR> compe#confirm({ 'keys': "\<Plug>AutoPairsReturn", 'mode': '' }) | |
elseif s:IsPlugged('lexima.vim') | |
let g:lexima_no_default_rules = 1 | |
call lexima#set_default_rules() | |
inoremap <silent> <expr> <CR> compe#confirm(lexima#expand('<LT>CR>', 'i')) | |
else | |
inoremap <silent> <expr> <CR> compe#confirm("\<CR>") | |
endif | |
" Disable completion in clap_input | |
augroup MyAutoCmd | |
autocmd FileType clap_input call compe#setup({ 'enabled': v:false }, 0) | |
augroup END | |
endif | |
if s:IsPlugged('deoplete.nvim') | |
" Shougo/deoplete.nvim | |
let g:deoplete#enable_at_startup = 1 | |
call deoplete#custom#option({ | |
\ 'auto_complete': v:true, | |
\ 'auto_complete_delay': 50, | |
\ 'refresh_always': v:true, | |
\ 'camel_case': v:true, | |
\ 'skip_multibyte': v:true, | |
\ 'auto_preview': v:true, | |
\ }) | |
" Ignore sources | |
call deoplete#custom#option('ignore_sources', { | |
\ '_': ['ale', 'dictionary', 'syntax', 'tag'], | |
\ }) | |
call deoplete#custom#option('keyword_patterns', { | |
\ '_': '[a-zA-Z_]\k*\(?', | |
\ }) | |
call deoplete#custom#option('omni_patterns', { | |
\ 'go': '[^. *\t]\.\w*', | |
\ }) | |
call deoplete#custom#source('_', 'converters', [ | |
\ 'converter_remove_overlap', | |
\ 'converter_case', | |
\ 'converter_truncate_abbr', | |
\ 'converter_truncate_info', | |
\ 'converter_truncate_menu', | |
\ ]) | |
call deoplete#custom#source('_', 'matchers', [ | |
\ 'matcher_fuzzy', | |
\ ]) | |
" deoplete-plugins/deoplete-lsp | |
" lighttiger2505/deoplete-vim-lsp | |
call deoplete#custom#source('lsp', { | |
\ 'rank': 500, | |
\ 'min_pattern_length': 1, | |
\ 'sorters': [], | |
\ }) | |
" hrsh7th/deoplete-vim-lsc | |
call deoplete#custom#source('lsc', { | |
\ 'is_volatile': v:true, | |
\ 'rank': 500, | |
\ 'min_pattern_length': 1, | |
\ 'sorters': [], | |
\ }) | |
" autozimu/LanguageClient-neovim | |
call deoplete#custom#source('LanguageClient', { | |
\ 'rank': 500, | |
\ 'min_pattern_length': 1, | |
\ 'sorters': [], | |
\ }) | |
" hrsh7th/deoplete-lamp | |
call deoplete#custom#source('lamp', { | |
\ 'rank': 500, | |
\ 'mark': '[lamp]', | |
\ 'sorters': [], | |
\ }) | |
" hrsh7th/vim-vsnip-integ | |
call deoplete#custom#source('vsnip', { | |
\ 'rank': 250, | |
\ 'mark': '', | |
\ 'min_pattern_length': 1, | |
\ 'sorters': ['sorter_word'], | |
\ }) | |
" SirVer/ultisnips | |
call deoplete#custom#source('ultisnips', { | |
\ 'rank': 200, | |
\ 'mark': '[U]', | |
\ 'min_pattern_length': 1, | |
\ 'sorters': ['sorter_word'], | |
\ }) | |
" Shougo/neosnippet.vim | |
call deoplete#custom#source('neosnippet', { | |
\ 'rank': 200, | |
\ 'mark': '[N]', | |
\ 'min_pattern_length': 1, | |
\ 'sorters': ['sorter_word'], | |
\ }) | |
call deoplete#custom#source('omni', { | |
\ 'is_volatile': v:true, | |
\ 'rank': 500, | |
\ }) | |
call deoplete#custom#source('around', { | |
\ 'rank': 180, | |
\ }) | |
" CTRL-E: Cancel popup | |
inoremap <expr> <C-e> deoplete#cancel_popup() | |
" CTRL-H, <BS>: close popup and delete backword char | |
inoremap <expr> <C-h> deoplete#smart_close_popup()."\<C-h>" | |
inoremap <expr> <BS> deoplete#smart_close_popup()."\<C-h>" | |
" <Tab>: completion | |
function! s:CheckBackSpace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
function! s:CleverTab() abort | |
if pumvisible() | |
return "\<C-n>" | |
endif | |
if s:CheckBackSpace() | |
return "\<Tab>" | |
endif | |
return deoplete#manual_complete() | |
endfunction | |
imap <silent> <expr> <Tab> <SID>CleverTab() | |
" <S-Tab>: completion back | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-h>" | |
" <CR>: close popup and insert newline | |
function! s:CleverCR() abort | |
return deoplete#close_popup() . "\<CR>" | |
endfunction | |
inoremap <silent> <CR> <C-r>=<SID>CleverCR()<CR> | |
inoremap <expr> <C-x><C-g> deoplete#undo_completion() | |
inoremap <expr> <C-x><C-l> deoplete#complete_common_string() | |
inoremap <silent> <expr> <C-x><C-f> deoplete#manual_complete('file') | |
inoremap <expr> <C-x><C-x> deoplete#manual_complete() | |
" Integrate with vim-visual-multi / vim-multiple-cursors plugin | |
function! Disable_Completion_Hook() abort | |
call deoplete#custom#buffer_option('auto_complete', v:false) | |
endfunction | |
function! Enable_Completion_Hook() abort | |
call deoplete#custom#buffer_option('auto_complete', v:true) | |
endfunction | |
endif | |
if s:IsPlugged('coc.nvim') | |
" neoclide/coc.nvim | |
" https://github.com/neoclide/coc.nvim/wiki/Using-coc-extensions | |
" https://github.com/neoclide/coc.nvim/wiki/Language-servers | |
let g:coc_global_extensions = [ | |
\ 'coc-json', | |
\ 'coc-tsserver', | |
\ 'coc-html', | |
\ 'coc-xml', | |
\ 'coc-css', | |
\ 'coc-markdownlint', | |
\ 'coc-eslint', | |
\ 'coc-clangd', | |
\ 'coc-python', | |
\ 'coc-pyright', | |
\ 'coc-jedi', | |
\ 'coc-go', | |
\ 'coc-rls', | |
\ 'coc-rust-analyzer', | |
\ 'coc-elixir', | |
\ 'coc-erlang_ls', | |
\ 'coc-metals', | |
\ 'coc-solargraph', | |
\ 'coc-yaml', | |
\ 'coc-sh', | |
\ 'coc-vimlsp', | |
\ ] | |
if s:IsPlugged('ultisnips') | |
call add(g:coc_global_extensions, 'coc-ultisnips') | |
elseif s:IsPlugged('neosnippet.vim') | |
call add(g:coc_global_extensions, 'coc-neosnippet') | |
endif | |
if executable('/usr/local/bin/node') | |
let g:coc_node_path = '/usr/local/bin/node' | |
endif | |
" <Tab>: completion | |
function! s:CheckBackSpace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
function! s:CleverTab() abort | |
if pumvisible() | |
return "\<C-n>" | |
endif | |
if s:CheckBackSpace() | |
return "\<Tab>" | |
endif | |
return coc#refresh() | |
endfunction | |
inoremap <expr> <Tab> <SID>CleverTab() | |
" <S-Tab>: completion back | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-h>" | |
" Use <CR> for confirm completion, | |
" `<C-g>u` means break undo chain at current position. | |
" Coc only does snippet and additional edit on confirm. | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>" | |
" Overwrite <C-x><C-u> | |
imap <silent> <C-x><C-u> <Plug>(coc-complete-custom) | |
" Use <C-x><C-x> to trigger completion. | |
inoremap <silent> <expr> <C-x><C-x> coc#refresh() | |
nnoremap <silent> <Plug>(coc-hover) :<C-u>call CocAction('doHover')<CR> | |
nnoremap <silent> <Plug>(coc-hover-async) :<C-u>call CocActionAsync('doHover')<CR> | |
" Use `[g` and `]g` to navigate diagnostics | |
nmap [g <Plug>(coc-diagnostic-prev) | |
nmap ]g <Plug>(coc-diagnostic-next) | |
nmap [k <Plug>(coc-diagnostic-prev-error) | |
nmap ]k <Plug>(coc-diagnostic-next-error) | |
nmap K <Plug>(coc-hover) | |
nmap g<CR> <Plug>(coc-codeaction) | |
vmap g<CR> <Plug>(coc-codeaction-selected) | |
nmap gr <Plug>(coc-rename) | |
nmap g= <Plug>(coc-format) | |
vmap g= <Plug>(coc-format-selected) | |
nmap gL <Plug>(coc-diagnostic-info) | |
nmap gd <Plug>(coc-declaration) | |
nmap g] <Plug>(coc-definition) | |
nmap g[ <Plug>(coc-type-definition) | |
nmap gI <Plug>(coc-implementation) | |
nmap gR <Plug>(coc-references) | |
nmap so <Plug>(coc-openlink) | |
nmap sf <Plug>(coc-fix-current) | |
nmap sr <Plug>(coc-refactor) | |
xmap ik <Plug>(coc-funcobj-i) | |
xmap ak <Plug>(coc-funcobj-a) | |
omap ik <Plug>(coc-funcobj-i) | |
omap ak <Plug>(coc-funcobj-a) | |
xmap iK <Plug>(coc-funcobj-i) | |
xmap aK <Plug>(coc-funcobj-a) | |
omap iK <Plug>(coc-funcobj-i) | |
omap aK <Plug>(coc-funcobj-a) | |
augroup MyAutoCmd | |
" Update signature help on jump placeholder | |
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
augroup END | |
" Integrate with vim-visual-multi / vim-multiple-cursors plugin | |
function! Disable_Completion_Hook() abort | |
let b:coc_suggest_disable = 1 | |
endfunction | |
function! Enable_Completion_Hook() abort | |
let b:coc_suggest_disable = 0 | |
endfunction | |
endif | |
if s:IsPlugged('YouCompleteMe') | |
" ycm-core/YouCompleteMe | |
let g:ycm_auto_trigger = 1 | |
let g:ycm_disable_signature_help = 1 | |
let g:ycm_always_populate_location_list = 1 | |
let g:ycm_confirm_extra_conf = 0 | |
let g:ycm_complete_in_comments = 1 | |
let g:ycm_complete_in_strings = 1 | |
let g:ycm_collect_identifiers_from_tags_files = 0 | |
let g:ycm_use_ultisnips_completer = s:IsPlugged('ultisnips') | |
let g:ycm_extra_conf_vim_data = ['&filetype'] | |
let g:ycm_global_ycm_extra_conf = filereadable(expand('~/.ycm_extra_conf.py')) ? expand('~/.ycm_extra_conf') : '' | |
let g:ycm_filetype_blacklist = { | |
\ 'ctrlp': 1, | |
\ 'tagbar': 1, | |
\ 'qf': 1, | |
\ 'nerdtree': 1, | |
\ 'fern': 1, | |
\ 'vaffle': 1, | |
\ 'notes': 1, | |
\ 'markdown': 1, | |
\ 'netrw': 1, | |
\ 'unite': 1, | |
\ 'text': 1, | |
\ 'vimwiki': 1, | |
\ 'pandoc': 1, | |
\ 'infolog': 1, | |
\ 'leaderf': 1, | |
\ 'mail': 1, | |
\ } | |
let g:ycm_error_symbol = g:zero_vim_signs.error | |
let g:ycm_warning_symbol = g:zero_vim_signs.warning | |
let g:ycm_key_detailed_diagnostics = 'L' | |
let g:ycm_key_invoke_completion = '<C-x><C-x>' | |
" <CR>: close popup and insert newline | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<CR>" | |
if executable('clangd') | |
let g:ycm_use_clangd = 1 | |
let g:ycm_clangd_binary_path = exepath('clangd') | |
let g:ycm_clangd_args = [] | |
endif | |
if executable('gopls') | |
let g:ycm_gopls_binary_path = exepath('gopls') | |
let g:ycm_gopls_args = [] | |
endif | |
if executable('rls') | |
let g:ycm_rls_binary_path = exepath('rls') | |
endif | |
if executable('rustc') | |
let g:ycm_rustc_binary_path = exepath('rustc') | |
endif | |
if executable('tsserver') | |
let g:ycm_tsserver_binary_path = exepath('tsserver') | |
endif | |
if !s:IsLSPEnabled() | |
let g:ycm_language_server = [] | |
function! s:SetupYcmLanguageServers() abort | |
let l:ycm_disabled_language_servers = [ | |
\ 'clangd', | |
\ 'ccls', | |
\ 'gopls', | |
\ 'rls', | |
\ 'rust-analyzer', | |
\ 'typescript-language-server', | |
\ ] | |
for l:name in s:GetEnabledLanguageServers() | |
if index(l:ycm_disabled_language_servers, l:name) > -1 | |
continue | |
endif | |
let l:server = g:language_servers[l:name] | |
let l:ycm_server = { | |
\ 'name': l:name, | |
\ 'cmdline': l:server['cmd'], | |
\ 'filetypes': l:server['filetypes'], | |
\ } | |
if has_key(l:server, 'root_markers') | |
let l:ycm_server['project_root_files'] = l:server['root_markers'] | |
endif | |
call add(g:ycm_language_server, l:ycm_server) | |
endfor | |
endfunction | |
call s:SetupYcmLanguageServers() | |
endif | |
" Integrate with vim-visual-multi / vim-multiple-cursors plugin | |
function! Disable_Completion_Hook() abort | |
let g:ycm_auto_trigger = 0 | |
endfunction | |
function! Enable_Completion_Hook() abort | |
let g:ycm_auto_trigger = 1 | |
endfunction | |
endif | |
if s:IsPlugged('asyncomplete.vim') | |
" prabirshrestha/asyncomplete.vim | |
let g:asyncomplete_auto_popup = 1 | |
let g:asyncomplete_popup_delay = 50 | |
" Show autocomplete popup manually | |
imap <C-x><C-x> <Plug>(asyncomplete_force_refresh) | |
" <CR>: close popup and insert newline | |
inoremap <expr> <CR> pumvisible() ? asyncomplete#close_popup()."\<CR>" : "\<CR>" | |
" <Tab>: completion | |
function! s:CheckBackSpace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
function! s:CleverTab() abort | |
if pumvisible() | |
return "\<C-n>" | |
endif | |
if s:CheckBackSpace() | |
return "\<Tab>" | |
endif | |
return asyncomplete#force_refresh() | |
endfunction | |
imap <silent> <expr> <Tab> <SID>CleverTab() | |
" <S-Tab>: completion back | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-h>" | |
" <C-y>: close popup | |
inoremap <expr> <C-y> pumvisible() ? asyncomplete#close_popup() : "\<C-y>" | |
" <C-e>: cancel popup | |
inoremap <expr> <C-e> pumvisible() ? asyncomplete#cancel_popup() : "\<C-e>" | |
function! s:SetupAsyncomplete() abort | |
" prabirshrestha/asyncomplete-buffer.vim | |
call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({ | |
\ 'name': 'buffer', | |
\ 'allowlist': ['*'], | |
\ 'blocklist': ['go'], | |
\ 'completor': function('asyncomplete#sources#buffer#completor'), | |
\ })) | |
" prabirshrestha/asyncomplete-file.vim | |
call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({ | |
\ 'name': 'file', | |
\ 'allowlist': ['*'], | |
\ 'priority': 10, | |
\ 'completor': function('asyncomplete#sources#file#completor'), | |
\ })) | |
" yami-beta/asyncomplete-omni.vim | |
call asyncomplete#register_source(asyncomplete#sources#omni#get_source_options({ | |
\ 'name': 'omni', | |
\ 'allowlist': ['*'], | |
\ 'blocklist': ['c', 'cpp', 'html', 'css', 'ruby'], | |
\ 'completor': function('asyncomplete#sources#omni#completor'), | |
\ })) | |
if s:IsPlugged('asyncomplete-ultisnips.vim') | |
" prabirshrestha/asyncomplete-ultisnips.vim | |
call asyncomplete#register_source(asyncomplete#sources#ultisnips#get_source_options({ | |
\ 'name': 'ultisnips', | |
\ 'allowlist': ['*'], | |
\ 'completor': function('asyncomplete#sources#ultisnips#completor'), | |
\ })) | |
endif | |
if s:IsPlugged('asyncomplete-neosnippet.vim') | |
" prabirshrestha/asyncomplete-neosnippet.vim | |
call asyncomplete#register_source(asyncomplete#sources#neosnippet#get_source_options({ | |
\ 'name': 'neosnippet', | |
\ 'allowlist': ['*'], | |
\ 'completor': function('asyncomplete#sources#neosnippet#completor'), | |
\ })) | |
endif | |
endfunction | |
augroup MyAutoCmd | |
autocmd User asyncomplete_setup call s:SetupAsyncomplete() | |
augroup END | |
" Integrate with vim-visual-multi / vim-multiple-cursors plugin | |
function! Disable_Completion_Hook() abort | |
let b:asyncomplete_enable = 0 | |
let g:asyncomplete_auto_popup = 0 | |
endfunction | |
function! Enable_Completion_Hook() abort | |
let b:asyncomplete_enable = 1 | |
let g:asyncomplete_auto_popup = 1 | |
endfunction | |
endif | |
if s:IsPlugged('ncm2') | |
" ncm2/ncm2 | |
let g:ncm2#auto_popup = 1 | |
let g:ncm2#popup_delay = 50 | |
let g:ncm2#complete_length = [ [1, 3], [7, 1] ] | |
" CTRL-C doesn't trigger the InsertLeave autocmd . map to <ESC> instead. | |
" inoremap <C-c> <ESC> | |
" Trigger complete manually | |
imap <C-x><C-x> <Plug>(ncm2_manual_trigger) | |
" <CR>: close popup and insert newline | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<CR>" | |
" <Tab>: completion | |
function! s:CheckBackSpace() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~ '\s' | |
endfunction | |
function! s:CleverTab() abort | |
if pumvisible() | |
return "\<C-n>" | |
endif | |
if s:CheckBackSpace() | |
return "\<Tab>" | |
endif | |
return "\<C-r>=ncm2#manual_trigger()\<CR>" | |
endfunction | |
inoremap <silent> <expr> <Tab> <SID>CleverTab() | |
" <S-Tab>: completion back | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-h>" | |
" Integrate with vim-visual-multi / vim-multiple-cursors plugin | |
function! Disable_Completion_Hook() abort | |
let b:ncm2_enable = 0 | |
call ncm2#lock('vim-visual-multi') | |
endfunction | |
function! Enable_Completion_Hook() abort | |
let b:ncm2_enable = 1 | |
call ncm2#unlock('vim-visual-multi') | |
endfunction | |
let g:ncm2_disable_filetypes = [ | |
\ 'nerdtree', | |
\ 'fern', | |
\ 'vaffle', | |
\ 'startify', | |
\ 'tagbar', | |
\ 'vista', | |
\ 'vim-plug', | |
\ 'terminal', | |
\ 'help', | |
\ 'qf', | |
\ 'godoc', | |
\ 'gitcommit', | |
\ 'fugitiveblame', | |
\ 'ctrlp', | |
\ 'leaderf', | |
\ 'clap_input', | |
\ ] | |
function! s:InitNcm2() abort | |
if index(g:ncm2_disable_filetypes, &filetype) > -1 | |
return | |
endif | |
call ncm2#enable_for_buffer() | |
endfunction | |
" Enable Autocomplete for all buffers | |
augroup MyAutoCmd | |
autocmd BufEnter * call <SID>InitNcm2() | |
augroup END | |
endif | |
if s:IsPlugged('completor.vim') | |
" maralla/completor.vim | |
let g:completor_auto_trigger = 1 | |
let g:completor_completion_delay = 50 | |
let g:completor_complete_options = 'menuone,noinsert,noselect' | |
let g:completor_auto_close_doc = 1 | |
if s:IsPlugged('completor-neosnippet') | |
let g:completor_disable_ultisnips = 1 | |
endif | |
" Trigger complete manually | |
inoremap <silent> <expr> <C-x><C-x> "<C-r>=completor#do('complete')<CR>" | |
" <CR>: close popup and insert newline | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<CR>" | |
" <Tab>: completion | |
function! s:CleverTab() abort | |
if pumvisible() | |
return "\<C-n>" | |
elseif col('.') > 1 && strpart(getline('.'), col('.') - 2, 3) =~ '^[[:keyword:][:ident:]]' | |
return "\<C-r>=completor#do('complete')\<CR>" | |
else | |
return "\<Tab>" | |
endif | |
endfunction | |
inoremap <silent> <expr> <Tab> <SID>CleverTab() | |
" <S-Tab>: completion back | |
inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-h>" | |
if !s:IsLSPEnabled() | |
" Enable LSP | |
let g:completor_filetype_map = {} | |
function! s:SetupCompletorLanguageServers() abort | |
for l:name in s:GetEnabledLanguageServers() | |
let l:server = g:language_servers[l:name] | |
let l:opts = { 'ft': 'lsp', 'cmd': join(l:server['cmd'], ' ') } | |
for ft in l:server['filetypes'] | |
if !has_key(g:completor_filetype_map, ft) | |
let g:completor_filetype_map[ft] = l:opts | |
endif | |
endfor | |
endfor | |
endfunction | |
call s:SetupCompletorLanguageServers() | |
command! CompletorHover call completor#do('hover') | |
command! CompletorDoc call completor#do('doc') | |
command! CompletorDefinition call completor#do('definition') | |
command! CompletorFormat call completor#do('format') | |
endif | |
" Integrate with vim-visual-multi / vim-multiple-cursors plugin | |
function! Disable_Completion_Hook() abort | |
silent! CompletorDisable | |
endfunction | |
function! Enable_Completion_Hook() abort | |
silent! CompletorEnable | |
endfunction | |
endif | |
if s:IsPlugged('vim-mucomplete') | |
" lifepillar/vim-mucomplete | |
let g:mucomplete#enable_auto_at_startup = 1 | |
let g:mucomplete#completion_delay = 0 | |
let g:mucomplete#reopen_immediately = 1 | |
let g:mucomplete#minimum_prefix_length = 1 | |
" prabirshrestha/vim-lsp: disable async completion | |
let g:lsp_async_completion = 0 | |
if s:IsPlugged('LanguageClient-neovim') || s:IsPlugged('LanguageClient-neovim-dev') | |
" autozimu/LanguageClient-neovim | |
let g:mucomplete#completion_delay = 50 | |
let g:mucomplete#reopen_immediately = 0 | |
endif | |
function! s:SetupMUCompleteDefaultChains() abort | |
let l:chains = ['omni'] | |
if s:IsPlugged('vim-vsnip') | |
call add(l:chains, 'vsnip') | |
endif | |
if s:IsPlugged('ultisnips') | |
call add(l:chains, 'ulti') | |
elseif s:IsPlugged('neosnippet.vim') | |
call add(l:chains, 'nsnp') | |
endif | |
call extend(l:chains, ['c-p', 'path']) | |
return l:chains | |
endfunction | |
let g:mucomplete#chains = { | |
\ 'default': s:SetupMUCompleteDefaultChains(), | |
\ } | |
" Cancel the current menu and try completing the text I originally typed in a different way | |
inoremap <silent> <Plug>(MUcompleteBwdKey) <C-x><C-h> | |
imap <C-x><C-h> <Plug>(MUcompleteCycBwd) | |
inoremap <silent> <Plug>(MUcompleteFwdKey) <C-x><C-j> | |
imap <C-x><C-j> <Plug>(MUcompleteCycFwd) | |
" <CR>: close popup and insert newline | |
inoremap <expr> <CR> pumvisible() ? "\<C-y>\<CR>" : "\<CR>" | |
" if !has('patch-8.0.0283') | |
" imap <expr> <CR> pumvisible() ? "\<C-y>\<Plug>(MUcompleteCR)" : "\<Plug>(MUcompleteCR)" | |
" endif | |
" Integrate with vim-visual-multi / vim-multiple-cursors plugin | |
function! Disable_Completion_Hook() abort | |
silent! MUcompleteAutoOff | |
endfunction | |
function! Enable_Completion_Hook() abort | |
silent! MUcompleteAutoOn | |
endfunction | |
endif | |
if s:IsPlugged('VimCompletesMe') | |
" ackyshake/VimCompletesMe | |
" Disable vim-lsp's async completion | |
let g:lsp_async_completion = 0 | |
endif | |
if s:IsPlugged('vim-gutentags') | |
" ludovicchabant/vim-gutentags | |
" Enable only ctags module | |
let g:gutentags_modules = ['ctags'] | |
let g:gutentags_generate_on_missing = 1 | |
let g:gutentags_generate_on_new = 1 | |
let g:gutentags_generate_on_write = 1 | |
" Generate datebases in my cache directory, prevent gtags files polluting my project | |
let g:gutentags_cache_dir = expand('~/.cache/tags') | |
let g:gutentags_ctag_executable = g:zero_vim_ctags_bin | |
" Universal Ctags | |
if g:zero_vim_universal_ctags && filereadable(g:zero_vim_ctags_ignore) | |
let g:gutentags_ctags_exclude = [ '@' . g:zero_vim_ctags_ignore ] | |
endif | |
" Ignored directories | |
let g:gutentags_exclude_project_root = split(glob('~/.vim/plugged/*')) | |
let g:gutentags_exclude_project_root += split(glob('~/.vim/*')) | |
let g:gutentags_exclude_project_root += [ | |
\ $HOME, | |
\ '/usr/local', | |
\ '/usr', | |
\ '/opt', | |
\ '/etc', | |
\ '/', | |
\ ] | |
" Ignored file types | |
let g:gutentags_exclude_filetypes = [ | |
\ 'html', | |
\ 'xml', | |
\ 'css', | |
\ 'sass', | |
\ 'scss', | |
\ 'coffee', | |
\ 'less', | |
\ 'eruby', | |
\ 'haml', | |
\ 'hamlc', | |
\ 'text', | |
\ 'git', | |
\ 'gitcommit', | |
\ 'fugitiveblame', | |
\ ] | |
" Define advanced commands | |
let g:gutentags_define_advanced_commands = 1 | |
" gtags_cscope | |
if g:zero_vim_gtags_cscope && has('cscope') && executable('gtags') | |
call add(g:gutentags_modules, 'gtags_cscope') | |
" Automatically add gtags database | |
let g:gutentags_auto_add_gtags_cscope = 1 | |
else | |
" Prevent gutentags adding gtags database | |
let g:gutentags_auto_add_gtags_cscope = 0 | |
endif | |
endif | |
if s:IsPlugged('gen_tags.vim') | |
" jsfaint/gen_tags.vim | |
let g:gen_tags#ctags_auto_gen = 1 | |
let g:gen_tags#ctags_auto_update = 1 | |
let g:gen_tags#cache_dir = expand('~/.cache/gen_tags') | |
let g:gen_tags#ctags_bin = g:zero_vim_ctags_bin | |
" Universal Ctags | |
if g:zero_vim_universal_ctags && filereadable(g:zero_vim_ctags_ignore) | |
let g:gen_tags#ctags_opts = [ '--exclude=@' . g:zero_vim_ctags_ignore ] | |
endif | |
" Ignored directories | |
let g:gen_tags#blacklist = split(glob('~/.vim/plugged/*')) | |
let g:gen_tags#blacklist += split(glob('~/.vim/*')) | |
let g:gen_tags#blacklist += [ | |
\ $HOME, | |
\ '/usr/local', | |
\ '/usr', | |
\ '/opt', | |
\ '/etc', | |
\ '/', | |
\ ] | |
" No default gtags mappings | |
let g:gen_tags#gtags_default_map = 0 | |
if g:zero_vim_gtags_cscope && has('cscope') && executable('gtags') | |
let g:loaded_gentags#gtags = 0 | |
else | |
" Disable gtags support | |
let g:loaded_gentags#gtags = 1 | |
endif | |
endif | |
" gtags_cscope mappings | |
if g:zero_vim_gtags_cscope && has('cscope') && executable('gtags') | |
" The following maps all invoke one of the following cscope search types: | |
" 0 or s: Find this C symbol | |
" 1 or g: Find this definition | |
" 2 or d: Find functions called by this function | |
" 3 or c: Find functions calling this function | |
" 4 or t: Find this text string | |
" 6 or e: Find this egrep pattern | |
" 7 or f: Find this file | |
" 8 or i: Find files #including this file | |
" 9 or a: Find places where this symbol is assigned a value | |
nnoremap <silent> <C-\>s :cscope find s <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\>g :cscope find g <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\>d :cscope find d <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\>c :cscope find c <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\>t :cscope find t <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\>e :cscope find e <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\>f :cscope find f <C-r>=expand('<cfile>')<CR><CR> | |
nnoremap <silent> <C-\>i :cscope find i <C-r>=expand('<cfile>')<CR><CR> | |
nnoremap <silent> <C-\>a :cscope find a <C-r>=expand('<cword>')<CR><CR> | |
xnoremap <silent> <C-\>s :cscope find s <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\>g :cscope find g <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\>d :cscope find d <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\>c :cscope find c <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\>t :cscope find t <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\>e :cscope find e <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\>a :cscope find a <C-r>=vim_helpers#Vword()<CR><CR> | |
nnoremap <silent> <C-\><C-s> :vertical scscope find s <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\><C-g> :vertical scscope find g <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\><C-d> :vertical scscope find d <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\><C-c> :vertical scscope find c <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\><C-t> :vertical scscope find t <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\><C-e> :vertical scscope find e <C-r>=expand('<cword>')<CR><CR> | |
nnoremap <silent> <C-\><C-f> :vertical scscope find f <C-r>=expand('<cfile>')<CR><CR> | |
nnoremap <silent> <C-\><C-i> :vertical scscope find i <C-r>=expand('<cfile>')<CR><CR> | |
nnoremap <silent> <C-\><C-a> :vertical scscope find a <C-r>=expand('<cword>')<CR><CR> | |
xnoremap <silent> <C-\><C-s> :vertical scscope find s <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\><C-g> :vertical scscope find g <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\><C-d> :vertical scscope find d <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\><C-c> :vertical scscope find c <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\><C-t> :vertical scscope find t <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\><C-e> :vertical scscope find e <C-r>=vim_helpers#Vword()<CR><CR> | |
xnoremap <silent> <C-\><C-a> :vertical scscope find a <C-r>=vim_helpers#Vword()<CR><CR> | |
command! -nargs=+ -complete=customlist,<SID>CscopeSearchTypes CsFind cscope find <args> | |
command! -nargs=+ -complete=customlist,<SID>CscopeSearchTypes ScsFind scscope find <args> | |
command! -nargs=+ -complete=customlist,<SID>CscopeSearchTypes VcsFind vertical scscope find <args> | |
function! s:CscopeSearchTypes(A, L, P) abort | |
let parts = split(a:L, '\s\+') | |
if len(parts) == 1 | |
return ['s', 'g', 'd', 'c', 't', 'e', 'f', 'i', 'a'] | |
elseif len(parts) == 2 | |
let l:list = [expand('<cword>'), expand('<cWORD>'), expand('<cfile>')] | |
let l:list = uniq(sort(l:list)) | |
return map(l:list, "escape(v:val, '#%')") | |
endif | |
return [] | |
endfunction | |
endif | |
if s:IsPlugged('tagbar') | |
" majutsushi/tagbar | |
let g:tagbar_sort = 0 | |
let g:tagbar_autofocus = 1 | |
let g:tagbar_autoclose = 0 | |
let g:tagbar_iconchars = ['▶', '▼'] | |
let g:tagbar_ctags_bin = g:zero_vim_ctags_bin | |
let g:tagbar_universal_ctags = g:zero_vim_universal_ctags | |
nnoremap <silent> <Leader>T :TagbarToggle<CR> | |
endif | |
if s:IsPlugged('vista.vim') | |
" liuchenxu/vista.vim | |
let g:vista#renderer#enable_icon = 0 | |
let g:vista_ctags_executable = g:zero_vim_ctags_bin | |
if g:zero_vim_universal_ctags && filereadable(g:zero_vim_ctags_ignore) | |
let g:vista_ctags_project_opts = '--exclude=@' . g:zero_vim_ctags_ignore | |
endif | |
let g:vista#executives = ['ctags'] | |
if s:IsPlugged('ale') | call add(g:vista#executives, 'ale') | endif | |
if s:IsPlugged('coc.nvim') | call add(g:vista#executives, 'coc') | endif | |
if s:IsPlugged('nvim-lspconfig') | call add(g:vista#executives, 'nvim_lsp') | endif | |
if s:IsPlugged('vim-lsp') | call add(g:vista#executives, 'vim_lsp') | endif | |
if s:IsPlugged('vim-lsc') | call add(g:vista#executives, 'vim_lsc') | endif | |
if s:IsPlugged('LanguageClient-neovim') | call add(g:vista#executives, 'lcn') | endif | |
endif | |
if s:IsPlugged('vim-fugitive') | |
" tpope/vim-fugitive | |
let g:fugitive_legacy_commands = 0 | |
nnoremap <Leader>gi :Git add -p %<CR> | |
nnoremap <Leader>ga :Git add -p<CR> | |
nnoremap <silent> <Leader>gs :Git<CR> | |
nnoremap <silent> <Leader>gd :Gdiffsplit<CR> | |
nnoremap <silent> <Leader>gc :Git commit<CR> | |
nnoremap <silent> <Leader>gb :Git blame<CR> | |
nnoremap <Leader>ge :Gedit<Space> | |
nnoremap <silent> <Leader>gr :Gread<CR> | |
nnoremap <silent> <Leader>gw :Gwrite<CR> | |
nnoremap <silent> <Leader>gx :Gwq <Bar> redraw<CR> | |
nnoremap <silent> <Leader>gf :Git fetch<CR> | |
nnoremap <silent> <Leader>gp :Git push<CR> | |
nnoremap <silent> <Leader>gu :Git pull --rebase<CR> | |
nnoremap <silent> <Leader>gh :echo "Branch: " . FugitiveHead()<CR> | |
" Git Grep | |
if g:zero_vim_use_git_grep | |
nnoremap <Leader>G :Gcgrep!<Space> | |
xnoremap <Leader>G <Esc>:Gcgrep! <C-r>=vim_helpers#VwordForGrep()<CR><Space> | |
nnoremap <silent> <Leader>sg :Gcgrep! <C-r>=vim_helpers#CCwordForGrep()<CR><CR><CR> | |
xnoremap <silent> <Leader>sg <Esc>:Gcgrep! <C-r>=vim_helpers#VwordForGrep()<CR><CR><CR> | |
nnoremap <silent> <Leader>bg :Glgrep! <C-r>=vim_helpers#CCwordForGrep()<CR><CR><CR> | |
xnoremap <silent> <Leader>bg <Esc>:Glgrep! <C-r>=vim_helpers#VwordForGrep()<CR><CR><CR> | |
nnoremap <silent> <Leader>.g :Gcgrep! <C-r>=vim_helpers#WordForGrep()<CR><CR><CR> | |
endif | |
augroup MyAutoCmd | |
autocmd FileType gitcommit nnoremap <buffer> <silent> U :Git checkout -- <C-r><C-g><CR> | |
autocmd BufReadPost fugitive://* set bufhidden=delete | |
autocmd BufEnter *.git/*MSG set omnifunc= | |
augroup END | |
endif | |
if s:IsPlugged('gv.vim') | |
" junegunn/gv.vim | |
nnoremap <silent> <Leader>gk :GV<CR> | |
nnoremap <silent> <Leader>gK :GV!<CR> | |
nnoremap <silent> <Leader>gv :GV?<CR> | |
endif | |
if s:IsPlugged('git-messenger.vim') | |
" rhysd/git-messenger.vim | |
let g:git_messenger_always_into_popup = v:true | |
endif | |
if s:IsPlugged('vim-gitgutter') | |
" airblade/vim-gitgutter | |
let g:gitgutter_enabled = g:zero_vim_git_gutter | |
let g:gitgutter_map_keys = 0 | |
if executable('rg') | |
let g:gitgutter_grep = 'rg --color=never' | |
let $GREP_OPTIONS = '' | |
endif | |
nmap [c <Plug>(GitGutterPrevHunk) | |
nmap ]c <Plug>(GitGutterNextHunk) | |
nnoremap <silent> yog :GitGutterToggle<CR>:echo printf('%s GitGutter!', g:gitgutter_enabled ? 'Enabled' : 'Disabled')<CR> | |
endif | |
if s:IsPlugged('vim-signify') | |
" mhinz/vim-signify | |
let g:signify_disable_by_default = !g:zero_vim_git_gutter | |
let g:signify_vcs_list = ['git', 'hg'] | |
let g:signify_cursorhold_insert = 0 | |
let g:signify_cursorhold_normal = 0 | |
let g:signify_update_on_bufenter = 0 | |
let g:signify_update_on_focusgained = 0 | |
nnoremap <silent> yog :SignifyToggle<CR>echo printf('%s Signify on buffer!', get(b:, 'sy', { 'active': 0 }).active ? 'Enabled' : 'Disabled')<CR> | |
endif | |
if s:IsPlugged('committia.vim') | |
" rhysd/committia.vim | |
let g:committia_hooks = {} | |
function! g:committia_hooks.edit_open(info) | |
" Additional settings | |
setlocal spell | |
" " If no commit message, start with insert mode | |
" if a:info.vcs ==# 'git' && getline(1) ==# '' | |
" startinsert | |
" endif | |
" Scroll the diff window | |
nmap <buffer> <C-f> <Plug>(committia-scroll-diff-down-page) | |
nmap <buffer> <C-b> <Plug>(committia-scroll-diff-up-page) | |
nmap <buffer> <C-d> <Plug>(committia-scroll-diff-down-half) | |
nmap <buffer> <C-u> <Plug>(committia-scroll-diff-up-half) | |
endfunction | |
endif | |
if s:IsPlugged('vim-hardtime') | |
" takac/vim-hardtime | |
let g:hardtime_default_on = 1 | |
let g:hardtime_showmsg = 1 | |
let g:list_of_visual_keys = ['h', 'j', 'k', 'l', '<UP>', '<DOWN>', '<LEFT>', '<RIGHT>'] | |
let g:list_of_normal_keys = ['h', 'j', 'k', 'l', '<UP>', '<DOWN>', '<LEFT>', '<RIGHT>'] | |
endif | |
" tpope/vim-markdown | |
let g:markdown_fenced_languages = [ | |
\ 'bash=sh', | |
\ 'sass', | |
\ 'scss', | |
\ 'css', | |
\ 'html', | |
\ 'xml', | |
\ 'erb=eruby', | |
\ 'ruby', | |
\ 'javascript', | |
\ 'js=javascript', | |
\ 'json=javascript', | |
\ 'python', | |
\ 'sql', | |
\ 'vim', | |
\ ] | |
" pangloss/vim-javascript | |
let g:javascript_plugin_jsdoc = 1 | |
let g:javascript_plugin_flow = 0 | |
if s:IsPlugged('vim-rails') | |
" tpope/vim-rails | |
nnoremap <silent> <Leader>ba :AE<CR> | |
nnoremap <silent> <Leader>br :RE<CR> | |
let g:rails_projections = { | |
\ "app/controllers/*_controller.rb": { | |
\ "alternate": [ | |
\ "spec/requests/{}_spec.rb", | |
\ "spec/requests/{}_request_spec.rb", | |
\ "spec/requests/{}_controller_spec.rb", | |
\ "spec/controllers/{}_controller_spec.rb", | |
\ ], | |
\ }, | |
\ "spec/requests/*_request_spec.rb": { | |
\ "alternate": [ | |
\ "app/controllers/{}_controller.rb", | |
\ ] | |
\ }, | |
\ "spec/requests/*_spec.rb": { | |
\ "alternate": [ | |
\ "app/controllers/{}.rb", | |
\ "app/controllers/{}_controller.rb", | |
\ ] | |
\ }, | |
\ "spec/routing/*_routing_spec.rb": { | |
\ "alternate": [ | |
\ "app/controllers/{}_controller.rb", | |
\ ] | |
\ }, | |
\ "spec/routing/*_spec.rb": { | |
\ "alternate": [ | |
\ "app/controllers/{}.rb", | |
\ "app/controllers/{}_controller.rb", | |
\ ] | |
\ }, | |
\ } | |
endif | |
if s:IsPlugged('vim-reek') | |
" phongnh/vim-reek | |
let g:reek_always_show = 1 | |
let g:reek_line_limit = 1000 | |
let g:reek_on_loading = 0 | |
augroup MyAutoCmd | |
autocmd FileType ruby nnoremap <silent> <Leader>re :RunReek<CR> | |
augroup END | |
endif | |
if s:IsPlugged('vim-go') | |
" fatih/vim-go and phongnh/go-explorer | |
let g:go_fmt_command = 'goimports' | |
let g:go_fmt_fail_silently = 1 | |
" Use completion from LSP plugin instead of go#complete#Complete except for coc.nvim | |
if s:IsPlugged('coc.nvim') | |
let g:go_code_completion_enabled = 1 | |
elseif s:IsLSPEnabled() || s:IsPlugged('YouCompleteMe') | |
let g:go_gopls_enabled = 1 | |
let g:go_code_completion_enabled = 0 | |
endif | |
let g:go_highlights_enabled = 0 | |
" These highlights are enabled by default | |
" let g:go_highlight_string_spellcheck = 1 | |
" let g:go_highlight_format_strings = 1 | |
" let g:go_highlight_diagnostic_errors = 1 | |
" let g:go_highlight_diagnostic_warnings = 1 | |
" let g:go_highlight_debug = 1 | |
function! s:ToggleGoHighlights() abort | |
let g:go_highlights_enabled = !g:go_highlights_enabled | |
" let g:go_highlight_array_whitespace_error = g:go_highlights_enabled | |
" let g:go_highlight_chan_whitespace_error = g:go_highlights_enabled | |
let g:go_highlight_extra_types = g:go_highlights_enabled | |
" let g:go_highlight_space_tab_error = g:go_highlights_enabled | |
" let g:go_highlight_trailing_whitespace_error = g:go_highlights_enabled | |
" let g:go_highlight_operators = g:go_highlights_enabled | |
let g:go_highlight_functions = g:go_highlights_enabled | |
let g:go_highlight_function_parameters = g:go_highlights_enabled | |
let g:go_highlight_function_calls = g:go_highlights_enabled | |
let g:go_highlight_fields = g:go_highlights_enabled | |
let g:go_highlight_types = g:go_highlights_enabled | |
let g:go_highlight_build_constraints = g:go_highlights_enabled | |
let g:go_highlight_generate_tags = g:go_highlights_enabled | |
" let g:go_highlight_variable_assignments = g:go_highlights_enabled | |
" let g:go_highlight_variable_declarations = g:go_highlights_enabled | |
confirm edit | |
redraw! | |
echo printf('%s highlights!', g:go_highlights_enabled ? 'Enabled' : 'Disabled') | |
endfunction | |
command! ToggleGoHighlights call <SID>ToggleGoHighlights() | |
function! s:BuildGoFiles() | |
let l:file = expand('%') | |
if l:file =~# '^\f\+_test\.go$' | |
call go#test#Test(0, 1) | |
elseif l:file =~# '^\f\+\.go$' | |
call go#cmd#Build(0) | |
endif | |
endfunction | |
function! s:SetupVimGo() abort | |
" :GoAlternate commands :A, :AV, :AS and :AT | |
command! -buffer -bang A call go#alternate#Switch(<bang>0, 'edit') | |
command! -buffer -bang AV call go#alternate#Switch(<bang>0, 'vsplit') | |
command! -buffer -bang AS call go#alternate#Switch(<bang>0, 'split') | |
command! -buffer -bang AT call go#alternate#Switch(<bang>0, 'tabe') | |
nnoremap <buffer> <silent> <Plug>(go-smart-build) :<C-u>call <SID>BuildGoFiles()<CR> | |
if empty(mapcheck('<Plug>(go-run-split)')) | |
nnoremap <buffer> <silent> <Plug>(go-run-split) :<C-u>GoRun!<CR>:redraw!<CR> | |
endif | |
nmap <buffer> <Leader>rr <Plug>(go-run) | |
nmap <buffer> <Leader>ru <Plug>(go-run-split) | |
nmap <buffer> <Leader>rb <Plug>(go-smart-build) | |
nmap <buffer> <Leader>rt <Plug>(go-test) | |
nmap <buffer> <Leader>rf <Plug>(go-test-func) | |
nmap <buffer> <Leader>rc <Plug>(go-coverage-toggle) | |
nmap <buffer> <Leader>ri <Plug>(go-info) | |
nmap <buffer> <Leader>r< <Plug>(go-imports) | |
nmap <buffer> <Leader>re <Plug>(go-rename) | |
if s:IsPlugged('ctrlp.vim') || s:IsPlugged('fzf.vim') | |
nmap <buffer> <Leader>ro <Plug>(go-decls-dir) | |
endif | |
nmap <buffer> <Leader>r] <Plug>(go-def) | |
nmap <buffer> <Leader>r[ <Plug>(go-def-type) | |
nmap <buffer> <Leader>rd <Plug>(go-doc-vertical) | |
nmap <buffer> <Leader>rs <Plug>(go-doc-split) | |
nmap <buffer> <Leader>rg <Plug>(go-doc-browser) | |
nmap <buffer> <Leader>rl <Plug>(go-metalinter) | |
nmap <buffer> <Leader>ra <Plug>(go-alternate-edit) | |
nmap <buffer> <Leader>ba <Plug>(go-alternate-edit) | |
nnoremap <buffer> g< :GoImport<Space> | |
nnoremap <buffer> g> :GoDrop<Space> | |
nnoremap <buffer> <Leader>rk :GoDocBrowser<Space> | |
nnoremap <buffer> <silent> <Leader>rh :ToggleGoHighlights<CR> | |
endfunction | |
function! s:SetupVimGoMod() abort | |
nnoremap <buffer> <silent> <Leader>bu :update<CR>:GoModFmt<CR> | |
endfunction | |
augroup MyAutoCmd | |
autocmd BufEnter go.mod if &filetype ==# 'lprolog' | setfiletype gomod | endif | |
autocmd FileType gomod call s:SetupVimGoMod() | |
autocmd FileType go call s:SetupVimGo() | |
augroup END | |
endif | |
if s:IsPlugged('vim-elixir') | |
" elixir-editors/vim-elixir | |
endif | |
if s:IsPlugged('vim-mix-format') | |
" mhinz/vim-mix-format | |
let g:mix_format_on_save = 0 | |
function! s:SetupMixFormat() abort | |
nnoremap <buffer> <silent> <Leader>bu :update<CR>:MixFormat<CR> | |
nnoremap <buffer> <silent> <Leader>bU :update<CR>:MixFormatDiff<CR> | |
endfunction | |
augroup MyAutoCmd | |
autocmd FileType elixir call s:SetupMixFormat() | |
augroup END | |
endif | |
if s:IsPlugged('vim-polyglot') | |
" sheerun/vim-polyglot | |
" plasticboy/vim-markdown | |
let g:vim_markdown_no_default_key_mappings = 1 | |
let g:vim_markdown_fenced_languages = [ | |
\ "c++=cpp", | |
\ 'bash=sh', | |
\ 'erb=eruby', | |
\ 'js=javascript', | |
\ 'json=javascript', | |
\ 'viml=vim', | |
\ ] | |
endif | |
if s:IsPlugged('vim-polyglot') || s:IsPlugged('vim-terraform') | |
" hashivim/vim-terraform | |
augroup MyAutoCmd | |
autocmd FileType terraform nnoremap <buffer> <silent> <Leader>bu :TerraformFmt<CR>:update<CR> | |
augroup END | |
endif | |
" vim-test/vim-test | |
function! Neovim2Strategy(cmd) abort | |
if g:test#neovim_mode ==? 's' | |
let win = 'botright new' | |
elseif g:test#neovim_mode ==? 'v' | |
let win = 'vertical new' | |
elseif g:test#neovim_mode ==? 't' | |
let win = 'tabnew' | |
else | |
let win = 'botright 15new' | |
endif | |
execute win | call termopen(a:cmd) | startinsert | |
endfunction | |
let g:test#custom_strategies = { 'neovim2': function('Neovim2Strategy') } | |
let g:test#strategy = 'neovim2' | |
let g:test#neovim_mode = 'd' | |
if s:IsPlugged('vim-tmuxify') | |
let g:test#preserve_screen = 0 | |
let g:test#strategy = 'tmuxify' | |
endif | |
nnoremap <silent> <Leader>tt :TestFile<CR> | |
nnoremap <silent> <Leader>tf :TestNearest<CR> | |
nmap <Leader>tn <Leader>tf | |
nnoremap <silent> <Leader>tl :TestLast<CR> | |
nnoremap <silent> <Leader>ts :TestSuite<CR> | |
nnoremap <silent> <Leader>tv :TestVisit<CR> | |
if s:IsPlugged('nvim-treesitter') | |
" nvim-treesitter/nvim-treesitter | |
function! s:InitTreesitter() abort | |
try | |
lua << EOF | |
require'nvim-treesitter.configs'.setup { | |
ensure_installed = "maintained", | |
highlight = { | |
enable = true, | |
use_languagetree = false, | |
disable = { "c", "ruby", "rust" }, | |
}, | |
incremental_selection = { | |
enable = true, | |
keymaps = { | |
init_selection = "sn", | |
node_incremental = "sn", | |
scope_incremental = "sc", | |
node_decremental = "sp", | |
}, | |
}, | |
indent = { | |
enable = true, | |
}, | |
refactor = { | |
highlight_definitions = { | |
enable = false, | |
}, | |
highlight_current_scope = { | |
enable = false, | |
}, | |
smart_rename = { | |
enable = true, | |
keymaps = { | |
smart_rename = "sr", | |
} | |
}, | |
navigation = { | |
enable = true, | |
keymaps = { | |
goto_definition = "sd", | |
list_definitions = "sl", | |
list_definitions_toc = "sc", | |
goto_next_usage = "sj", | |
goto_previous_usage = "sk", | |
}, | |
}, | |
}, | |
textobjects = { | |
select = { | |
enable = true, | |
keymaps = { | |
-- You can use the capture groups defined in textobjects.scm | |
["af"] = "@function.outer", | |
["if"] = "@function.inner", | |
["ac"] = "@class.outer", | |
["ic"] = "@class.inner", | |
-- Or you can define your own textobjects like this | |
["iF"] = { | |
c = "(function_definition) @function", | |
go = "(function_definition) @function", | |
javascript = "(function_declaration) @function", | |
python = "(function_definition) @function", | |
}, | |
}, | |
}, | |
swap = { | |
enable = true, | |
swap_next = { | |
["sN"] = "@parameter.inner", | |
}, | |
swap_previous = { | |
["sP"] = "@parameter.inner", | |
}, | |
}, | |
move = { | |
enable = true, | |
goto_next_start = { | |
["]m"] = "@function.outer", | |
["]]"] = "@class.outer", | |
}, | |
goto_next_end = { | |
["]M"] = "@function.outer", | |
["]["] = "@class.outer", | |
}, | |
goto_previous_start = { | |
["[m"] = "@function.outer", | |
["[["] = "@class.outer", | |
}, | |
goto_previous_end = { | |
["[M"] = "@function.outer", | |
["[]"] = "@class.outer", | |
}, | |
}, | |
lsp_interop = { | |
enable = false, | |
}, | |
}, | |
} | |
EOF | |
catch /^Vim(lua):E5108/ | |
call s:Warn('nvim-treesitter: ' . v:exception) | |
endtry | |
endfunction | |
call s:InitTreesitter() | |
endif | |
" altercation/vim-colors-solarized | |
let g:loaded_togglebg = 1 | |
let g:solarized_menu = 0 | |
let g:solarized_termcolors = g:zero_vim_solarized || has('gui_running') ? 16 : 256 | |
let g:solarized_italic = 1 | |
augroup MyAutoCmd | |
autocmd ColorScheme solarized highlight VertSplit ctermbg=NONE guibg=NONE | |
augroup END | |
" lifepillar/vim-solarized8 | |
let g:solarized_use16 = 1 | |
let g:solarized_italics = 1 | |
let g:solarized_termtrans = g:zero_vim_transparent | |
let g:solarized_extra_hi_groups = g:zero_vim_extra_hi_groups | |
augroup MyAutoCmd | |
autocmd ColorScheme solarized8* highlight VertSplit ctermbg=NONE guibg=NONE | |
augroup END | |
" lifepillar/vim-gruvbox8 | |
let g:gruvbox_italic = 1 | |
let g:gruvbox_transp_bg = g:zero_vim_transparent | |
let g:gruvbox_filetype_hi_groups = g:zero_vim_extra_hi_groups | |
let g:gruvbox_plugin_hi_groups = g:zero_vim_extra_hi_groups | |
" sainnhe/sonokai | |
let g:sonokai_enable_italic = 0 | |
let g:sonokai_disable_italic_comment = 0 | |
let g:sonokai_transparent_background = g:zero_vim_transparent | |
" mhartington/oceanic-next | |
let g:oceanic_next_terminal_bold = 1 | |
let g:oceanic_next_terminal_italic = 1 | |
" junegunn/seoul256.vim | |
let g:seoul256_background = 236 | |
let g:seoul256_light_background = 252 | |
let g:seoul256_srgb = has('linux') | |
if s:IsPlugged('glyph-palette.vim') | |
" lambdalisue/glyph-palette.vim | |
augroup MyAutoCmd | |
autocmd FileType fern,vaffle call glyph_palette#apply() | |
if s:IsPlugged('vim-devicons') | |
autocmd FileType nerdtree,startify call glyph_palette#apply() | |
endif | |
augroup END | |
endif | |
if s:IsPlugged('vim-which-key') | |
" liuchengxu/vim-which-key | |
let g:which_key_exit = ["\<C-[>", "\<ESC>", "\<C-G>"] | |
let g:which_key_map = { | |
\ 'w': 'save-buffer', | |
\ 'x': 'save-and-close-buffer', | |
\ 'n': 'open-selected-region', | |
\ 'S': 'search-prompt', | |
\ 'B': 'buffer-search-prompt', | |
\ 'F': 'ctrlsf-search-prompt', | |
\ 'G': 'git-grep-prompt', | |
\ 'R': 'replace-prompt', | |
\ 'V': 'subvert-replace-prompt', | |
\ 'a': 'all-files', | |
\ 'f': 'files', | |
\ 'p': 'buffer-project', | |
\ 'o': 'opening-buffers', | |
\ 'O': 'recent-files', | |
\ 'd': 'files-in-buffer-dir', | |
\ 'W': 'opening-windows/tabs', | |
\ '\': 'tags', | |
\ ';': 'command-palette', | |
\ ':': 'command-history', | |
\ '/': 'search-history', | |
\ 'l': 'location-list', | |
\ 'q': 'quickfix', | |
\ } | |
let g:which_key_map.i = { 'name': '+insert-date-time' } | |
call extend(g:which_key_map.i, { | |
\ 'd': 'insert-current-date', | |
\ 'c': 'insert-current-time', | |
\ 'r': 'insert-rfc822-time', | |
\ 't': 'insert-iso8601-time', | |
\ }) | |
let g:which_key_map.b = { 'name': '+buffer' } | |
call extend(g:which_key_map.b, { | |
\ 'e': 'reload-buffer', | |
\ 'w': 'save-buffer', | |
\ 'x': 'save-and-close-buffer', | |
\ 'u': 'save-and-format-buffer', | |
\ 'k': 'delete-buffer', | |
\ 'm': 'maximize-buffer', | |
\ 'y': 'copy-buffer-to-clipboard', | |
\ 'n': 'open-selected-region', | |
\ 'b': 'opening-buffers', | |
\ 'd': 'files-in-buffer-dir', | |
\ 'p': 'buffer-project', | |
\ 't': 'buffer-tags', | |
\ 'o': 'buffer-outline', | |
\ 'l': 'buffer-lines', | |
\ 'a': 'buffer-alternative', | |
\ 'r': 'buffer-related', | |
\ 's': 'buffer-search-cword', | |
\ 'c': 'buffer-search-word', | |
\ '/': 'buffer-search-pattern-from-/', | |
\ '?': 'buffer-search-pattern-from-/-prompt', | |
\ 'g': 'buffer-git-grep-cword', | |
\ 'h': 'toggle-bracket-highlight', | |
\ }) | |
let g:which_key_map.s = { 'name': '+search/replace' } | |
call extend(g:which_key_map.s, { | |
\ 's': 'search-cword', | |
\ 'c': 'search-word', | |
\ 'p': 'search-cword-in-repo-or-cwd', | |
\ 'd': 'search-cword-in-buffer-dir', | |
\ '/': 'search-pattern-from-/', | |
\ '?': 'search-pattern-from-/-prompt', | |
\ 'f': 'ctrlsf-search-cword', | |
\ 'w': 'ctrlsf-search-word', | |
\ 'h': 'ctrlsf-search-cword-horizontally', | |
\ 'o': 'ctrlsf-search-cword-in-repo-or-cwd', | |
\ 'u': 'ctrlsf-search-update', | |
\ 't': 'toogle-ctrlsf-search-result', | |
\ 'g': 'git-grep-cword', | |
\ 'e': 'search-cword-fuzzy', | |
\ 'r': 'replace-cword-prompt', | |
\ 'v': 'subvert-replace-cword-prompt', | |
\ }) | |
if s:IsPlugged('any-jump.vim') | |
call extend(g:which_key_map.s, { | |
\ 'a': 'any-jump', | |
\ 'j': 'any-jump', | |
\ 'l': 'any-jump-last-results', | |
\ 'k': 'any-jump-last-results', | |
\ 'b': 'any-jump-back', | |
\ }) | |
let g:which_key_map.s.name = '+search/any-jump/replace' | |
endif | |
let g:which_key_map['.'] = { 'name': '+word-search/word-replace' } | |
call extend(g:which_key_map['.'], { | |
\ 's': 'word-search', | |
\ 'S': 'word-search-prompt', | |
\ 'p': 'word-search-in-repo-or-cwd', | |
\ 'd': 'word-search-in-buffer-dir', | |
\ 'b': 'buffer-word-search', | |
\ 'B': 'buffer-word-search-prompt', | |
\ 'f': 'ctrlsf-word-search', | |
\ 'F': 'ctrlsf-word-search-prompt', | |
\ 'h': 'ctrlsf-word-search-horizontally', | |
\ 'o': 'ctrlsf-word-search-in-repo-or-cwd', | |
\ 'g': 'git-grep-word', | |
\ 'r': 'word-replace', | |
\ 'v': 'subvert-word-replace', | |
\ }) | |
let g:which_key_map.r = { 'name': '+replace/rubocop' } | |
call extend(g:which_key_map.r, { | |
\ 'r': 'replace-cword-prompt', | |
\ 'v': 'subvert-replace-cword-prompt', | |
\ }) | |
let g:which_key_map.t = { 'name': '+test' } | |
call extend(g:which_key_map.t, { | |
\ 't': 'run-all-tests-in-current-file', | |
\ 'f': 'run-test-nearest-to-current-cursor', | |
\ 'n': 'run-test-nearest-to-current-cursor', | |
\ 'l': 'run-last-test', | |
\ 's': 'run-whole-test-suite', | |
\ 'v': 'visit-last-test', | |
\ }) | |
let g:which_key_map.g = { 'name': '+git' } | |
call extend(g:which_key_map.g, { | |
\ 't': 'tig-status', | |
\ }) | |
if s:IsPlugged('vim-tmuxify') | |
let g:which_key_map.m = { 'name': '+tmuxify' } | |
call extend(g:which_key_map.m, { | |
\ 'b': 'send-<ctrl-c>', | |
\ 'c': 'send-<ctrl-l>', | |
\ 'C': 'send-clear', | |
\ 'f': 'send-clear', | |
\ 'n': 'create-and-associate-with-pane', | |
\ 'p': 'associate-with-existing-pane', | |
\ 'q': 'close-associated-pane', | |
\ 'r': 'send-text-prompt', | |
\ 't': 'create-pane', | |
\ 'i': 'send-prompt-input', | |
\ 's': 'send-paragraph', | |
\ 'S': 'send-buffer', | |
\ 'l': 'send-line', | |
\ 'w': 'send-word', | |
\ 'a': 'resend-last-text', | |
\ 'k': 'send-key-prompt', | |
\ 'e': 'send-<q>', | |
\ 'x': 'send-<q>', | |
\ 'm': 'send-<enter>', | |
\ 'd': 'send-<ctrl-d>', | |
\ }) | |
let g:which_key_map.v = extend(copy(g:which_key_map.m), { 'name': '+tmuxify-buffer/plug' }) | |
endif | |
if s:IsPlugged('nerdcommenter') | |
let g:which_key_map.c = { 'name': '+comment' } | |
call extend(g:which_key_map.c, { | |
\ ' ': 'toggle-comment', | |
\ 'i': 'toggle-comment-individually', | |
\ 'c': 'comment', | |
\ 'a': 'comment-with-alternate-delimiters', | |
\ 'l': 'comment-align-left', | |
\ 'b': 'comment-align-both', | |
\ 'n': 'comment-line-nesting', | |
\ 'm': 'comment-minimal', | |
\ 's': 'comment-sexily', | |
\ '$': 'comment-from-cursor-to-eol', | |
\ 'y': 'yank-and-comment', | |
\ 'u': 'uncomment-current-line', | |
\ 'A': 'add-comment-to-eol', | |
\ }) | |
endif | |
if s:IsPlugged('indentLine') || s:IsPlugged('vim-indent-guides') | |
let g:which_key_map['b']['i'] = 'toggle-indent-guide' | |
endif | |
if s:IsPlugged('vim-startify') | |
let g:which_key_map['H'] = 'toggle-start-screen' | |
endif | |
if s:IsPlugged('goyo.vim') | |
call extend(g:which_key_map, { | |
\ '<CR>': 'toggle-distraction-free-writing', | |
\ 'L': 'toggle-hyperfocus-writing', | |
\ }) | |
endif | |
if s:IsPlugged('gundo.vim') || s:IsPlugged('vim-mundo') || s:IsPlugged('undotree') | |
let g:which_key_map['U'] = 'toggle-undo-tree' | |
endif | |
if s:IsPlugged('fern.vim') || s:IsPlugged('vaffle.vim') || s:IsPlugged('nerdtree') | |
call extend(g:which_key_map, { | |
\ 'e': 'toggle-explorer', | |
\ 'E': 'open-explorer-in-cwd', | |
\ }) | |
let g:which_key_map['b']['f'] = 'find-buffer-in-explorer' | |
endif | |
if s:IsPlugged('vim-autoformat') | |
call extend(g:which_key_map, { | |
\ 'A': 'auto-format-buffer', | |
\ '=': 'auto-format-buffer', | |
\ }) | |
endif | |
if s:IsPlugged('vim-autoformat') || s:IsPlugged('ale') | |
let g:which_key_map['b']['='] = 'auto-format-buffer' | |
endif | |
if s:IsPlugged('ale') || s:IsPlugged('neomake') || s:IsPlugged('syntastic') | |
let g:which_key_map['b']['v'] = 'verify-buffer-syntax' | |
endif | |
if s:IsPlugged('vim-prettier') | |
let g:which_key_map['P'] = 'prettier' | |
endif | |
if s:IsPlugged('tagbar') | |
let g:which_key_map['T'] = 'toggle-tagbar' | |
endif | |
if s:IsPlugged('vim-fugitive') | |
call extend(g:which_key_map.g, { | |
\ 'i': 'stage-current-file-interactive', | |
\ 'a': 'stage-all-files-interactive', | |
\ 's': 'status', | |
\ 'd': 'diff', | |
\ 'c': 'commit', | |
\ 'b': 'blame', | |
\ 'e': 'edit-prompt', | |
\ 'r': 'reset-file', | |
\ 'w': 'save-and-stage-current-file', | |
\ 'x': 'save-and-stage-current-file-and-quit', | |
\ 'f': 'fetch', | |
\ 'p': 'push', | |
\ 'u': 'pull-and-rebase', | |
\ 'h': 'print-git-branch', | |
\ 'k': 'commit-browser', | |
\ 'K': 'current-file-commit-browser', | |
\ 'v': 'current-file-revisions', | |
\ }) | |
endif | |
if s:IsPlugged('git-messenger.vim') | |
let g:which_key_map['g']['m'] = 'git-messenger' | |
endif | |
if s:IsPlugged('vim-rubocop') | |
call extend(g:which_key_map.r, { | |
\ 'u': 'run-rubocop', | |
\ 'p': 'run-rubocop-for-project', | |
\ }) | |
endif | |
call which_key#register('<Space>', 'g:which_key_map') | |
nnoremap <silent> <Leader> :<C-u>WhichKey '<Space>'<CR> | |
vnoremap <silent> <Leader> :<C-u>WhichKeyVisual '<Space>'<CR> | |
endif | |
" Find and source .init.vim.local from root to current folder | |
call s:Source('.init.vim.local') | |
" Default colorscheme | |
let g:zero_vim_default_colorscheme = g:zero_vim_true_color ? 'gruvbox8' : 'gruvbox' | |
try | |
if exists('g:zero_vim_colorscheme') | |
if exists('g:zero_vim_background') | |
execute 'set background=' . g:zero_vim_background | |
endif | |
execute 'colorscheme ' . g:zero_vim_colorscheme | |
else | |
set background=dark | |
execute 'colorscheme ' . g:zero_vim_default_colorscheme | |
endif | |
catch | |
set background=dark | |
execute 'colorscheme ' . g:zero_vim_default_colorscheme | |
endtry | |
set secure |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment