dotfiles/nvim/.config/nvim/init.vim
Sanchayan Maity efbde43c1e nvim: Add vim any fold
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
2020-04-06 21:28:24 +05:30

811 lines
28 KiB
VimL

" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.config/nvim/plugged')
" ----------------------------- Plugins --------------------------------------
" Automatically match structures as you type
Plug 'tpope/vim-endwise'
" Tab completion
Plug 'ervandew/supertab'
" EasyMotion
Plug 'easymotion/vim-easymotion'
Plug 'haya14busa/incsearch.vim'
Plug 'haya14busa/incsearch-easymotion.vim'
" Fuzzy search
Plug 'junegunn/fzf.vim'
Plug 'pbogut/fzf-mru.vim'
" Remove extraneous whitespace when edit mode is exited
Plug 'axelf4/vim-strip-trailing-whitespace'
" Status bar mods
Plug 'vim-airline/vim-airline'
" Manage Project sessions
Plug 'thaerkh/vim-workspace'
" Commenter
Plug 'tpope/vim-commentary'
" Theme
Plug 'sainnhe/sonokai'
" Syntax highlighting
Plug 'sheerun/vim-polyglot'
" Autoload and read from dish if file changes
Plug 'tmux-plugins/vim-tmux-focus-events'
Plug 'wellle/tmux-complete.vim'
" For LaTeX support
Plug 'lervag/vimtex'
" Primary git support
Plug 'tpope/vim-fugitive'
" Manage git hunks
Plug 'airblade/vim-gitgutter'
" Git blame
Plug 'rhysd/git-messenger.vim'
" Git logs
Plug 'rbong/vim-flog'
" Handle merge conflicts
Plug 'samoshkin/vim-mergetool'
" Git diffs in quickfix list
Plug 'oguzbilgic/vim-gdiff'
" For tmux yank
Plug 'vim-utils/vim-husk'
" GDB
Plug 'sakhnik/nvim-gdb', { 'do': ':UpdateRemotePlugins' }
" Lisp
Plug 'guns/vim-sexp', { 'for': [ 'scheme', 'lisp', 'clojure' ] }
Plug 'tpope/vim-sexp-mappings-for-regular-people', { 'for': [ 'scheme', 'lisp', 'clojure' ] }
Plug 'junegunn/rainbow_parentheses.vim', { 'for': [ 'scheme', 'lisp', 'clojure' ] }
Plug 'kovisoft/slimv', { 'for': [ 'scheme', 'lisp', 'clojure' ] }
" Haskell
Plug 'ndmitchell/ghcid', { 'rtp': 'plugins/nvim' }
Plug 'Twinside/vim-hoogle', { 'for': 'haskell' }
Plug 'hspec/hspec.vim'
Plug 'pbrisbin/vim-syntax-shakespeare'
Plug 'zenzike/vim-haskell-unicode', { 'for': 'haskell' }
Plug 'godlygeek/tabular'
" For autocompletion
Plug 'prabirshrestha/asyncomplete.vim'
Plug 'prabirshrestha/asyncomplete-buffer.vim'
Plug 'prabirshrestha/asyncomplete-file.vim'
Plug 'prabirshrestha/asyncomplete-tags.vim'
" Rust
Plug 'mhinz/vim-crates'
" Erlang Support
Plug 'vim-erlang/vim-erlang-tags', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-omnicomplete', { 'for': 'erlang' }
Plug 'vim-erlang/vim-erlang-compiler', { 'for': 'erlang' }
" Neo/Async stuff
Plug 'sbdchd/neoformat'
Plug 'neomake/neomake'
" Quickfix
Plug 'sk1418/QFGrep'
Plug 'ronakg/quickr-cscope.vim'
Plug 'stefandtw/quickfix-reflector.vim'
Plug 'romainl/vim-qlist'
Plug 'mhinz/vim-grepper'
" Text Object plugins
Plug 'kana/vim-textobj-user'
Plug 'danidiaz/vim-textobj-do-block'
Plug 'michaeljsmith/vim-indent-object'
Plug 'wellle/targets.vim'
Plug 'tpope/vim-surround'
Plug 'junegunn/vim-easy-align'
Plug 'tommcdo/vim-exchange'
" For folds
Plug 'pseewald/vim-anyfold'
" Absolute essentials miscellaneous
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-sleuth'
Plug 'tpope/vim-vinegar'
Plug 'Yggdroot/indentLine'
" LSP related
Plug 'liuchengxu/vista.vim'
Plug 'prabirshrestha/async.vim'
Plug 'prabirshrestha/vim-lsp'
Plug 'prabirshrestha/asyncomplete-lsp.vim'
" Search and Replace
Plug 'brooth/far.vim'
" Floating terminal
Plug 'voldikss/vim-floaterm'
" Language agnostic
Plug 'pechorin/any-jump.nvim'
" Smooth scrolling
Plug 'psliwka/vim-smoothie'
" Auto correction
Plug 'sedm0784/vim-you-autocorrect', { 'for': [ 'text', 'markdown' ] }
Plug 'rhysd/vim-grammarous', { 'for': [ 'text', 'markdown' ] }
" Miscellaneous
Plug 'junegunn/vim-slash'
Plug 'andymass/vim-matchup'
Plug 'editorconfig/editorconfig-vim'
Plug 'igankevich/mesonic'
Plug 'simnalamburt/vim-mundo'
Plug 'milkypostman/vim-togglelist'
Plug 'liuchengxu/vim-which-key'
Plug 'farmergreg/vim-lastplace'
" Initialize plugin system
call plug#end()
" ----------------------------- Settings -------------------------------------
" Set up leaders
let mapleader="\<SPACE>"
let maplocalleader=","
set colorcolumn=80 " Highlight 80th column
set laststatus=2 " Always show status bar
set updatetime=300 " Let plugins show effects after 500ms
set mouse-=a " Disable mouse click to go to position
set encoding=utf-8
set exrc " Allow loading local .nvimrc files
set secure " Disallow use of autocmd, shell and write in local rc
set showcmd " Show (partial) command in status line.
set showmatch " Show matching brackets.
set ruler " Show the line and column numbers of the cursor.
set formatoptions+=o " Continue comment marker in new lines.
set formatoptions+=j " Delete comment character when joining commented lines
set textwidth=78 " Hard-wrap long lines as you type them.
set autoindent " Copy indent from current line when starting a new line
set noerrorbells " No beeps.
set modeline " Enable modeline.
set linespace=0 " Set line-spacing to minimum.
set nojoinspaces " Prevents inserting two spaces after punctuation on a join (J)
set noshowmode " Because of neovim's cursor shape
set splitbelow " Horizontal split below current.
set splitright " Vertical split to right of current.
set nobackup " no backup files
set nowritebackup " only in case you don't want a backup file while editing
set noswapfile " no swap files
set foldmethod=syntax " Create folds based on files syntax
set nofoldenable " Open folds by default
set undofile " Enable undo persistence across sessions
set hidden " Required by LC
set noautochdir
" Wild menu
set wildmenu
set wildmode=list:longest,full
set wildoptions=pum
set pumblend=30
set wildignore+=.hg,.git,.svn " Version control
set wildignore+=*.aux,*.out,*.toc " LaTeX intermediate files
set wildignore+=*.jpg,*.bmp,*.gif,*.png,*.jpeg " binary images
set wildignore+=*.o " compiled object files
set wildignore+=*.sw? " Vim swap files
set wildignore+=*.luac " Lua byte code
set wildignore+=*.pyc " Python byte code
set wildignore+=*.orig " Merge resolution files
if !&scrolloff
set scrolloff=3 " Show next 3 lines while scrolling.
endif
if !&sidescrolloff
set sidescrolloff=5 " Show next 5 columns while side-scrolling.
endif
set nostartofline " Do not jump to first character with page commands.
set ignorecase " Make searching case insensitive
set smartcase " ... unless the query has capital letters.
set magic " Use 'magic' patterns (extended regular expressions).
set autoread " Autoload file if it changes on disk
set termguicolors " Enable colors for terminal
set fileformat=unix
set inccommand=split
set clipboard^=unnamed,unnamedplus
set backspace=indent,eol,start
set completeopt=menu,noselect,preview,noinsert
" Required for vim-workspace
" See https://github.com/thaerkh/vim-workspace/issues/11
set sessionoptions-=blank
" Theme
let g:sonokai_style = 'atlantis'
let g:sonokai_enable_italic = 1
let g:sonokai_disable_italic_comment = 1
colorscheme sonokai
" --------------------------- Key Bindings -----------------------------------
" Remap escape keys to something usable on home row
inoremap jk <Esc>
cnoremap jk <C-C>
inoremap <Esc> <Nop>
cnoremap <Esc> <Nop>
" Use Q to execute default register.
nnoremap Q <Nop>
" Bind vanilla buffer switching
nnoremap <Leader>b :b<SPACE>
" For Fuzzy
nnoremap <Leader>ff :GFiles<CR>
nnoremap <Leader>f? :GFiles?<CR>
nnoremap <Leader>fF :Files<CR>
nnoremap <Leader>fb :Buffers<CR>
nnoremap <Leader>fL :Lines<CR>
nnoremap <Leader>fl :BLines<CR>
nnoremap <Leader>ft :BTags<CR>
nnoremap <Leader>fT :Tags<CR>
nnoremap <Leader>fc :BCommits<CR>
nnoremap <Leader>fC :Commits<CR>
nnoremap <Leader>fh :History:<CR>
nnoremap <Leader>fH :History/<CR>
nnoremap <Leader>fm :Commands<CR>
nnoremap <Leader>fo :Locate<SPACE>
nnoremap <Leader>fk :Maps<CR>
nnoremap <Leader>fr :FZFMru<CR>
nnoremap <Leader>f/ :Rg<CR>
nnoremap <Leader>fs :exe ':Rg ' . expand('<cword>')<CR>
imap <C-x><C-w> <plug>(fzf-complete-word)
imap <C-x><C-p> <plug>(fzf-complete-path)
imap <C-x><C-f> <plug>(fzf-complete-file)
imap <C-x><C-l> <plug>(fzf-complete-line)
" Undo tree
nnoremap <Leader>u :MundoToggle<CR>
" Save
nnoremap <Leader>w <Esc>:w<CR>
" Search and Replace
nnoremap sr :%s//g<Left><Left>
nnoremap <Leader>sr :%s/\<<C-r><C-w>\>//g<Left><Left>
" Quit
nnoremap <Leader>x <Esc>:x<CR>
nnoremap <Leader>q <Esc>:q<CR>
nnoremap <Leader>Q <Esc>:qa<CR>
" Navigate buffers
nnoremap [b :bprevious<CR>
nnoremap ]b :bnext<CR>
nnoremap [B :bfirst<CR>
nnoremap ]B :blast<CR>
" For floating terminal
nnoremap se :FloatermNew<CR>
nnoremap [s :FloatermPrev<CR>
nnoremap ]s :FloatermNext<CR>
nnoremap st :FloatermToggle<CR>
" For git
nnoremap <Leader>gm :GitMessenger<CR>
nnoremap <Leader>gl :0Glog<CR>
nnoremap <Leader>gL :Glog<CR>
nnoremap <Leader>gd :Gdiff<CR>
nnoremap <Leader>gD :Gdiffsplit<CR>
nnoremap <Leader>gs :Gstatus<CR>
nnoremap <Leader>gc :Gcommit -v -q --signoff<CR>
nnoremap <Leader>gt :Gcommit -v -q --signoff %:p<CR>
nnoremap <Leader>gp :Git push<CR>
nnoremap <Leader>gu :Git push -u<SPACE>
nnoremap <Leader>gr :Git remote -v<CR>
nnoremap <Leader>gb :Git branch<SPACE>
nnoremap <Leader>go :Git checkout<SPACE>
nnoremap <Leader>g- :Git stash<CR>:e<CR>
nnoremap <Leader>g+ :Git stash pop<CR>:e<CR>
nnoremap <Leader>gG :exe ':Ggrep ' . expand('<cword>')<CR>
nnoremap <Leader>gF :Ggrep<SPACE>
nnoremap <Leader>gg :GGrep<SPACE>
nnoremap <Leader>ml :MergetoolDiffExchangeLeft<CR>
nnoremap <Leader>mr :MergetoolDiffExchangeRight<CR>
nnoremap <Leader>mu :MergetoolDiffExchangeUp<CR>
nnoremap <Leader>md :MergetoolDiffExchangeDown<CR>
nnoremap <Leader>mg :diffget<CR>
nnoremap <Leader>mp :diffput<CR>
" For gitgutter
nnoremap ]h :GitGutterNextHunk<CR>
nnoremap [h :GitGutterPrevHunk<CR>
nnoremap <Leader>sh :GitGutterStageHunk<CR>
nnoremap <Leader>uh :GitGutterUndoHunk<CR>
nnoremap <Leader>ph :GitGutterPreviewHunk<CR>
nnoremap <Leader>qh :GitGutterQuickFix<CR>
nnoremap <Leader>gf :GitGutterFold<CR>
" For Neomake/Neoformat
nnoremap <Leader>nm :Neomake<CR>
nnoremap <Leader>nc :NeomakeClean<CR>
nnoremap <Leader>ns :NeomakeSh<SPACE>
nnoremap <Leader>njl :NeomakeListJobs<CR>
nnoremap <Leader>nja :NeomakeCancelJobs<CR>
nnoremap <Leader>njc :NeomakeCancelJob<SPACE>
nnoremap <Leader>nf :Neoformat<CR>
nnoremap <Leader>ne :NeomakeEnable<CR>
nnoremap <Leader>nd :NeomakeDisable<CR>
" For workspace
nnoremap <Leader>ws :ToggleWorkspace<CR>
" Quickfix & Location list mappings
nnoremap qo :copen<CR>
nnoremap qc :cclose<CR>
nnoremap [q :cprevious<CR>
nnoremap ]q :cnext<CR>
nnoremap [Q :cfirst<CR>
nnoremap ]Q :clast<CR>
nnoremap qs :Grepper -nojump -query<SPACE>
nnoremap q* :Grepper -nojump -cword<CR>
nnoremap qt :call ToggleQuickfixList()<CR>
nnoremap Lo :lopen<CR>
nnoremap Lc :lclose<CR>
nnoremap [l :lprevious<CR>
nnoremap ]l :lnext<CR>
nnoremap [L :lfirst<CR>
nnoremap ]L :llast<CR>
nnoremap Ls :Grepper -nojump -noquickfix -query<SPACE>
nnoremap L* :Grepper -nojump -noquickfix -cword<CR>
nnoremap Lt :call ToggleLocationList()<CR>
" Preview tags
nnoremap pt :ptag <C-R><C-W><CR>
nnoremap [p :ptprevious<CR>
nnoremap ]p :ptnext<CR>
nnoremap po :ppop<CR>
nnoremap pc :pc<CR>
nnoremap pi :psearch <C-R><C-W><CR>
" Short cuts for setting fold methods
nnoremap zmi :set foldmethod=indent<CR>
nnoremap zmm :set foldmethod=manual<CR>
nnoremap zme :set foldmethod=expr<CR>
nnoremap zmk :set foldmethod=marker<CR>
nnoremap zms :set foldmethod=syntax<CR>
" Key Bindings to help with terminal mode
:tnoremap jk <C-\><C-n>
" Key bindings to move between window splits
for key in range(0, 9)
execute 'nnoremap <Space>'.key key.'<C-w>w'
endfor
" Disable Arrow Keys
inoremap <Up> <NOP>
inoremap <Down> <NOP>
inoremap <Left> <NOP>
inoremap <Right> <NOP>
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" Whick key
nnoremap <silent> <Leader> :<C-U>WhichKey '<Space>'<CR>
nnoremap <silent> <LocalLeader> :<C-U>WhichKey ','<CR>
" Bindings for easy motion
" Character motions
map <Leader><Leader>c <Plug>(easymotion-bd-f)
nmap <Leader><Leader>c <Plug>(easymotion-overwin-f)
" Line motions
map <Leader><Leader>L <Plug>(easymotion-bd-jk)
nmap <Leader><Leader>L <Plug>(easymotion-overwin-line)
" Word motions
map <Leader><Leader>w <Plug>(easymotion-bd-w)
nmap <Leader><Leader>w <Plug>(easymotion-overwin-w)
" Line motion jump
map <Leader>l <Plug>(easymotion-lineforward)
map <Leader>j <Plug>(easymotion-j)
map <Leader>k <Plug>(easymotion-k)
map <Leader>h <Plug>(easymotion-linebackward)
" Incremental search + easymotion
noremap <silent><expr> / incsearch#go(<SID>incsearch_config())
noremap <silent><expr> ? incsearch#go(<SID>incsearch_config({'command': '?'}))
noremap <silent><expr> g/ incsearch#go(<SID>incsearch_config({'is_stay': 1}))
" Tag helpers
nnoremap <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
nnoremap <A-]> :sp <CR>:exec("tag ".expand("<cword>"))<CR>
" Tabular helpers
vnoremap <Leader>= :Tabularize /=<CR>
vnoremap <Leader>- :Tabularize /-><CR>
vnoremap <Leader>< :Tabularize /<-<CR>
vnoremap <Leader>, :Tabularize /,<CR>
vnoremap <Leader># :Tabularize /#-}<CR>
vnoremap <Leader>: :Tabularize /::<CR>
vnoremap <Leader>[ :Tabularize /[<CR>
" Any jump
nnoremap <Leader>aj :AnyJump<CR>
nnoremap <Leader>ab :AnyJumpBack<CR>
nnoremap <Leader>al :AnyJumpLastResults<CR>
" 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)
command! -bang -nargs=* GGrep
\ call fzf#vim#grep(
\ 'git grep --line-number '.shellescape(<q-args>), 0,
\ fzf#vim#with_preview({'dir': systemlist('git rev-parse --show-toplevel')[0]}), <bang>0)
" --------------------------- Autocmd groups ---------------------------------
augroup vimplug_maps
au!
au FileType vim nmap pg :PlugUpgrade<CR>
au FileType vim nmap pd :PlugUpdate<CR>
au FileType vim nmap pc :PlugClean<CR>
au FileType vim nmap pr :so %<CR>
augroup END
augroup haskell_maps
au!
" https://www.reddit.com/r/neovim/comments/es8wn7/haskell_makeprg_for_stack_build/
" https://github.com/maxigit/vimrc/tree/2020/compiler
au FileType haskell compiler stack
au FileType haskell setlocal makeprg=stack\ build
au FileType haskell setlocal keywordprg=:Hoogle
au FileType haskell nmap <LocalLeader>b :Neomake!<CR>
au FileType haskell nmap <LocalLeader>t :NeomakeSh stack exec -- hasktags -x -c .<CR>
au FileType haskell nmap <LocalLeader>td :NeomakeSh stack exec -- haskdogs<CR>
au FileType haskell nmap <LocalLeader>g :Ghcid<CR>
au FileType haskell nmap <LocalLeader>k :GhcidKill<CR>
au FileType haskell nmap <LocalLeader>c :HoogleClose<CR>
au FileType haskell nmap <LocalLeader>o :exe ':Hoogle ' . expand('<cword>')<CR>
au FileType haskell nmap <LocalLeader>i :exe ':HoogleInfo ' . expand('<cword>')<CR>
au FileType haskell nnoremap <buffer><silent> ]] :call JumpHaskellFunction(0)<CR>
au FileType haskell nnoremap <buffer><silent> [[ :call JumpHaskellFunction(1)<CR>
au FileType haskell inoremap <buffer> ;; <ESC>:call MakeArrow(1)<CR>
au FileType haskell inoremap <buffer> ;: <ESC>:call MakeArrow(0)<CR>
augroup END
augroup c_maps
au!
au FileType c nmap <LocalLeader>ct :NeomakeSh ctags -R .<CR>
au FileType c nmap <LocalLeader>cu :NeomakeSh cscope -bqR<CR>
au FileType c nmap <LocalLeader>cr :cs reset<CR>
au FileType c nmap <silent> <LocalLeader>s <Plug>(quickr_cscope_symbols)
au FileType c nmap <silent> <LocalLeader>g <Plug>(quickr_cscope_global)
au FileType c nmap <silent> <LocalLeader>h <Plug>(quickr_cscope_global_split)
au FileType c nmap <silent> <LocalLeader>v <Plug>(quickr_cscope_global_vert_split)
au FileType c nmap <silent> <LocalLeader>d <Plug>(quickr_cscope_functions)
au FileType c nmap <silent> <LocalLeader>c <Plug>(quickr_cscope_callers)
au FileType c nmap <silent> <LocalLeader>t <Plug>(quickr_cscope_text)
au FileType c nmap <silent> <LocalLeader>e <Plug>(quickr_cscope_egrep)
au FileType c nmap <silent> <LocalLeader>f <Plug>(quickr_cscope_files)
au FileType c nmap <silent> <LocalLeader>i <Plug>(quickr_cscope_includes)
au FileType c nmap <silent> <LocalLeader>a <Plug>(quickr_cscope_assignments)
augroup END
augroup rust_maps
au!
" Taken from http://seenaburns.com/vim-setup-for-rust/
" Neomake
" Gross hack to stop Neomake running when exitting because it creates a zombie cargo check process
" which holds the lock and never exits. But then, if you only have QuitPre, closing one pane will
" disable neomake, so BufEnter reenables when you enter another buffer.
let s:quitting = 0
au FileType rust au QuitPre let s:quitting = 1
au FileType rust au BufEnter let s:quitting = 0
au FileType rust au BufWritePost if ! s:quitting | Neomake | else | echom "Neomake disabled" | endif
augroup END
augroup rainbow_lisp
autocmd!
autocmd FileType lisp,clojure,scheme RainbowParentheses
augroup END
" Toggles search highlighting off/on according to current mode. Source: http://blog.sanctum.geek.nz/vim-search-highlighting/
augroup toggle_search
autocmd!
autocmd InsertEnter * setlocal nohlsearch
autocmd InsertLeave * setlocal hlsearch
augroup END
augroup quickfix
au!
" Close QF window if it is last window
au WinEnter * if winnr('$') == 1 && &buftype == "quickfix"|q|endif
" Existing bindings for QFGrep
" <Leader>g input pattern to do further filtering
" <Leader>v input pattern to do further inverted filtering
" <Leader>r restore the Quickfix/location list with original entries
augroup END
augroup terminal_job
au!
au TermOpen * startinsert
au TermOpen * setlocal listchars= nonumber norelativenumber
augroup END
augroup spell_check
au!
autocmd FileType gitcommit setlocal spell textwidth=72
autocmd BufRead,BufNewFile *.md,*.txt setlocal spell
augroup END
augroup ResizeWindowsProportionally
au!
autocmd VimResized * :wincmd =
augroup END
augroup LSP
au!
nnoremap <LocalLeader>le :call lsp#enable()<CR>
nnoremap <LocalLeader>ld :call lsp#disable()<CR>
nnoremap <LocalLeader>lh :LspStopServer()<CR>
nnoremap <LocalLeader>ls :LspStatus<CR>
au User lsp_server_init call s:on_lsp_server_init()
augroup END
augroup VimLspSettings
au!
if executable('pyls')
au User lsp_setup call lsp#register_server({
\ 'name': 'pyls',
\ 'cmd': {server_info->['pyls']},
\ 'whitelist': ['python'],
\ })
endif
if executable('ra_lsp_server')
au User lsp_setup call lsp#register_server({
\ 'name': 'ra_lsp_server',
\ 'cmd': {server_info->['ra_lsp_server']},
\ 'whitelist': ['rust'],
\ })
endif
if executable('purescript-language-server')
au User lsp_setup call lsp#register_server({
\ 'name': 'purescript-language-server',
\ 'cmd': {server_info->['purescript-language-server', '--stdio']},
\ 'whitelist': ['purescript'],
\ })
endif
if executable('ghcide')
au User lsp_setup call lsp#register_server({
\ 'name': 'ghcide',
\ 'cmd': {server_info->['ghcide', '--lsp']},
\ 'whitelist': ['haskell'],
\ })
endif
augroup END
augroup AsyncCompleteSetup
au!
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#tags#get_source_options({
\ 'name': 'tags',
\ 'whitelist': ['c', 'haskell'],
\ 'completor': function('asyncomplete#sources#tags#completor'),
\ }))
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#buffer#get_source_options({
\ 'name': 'buffer',
\ 'whitelist': ['*'],
\ 'blacklist': ['go'],
\ 'completor': function('asyncomplete#sources#buffer#completor'),
\ 'config': {
\ 'max_buffer_size': 5000000,
\ },
\ }))
au User asyncomplete_setup call asyncomplete#register_source(asyncomplete#sources#file#get_source_options({
\ 'name': 'file',
\ 'whitelist': ['*'],
\ 'priority': 10,
\ 'completor': function('asyncomplete#sources#file#completor')
\ }))
augroup END
" --------------------------- Plugin settings --------------------------------
let g:haskell_enable_quantification = 1 " to enable highlighting of `forall`
let g:haskell_enable_recursivedo = 1 " to enable highlighting of `mdo` and `rec`
let g:haskell_enable_arrowsyntax = 1 " to enable highlighting of `proc`
let g:haskell_enable_pattern_synonyms = 1 " to enable highlighting of `pattern`
let g:haskell_enable_typeroles = 1 " to enable highlighting of type roles
let g:haskell_enable_static_pointers = 1 " to enable highlighting of `static`
let g:haskell_backpack = 1 " to enable highlighting of backpack keywords
let g:haskell_classic_highlighting = 0
let g:haskell_indent_if = 3
let g:haskell_indent_case = 2
let g:haskell_indent_let = 4
let g:haskell_indent_where = 6
let g:haskell_indent_before_where = 2
let g:haskell_indent_after_bare_where = 2
let g:haskell_indent_do = 3
let g:haskell_indent_in = 1
let g:haskell_indent_guard = 2
let g:haskell_indent_case_alternative = 1
let g:cabal_indent_section = 2
" Either check empty($IN_NIX_SHELL) for nix specific or executable('ghcid')
if executable('ghcid')
let g:ghcid_command = 'ghcid'
else
let g:ghcid_command = 'stack exec -- ghcid'
endif
if executable('hoogle')
let g:hoogle_search_bin = 'hoogle'
else
let g:hoogle_search_bin = 'stack exec -- hoogle'
endif
let g:hoogle_search_count = 30
" Use airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#fnamemod = ':t'
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#right_sep = ' '
let g:airline#extensions#tabline#right_alt_sep = '|'
let g:airline#extensions#tabline#formatter = 'default'
let g:airline#extensions#tabline#buffer_nr_show = 1
let g:airline_left_sep = ' '
let g:airline_left_alt_sep = '|'
let g:airline_right_sep = ' '
let g:airline_right_alt_sep = '|'
let g:airline_section_y = '%{winnr()}'
" Let vim-gitgutter do its thing on large files
let g:gitgutter_max_signs=1000
let g:gitgutter_map_keys = 0
let g:gitgutter_highlight_linenrs = 1
let g:gitgutter_preview_win_floating = 1
let g:gitgutter_use_location_list = 1
let g:gitgutter_sign_added = '+a'
let g:gitgutter_sign_modified = '+m'
let g:gitgutter_sign_removed = '-r'
let g:gitgutter_sign_removed_first_line = '^^'
let g:gitgutter_sign_modified_removed = 'mr'
" Neomake
" When compilation is done, open the Location list or quickfix list
" Value of 2 preserves cursor position
let g:neomake_open_list = 2
let g:neomake_warning_sign = {'text': '?'}
let g:neomake_c_enabled_makers = ['gcc']
let g:neomake_c_gcc_maker = {
\ 'exe': 'gcc',
\ 'args': ['-Wall', '-Iinclude', '-Wextra', '-Weverything', '-pedantic', '-Wno-sign-conversion'],
\ }
" Automatically detect style file and apply style to formatting
let g:clang_format#detect_style_file = 1
" Fix tab behaviour while switching through completion options
let g:SuperTabDefaultCompletionType = "<c-n>"
" For workspace
let g:workspace_session_directory = $HOME . '/.vim/session/'
let g:workspace_undodir = $HOME . '/.vim/undodir'
let g:workspace_autosave = 0
let g:workspace_autosave_ignore = ['gitcommit', 'qf', 'tagbar']
let g:workspace_session_disable_on_args = 1
" Toggle quickfix/location list
let g:toggle_list_no_mappings = 1
let g:nvimgdb_config_override = {
\ 'key_next': 'n',
\ 'key_step': 's',
\ 'key_finish': 'f',
\ 'key_continue': 'c',
\ 'key_until': 'u',
\ 'key_breakpoint': 'b',
\ 'set_tkeymaps': "NvimGdbNoTKeymaps",
\ }
let g:mapleader = "\<Space>"
let g:maplocalleader = ','
let g:which_key_use_floating_win = 1
let g:cpp_class_scope_highlight = 1
let g:cpp_member_variable_highlight = 1
let g:cpp_class_decl_highlight = 1
let g:cpp_posix_standard = 1
let g:cpp_concepts_highlight = 1
" For SLIMV
let g:lisp_rainbow=1
" FZF
let g:fzf_mru_no_sort = 1
let $FZF_DEFAULT_OPTS='--layout=reverse'
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.6 } }
" Quickr
let g:quickr_cscope_keymaps = 0
" LSP
let g:lsp_diagnostics_enabled = 1
let g:lsp_signs_enabled = 1
let g:lsp_diagnostics_echo_cursor = 1
let g:lsp_highlight_references_enabled = 1
let g:lsp_auto_enable = 0
" Vista
let g:vista_executive_for = {
\ 'c': 'ctags',
\ 'haskell': 'vim_lsp',
\ 'rust': 'vim_lsp',
\ 'purescript': 'vim_lsp',
\ 'python': 'vim_lsp',
\ }
let g:vista_ctags_cmd = {
\ 'haskell': 'stack exec -- hasktags -x -o - -c .',
\ }
" Allow nightfly theme to set indentline colors
let g:indentLine_setColors = 0
" Disable providers we do not give a shit about
let g:loaded_python_provider = 0
let g:loaded_python3_provider = 0
let g:loaded_ruby_provider = 0
let g:loaded_perl_provider = 0
let g:loaded_node_provider = 0
" Mergetool
let g:mergetool_layout = 'mr'
let g:mergetool_prefer_revision = 'unmodified'
" Floaterm
let g:floaterm_open_in_root = 0
let g:floaterm_position = 'center'
let g:floaterm_width = 0.8
let g:floaterm_height = 0.8
let g:floaterm_winblend = 0
let g:floaterm_borderchars = ['─', '│', '─', '│', '╭', '╮', '╯', '╰']
" Any jump
let g:any_jump_disable_default_keybindings = 1
let g:any_jump_search_prefered_engine = 'ag'
" Vim grepper
let g:grepper = {}
let g:grepper.tools = ['rg']
let g:grepper.quickfix = 1
let g:grepper.buffer = 0
let g:grepper.buffers = 0
let g:grepper.switch = 0
let g:grepper.append = 0
let g:grepper.prompt = 0
" ----------------------------- Functions ------------------------------------
function! NvimGdbNoTKeymaps()
tnoremap <silent> <buffer> <Esc> <C-\><C-n>
endfunction
function! s:incsearch_config(...) abort
return incsearch#util#deepextend(deepcopy({
\ 'modules': [incsearch#config#easymotion#module({'overwin': 1})],
\ 'keymap': {
\ "\<CR>": '<Over>(easymotion)'
\ },
\ 'is_expr': 0
\ }), get(a:, 1, {}))
endfunction
function! JumpHaskellFunction(reverse)
call search('\C[[:alnum:]]*\s*::', a:reverse ? 'bW' : 'W')
endfunction
function! MakeArrow(type)
if a:type
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a-> "
else
exe "norm! a -> "
endif
exe "startreplace"
else
if (matchstr(getline('.'), '\%' . col('.') . 'c.') ==? ' ')
exe "norm! a=> "
else
exe "norm! a => "
endif
exe "startreplace"
endif
endfunction
function! s:on_lsp_server_init() abort
setlocal omnifunc=lsp#complete
setlocal signcolumn=yes
" Always expected to work
nmap <buffer> gd :LspDefinition<CR>
nmap <buffer> gpd :LspPeekDefinition<CR>
nmap <buffer> gk :LspHover<CR>
" May or may not be available depending on language server
nmap <buffer> gx :LspReferences<CR>
nmap <buffer> gr :LspRename<CR>
nmap <buffer> <LocalLeader>ca :LspCodeAction<CR>
nmap <buffer> <LocalLeader>dd :LspDocumentDiagnostics<CR>
nmap <buffer> <LocalLeader>df :LspDocumentFormat<CR>
nmap <buffer> <LocalLeader>rf :LspDocumentRangeFormat<CR>
nmap <buffer> <LocalLeader>ds :LspDocumentSymbol<CR>
nmap <buffer> <LocalLeader>di :LspImplementation<CR>
nmap <buffer> <LocalLeader>nd :LspNextDiagnostic<CR>
nmap <buffer> <LocalLeader>pd :LspPreviousDiagnostic<CR>
nmap <buffer> <LocalLeader>ne :LspNextError<CR>
nmap <buffer> <LocalLeader>pe :LspPreviousError<CR>
nmap <buffer> <LocalLeader>nr :LspNextReference<CR>
nmap <buffer> <LocalLeader>pr :LspPreviousReference<CR>
nmap <buffer> <LocalLeader>nw :LspNextWarning<CR>
nmap <buffer> <LocalLeader>pw :LspPreviousWarning<CR>
nmap <buffer> <LocalLeader>dt :LspTypeDefinition<CR>
nmap <buffer> <LocalLeader>td :LspPeekTypeDefinition<CR>
nmap <buffer> <LocalLeader>pi :LspPeekImplementation<CR>
endfunction