nvim: Refactor neovim configuration

Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
This commit is contained in:
Sanchayan Maity 2020-05-06 17:21:31 +05:30
parent fe35fd065c
commit 80e2aa9341
7 changed files with 512 additions and 504 deletions

View file

@ -0,0 +1,34 @@
augroup rainbow_lisp
autocmd!
autocmd FileType lisp,clojure,scheme RainbowParentheses
augroup END
augroup terminal_job
au!
au TermOpen * startinsert
au TermOpen * setlocal listchars= nonumber norelativenumber
augroup END
augroup ResizeWindowsProportionally
au!
autocmd VimResized * :wincmd =
augroup END
augroup VinegarNetrw
au!
autocmd FileType netrw set bufhidden=delete
augroup END
augroup UserStatusline
autocmd!
autocmd BufEnter,WinEnter,TermOpen * setlocal statusline=%!ActiveStatus()
autocmd WinLeave * setlocal statusline=%!PassiveStatus()
autocmd ColorScheme * hi User1 guifg=DarkRed guibg=Black
autocmd ColorScheme * hi User2 guifg=White guibg=Black
autocmd ColorScheme * hi User3 guifg=Cyan guibg=Black
autocmd ColorScheme * hi User4 guifg=Orange guibg=Black
autocmd ColorScheme * hi User5 guifg=Red guibg=Black
autocmd ColorScheme * hi User6 guifg=Gray guibg=Black
autocmd ColorScheme * hi User7 guifg=Gray guibg=Black
autocmd ColorScheme * hi User8 guifg=DarkYellow guibg=Black
augroup END

View file

@ -0,0 +1,83 @@
" Set up leaders
let mapleader="\<SPACE>"
let maplocalleader=","
set shada="NONE" " Prevent SHADA files from being generated or read
set colorcolumn=80 " Highlight 80th column
set laststatus=2 " Always show status bar
set updatetime=100 " Let plugins show effects after 100ms
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 nofoldenable " Open folds by default
set undofile " Enable undo persistence across sessions
set hidden
set noautochdir
set hlsearch
" 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 switchbuf=useopen
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
let g:jellybeans_use_term_italics = 1
let g:jellybeans_overrides = { 'background': { 'guibg': '000000' } }
colorscheme jellybeans
" Disable providers we do not give a shit about
let g:loaded_python_provider = 0
let g:loaded_ruby_provider = 0
let g:loaded_perl_provider = 0
let g:loaded_node_provider = 0
let g:python3_host_prog = '/usr/bin/python3'

View file

@ -0,0 +1,60 @@
function! NvimGdbNoTKeymaps()
tnoremap <silent> <buffer> <Esc> <C-\><C-n>
endfunction
" Taken from gitgutter README. Cycles through all hunks in all open buffers.
function! NextHunkAllBuffers()
let line = line('.')
GitGutterNextHunk
if line('.') != line
return
endif
let bufnr = bufnr('')
while 1
bnext
if bufnr('') == bufnr
return
endif
if !empty(GitGutterGetHunks())
1
GitGutterNextHunk
return
endif
endwhile
endfunction
function! PrevHunkAllBuffers()
let line = line('.')
GitGutterPrevHunk
if line('.') != line
return
endif
let bufnr = bufnr('')
while 1
bprevious
if bufnr('') == bufnr
return
endif
if !empty(GitGutterGetHunks())
normal! G
GitGutterPrevHunk
return
endif
endwhile
endfunction
function! GotoJump()
jumps
let j = input("Please select your jump: ")
if j != ''
let pattern = '\v\c^\+'
if j =~ pattern
let j = substitute(j, pattern, '', 'g')
execute "normal " . j . "\<C-i>"
else
execute "normal " . j . "\<C-o>"
endif
endif
endfunction

View file

@ -1,7 +1,5 @@
" Specify a directory for plugins (for Neovim: ~/.local/share/nvim/plugged)
call plug#begin('~/.config/nvim/plugged')
" ----------------------------- Plugins --------------------------------------
" Tab completion
Plug 'ervandew/supertab'
" EasyMotion
@ -103,502 +101,18 @@ Plug 'andymass/vim-matchup'
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 shada="NONE" " Prevent SHADA files from being generated or read
set colorcolumn=80 " Highlight 80th column
set laststatus=2 " Always show status bar
set updatetime=100 " Let plugins show effects after 100ms
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 nofoldenable " Open folds by default
set undofile " Enable undo persistence across sessions
set hidden
set noautochdir
set hlsearch
" 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 switchbuf=useopen
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
set grepprg=rg\ --vimgrep
let g:jellybeans_use_term_italics = 1
let g:jellybeans_overrides = { 'background': { 'guibg': '000000' } }
colorscheme jellybeans
" --------------------------- Key Bindings -----------------------------------
" Allow saving of files as sudo when I forgot to start vim using sudo
cmap w!! w !sudo tee > /dev/null %
" 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>
" Jump and change list
nnoremap <Leader>o :call GotoJump()<CR>
nnoremap <Leader>; :changes<CR>:keepjumps norm g;<Left><Left>
nnoremap <Leader>, :changes<CR>:keepjumps norm g,<Left><Left>
" 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>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)
" 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>
nnoremap [t :tabprevious<CR>
nnoremap ]t :tabnext<CR>
nnoremap [T :tabfirst<CR>
nnoremap ]T :tablast<CR>
nnoremap <Leader>b :b<SPACE>
nnoremap <Leader>bl :ls<CR>:b<SPACE>
nnoremap <Leader>bd :bd<SPACE>
" 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>glh :Gina log --opener=split<CR>
nnoremap <Leader>glv :Gina log --opener=vsplit<CR>
nnoremap <Leader>gL :Gina log<SPACE>
nnoremap <Leader>gdh :Gina diff --opener=split<CR>
nnoremap <Leader>gdv :Gina diff --opener=split<CR>
nnoremap <Leader>gD :Gina diff<SPACE>
nnoremap <Leader>gs :Gina! status<CR>
nnoremap <Leader>ghs :Gina status --opener=split<CR>
nnoremap <Leader>gvs :Gina status --opener=vsplit<CR>
nnoremap <Leader>gc :Gina commit -v -q --signoff<CR>
nnoremap <Leader>gt :Gina commit -v -q --signoff %:p<CR>
nnoremap <Leader>gp :Gina push<CR>
nnoremap <Leader>gu :Gina push -u<SPACE>
nnoremap <Leader>gr :Gina remote -v<CR>
nnoremap <Leader>gb :Gina! branch<CR>
nnoremap <Leader>gB :Gina branch<SPACE>
nnoremap <Leader>go :Gina checkout<SPACE>
nnoremap <Leader>g- :Gina stash<CR>:e<CR>
nnoremap <Leader>g+ :Gina stash<SPACE>
" For gitgutter
nnoremap ]h :GitGutterNextHunk<CR>
nnoremap [h :GitGutterPrevHunk<CR>
nnoremap ]c :call NextHunkAllBuffers()<CR>
nnoremap [c :call PrevHunkAllBuffers()<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>
omap ih <Plug>(GitGutterTextObjectInnerPending)
omap ah <Plug>(GitGutterTextObjectOuterPending)
xmap ih <Plug>(GitGutterTextObjectInnerVisual)
xmap ah <Plug>(GitGutterTextObjectOuterVisual)
" Jump to sections of diff
nnoremap [d ?^@@<CR>
nnoremap ]d /^@@<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'
let g:vim_home = get(g:, 'vim_home', expand('~/.config/nvim/'))
let config_list = [
\ 'config.vim',
\ 'autocmd.vim',
\ 'functions.vim',
\ 'keymappings.vim',
\ 'plugin_settings.vim',
\]
for files in config_list
for f in glob(g:vim_home.files, 1, 1)
exec 'source' f
endfor
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}))
" Incremental search
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
" Tag helpers
nnoremap <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
nnoremap <A-]> :sp <CR>:exec("tag ".expand("<cword>"))<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)
" --------------------------- Autocmd groups ---------------------------------
augroup rainbow_lisp
autocmd!
autocmd FileType lisp,clojure,scheme RainbowParentheses
augroup END
augroup terminal_job
au!
au TermOpen * startinsert
au TermOpen * setlocal listchars= nonumber norelativenumber
augroup END
augroup ResizeWindowsProportionally
au!
autocmd VimResized * :wincmd =
augroup END
augroup VinegarNetrw
au!
autocmd FileType netrw set bufhidden=delete
augroup END
" --------------------------- Plugin settings --------------------------------
" Close open netrw buffers once done selecting file in vinegar
" See https://github.com/tpope/vim-vinegar/issues/13
let g:netrw_fastbrowse = 0
" 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
" For SLIMV
let g:lisp_rainbow=1
" FZF
let $FZF_DEFAULT_OPTS='--layout=reverse'
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.6 } }
" Disable providers we do not give a shit about
let g:loaded_python_provider = 0
let g:loaded_ruby_provider = 0
let g:loaded_perl_provider = 0
let g:loaded_node_provider = 0
let g:python3_host_prog = '/usr/bin/python3'
" 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 = ['─', '│', '─', '│', '╭', '╮', '╯', '╰']
" 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
" Easymotion incsearch
let g:incsearch#auto_nohlsearch = 1
" Buftabline
let g:buftabline_plug_max = 0
let g:buftabline_numbers = 1
let g:buftabline_indicators = 1
" Deoplete
let g:deoplete#enable_at_startup = 0
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')
let g:deoplete#sources = {}
call deoplete#custom#source('_', 'disabled_syntaxes', ['Comment', 'String'])
call deoplete#custom#option('sources', {
\ '_' : ['buffer', 'omni', 'around', 'file', 'member'],
\ 'haskell': ['tag', 'buffer', 'omni'],
\ 'c': ['tag', 'buffer'],
\ 'purescript': ['buffer', 'omni'],
\ 'rust': ['racer', 'buffer'],
\})
call deoplete#custom#source('omni', 'functions', {
\ 'purescript': 'PSCIDEComplete',
\})
call deoplete#custom#var('omni', 'input_patterns', {
\ 'purescript': '\w*',
\})
call deoplete#custom#option({
\ 'auto_complete_delay': 200,
\ 'auto_complete': v:true,
\ 'smart_case': v:true,
\ })
" ----------------------------- 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
" Taken from gitgutter README. Cycles through all hunks in all open buffers.
function! NextHunkAllBuffers()
let line = line('.')
GitGutterNextHunk
if line('.') != line
return
endif
let bufnr = bufnr('')
while 1
bnext
if bufnr('') == bufnr
return
endif
if !empty(GitGutterGetHunks())
1
GitGutterNextHunk
return
endif
endwhile
endfunction
function! PrevHunkAllBuffers()
let line = line('.')
GitGutterPrevHunk
if line('.') != line
return
endif
let bufnr = bufnr('')
while 1
bprevious
if bufnr('') == bufnr
return
endif
if !empty(GitGutterGetHunks())
normal! G
GitGutterPrevHunk
return
endif
endwhile
endfunction
function! GotoJump()
jumps
let j = input("Please select your jump: ")
if j != ''
let pattern = '\v\c^\+'
if j =~ pattern
let j = substitute(j, pattern, '', 'g')
execute "normal " . j . "\<C-i>"
else
execute "normal " . j . "\<C-o>"
endif
endif
endfunction

View file

@ -0,0 +1,211 @@
" Allow saving of files as sudo when I forgot to start vim using sudo
cmap w!! w !sudo tee > /dev/null %
" 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>
" Jump and change list
nnoremap <Leader>o :call GotoJump()<CR>
nnoremap <Leader>; :changes<CR>:keepjumps norm g;<Left><Left>
nnoremap <Leader>, :changes<CR>:keepjumps norm g,<Left><Left>
" 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>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)
" 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>
nnoremap [t :tabprevious<CR>
nnoremap ]t :tabnext<CR>
nnoremap [T :tabfirst<CR>
nnoremap ]T :tablast<CR>
nnoremap <Leader>b :b<SPACE>
nnoremap <Leader>bl :ls<CR>:b<SPACE>
nnoremap <Leader>bd :bd<SPACE>
" 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>glh :Gina log --opener=split<CR>
nnoremap <Leader>glv :Gina log --opener=vsplit<CR>
nnoremap <Leader>gL :Gina log<SPACE>
nnoremap <Leader>gdh :Gina diff --opener=split<CR>
nnoremap <Leader>gdv :Gina diff --opener=split<CR>
nnoremap <Leader>gD :Gina diff<SPACE>
nnoremap <Leader>gs :Gina! status<CR>
nnoremap <Leader>ghs :Gina status --opener=split<CR>
nnoremap <Leader>gvs :Gina status --opener=vsplit<CR>
nnoremap <Leader>gc :Gina commit -v -q --signoff<CR>
nnoremap <Leader>gt :Gina commit -v -q --signoff %:p<CR>
nnoremap <Leader>gp :Gina push<CR>
nnoremap <Leader>gu :Gina push -u<SPACE>
nnoremap <Leader>gr :Gina remote -v<CR>
nnoremap <Leader>gb :Gina! branch<CR>
nnoremap <Leader>gB :Gina branch<SPACE>
nnoremap <Leader>go :Gina checkout<SPACE>
nnoremap <Leader>g- :Gina stash<CR>:e<CR>
nnoremap <Leader>g+ :Gina stash<SPACE>
" For gitgutter
nnoremap ]h :GitGutterNextHunk<CR>
nnoremap [h :GitGutterPrevHunk<CR>
nnoremap ]c :call NextHunkAllBuffers()<CR>
nnoremap [c :call PrevHunkAllBuffers()<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>
omap ih <Plug>(GitGutterTextObjectInnerPending)
omap ah <Plug>(GitGutterTextObjectOuterPending)
xmap ih <Plug>(GitGutterTextObjectInnerVisual)
xmap ah <Plug>(GitGutterTextObjectOuterVisual)
" Jump to sections of diff
nnoremap [d ?^@@<CR>
nnoremap ]d /^@@<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}))
" Incremental search
map n <Plug>(incsearch-nohl-n)
map N <Plug>(incsearch-nohl-N)
map * <Plug>(incsearch-nohl-*)
map # <Plug>(incsearch-nohl-#)
map g* <Plug>(incsearch-nohl-g*)
map g# <Plug>(incsearch-nohl-g#)
" Tag helpers
nnoremap <C-\> :vsp <CR>:exec("tag ".expand("<cword>"))<CR>
nnoremap <A-]> :sp <CR>:exec("tag ".expand("<cword>"))<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)
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

View file

@ -1,9 +1,3 @@
augroup UserStatusline
autocmd!
autocmd BufEnter,WinEnter,TermOpen * setlocal statusline=%!ActiveStatus()
autocmd WinLeave * setlocal statusline=%!PassiveStatus()
augroup END
hi User1 guifg=DarkRed guibg=Black
hi User2 guifg=White guibg=Black
hi User3 guifg=Cyan guibg=Black

View file

@ -0,0 +1,112 @@
" Close open netrw buffers once done selecting file in vinegar
" See https://github.com/tpope/vim-vinegar/issues/13
let g:netrw_fastbrowse = 0
" 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
" For SLIMV
let g:lisp_rainbow=1
" FZF
let $FZF_DEFAULT_OPTS='--layout=reverse'
let g:fzf_layout = { 'window': { 'width': 0.8, 'height': 0.6 } }
" 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 = ['─', '│', '─', '│', '╭', '╮', '╯', '╰']
" 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
" Easymotion incsearch
let g:incsearch#auto_nohlsearch = 1
" Buftabline
let g:buftabline_plug_max = 0
let g:buftabline_numbers = 1
let g:buftabline_indicators = 1
" Deoplete
let g:deoplete#enable_at_startup = 0
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')
let g:deoplete#sources = {}
call deoplete#custom#source('_', 'disabled_syntaxes', ['Comment', 'String'])
call deoplete#custom#option('sources', {
\ '_' : ['buffer', 'omni', 'around', 'file', 'member'],
\ 'haskell': ['tag', 'buffer', 'omni'],
\ 'c': ['tag', 'buffer'],
\ 'purescript': ['buffer', 'omni'],
\ 'rust': ['racer', 'buffer'],
\})
call deoplete#custom#source('omni', 'functions', {
\ 'purescript': 'PSCIDEComplete',
\})
call deoplete#custom#var('omni', 'input_patterns', {
\ 'purescript': '\w*',
\})
call deoplete#custom#option({
\ 'auto_complete_delay': 200,
\ 'auto_complete': v:true,
\ 'smart_case': v:true,
\ })