460 lines
16 KiB
VimL
460 lines
16 KiB
VimL
" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
|
|
call plug#begin('~/.config/nvim/plugged')
|
|
|
|
" Automatically match brackets as you type
|
|
Plug 'Raimondi/delimitMate'
|
|
" Tab completion
|
|
Plug 'ervandew/supertab'
|
|
" EasyMotion - Allows <leader><leader>(b|e) to jump to (b)eginning or (end)
|
|
" of words.
|
|
Plug 'easymotion/vim-easymotion'
|
|
" Fuzzy file search
|
|
"Plug '~/.fzf'
|
|
Plug 'junegunn/fzf.vim'
|
|
" Remove extraneous whitespace when edit mode is exited
|
|
Plug 'thirtythreeforty/lessspace.vim'
|
|
" Status bar mods
|
|
Plug 'bling/vim-airline'
|
|
Plug 'airblade/vim-gitgutter'
|
|
" Manage Project sessions
|
|
Plug 'tpope/vim-obsession'
|
|
Plug 'dhruvasagar/vim-prosession'
|
|
" Explore filesystem
|
|
Plug 'scrooloose/nerdtree'
|
|
" Commenter
|
|
Plug 'scrooloose/nerdcommenter'
|
|
" Theme
|
|
Plug 'sickill/vim-monokai'
|
|
" 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'
|
|
" For git support
|
|
Plug 'tpope/vim-fugitive'
|
|
Plug 'junegunn/gv.vim'
|
|
Plug 'rhysd/git-messenger.vim'
|
|
Plug 'sodapopcan/vim-twiggy'
|
|
Plug 'christoomey/vim-conflicted'
|
|
Plug 'rbong/vim-flog'
|
|
" For tmux yank
|
|
Plug 'vim-utils/vim-husk'
|
|
" Tags
|
|
Plug 'steffanc/cscopemaps.vim'
|
|
Plug 'ludovicchabant/vim-gutentags'
|
|
" GDB
|
|
Plug 'sakhnik/nvim-gdb', { 'do': ':UpdateRemotePlugins' }
|
|
" Lisp
|
|
Plug 'guns/vim-sexp'
|
|
Plug 'tpope/vim-sexp-mappings-for-regular-people'
|
|
Plug 'junegunn/rainbow_parentheses.vim'
|
|
Plug 'Olical/vim-scheme', { 'for': 'scheme', 'on': 'SchemeConnect' }
|
|
" Haskell
|
|
Plug 'neovimhaskell/haskell-vim', { 'for': [ 'haskell', 'cabal' ] }
|
|
Plug 'parsonsmatt/intero-neovim'
|
|
Plug 'neomake/neomake'
|
|
" For Nix
|
|
Plug 'LnL7/vim-nix', { 'for': 'nix' }
|
|
" For autocompletion
|
|
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
|
|
" Autocomplete for Python
|
|
Plug 'zchee/deoplete-jedi'
|
|
" Autocomplete for Rust
|
|
Plug 'sebastianmarkow/deoplete-rust'
|
|
Plug 'cespare/vim-toml', { 'for': 'rust' }
|
|
Plug 'rust-lang/rust.vim', { 'for': 'rust' }
|
|
" Erlang Support
|
|
Plug 'vim-erlang/vim-erlang-tags'
|
|
Plug 'vim-erlang/vim-erlang-runtime'
|
|
Plug 'vim-erlang/vim-erlang-omnicomplete'
|
|
Plug 'vim-erlang/vim-erlang-compiler'
|
|
" Miscellaneous
|
|
Plug 'tpope/vim-surround'
|
|
Plug 'tpope/vim-repeat'
|
|
Plug 'editorconfig/editorconfig-vim'
|
|
Plug 'tpope/vim-eunuch'
|
|
Plug 'jeetsukumaran/vim-buffergator'
|
|
Plug 'vim-utils/vim-man'
|
|
Plug 'unblevable/quick-scope'
|
|
Plug 'igankevich/mesonic'
|
|
Plug 'rhysd/vim-clang-format', { 'for': [ 'c', 'cpp'] }
|
|
Plug 'pelodelfuego/vim-swoop'
|
|
|
|
" Initialize plugin system
|
|
call plug#end()
|
|
|
|
syntax on
|
|
filetype plugin indent on
|
|
|
|
" Set up leaders
|
|
let mapleader="\<SPACE>"
|
|
|
|
set colorcolumn=80 " Highlight 80th column
|
|
set laststatus=2 " Always show status bar
|
|
set updatetime=500 " 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 showmode " Show current mode.
|
|
set ruler " Show the line and column numbers of the cursor.
|
|
set number " Show the line numbers on the left side.
|
|
set formatoptions+=o " Continue comment marker in new lines.
|
|
set textwidth=0 " Hard-wrap long lines as you type them.
|
|
set softtabstop=4 " Finetunes the amount of white space to be added.
|
|
set tabstop=4 " Render TABs using this many spaces.
|
|
set shiftwidth=4 " Indentation amount for < and > commands.
|
|
set smarttab " Indent with tabs, align with spaces.
|
|
set expandtab " When on, uses space instead of tabs.
|
|
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 splitbelow " Horizontal split below current.
|
|
set splitright " Vertical split to right of current.
|
|
|
|
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 gdefault " Use 'g' flag by default with :s/foo/bar/.
|
|
set magic " Use 'magic' patterns (extended regular expressions).
|
|
set autoread " Autoload file if it changes on disk
|
|
set termguicolors " Enable colors for terminal
|
|
|
|
set clipboard^=unnamed,unnamedplus
|
|
set completeopt=menuone,preview,noinsert
|
|
set rtp+=/usr/bin/fzf
|
|
|
|
" Theme
|
|
syntax enable
|
|
colorscheme monokai
|
|
|
|
" Use <C-L> to clear the highlighting of :set hlsearch.
|
|
if maparg('<C-L>', 'n') ==# ''
|
|
nnoremap <silent> <C-L> :nohlsearch<CR><C-L>
|
|
endif
|
|
|
|
"nnoremap ; : " Use ; for commands.
|
|
"nnoremap Q @q " Use Q to execute default register.
|
|
|
|
" Plug shortcuts
|
|
nnoremap <Leader>pg :PlugUpgrade<CR>
|
|
nnoremap <Leader>pd :PlugUpdate<CR>
|
|
nnoremap <Leader>pc :PlugClean<CR>
|
|
" Open NerdTree
|
|
nnoremap <Leader>ee :NERDTree<CR>
|
|
" Open fuzzy file search
|
|
nnoremap <Leader>f :Files<CR>
|
|
nnoremap <Leader>gf :GFiles<CR>
|
|
" Use ripgrep to search for content in files
|
|
nnoremap <Leader>/ :Rg<CR>
|
|
" Save
|
|
nnoremap <Leader>w <Esc>:w<CR>
|
|
" Search and Replace
|
|
nnoremap <Leader>sr :%s//g<Left><Left>
|
|
" Quit
|
|
nnoremap <Leader>q <Esc>:q<CR>
|
|
" Search for the word under cursor
|
|
noremap <Leader>d :exe ':Rg ' . expand('<cword>')<CR>
|
|
" Open terminal
|
|
nnoremap <Leader>te :vsp<CR> :terminal<CR>
|
|
" Reload opened vim config file
|
|
nnoremap <Leader>vc :so %<CR>
|
|
" For git
|
|
nnoremap <Leader>gm :GitMessenger<CR>
|
|
nnoremap <Leader>gl :Glog<CR>
|
|
nnoremap <Leader>gd :Gdiffsplit<CR>
|
|
nnoremap <Leader>gs :Gstatus<CR>
|
|
nnoremap <Leader>gc :Gcommit --signoff<CR>
|
|
nnoremap <Leader>gp :Git! push<CR>
|
|
nnoremap <Leader>gu :Git! push -u
|
|
nnoremap <Leader>gr :Git! remote -v<CR>
|
|
" For Cscope
|
|
nnoremap <Leader>cr :cs reset<CR>
|
|
" For Neomake
|
|
nnoremap <Leader>nm :Neomake<CR>
|
|
nnoremap <Leader>nr :NeomakeClean<CR>
|
|
nnoremap <Leader>ns :NeomakeSh
|
|
nnoremap <Leader>nj :NeomakeListJobs<CR>
|
|
nnoremap <Leader>nca :NeomakeCancelJobs<CR>
|
|
nnoremap <Leader>ncj :NeomakeCancelJob
|
|
|
|
" Quickfix
|
|
nnoremap <Leader>fn :cnext<CR>
|
|
nnoremap <Leader>fp :cprevious<CR>
|
|
nnoremap <Leader>fo :copen<CR>
|
|
nnoremap <Leader>fc :cclose<CR>
|
|
|
|
" Location
|
|
nnoremap <Leader>ffn :lnext<CR>
|
|
nnoremap <Leader>ffp :lprevious<CR>
|
|
nnoremap <Leader>ffo :lopen<CR>
|
|
nnoremap <Leader>ffc :lclose<CR>
|
|
|
|
" Key Bindings to help with terminal mode
|
|
:tnoremap <Esc> <C-\><C-n>
|
|
" Key bindings to move between window splits
|
|
nnoremap <A-h> <C-w>h
|
|
nnoremap <A-j> <C-w>j
|
|
nnoremap <A-k> <C-w>k
|
|
nnoremap <A-l> <C-w>l
|
|
|
|
" 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>
|
|
|
|
augroup interoMaps
|
|
au!
|
|
" Maps for intero. Restrict to Haskell buffers so the bindings don't collide.
|
|
|
|
" Background process and window management
|
|
au FileType haskell nnoremap <silent> <leader>is :InteroStart<CR>
|
|
au FileType haskell nnoremap <silent> <leader>ir :InteroRestart<CR>
|
|
au FileType haskell nnoremap <silent> <leader>ik :InteroKill<CR>
|
|
|
|
" Open intero/GHCi split horizontally
|
|
au FileType haskell nnoremap <silent> <leader>io :InteroOpen<CR>
|
|
" Open intero/GHCi split vertically
|
|
au FileType haskell nnoremap <silent> <leader>iov :InteroOpen<CR><C-W>H
|
|
au FileType haskell nnoremap <silent> <leader>ih :InteroHide<CR>
|
|
|
|
" Reloading (pick one)
|
|
" Automatically reload on save
|
|
" au BufWritePost *.hs InteroReload
|
|
" Manually save and reload
|
|
au FileType haskell nnoremap <silent> <leader>wr :w \| :InteroReload<CR>
|
|
|
|
" Load individual modules
|
|
au FileType haskell nnoremap <silent> <leader>il :InteroLoadCurrentModule<CR>
|
|
au FileType haskell nnoremap <silent> <leader>if :InteroLoadCurrentFile<CR>
|
|
|
|
" Type-related information
|
|
" Heads up! These next two differ from the rest.
|
|
au FileType haskell map <silent> <leader>it <Plug>InteroGenericType
|
|
au FileType haskell map <silent> <leader>T <Plug>InteroType
|
|
au FileType haskell nnoremap <silent> <leader>iit :InteroTypeInsert<CR>
|
|
|
|
" Navigation
|
|
au FileType haskell nnoremap <silent> <leader>id :InteroGoToDef<CR>
|
|
|
|
" Managing targets
|
|
" Prompts you to enter targets (no silent):
|
|
au FileType haskell nnoremap <leader>ist :InteroSetTargets<SPACE>
|
|
augroup END
|
|
|
|
augroup deopleteMaps
|
|
au!
|
|
" For deoplete Rust
|
|
au FileType rust nmap <buffer> <Leader>rd <plug>DeopleteRustGoToDefinitionDefault
|
|
au FileType rust nmap <buffer> <Leader>rc <plug>DeopleteRustShowDocumentation
|
|
au FileType rust nmap <buffer> <Leader>rv <plug>DeopleteRustGoToDefinitionVSplit
|
|
au FileType rust nmap <buffer> <Leader>rh <plug>DeopleteRustGoToDefinitionSplit
|
|
au FileType rust nmap <buffer> <Leader>rt <plug>DeopleteRustGoToDefinitionTab
|
|
augroup END
|
|
|
|
augroup rainbow_lisp
|
|
autocmd!
|
|
autocmd FileType lisp,clojure,scheme RainbowParentheses
|
|
augroup END
|
|
|
|
" Starts the REPL.
|
|
autocmd FileType scheme nnoremap <buffer> <Leader>rc :SchemeConnect<cr>
|
|
" Evaluates the outer most / top level form and jumps the cursor back to where it was.
|
|
autocmd FileType scheme nnoremap <buffer> <Leader>re :normal mscpaF<cr>`s
|
|
" Evaluates the entire file.
|
|
autocmd FileType scheme nnoremap <buffer> <Leader>rf :normal msggcpG<cr>`s
|
|
|
|
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
|
|
|
|
" Intero starts automatically. Set this if you'd like to prevent that.
|
|
let g:intero_start_immediately = 0
|
|
" Enable type information on hover (when holding cursor at point for ~1 second).
|
|
let g:intero_type_on_hover = 1
|
|
" Change the intero window size; default is 10.
|
|
let g:intero_window_size = 75
|
|
" Sets the intero window to split vertically; default is horizontal
|
|
let g:intero_vertical_split = 1
|
|
" Use GHCi backend
|
|
let g:intero_backend = {
|
|
\ 'command' : 'stack ghci',
|
|
\ }
|
|
|
|
" Use deoplete
|
|
let g:deoplete#enable_at_startup = 1
|
|
" Disable autocomplete by default
|
|
" let b:deoplete_disable_auto_complete = 1
|
|
" let g:deoplete_disable_auto_complete = 1
|
|
" Let sources be empty by default
|
|
let g:deoplete#sources = {}
|
|
" Disable the candidates in Comment/String syntaxes.
|
|
call deoplete#custom#source('_',
|
|
\ 'disabled_syntaxes', ['Comment', 'String'])
|
|
call deoplete#custom#option('sources', {
|
|
\ '_' : ['buffer', 'tag'],
|
|
\ 'rust': ['racer'],
|
|
\})
|
|
let g:deoplete#sources#rust#disable_keymap = 1
|
|
let g:deoplete#sources#rust#racer_binary=expand('$HOME/.cargo/bin/racer')
|
|
let g:deoplete#sources#rust#rust_source_path=expand('$HOME/GitSources/rust/src')
|
|
|
|
" Use airline
|
|
let g:airline#extensions#tabline#enabled = 2
|
|
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_left_sep = ' '
|
|
let g:airline_left_alt_sep = '|'
|
|
let g:airline_right_sep = ' '
|
|
let g:airline_right_alt_sep = '|'
|
|
|
|
" Let vim-gitgutter do its thing on large files
|
|
let g:gitgutter_max_signs=10000
|
|
|
|
" gutentags configuration
|
|
" https://www.reddit.com/r/vim/comments/d77t6j/guide_how_to_setup_ctags_with_gutentags_properly/
|
|
let g:gutentags_add_default_project_roots = 0
|
|
let g:gutentags_project_root = ['.git']
|
|
let g:gutentags_cache_dir = expand('$HOME/.vim/tags/')
|
|
|
|
let g:gutentags_generate_on_new = 1
|
|
let g:gutentags_generate_on_missing = 1
|
|
let g:gutentags_generate_on_write = 1
|
|
let g:gutentags_generate_on_empty_buffer = 0
|
|
|
|
let g:gutentags_ctags_extra_args = [
|
|
\ '--tag-relative=no',
|
|
\ '--fields=+ailmnS',
|
|
\ '--recurse',
|
|
\ '--if0=yes'
|
|
\ ]
|
|
|
|
" Automatically detect style file and apply style to formatting
|
|
let g:clang_format#detect_style_file = 1
|
|
" Additional trigger not required with deoplete
|
|
let g:tmuxcomplete#trigger = ''
|
|
|
|
" Default indentations
|
|
autocmd BufRead,BufNewFile */gst-*/*.[ch] set et sw=2
|
|
autocmd BufRead,BufNewFile */gstreamer-*/*.[ch] set et sw=2
|
|
autocmd BufRead,BufNewFile */pulseaudio/*.[ch] set et sw=4 tw=128
|
|
" Spell Checking
|
|
autocmd BufRead,BufNewFile *.md,*.txt setlocal spell spelllang=en_uk
|
|
|
|
" For swoop
|
|
let g:swoopUseDefaultKeyMap = 0
|
|
let g:swoopPatternSpaceInsertsWildcard = 0
|
|
let g:swoopAutoInsertMode = 0
|
|
let g:swoopWindowsVerticalLayout = 1
|
|
|
|
nmap <Leader>os :call Swoop()<CR>
|
|
vmap <Leader>os :call SwoopSelection()<CR>
|
|
nmap <Leader>om :call SwoopMulti()<CR>
|
|
vmap <Leader>om :call SwoopMultiSelection()<CR>
|
|
|
|
" CScope & fzf integration
|
|
" Taken from https://gist.github.com/amitab/cd051f1ea23c588109c6cfcb7d1d5776
|
|
" However, the above gist has completely wrong mappings
|
|
function! Cscope(option, query)
|
|
let color = '{ x = $1; $1 = ""; z = $3; $3 = ""; printf "\033[34m%s\033[0m:\033[31m%s\033[0m\011\033[37m%s\033[0m\n", x,z,$0; }'
|
|
let opts = {
|
|
\ 'source': "cscope -dL" . a:option . " " . a:query . " | awk '" . color . "'",
|
|
\ 'options': ['--ansi', '--prompt', '> ',
|
|
\ '--multi', '--bind', 'alt-a:select-all,alt-d:deselect-all',
|
|
\ '--color', 'bw'],
|
|
\ 'down': '40%'
|
|
\ }
|
|
function! opts.sink(lines)
|
|
let data = split(a:lines)
|
|
let file = split(data[0], ":")
|
|
execute 'e ' . '+' . file[1] . ' ' . file[0]
|
|
endfunction
|
|
call fzf#run(opts)
|
|
endfunction
|
|
|
|
function! CscopeQuery(option)
|
|
call inputsave()
|
|
if a:option == '9'
|
|
let query = input('Assignments to: ')
|
|
elseif a:option == '3'
|
|
let query = input('Functions calling: ')
|
|
elseif a:option == '2'
|
|
let query = input('Functions called by: ')
|
|
elseif a:option == '6'
|
|
let query = input('Egrep: ')
|
|
elseif a:option == '7'
|
|
let query = input('File: ')
|
|
elseif a:option == '1'
|
|
let query = input('Definition: ')
|
|
elseif a:option == '8'
|
|
let query = input('Files #including: ')
|
|
elseif a:option == '0'
|
|
let query = input('C Symbol: ')
|
|
elseif a:option == '4'
|
|
let query = input('Text: ')
|
|
else
|
|
echo "Invalid option!"
|
|
return
|
|
endif
|
|
call inputrestore()
|
|
if query != ""
|
|
call Cscope(a:option, query)
|
|
else
|
|
echom "Cancelled Search!"
|
|
endif
|
|
endfunction
|
|
|
|
nnoremap <silent> <Leader>ss :call Cscope('0', expand('<cword>'))<CR>
|
|
nnoremap <silent> <Leader>sg :call Cscope('1', expand('<cword>'))<CR>
|
|
nnoremap <silent> <Leader>sd :call Cscope('2', expand('<cword>'))<CR>
|
|
nnoremap <silent> <Leader>sc :call Cscope('3', expand('<cword>'))<CR>
|
|
nnoremap <silent> <Leader>st :call Cscope('4', expand('<cword>'))<CR>
|
|
nnoremap <silent> <Leader>se :call Cscope('6', expand('<cword>'))<CR>
|
|
nnoremap <silent> <Leader>sf :call Cscope('7', expand('<cword>'))<CR>
|
|
nnoremap <silent> <Leader>si :call Cscope('8', expand('<cword>'))<CR>
|
|
nnoremap <silent> <Leader>sa :call Cscope('9', expand('<cword>'))<CR>
|
|
|
|
nnoremap <silent> <Leader><Leader>ss :call CscopeQuery('0')<CR>
|
|
nnoremap <silent> <Leader><Leader>sg :call CscopeQuery('1')<CR>
|
|
nnoremap <silent> <Leader><Leader>sd :call CscopeQuery('2')<CR>
|
|
nnoremap <silent> <Leader><Leader>sc :call CscopeQuery('3')<CR>
|
|
nnoremap <silent> <Leader><Leader>st :call CscopeQuery('4')<CR>
|
|
nnoremap <silent> <Leader><Leader>se :call CscopeQuery('6')<CR>
|
|
nnoremap <silent> <Leader><Leader>sf :call CscopeQuery('7')<CR>
|
|
nnoremap <silent> <Leader><Leader>si :call CscopeQuery('8')<CR>
|
|
nnoremap <silent> <Leader><Leader>sa :call CscopeQuery('9')<CR>
|