2016-03-31 02:03:55 +00:00
|
|
|
set nocompatible " be iMproved, required
|
|
|
|
|
2017-11-23 19:15:43 +00:00
|
|
|
" Reconfigure Vim to be clean!
|
2018-04-20 23:20:51 +00:00
|
|
|
set undodir=$XDG_CACHE_HOME/vim/undo//
|
|
|
|
set directory=$XDG_CACHE_HOME/vim/swap//
|
|
|
|
set backupdir=$XDG_CACHE_HOME/vim/backup//
|
2018-04-12 01:51:32 +00:00
|
|
|
set viminfo+='1000,n$XDG_CACHE_HOME/vim/viminfo
|
2018-10-19 10:57:19 +00:00
|
|
|
set runtimepath-=$HOME/.vim
|
|
|
|
set runtimepath^=$XDG_CONFIG_HOME/vim,$VIMRUNTIME,$XDG_CONFIG_HOME/vim/after
|
2018-10-19 10:51:24 +00:00
|
|
|
let g:netrw_home=$XDG_CACHE_HOME.'/vim'
|
2017-11-23 19:15:43 +00:00
|
|
|
|
2018-04-20 23:20:51 +00:00
|
|
|
silent !mkdir -p $XDG_CACHE_HOME/vim/swap $XDG_CACHE_HOME/vim/undo $XDG_CACHE_HOME/vim/backup
|
|
|
|
|
2016-04-01 11:45:17 +00:00
|
|
|
set tabstop=4
|
2016-11-14 14:06:52 +00:00
|
|
|
set shiftwidth=0 " Use tabstop
|
|
|
|
set softtabstop=-1 " Use tabstop
|
2016-04-01 11:45:17 +00:00
|
|
|
set expandtab
|
2017-09-05 20:48:36 +00:00
|
|
|
set smarttab
|
|
|
|
set smartindent
|
2016-04-01 11:45:17 +00:00
|
|
|
set number
|
2017-11-15 23:49:37 +00:00
|
|
|
set linebreak
|
2016-04-01 11:45:17 +00:00
|
|
|
set autoindent
|
2018-03-31 12:44:42 +00:00
|
|
|
set breakindent
|
2016-04-01 11:45:17 +00:00
|
|
|
set laststatus=2
|
|
|
|
set encoding=utf-8
|
2016-04-01 16:39:00 +00:00
|
|
|
set background=dark
|
2017-11-23 19:15:43 +00:00
|
|
|
set omnifunc=syntaxcomplete#Complete
|
2017-09-05 20:48:36 +00:00
|
|
|
set title
|
|
|
|
set clipboard=unnamed
|
|
|
|
set wildmenu
|
|
|
|
set report=0
|
|
|
|
set lazyredraw
|
|
|
|
set ttyfast
|
|
|
|
set autoread
|
|
|
|
set showmatch
|
|
|
|
set scrolloff=6
|
|
|
|
set nojoinspaces
|
2018-03-30 13:44:32 +00:00
|
|
|
set updatetime=500 " reduce delay from 4s default
|
2017-09-05 20:48:36 +00:00
|
|
|
|
2018-03-31 20:52:02 +00:00
|
|
|
let mapleader="\<space>"
|
|
|
|
|
2021-07-31 00:14:10 +00:00
|
|
|
" ALE config
|
|
|
|
let g:ale_completion_enabled = 1
|
|
|
|
let g:ale_open_list = 1
|
|
|
|
augroup CloseLoclistWindowGroup
|
|
|
|
autocmd!
|
|
|
|
autocmd QuitPre * if empty(&buftype) | lclose | endif
|
|
|
|
augroup END
|
|
|
|
|
2017-11-26 00:57:47 +00:00
|
|
|
" Autosave settings
|
2018-03-30 13:44:32 +00:00
|
|
|
function! SaveIfExist()
|
2018-03-31 20:52:28 +00:00
|
|
|
if @% != "" && filereadable(@%) && !&readonly && &modified
|
2018-03-29 11:15:20 +00:00
|
|
|
write
|
|
|
|
endif
|
|
|
|
endfunction
|
2017-11-26 00:57:47 +00:00
|
|
|
set autowrite
|
2018-03-31 20:52:28 +00:00
|
|
|
autocmd CursorHold,CursorHoldI,InsertLeave,FocusGained,FocusLost * call SaveIfExist()
|
2017-07-15 12:36:22 +00:00
|
|
|
|
2017-09-29 11:54:19 +00:00
|
|
|
" Search options
|
|
|
|
set hlsearch
|
|
|
|
set ignorecase
|
|
|
|
set smartcase
|
2018-03-31 20:53:40 +00:00
|
|
|
set magic
|
2017-09-29 11:54:19 +00:00
|
|
|
|
2020-08-10 21:01:22 +00:00
|
|
|
" Auto-resize split on window resize
|
|
|
|
autocmd VimResized * wincmd =
|
2018-03-31 20:52:52 +00:00
|
|
|
" More natural splits
|
|
|
|
set splitbelow " Horizontal split below current.
|
|
|
|
set splitright " Vertical split to right of current.
|
|
|
|
|
2017-11-10 12:43:29 +00:00
|
|
|
" Whitespace highlight settings
|
|
|
|
set list
|
2018-04-03 16:09:31 +00:00
|
|
|
set listchars=eol:$,space:·,tab:>-,trail:◦,extends:▶,precedes:◀
|
2018-03-29 10:54:40 +00:00
|
|
|
highlight SpecialKey ctermfg=8
|
2017-11-10 12:43:29 +00:00
|
|
|
|
2018-03-29 11:16:30 +00:00
|
|
|
if exists('+colorcolumn')
|
|
|
|
highlight ColorColumn ctermbg=8
|
|
|
|
autocmd filetype c,h,cpp,hpp set colorcolumn=81
|
|
|
|
autocmd filetype c,h,cpp,hpp match ErrorMsg '\%>80v.\+'
|
|
|
|
endif
|
|
|
|
|
2018-03-31 20:54:36 +00:00
|
|
|
" Highlight line and column of cursor
|
|
|
|
set cul cuc
|
|
|
|
highlight CursorLine cterm=NONE ctermbg=8
|
|
|
|
highlight CursorColumn cterm=NONE ctermbg=8
|
2017-11-26 00:57:47 +00:00
|
|
|
|
2018-04-23 00:10:05 +00:00
|
|
|
if empty(glob('$XDG_CONFIG_HOME/vim/autoload/plug.vim'))
|
|
|
|
silent !curl -fsSLo $XDG_CONFIG_HOME/vim/autoload/plug.vim --create-dirs
|
|
|
|
\ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
|
|
|
|
autocmd VimEnter * PlugInstall --sync | source $VIMRC
|
|
|
|
endif
|
|
|
|
|
|
|
|
call plug#begin('$XDG_CONFIG_HOME/vim/plug')
|
|
|
|
|
|
|
|
Plug 'scrooloose/nerdtree', { 'on': 'NERTreeToggle' }
|
|
|
|
Plug 'tpope/vim-sensible'
|
|
|
|
Plug 'tpope/vim-fugitive'
|
|
|
|
Plug 'tpope/vim-rhubarb'
|
|
|
|
Plug 'tpope/vim-abolish'
|
|
|
|
Plug 'tpope/vim-surround'
|
|
|
|
Plug 'tpope/vim-repeat'
|
|
|
|
Plug 'tpope/vim-commentary'
|
|
|
|
Plug 'majutsushi/tagbar'
|
|
|
|
Plug 'airblade/vim-gitgutter'
|
|
|
|
Plug 'ryanoasis/vim-devicons'
|
|
|
|
Plug 'vim-airline/vim-airline'
|
|
|
|
Plug 'vim-airline/vim-airline-themes'
|
|
|
|
Plug 'lervag/vimtex'
|
|
|
|
Plug 'JamshedVesuna/vim-markdown-preview'
|
|
|
|
Plug 'junegunn/fzf.vim'
|
2021-07-31 00:14:10 +00:00
|
|
|
|
|
|
|
" Completion and linting
|
|
|
|
Plug 'dense-analysis/ale'
|
|
|
|
Plug 'Shougo/deoplete.nvim'
|
|
|
|
Plug 'roxma/nvim-yarp'
|
|
|
|
Plug 'roxma/vim-hug-neovim-rpc'
|
|
|
|
|
2018-04-23 00:10:05 +00:00
|
|
|
Plug 'fatih/vim-go', { 'do': ':GoUpdateBinaries' }
|
|
|
|
|
2018-10-22 20:26:31 +00:00
|
|
|
" Syntax Highlighting
|
|
|
|
Plug 'chr4/nginx.vim'
|
|
|
|
Plug 'PotatoesMaster/i3-vim-syntax'
|
|
|
|
Plug 'puppetlabs/puppet-syntax-vim'
|
2020-07-14 20:07:18 +00:00
|
|
|
Plug 'saltstack/salt-vim'
|
2018-10-22 20:26:31 +00:00
|
|
|
Plug 'arrufat/vala.vim'
|
2021-07-31 00:14:10 +00:00
|
|
|
Plug 'Glench/Vim-Jinja2-Syntax'
|
|
|
|
Plug 'pearofducks/ansible-vim'
|
|
|
|
Plug 'jvirtanen/vim-hcl'
|
|
|
|
Plug 'hashivim/vim-terraform'
|
2018-10-22 20:26:31 +00:00
|
|
|
|
2018-04-23 00:10:05 +00:00
|
|
|
call plug#end()
|
2016-03-31 02:03:55 +00:00
|
|
|
|
2017-11-23 19:07:36 +00:00
|
|
|
" Change to dvorak-mapped keys
|
|
|
|
let g:use_dvorak = 1
|
2016-10-04 08:50:16 +00:00
|
|
|
|
2021-07-31 00:14:10 +00:00
|
|
|
" Deoplete config
|
|
|
|
call deoplete#custom#option({
|
|
|
|
\ 'camel_case': v:true,
|
|
|
|
\ })
|
|
|
|
call deoplete#enable()
|
2017-11-23 21:33:03 +00:00
|
|
|
|
2016-04-01 11:45:17 +00:00
|
|
|
" Vim-Airline config
|
|
|
|
let g:Powerline_symbols = 'fancy'
|
|
|
|
let g:airline_powerline_fonts = 1
|
2016-04-01 16:39:00 +00:00
|
|
|
let g:airline_theme='solarized'
|
2016-05-10 16:07:08 +00:00
|
|
|
let g:airline#extensions#tabline#enabled = 1
|
2021-07-31 00:14:10 +00:00
|
|
|
" ALE integration
|
|
|
|
let g:airline#extensions#ale#enabled = 1
|
2016-05-10 16:07:08 +00:00
|
|
|
|
2017-09-05 20:48:36 +00:00
|
|
|
" vim-markdown plugin
|
|
|
|
let vim_markdown_preview_toggle=0
|
|
|
|
let vim_markdown_preview_browser='Chromium'
|
|
|
|
let vim_markdown_preview_use_xdg_open=1
|
|
|
|
let vim_markdown_preview_github=1
|
2016-05-10 16:07:08 +00:00
|
|
|
|
2021-07-31 00:14:10 +00:00
|
|
|
" LaTeX config
|
|
|
|
let g:tex_flavor='xelatex'
|
|
|
|
let g:vimtex_indent_enabled = 0 " auto-indentation is wrong and annoying
|
|
|
|
autocmd FileType tex silent VimtexCompile
|
|
|
|
autocmd FileType tex setlocal spell
|
|
|
|
augroup vimtex
|
|
|
|
autocmd!
|
|
|
|
autocmd BufWritePost tex call vimtex#toc#refresh()
|
|
|
|
autocmd BufWritePost tex call vimtex#labels#refresh()
|
|
|
|
autocmd BufWritePost tex silent VimtexCompile
|
|
|
|
augroup END
|
2018-03-29 15:00:15 +00:00
|
|
|
|
|
|
|
" Tagbar configuration
|
|
|
|
let g:tagbar_width = 50
|
|
|
|
let g:tagbar_compact = 1
|
|
|
|
let g:tagbar_show_linenumbers = 1
|
|
|
|
let g:tagbar_singleclick = 1
|
|
|
|
let g:tagbar_autopreview = 1
|
2017-11-26 00:57:47 +00:00
|
|
|
|
2018-03-31 20:52:02 +00:00
|
|
|
" NERDTree configuration
|
2018-04-12 02:00:02 +00:00
|
|
|
map <leader><tab> :NERDTreeToggle<CR>
|
2018-03-31 20:52:02 +00:00
|
|
|
|
|
|
|
" FZF configurationn
|
2018-04-12 02:00:02 +00:00
|
|
|
map <leader><space> :Files<CR>
|
|
|
|
map <leader>b :Buffers<CR>
|
|
|
|
map <leader>l :Lines<CR>
|
2018-03-31 20:52:02 +00:00
|
|
|
|
2017-11-26 00:57:47 +00:00
|
|
|
" Disable mouse
|
|
|
|
set mouse=nicr
|
|
|
|
nnoremap <LeftMouse> <nop>
|
|
|
|
nnoremap <RightMouse> <nop>
|
|
|
|
|
2018-03-14 02:08:51 +00:00
|
|
|
" Remap completion
|
|
|
|
inoremap <C-Space> <C-x><C-o>
|
|
|
|
inoremap <C-@> <C-Space>
|
|
|
|
|
2016-10-12 14:03:09 +00:00
|
|
|
" Unbind arrow keys
|
2016-10-20 23:04:45 +00:00
|
|
|
for prefix in ['n', 'v']
|
2016-10-12 14:03:09 +00:00
|
|
|
for key in ['<Up>', '<Down>', '<Left>', '<Right>']
|
|
|
|
exe prefix . "noremap " . key . " <Nop>"
|
|
|
|
endfor
|
|
|
|
endfor
|
2016-05-10 16:07:08 +00:00
|
|
|
|
2018-03-29 15:00:15 +00:00
|
|
|
" Source: https://github.com/ChrisLane/dotfiles/blob/1f5efd44e1b78224568645eaec2e6e243959c0a9/.vimrc#L66
|
|
|
|
" Remove whitespace at end of lines with F5
|
|
|
|
:nnoremap <silent> <F5> :let _s=@/ <Bar> :%s/\s\+$//e <Bar> :let @/=_s <Bar> :nohl <Bar> :unlet _s <CR>
|
|
|
|
|
2016-05-10 16:07:08 +00:00
|
|
|
" Dvorak Hackery
|
|
|
|
" Source: https://github.com/sporkbox/vimrc/blob/master/vimrc
|
|
|
|
if (exists("g:use_dvorak") && g:use_dvorak == 1)
|
|
|
|
" I use a Dvorak keyboard, so standard vim movement keys are a hassle.
|
|
|
|
" Since mnemonics are helpful all around, I need a mapping that gives me
|
|
|
|
" pain-free file navigation without screwing up mnemonics (too much).
|
|
|
|
"
|
|
|
|
" Thus:
|
|
|
|
" (D)elete is now (K)ill: d2w == k2w "kill 2 words"
|
|
|
|
" Un(T)il is now (J)ump-To: dt( == kj( "kill, jump-to paren"
|
|
|
|
" (N)ext is now (L)eap: cn == cl "change up to leap point"
|
|
|
|
|
|
|
|
" Standard movement, which is the true focus of this hack.
|
|
|
|
" Mnemonics are awesome, so let's preserve as much as possible.
|
|
|
|
noremap d h
|
|
|
|
noremap h j
|
|
|
|
noremap t k
|
|
|
|
noremap n l
|
|
|
|
|
|
|
|
noremap gh gj
|
|
|
|
noremap gt gk
|
|
|
|
|
|
|
|
" I work with tabs every now and then. No, I don't have a mnemonic, so
|
|
|
|
" stfu.
|
|
|
|
noremap gj gt
|
|
|
|
noremap gJ gT
|
|
|
|
|
|
|
|
" Window movement, equally important
|
|
|
|
noremap <C-w>d <C-w>h
|
|
|
|
noremap <C-w>h <C-w>j
|
|
|
|
noremap <C-w>t <C-w>k
|
|
|
|
noremap <C-w>n <C-w>l
|
|
|
|
|
|
|
|
nnoremap <C-w><C-d> <C-w><C-h>
|
|
|
|
nnoremap <C-w><C-h> <C-w><C-j>
|
|
|
|
nnoremap <C-w><C-t> <C-w><C-k>
|
|
|
|
nnoremap <C-w><C-n> <C-w><C-l>
|
|
|
|
|
2017-11-23 19:07:36 +00:00
|
|
|
nnoremap <C-d> <C-w>h
|
|
|
|
nnoremap <C-h> <C-w>j
|
|
|
|
nnoremap <C-t> <C-w>k
|
|
|
|
nnoremap <C-n> <C-w>l
|
2016-05-10 16:07:08 +00:00
|
|
|
|
|
|
|
" Account for tag jumping
|
|
|
|
nnoremap <C-j> <C-t>
|
|
|
|
|
|
|
|
" Remappings for the D key
|
|
|
|
noremap k d
|
|
|
|
noremap K D
|
|
|
|
|
|
|
|
" Remappings for the T key
|
|
|
|
noremap j t
|
2017-11-26 00:57:47 +00:00
|
|
|
"noremap J T
|
2016-05-10 16:07:08 +00:00
|
|
|
|
|
|
|
" Remapping for the L key
|
|
|
|
noremap l n
|
|
|
|
noremap L N
|
|
|
|
|
|
|
|
" General purpose help; the originals remain for convenience
|
|
|
|
noremap - 0
|
|
|
|
noremap _ $
|
|
|
|
|
|
|
|
" Fold-related keybindings
|
|
|
|
noremap zh zj
|
|
|
|
noremap zt zk
|
|
|
|
|
2017-11-23 21:26:29 +00:00
|
|
|
" Disable some default vimtex mappings that conflict with rebound keys
|
|
|
|
let g:vimtex_mappings_disable = {
|
|
|
|
\ 'n': ['tse', 'tsd', 'tsD', 'tsc', 'dse', 'dsc', 'ds$', 'dsd'],
|
|
|
|
\ 'x': ['tsd', 'tsD'],
|
|
|
|
\}
|
|
|
|
|
2018-04-12 02:00:02 +00:00
|
|
|
" NERDTree configuration
|
|
|
|
let NERDTreeMapOpenInTab='\t' " prevent t opening file
|
2018-03-31 20:52:02 +00:00
|
|
|
|
2018-10-19 13:44:31 +00:00
|
|
|
" Also remap keys in :Explore
|
|
|
|
augroup netrw_dvorak_fix
|
|
|
|
autocmd!
|
|
|
|
autocmd filetype netrw call Fix_netrw_maps_for_dvorak()
|
|
|
|
augroup END
|
|
|
|
function! Fix_netrw_maps_for_dvorak()
|
|
|
|
noremap <buffer> d h
|
|
|
|
noremap <buffer> h j
|
|
|
|
noremap <buffer> t k
|
|
|
|
noremap <buffer> n l
|
|
|
|
endfunction
|
|
|
|
|
2016-05-10 16:07:08 +00:00
|
|
|
endif
|
2016-03-31 02:03:55 +00:00
|
|
|
|
2016-05-16 16:46:22 +00:00
|
|
|
" Save aliases.
|
2018-03-30 13:44:32 +00:00
|
|
|
com! W w
|
|
|
|
com! Q q
|
|
|
|
com! Wq wq
|
|
|
|
com! WQ wq
|
2018-03-31 20:54:08 +00:00
|
|
|
com! Wqa wqa
|
|
|
|
com! WQa wqa
|
|
|
|
com! WQA wqa
|
2016-03-31 02:03:55 +00:00
|
|
|
" Write with sudo
|
|
|
|
cmap w!! w !sudo tee > /dev/null %
|
2017-11-10 12:47:10 +00:00
|
|
|
|
2018-04-05 10:25:42 +00:00
|
|
|
" Unmap ex-mode
|
|
|
|
map Q <nop>
|
|
|
|
|
2020-08-10 21:02:24 +00:00
|
|
|
|
2017-11-10 12:47:10 +00:00
|
|
|
autocmd FileType markdown setlocal ts=2 sts=2 sw=2 et
|
2020-08-10 21:02:24 +00:00
|
|
|
autocmd FileType yaml setlocal ts=2 sts=2 sw=2 et indentkeys-=<:>
|
2020-04-02 10:41:18 +00:00
|
|
|
autocmd FileType gitcommit setlocal cc=72 et sw=4
|