Created
April 16, 2021 18:17
-
-
Save faraazkhan/36b49bcae9e8fe1c44f34639040a4ca8 to your computer and use it in GitHub Desktop.
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
"https://github.com/golang/tools/blob/master/gopls/doc/settings.md#buildflags-string Specify a directory for plugins | |
" - For Neovim: ~/.local/share/nvim/plugged | |
" - Avoid using standard Vim directory names like 'plugin' | |
call plug#begin('~/.local/share/nvim/plugged') | |
Plug 'neoclide/coc.nvim' | |
Plug 'fatih/vim-go', { 'for': ['go'] } | |
Plug 'Chiel92/vim-autoformat' | |
Plug 'tsandall/vim-rego' | |
Plug 'google/vim-jsonnet' | |
Plug 'ekalinin/Dockerfile.vim' | |
Plug 'editorconfig/editorconfig-vim' | |
Plug '~/developer/personal/aws-cfn-snippet.vim' | |
Plug 'zhaocai/GoldenView.Vim' | |
Plug 'yssl/QFEnter' | |
Plug 'w0rp/ale' | |
Plug 'pearofducks/ansible-vim', {'for': ['yaml'] } | |
Plug 'phenomenes/ansible-snippets', {'for': ['yaml'] } | |
Plug 'jiangmiao/auto-pairs' | |
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app & yarn install', 'for': ['markdown', 'vim-plug'] } | |
" Plug 'flazz/vim-colorschemes' | |
Plug 'neomake/neomake' | |
Plug '/usr/local/opt/fzf' | |
Plug 'junegunn/fzf.vim' | |
Plug 'haya14busa/incsearch-easymotion.vim' | |
Plug 'haya14busa/incsearch-fuzzy.vim' | |
Plug 'haya14busa/incsearch.vim' | |
Plug 'Yggdroot/indentLine' | |
Plug 'tomasr/molokai' | |
"Plug 'lifepillar/vim-solarized8' | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } | |
Plug 'roxma/nvim-yarp' | |
Plug 'kien/rainbow_parentheses.vim' | |
Plug 'AndrewRadev/splitjoin.vim' | |
Plug 'majutsushi/tagbar' | |
"Plug 'SirVer/ultisnips' | |
Plug 'mbbill/undotree' | |
" Plug 'c9s/vikube.vim' | |
Plug 'vim-airline/vim-airline' | |
Plug 'christianrondeau/vim-base64' | |
Plug 'junegunn/vim-easy-align' | |
Plug 'easymotion/vim-easymotion' | |
Plug 'terryma/vim-expand-region' | |
Plug 'tpope/vim-fugitive' | |
Plug 'hashivim/vim-hashicorp-tools' | |
Plug 'roxma/vim-hug-neovim-rpc' | |
Plug 'honza/vim-snippets' | |
Plug 'tpope/vim-surround' | |
Plug 'juliosueiras/vim-terraform-completion', { 'for': 'terraform' } | |
Plug 'elzr/vim-json', { 'for': 'json' } | |
Plug 'prettier/vim-prettier', {'do': 'yarn install', 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'yaml', 'html'] } | |
Plug 'andrewstuart/vim-kubernetes', { 'for': 'yaml' } | |
Plug 'sebosp/vim-snippets-terraform', { 'for': 'terraform' } | |
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' } | |
Plug 'leafgarland/typescript-vim' | |
Plug 'rhysd/vim-grammarous', { 'for': 'markdown' } | |
call plug#end() | |
" Turn off toolbar for macvim | |
if has("gui_running") | |
set guioptions=emgrt | |
endif | |
" http://springest.io/vim-font-size-depending-screen-size | |
" Set font size based on screen size. When vertical height is greater than 900 | |
" (i.e. an external monitor is attached on 13" or smaller MacBooks), use 22, else use 16 | |
"if has('mac') | |
"if system("osascript -e 'tell application \"Finder\" to get bounds of window of desktop' | cut -d ' ' -f 4") > 900 | |
"set guifont=Menlo\ Regular:h22 | |
"else | |
"set guifont=Menlo\ Regular:h16 | |
"endif | |
"endif | |
" Basic Vim Settings | |
syntax enable | |
syntax sync minlines=256 | |
filetype off | |
filetype plugin indent on | |
colorscheme molokai | |
highlight Comment cterm=italic gui=italic | |
scriptencoding utf-8 | |
set mmp=10000 | |
set background=dark | |
set colorcolumn=120 "highlight this column so you can break line | |
set ttyfast "faster terminal connection | |
set laststatus=2 "always show statusline | |
set encoding=utf-8 "set default encoding | |
set autoread "auto read changed files | |
set autowrite "auto write changed files | |
set backspace=indent,eol,start "meaningful backspace | |
set cmdheight=2 "give more space for displaying messages | |
set updatetime=300 | |
set shortmess+=c | |
set noerrorbells "No beeps | |
set number "show line numbers | |
set showcmd "show what I am typing | |
set noshowmode "we use airline | |
set noswapfile "dont use swapfile | |
set nobackup "no backups! | |
set nowritebackup | |
set signcolumn=yes | |
set nocompatible "Enables vim specific features | |
set hidden " buffer should exist if window is closed | |
set fileformats=unix,dos,mac "Prefer unix over windows over OS 9 formats | |
set history=100 | |
set mouse=a " Automatically enable mouse usage | |
set mousehide " Hide the mouse cursor while typing | |
set completeopt=menu,menuone "show popup menu even with one match | |
set pumheight=10 "max height for completion window | |
set nocursorcolumn " do not highlight column | |
set nocursorline " do not highlight line | |
set lazyredraw "wait to redraw | |
set t_Co=256 "enable 256 colors | |
set synmaxcol=300 | |
set re=1 | |
set termguicolors | |
set showmatch " show matching parentheses | |
set foldmethod=syntax "fold based on syntax | |
set foldnestmax=10 "deepest fold is 10 levels | |
set nofoldenable "dont fold by default | |
set foldlevel=1 "what I use right now | |
set wildignore+=*/vcr_cassettes/*,*/bundle_vendor/*,*/node_modules/*,*/tmp/*,*/log/*,*.iso,*.box,packer_cache/*,output-*,*/.git/*,*/vendor/* "ignore these dirs when searching or with NerdTree | |
set nowrap | |
set splitright "Puts new vsplit to the right | |
set splitbelow "Puts new hsplit to the bottom | |
set tags=tags;/ "Set tags in current directory or parent dir | |
" Dont like molokai's settings for Visual mode | |
hi Visual term=reverse cterm=reverse guibg=Yellow guifg=#004A85 | |
" Search related settings | |
set hlsearch " vim will highlight searched words | |
set incsearch " Find as you type search | |
set ignorecase " Case insensitive search | |
set smartcase " Case sensitive when upper case present | |
set wildmenu " Show list instead of just completing | |
" Auto completion settings | |
set wildmode=list:longest,full " Command <Tab> completion, list matches, then longest common part, then all. | |
" Indentation without hard tabs | |
set autoindent "copy indent level from previous file | |
set shiftwidth=2 | |
set expandtab "tabs are spaces not tabs | |
set tabstop=2 | |
set softtabstop=2 | |
set smartindent "automatically insert extra level of indentation when appropriate | |
" yank, d, c all write to the mac clipboard | |
if has('clipboard') | |
if has('unnamedplus') " When possible use + register for copy-paste | |
set clipboard^=unnamed | |
set clipboard^=unnamedplus | |
else " On mac and Windows, use * register for copy-paste | |
set clipboard=unnamed | |
endif | |
endif | |
" Undo Stuff | |
if has('persistent_undo') | |
set undofile " So is persistent undo ... | |
set undolevels=1000 " Maximum number of changes that can be undone | |
set undoreload=10000 " Maximum number lines to save for undo on a buffer reload | |
set undodir=~/.undodir | |
endif | |
" Explicitly set python3 from coc.nvim | |
" | |
let g:python3_host_prog = '/usr/local/bin/python3' | |
" XML formatter use <leader>x to prettify xml | |
function! DoFormatXML() range | |
" Save the file type | |
let l:origft = &ft | |
" Clean the file type | |
set ft= | |
" Add fake initial tag (so we can process multiple top-level elements) | |
exe ":let l:beforeFirstLine=" . a:firstline . "-1" | |
if l:beforeFirstLine < 0 | |
let l:beforeFirstLine=0 | |
endif | |
exe a:lastline . "put ='</PrettyXML>'" | |
exe l:beforeFirstLine . "put ='<PrettyXML>'" | |
exe ":let l:newLastLine=" . a:lastline . "+2" | |
if l:newLastLine > line('$') | |
let l:newLastLine=line('$') | |
endif | |
" Remove XML header | |
exe ":" . a:firstline . "," . a:lastline . "s/<\?xml\\_.*\?>\\_s*//e" | |
" Recalculate last line of the edited code | |
let l:newLastLine=search('</PrettyXML>') | |
" Execute external formatter | |
exe ":silent " . a:firstline . "," . l:newLastLine . "!xmllint --noblanks --format --recover -" | |
" Recalculate first and last lines of the edited code | |
let l:newFirstLine=search('<PrettyXML>') | |
let l:newLastLine=search('</PrettyXML>') | |
" Get inner range | |
let l:innerFirstLine=l:newFirstLine+1 | |
let l:innerLastLine=l:newLastLine-1 | |
" Remove extra unnecessary indentation | |
exe ":silent " . l:innerFirstLine . "," . l:innerLastLine "s/^ //e" | |
" Remove fake tag | |
exe l:newLastLine . "d" | |
exe l:newFirstLine . "d" | |
" Put the cursor at the first line of the edited code | |
exe ":" . l:newFirstLine | |
" Restore the file type | |
exe "set ft=" . l:origft | |
endfunction | |
command! -range=% FormatXML <line1>,<line2>call DoFormatXML() | |
nmap <silent> <leader>x :%FormatXML<CR> | |
vmap <silent> <leader>x :FormatXML<CR> | |
" Find and Replace helpers | |
function! GlobalFindAndReplace() | |
" Build arglist with all files | |
exe ":arg % `git ls-files -co --exclude-standard *[^.*]`<CR>" | |
let find = input("Find:") | |
let replace = input("Replace:") | |
let replaceCommand = "argdo %s/" . find . "/" . replace . "/gce" | |
exe replaceCommand | |
endfunction | |
command! Replace call GlobalFindAndReplace() | |
nmap <silent> <leader>rr :Replace<C-R><C-R> | |
" When you forget to sudo, try :w!! | |
cmap w!! w !sudo tee % >/dev/null | |
" Scroll page to the right (horizontal) | |
map zl zL | |
" Scroll page to the left (horizontal) | |
map zh zH | |
" Visual linewise up and down by default (and use gj gk to go quicker) | |
noremap <Up> gk | |
noremap <Down> gj | |
noremap j gj | |
noremap k gk | |
" Search mappings: These will make it so that going to the next one in a | |
" search will center on the line it's found in. | |
nnoremap n nzzzv | |
nnoremap N Nzzzv | |
" Make double-<Esc> clear search highlights | |
nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc> | |
" Make F1 map to escape | |
map <F1> <Esc> | |
imap <F1> <Esc> | |
map <F2> <Esc> | |
imap <F2> <Esc> | |
" Yank to the end of the line | |
nnoremap Y y$ | |
" Enter automatically into the files directory | |
"autocmd BufEnter * silent! lcd %:p:h | |
" Dealing with Whitespaces, remove them on save | |
autocmd BufWritePre * :%s/\s\+$//e | |
" Uncommon file types | |
autocmd BufNewFile,BufRead *.coffee setfiletype coffee | |
autocmd BufRead,BufNewFile *.arb setfiletype ruby | |
autocmd BufRead,BufNewFile Vagrantfile setfiletype ruby | |
autocmd BufNewFile,BufRead Jenkinsfile setfiletype groovy | |
autocmd filetype crontab setlocal nobackup nowritebackup | |
autocmd BufWrite jsonnet,rego :Autoformat | |
" Adjust viewports to the same size | |
map <Leader>= <C-w>= | |
" format the entire file | |
nnoremap <leader>fef :normal! gg=G``<CR> | |
nmap <Leader>fp <Plug>(PrettierAsync) | |
autocmd FileType terraform map <buffer> <leader>fef :TerraformFmt<CR> | |
autocmd FileType xml map <buffer> <leader>fef :%FormatXML<CR> | |
" change case | |
" upper/lower word | |
nmap <leader>u mQviwU`Q | |
nmap <leader>l mQviwu`Q | |
" upper/lower first char of word | |
nmap <leader>U mQgewvU`Q | |
nmap <leader>L mQgewvu`Q | |
" Plugin Specific Settings | |
" | |
" | |
"------------------------------------------------------------------------------ | |
" FZF | |
"------------------------------------------------------------------------------ | |
" Enable per-command history. | |
" CTRL-N and CTRL-P will be automatically bound to next-history and | |
" previous-history instead of down and up. If you don't like the change, | |
" explicitly bind the keys to down and up in your $FZF_DEFAULT_OPTS. | |
let g:fzf_history_dir = '~/.local/share/fzf-history' | |
" [Buffers] Jump to the existing window if possible | |
let g:fzf_buffers_jump = 1 | |
" [[B]Commits] Customize the options used by 'git log': | |
let g:fzf_commits_log_options = '--graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr"' | |
" [Tags] Command to generate tags file | |
let g:fzf_tags_command = 'ctags -R' | |
" [Commands] --expect expression for directly executing the command | |
let g:fzf_commands_expect = 'alt-enter,ctrl-x' | |
" FZF is currently set to use ripgrep via environment variable set in ~/.zshrc | |
nnoremap <leader>p :Files<Cr> | |
nnoremap <C-g> :Rg<Cr> | |
"------------------------------------------------------------------------------ | |
" | |
" vim-terraform-completion | |
"------------------------------------------------------------------------------ | |
" (Optional) Default: 0, enable(1)/disable(0) plugin's keymapping | |
let g:terraform_completion_keys = 1 | |
" (Optional) Default: 1, enable(1)/disable(0) terraform module registry completion | |
let g:terraform_registry_module_completion = 1 | |
" | |
"------------------------------------------------------------------------------ | |
" vim tagbar when you need it | |
"------------------------------------------------------------------------------ | |
" toggle tagbar with <leader>tt | |
nnoremap <silent> <leader>tt :TagbarToggle<CR> | |
"------------------------------------------------------------------------------ | |
" Nerd Tree Dir structure | |
"------------------------------------------------------------------------------ | |
let NERDTreeHijackNetrw = 0 | |
function! s:CdIfDirectory(directory) | |
let explicitDirectory = isdirectory(a:directory) | |
let directory = explicitDirectory || empty(a:directory) | |
if explicitDirectory | |
exe "cd " . fnameescape(a:directory) | |
endif | |
" Allows reading from stdin | |
" ex: git diff | mvim -R - | |
if strlen(a:directory) == 0 | |
return | |
endif | |
if directory | |
NERDTree | |
wincmd p | |
bd | |
endif | |
if explicitDirectory | |
wincmd p | |
endif | |
endfunction | |
function! s:UpdateNERDTree(...) | |
let stay = 0 | |
if(exists("a:1")) | |
let stay = a:1 | |
end | |
if exists("t:NERDTreeBufName") | |
let nr = bufwinnr(t:NERDTreeBufName) | |
if nr != -1 | |
exe nr . "wincmd w" | |
exe substitute(mapcheck("R"), "<CR>", "", "") | |
if !stay | |
wincmd p | |
end | |
endif | |
endif | |
endfunction | |
let NERDTreeIgnore=['\.pyc$', '\.pyo$', '\.rbc$', '\.rbo$', '\.class$', '\.o$', '\~$'] | |
augroup AuNERDTreeCmd | |
"autocmd AuNERDTreeCmd VimEnter * call s:CdIfDirectory(expand("<amatch>")) | |
"Consider autocmd VimEnter * if argc() == 1 | NERDTree | wincmd p | endif | |
" instead of below | |
" also why is line 256 in CdIfDirectory not working as expected | |
autocmd AuNERDTreeCmd VimEnter * wincmd p | |
autocmd AuNERDTreeCmd FocusGained * call s:UpdateNERDTree() | |
" Auto close if NERDTree is the buffer open | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" If the parameter is a directory, cd into it | |
map <leader>n :NERDTreeToggle<CR>:NERDTreeMirror<CR> | |
"------------------------------------------------------------------------------ | |
" Nerd Commenter to comment and uncomment stuff | |
"------------------------------------------------------------------------------ | |
" Use compact syntax for prettified multi-line comments | |
let g:NERDCompactSexyComs = 1 | |
let g:NERDCommentEmptyLines = 1 | |
map <D-/> <plug>NERDCommenterToggle<CR> | |
imap <D-/> <Esc><plug>NERDCommenterToggle<CR>i' | |
map <leader>/ <plug>NERDCommenterToggle<CR> | |
"------------------------------------------------------------------------------ | |
" Ack.vim # No longer installed, Replaced by RipGrep | |
"------------------------------------------------------------------------------ | |
"------------------------------------------------------------------------------ | |
" QFEnter -- own the quickfix window | |
"------------------------------------------------------------------------------ | |
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>'] | |
"------------------------------------------------------------------------------ | |
" Vim-Terraform for terraform file type support | |
"------------------------------------------------------------------------------ | |
let g:terraform_align=1 " allow terraform to override fmt settings | |
let g:terraform_completion_keys = 1 | |
autocmd FileType terraform setlocal commentstring=#%s "enable vim-commentary for terraform | |
au BufRead,BufNewFile *.tf setlocal filetype=terraform | |
au BufRead,BufNewFile *.tfvars setlocal filetype=terraform | |
au BufRead,BufNewFile *.tfstate setlocal filetype=javascript | |
au BufRead,BufNewFile *.yaml.template setlocal filetype=cfn | |
au BufRead,BufNewFile *.yaml.template setlocal syntax=yaml | |
au BufRead,BufNewFile *.json.template setlocal filetype=cfn | |
au BufRead,BufNewFile *.json.template setlocal syntax=json | |
"------------------------------------------------------------------------------ | |
" Vim-Rego for rego/opa file format support | |
"------------------------------------------------------------------------------ | |
let g:formatdef_rego = '"opa fmt"' | |
let g:formatters_rego = ['rego'] | |
let g:autoformat_autoindent = 0 | |
let g:autoformat_retab = 0 | |
let g:autoformat_verbosemode = 1 | |
"------------------------------------------------------------------------------ | |
" Ansible-vim for basic ansible support | |
"------------------------------------------------------------------------------ | |
let g:ansible_extra_keywords_highlight = 1 | |
let g:ansible_unindent_after_newline = 1 | |
au BufRead,BufNewFile */playbooks/*.yml set filetype=yaml.ansible | |
au BufRead,BufNewFile */roles/*.yml set filetype=yaml.ansible | |
"------------------------------------------------------------------------------ | |
"vim-ultisnips for snippets | |
"------------------------------------------------------------------------------ | |
"let g:UltiSnipsExpandTrigger ="<c-j>" | |
"let g:UltiJumpForwardTrigger="<c-j>" | |
"let g:UltiSnipsJumpBackwardTrigger="<c-k>" | |
"let g:UltiSnipsListSnippets="<c-tab>" | |
"let g:UltiSnipsSnippetsDir = '~/.vim/snippets' | |
"------------------------------------------------------------------------------ | |
" coc-snippets for snippets | |
"------------------------------------------------------------------------------ | |
" | |
" Use <C-l> for trigger snippet expand. | |
imap <C-l> <Plug>(coc-snippets-expand) | |
" Use <C-j> for select text for visual placeholder of snippet. | |
vmap <C-j> <Plug>(coc-snippets-select) | |
" Use <C-j> for jump to next placeholder, it's default of coc.nvim | |
let g:coc_snippet_next = '<c-j>' | |
" Use <C-k> for jump to previous placeholder, it's default of coc.nvim | |
let g:coc_snippet_prev = '<c-k>' | |
" Use <C-j> for both expand and jump (make expand higher priority.) | |
imap <C-j> <Plug>(coc-snippets-expand-jump) | |
" Use <leader>x for convert visual selected code to snippet | |
xmap <leader>x <Plug>(coc-convert-snippet) | |
"------------------------------------------------------------------------------ | |
" ale # instead of syntastic | |
"------------------------------------------------------------------------------ | |
let g:ale_sign_column_always = 1 | |
let g:ale_set_balloons = 1 | |
let g:ale_echo_cursor = 1 | |
let g:ale_set_highlights = 1 | |
let g:ale_set_signs = 1 | |
let g:airline#extensions#ale#enabled = 1 | |
let g:ale_set_loclist = 1 " Use loclist for ALE, since we use quickfix for search results | |
let g:ale_set_quickfix = 0 | |
let g:ale_open_list = 0 " Do not automatically open loclist, this is annoying | |
let g:ale_fixers = { | |
\ '*': ['remove_trailing_lines', 'trim_whitespace'], | |
\ 'javascript': ['prettier'], | |
\ 'css': ['prettier'], | |
\ 'ruby': ['prettier'], | |
\ 'terraform': ['terraform'], | |
\} | |
let g:ale_fix_on_save = 1 | |
let g:ale_disable_lsp = 1 | |
" Disable ALE for yaml since we are satisfied with coc.nvim here | |
let g:ale_pattern_options = { | |
\ '.*\.yaml$': {'ale_enabled': 0}, | |
\ '.*\.json$': {'ale_enabled': 0}, | |
\} | |
"------------------------------------------------------------------------------ | |
" vim-youcompleteme Auto Completion! | |
"------------------------------------------------------------------------------ | |
" | |
" | |
let g:ycm_min_num_of_chars_for_completion = 1 | |
let g:ycm_show_diagnostics_ui = 0 | |
let g:EclimCompletionMethod = 'omnifunc' | |
" YCM is triggered by the semantic triggers below and by Control + Space | |
let g:ycm_semantic_triggers = { | |
\ 'c' : ['->', '.'], | |
\ 'objc' : ['->', '.', 're!\[[_a-zA-Z]+\w*\s', 're!^\s*[^\W\d]\w*\s', | |
\ 're!\[.*\]\s'], | |
\ 'ocaml' : ['.', '#'], | |
\ 'cpp,objcpp' : ['->', '.', '::'], | |
\ 'perl' : ['->'], | |
\ 'php' : ['->', '::'], | |
\ 'cs,java,javascript,typescript,d,python,perl6,scala,vb,elixir' : ['.'], | |
\ 'ruby' : ['.', '::'], | |
\ 'lua' : ['.', ':'], | |
\ 'erlang' : [':'], | |
\ 'terraform': ['.', '_'], | |
\ } | |
"------------------------------------------------------------------------------ | |
" Vim-Easymotion to navigate to any point in the file and fuzzy search try | |
" space / | |
"------------------------------------------------------------------------------ | |
" Move to line | |
map <Leader>L <Plug>(easymotion-bd-jk) | |
nmap <Leader>L <Plug>(easymotion-overwin-line) | |
" Move to word | |
map <Leader>w <Plug>(easymotion-bd-w) | |
nmap <Leader>w <Plug>(easymotion-overwin-w) | |
" <Leader>f{char} to move to {char} | |
map <Leader>f <Plug>(easymotion-bd-f) | |
nmap <Leader>f <Plug>(easymotion-overwin-f) | |
" s{char}{char} to move to {char}{char} | |
nmap s <Plug>(easymotion-overwin-f2) | |
" Fuzzy Search with Easy Motion Requires three additional plugins!! | |
" haya14busa/incsearch.vim | |
map / <Plug>(incsearch-forward) | |
map ? <Plug>(incsearch-backward) | |
map g/ <Plug>(incsearch-stay) | |
" haya14busa/incsearch-easymotion.vim | |
map z/ <Plug>(incsearch-easymotion-/) | |
map z? <Plug>(incsearch-easymotion-?) | |
map zg/ <Plug>(incsearch-easymotion-stay) | |
function! s:config_easyfuzzymotion(...) abort | |
return extend(copy({ | |
\ 'converters': [incsearch#config#fuzzy#converter()], | |
\ 'modules': [incsearch#config#easymotion#module()], | |
\ 'keymap': {"\<CR>": '<Over>(easymotion)'}, | |
\ 'is_expr': 0, | |
\ 'is_stay': 1 | |
\ }), get(a:, 1, {})) | |
endfunction | |
noremap <silent><expr> <Space>/ incsearch#go(<SID>config_easyfuzzymotion()) | |
"------------------------------------------------------------------------------ | |
" Vim-Easyalign to align those = signs and markdown tables | |
"------------------------------------------------------------------------------ | |
" Fold markdown at 100 characters | |
au BufRead,BufNewFile *.md setlocal textwidth=100 | |
" Use grip for Markdown preview | |
let vim_markdown_preview_github=1 | |
" Align GitHub-flavored Markdown tables | |
au FileType markdown vmap <Leader><Bslash> :EasyAlign*<Bar><Enter> | |
" Start interactive EasyAlign in visual mode (e.g. vipga) | |
xmap ga <Plug>(EasyAlign) | |
" Start interactive EasyAlign for a motion/text object (e.g. gaip) | |
nmap ga <Plug>(EasyAlign) | |
"------------------------------------------------------------------------------ | |
" Vim-Polyglot for when I work with a language, that I usually dont | |
"------------------------------------------------------------------------------ | |
"Disable individually installed plugins in polyglot | |
"These are things I actually use | |
"let g:polyglot_disabled = ['go', 'ruby', 'ansible', 'terraform', 'dockerfile'] | |
" | |
" | |
"" Configuration for coc.nvim | |
"inoremap <silent><expr> <TAB> | |
"\ pumvisible() ? coc#_select_confirm() : | |
"\ coc#expandableOrJumpable() ? "\<C-r>=coc#rpc#request('doKeymap', ['snippets-expand-jump',''])\<CR>" : | |
"\ <SID>check_back_space() ? "\<TAB>" : | |
"\ coc#refresh() | |
function! s:check_back_space() abort | |
let col = col('.') - 1 | |
return !col || getline('.')[col - 1] =~# '\s' | |
endfunction | |
let g:coc_snippet_next = '<tab>' | |
" Use tab for trigger completion with characters ahead and navigate. | |
" NOTE: Use command ':verbose imap <tab>' to make sure tab is not mapped by | |
" other plugin before putting this into your config. | |
inoremap <silent><expr> <TAB> | |
\ pumvisible() ? "\<C-n>" : | |
\ <SID>check_back_space() ? "\<TAB>" : | |
\ coc#refresh() | |
inoremap <expr><S-TAB> pumvisible() ? "\<C-p>" : "\<C-h>" | |
" | |
"function! s:check_back_space() abort | |
"let col = col('.') - 1 | |
"return !col || getline('.')[col - 1] =~# '\s' | |
"endfunction | |
" Use <c-space> to trigger completion. | |
if has('nvim') | |
inoremap <silent><expr> <c-space> coc#refresh() | |
else | |
inoremap <silent><expr> <c-@> coc#refresh() | |
endif | |
" Make <CR> auto-select the first completion item and notify coc.nvim to | |
" format on enter, <cr> could be remapped by other vim plugin | |
inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() | |
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>" | |
" Use `[g` and `]g` to navigate diagnostics | |
" Use `:CocDiagnostics` to get all diagnostics of current buffer in location list. | |
nmap <silent> [g <Plug>(coc-diagnostic-prev) | |
nmap <silent> ]g <Plug>(coc-diagnostic-next) | |
" GoTo code navigation. | |
nmap <silent> gd <Plug>(coc-definition) | |
nmap <silent> gy <Plug>(coc-type-definition) | |
nmap <silent> gi <Plug>(coc-implementation) | |
nmap <silent> gr <Plug>(coc-references) | |
" Use K to show documentation in preview window. | |
nnoremap <silent> K :call <SID>show_documentation()<CR> | |
function! s:show_documentation() | |
if (index(['vim','help'], &filetype) >= 0) | |
execute 'h '.expand('<cword>') | |
elseif (coc#rpc#ready()) | |
call CocActionAsync('doHover') | |
else | |
execute '!' . &keywordprg . " " . expand('<cword>') | |
endif | |
endfunction | |
" Highlight the symbol and its references when holding the cursor. | |
autocmd CursorHold * silent call CocActionAsync('highlight') | |
" Symbol renaming. | |
nmap <leader>rn <Plug>(coc-rename) | |
" Formatting selected code. | |
xmap <leader>f <Plug>(coc-format-selected) | |
nmap <leader>f <Plug>(coc-format-selected) | |
augroup mygroup | |
autocmd! | |
" Setup formatexpr specified filetype(s). | |
autocmd FileType typescript,json setl formatexpr=CocAction('formatSelected') | |
" Update signature help on jump placeholder. | |
autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp') | |
augroup end | |
" Applying codeAction to the selected region. | |
" Example: `<leader>aap` for current paragraph | |
xmap <leader>a <Plug>(coc-codeaction-selected) | |
nmap <leader>a <Plug>(coc-codeaction-selected) | |
" Remap keys for applying codeAction to the current buffer. | |
nmap <leader>ac <Plug>(coc-codeaction) | |
" Apply AutoFix to problem on the current line. | |
nmap <leader>qf <Plug>(coc-fix-current) | |
" Map function and class text objects | |
" NOTE: Requires 'textDocument.documentSymbol' support from the language server. | |
xmap if <Plug>(coc-funcobj-i) | |
omap if <Plug>(coc-funcobj-i) | |
xmap af <Plug>(coc-funcobj-a) | |
omap af <Plug>(coc-funcobj-a) | |
xmap ic <Plug>(coc-classobj-i) | |
omap ic <Plug>(coc-classobj-i) | |
xmap ac <Plug>(coc-classobj-a) | |
omap ac <Plug>(coc-classobj-a) | |
" Remap <C-f> and <C-b> for scroll float windows/popups. | |
if has('nvim-0.4.0') || has('patch-8.2.0750') | |
nnoremap <silent><nowait><expr> <C-a> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-a>" | |
nnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
inoremap <silent><nowait><expr> <C-a> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(1)\<cr>" : "\<Right>" | |
inoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? "\<c-r>=coc#float#scroll(0)\<cr>" : "\<Left>" | |
vnoremap <silent><nowait><expr> <C-a> coc#float#has_scroll() ? coc#float#scroll(1) : "\<C-a>" | |
vnoremap <silent><nowait><expr> <C-b> coc#float#has_scroll() ? coc#float#scroll(0) : "\<C-b>" | |
endif | |
nmap <silent><nowait><Esc> :call coc#float#close_all() <CR> | |
" Use CTRL-S for selections ranges. | |
" Requires 'textDocument/selectionRange' support of language server. | |
nmap <silent> <C-s> <Plug>(coc-range-select) | |
xmap <silent> <C-s> <Plug>(coc-range-select) | |
" Add `:Format` command to format current buffer. | |
command! -nargs=0 Format :call CocAction('format') | |
" Add `:Fold` command to fold current buffer. | |
command! -nargs=? Fold :call CocAction('fold', <f-args>) | |
" Add `:OR` command for organize imports of the current buffer. | |
command! -nargs=0 OR :call CocAction('runCommand', 'editor.action.organizeImport') | |
" Add (Neo)Vim's native statusline support. | |
" NOTE: Please see `:h coc-status` for integrations with external plugins that | |
" provide custom statusline: lightline.vim, vim-airline. | |
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} | |
" Mappings for CoCList | |
" Show all diagnostics. | |
nnoremap <silent><nowait> <space>a :<C-u>CocList diagnostics<cr> | |
" Manage extensions. | |
nnoremap <silent><nowait> <space>e :<C-u>CocList extensions<cr> | |
" Show commands. | |
nnoremap <silent><nowait> <space>c :<C-u>CocList commands<cr> | |
" Find symbol of current document. | |
nnoremap <silent><nowait> <space>o :<C-u>CocList outline<cr> | |
" Search workspace symbols. | |
nnoremap <silent><nowait> <space>s :<C-u>CocList -I symbols<cr> | |
" Do default action for next item. | |
nnoremap <silent><nowait> <space>j :<C-u>CocNext<CR> | |
" Do default action for previous item. | |
nnoremap <silent><nowait> <space>k :<C-u>CocPrev<CR> | |
" Resume latest coc list. | |
nnoremap <silent><nowait> <space>p :<C-u>CocListResume<CR> | |
" Open diagnostics | |
nnoremap <silent><nowait> <space>l :CocDiagnostics<CR> | |
" Close all lists | |
nnoremap <silent><nowait> <space>h :ccl <bar> lcl<CR> | |
" Vim-Go configuration | |
" | |
let g:go_gocode_unimported_packages = 1 | |
let g:go_fmt_fail_silently = 1 | |
let g:go_fmt_command = 'goimports' | |
let g:go_def_mode = 'gopls' | |
let g:go_autodetect_gopath = 1 | |
" Navigate Splits with arrow keys | |
" | |
nmap <up> <C-w><up> | |
nmap <down> <C-w><down> | |
nmap <left> <C-w><left> | |
nmap <right> <C-w><right> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment