Dotfiles for my tiling window manager + terminal workflow.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

340 lines
9.8 KiB

7 years ago
7 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
7 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  1. " set x=y {{{ "
  2. au BufWinEnter * set relativenumber
  3. " set background=dark
  4. set encoding=utf-8
  5. set background=light
  6. " set t_Co=256
  7. filetype plugin on
  8. syntax on
  9. set tabstop=4
  10. set tw=80
  11. set linebreak
  12. " set colorcolumn=80
  13. set shiftwidth=4
  14. set autoindent
  15. " set mouse=c
  16. set mouse=a
  17. set clipboard+=unnamedplus
  18. set foldmethod=marker
  19. set linespace=5
  20. " cursor indicator {{{ "
  21. " set listchars=tab:\|\
  22. " set list
  23. " set cursorcolumn
  24. " set cursorline
  25. " }}} cursor indicator "
  26. " set timeoutlen=500
  27. set timeoutlen=350
  28. set hlsearch
  29. set noswapfile
  30. let maplocalleader="-"
  31. " }}} set x=y "
  32. " commands for file types {{{ "
  33. autocmd VimResized * wincmd =
  34. autocmd BufNewFile,BufRead .* set syntax=sh
  35. filetype plugin on
  36. filetype indent on
  37. autocmd FileType *css,htmldjango,html,tex,markdown,yaml set tabstop=2 shiftwidth=2 expandtab
  38. autocmd BufNewFile,BufRead *.txt set tabstop=2 shiftwidth=2 expandtab
  39. autocmd BufNewFile,BufRead watson*.fish set tabstop=2 shiftwidth=2 expandtab
  40. autocmd BufRead commit-msg.txt set filetype=gitcommit tw=72
  41. autocmd BufNewFile,BufRead *.md set filetype=markdown
  42. autocmd Filetype markdown set textwidth=0
  43. " autocmd Filetype html set foldmarker=0
  44. autocmd Filetype c let maplocalleader="\\"
  45. autocmd BufWritePost key_* !sync-shortcuts
  46. autocmd VimLeave *.tex !tex-clean %
  47. " " auto-reload vimrc {{{ "
  48. " augroup myvimrc
  49. " au!
  50. " au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
  51. " augroup END
  52. " " }}} auto-reload vimrc "
  53. " }}} commands for file types "
  54. " vim-plug {{{ "
  55. " plug auto-install
  56. if empty(glob('~/.vim/autoload/plug.vim'))
  57. silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  58. \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  59. autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  60. endif
  61. call plug#begin('~/.vim/plugged')
  62. " prequisite for other plugins
  63. Plug 'vim-scripts/L9'
  64. " find files from within Vim
  65. " Plug 'vim-scripts/FuzzyFinder'
  66. " Gotham color scheme
  67. " Plug 'whatyouhide/vim-gotham'
  68. " " collection of Vim color schemes
  69. " Plug 'flazz/vim-colorschemes'
  70. " " preview Vim color scheme easily within Vim
  71. " Plug 'xolox/vim-colorscheme-switcher'
  72. " " prerequisite for above plugin
  73. " Plug 'xolox/vim-misc'
  74. " automatically save buffers upon returning to normal mode
  75. Plug '907th/vim-auto-save'
  76. let g:auto_save = 1
  77. " provides various functionality for writing LaTeX in Vim
  78. Plug 'lervag/vimtex'
  79. au BufWritePost *.tex silent call Tex_RunLaTeX()
  80. au BufWritePost *.tex silent !pkill -USR1 xdvi.bin
  81. let g:vimtex_view_general_viewer = 'zathura'
  82. let g:vimtex_quickfix_latexlog = {
  83. \ 'overfull' : 0,
  84. \ 'underfull' : 0,
  85. \ 'global' : 0,
  86. \ 'unused' : 0,
  87. \}
  88. " auto-completion for various languages
  89. Plug 'Valloric/YouCompleteMe'
  90. " wrote short bits of text that expand into whatever you want
  91. " demo: https://www.youtube.com/watch?v=Zik6u0klD40
  92. Plug 'SirVer/ultisnips'
  93. " better key bindings for UltiSnipsExpandTrigger
  94. let g:UltiSnipsExpandTrigger = "<tab>"
  95. let g:UltiSnipsJumpForwardTrigger = "<tab>"
  96. let g:UltiSnipsJumpBackwardTrigger = "<C-tab>"
  97. " custom snippets
  98. Plug 'Kevin-Mok/vim-snippets'
  99. " to make YouCompleteMe work with UltiSnips (both use Tab)
  100. Plug 'ervandew/supertab'
  101. " make YCM compatible with UltiSnips (using supertab)
  102. let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
  103. let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
  104. let g:SuperTabDefaultCompletionType = '<C-n>'
  105. " easily comment/uncomment lines
  106. Plug 'scrooloose/nerdcommenter'
  107. let g:NERDTrimTrailingWhitespace = 1
  108. let g:NERDSpaceDelims = 1
  109. " add quotes/brackets around chunks of text easily
  110. Plug 'tpope/vim-surround'
  111. " navigate around file easily and precisely
  112. Plug 'easymotion/vim-easymotion'
  113. map <Space> <Plug>(easymotion-prefix)
  114. " status bar displaying various info about the current buffer
  115. Plug 'vim-airline/vim-airline'
  116. let g:airline_section_c = '%F'
  117. Plug 'vim-airline/vim-airline-themes'
  118. let g:airline_powerline_fonts = 1
  119. " continue Markdown lists when started
  120. Plug 'dkarter/bullets.vim'
  121. " coordinate Vim color scheme with terminal color scheme
  122. Plug 'dylanaraps/wal.vim'
  123. " repeat plugin commands
  124. Plug 'tpope/vim-repeat'
  125. " better Django support
  126. Plug 'tweekmonster/django-plus.vim'
  127. " auto-close brackets
  128. Plug 'jiangmiao/auto-pairs'
  129. let g:AutoPairsMapSpace = 0
  130. Plug 'henrik/vim-indexed-search'
  131. Plug 'PotatoesMaster/i3-vim-syntax'
  132. " vim file explorer
  133. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  134. Plug 'terryma/vim-multiple-cursors'
  135. " let g:multi_cursor_select_all_word_key='<C-a>'
  136. Plug 'dag/vim-fish'
  137. call plug#end()
  138. " }}} vim-plug "
  139. " colorscheme gotham256
  140. colorscheme wal
  141. " Mappings {{{ "
  142. " function keys {{{ "
  143. " map <F1> :silent !scp %:p k@192.168.0.17:/home/k/a1<CR>
  144. " map <F2> :silent !gcc -m32 -o test_full test_full.c && scp test_full k@192.168.0.17:/home/k/a1<CR>
  145. " map <F2> :silent !scp -P 2222 e1.html e1_style.css kevin@127.0.0.1:/home/kevin/Downloads/e1<CR>
  146. " map <F3> :silent !gcc -m32 -o test_intercept test_intercept.c && scp test_intercept k@192.168.0.17:/home/k/a1<CR>
  147. map <F4> :xa<CR>
  148. map <F5> :q!<CR>
  149. " map <F6> :make -C ~/Documents/resume cv<CR>
  150. " map <F7> :AutoSaveToggle<CR>
  151. map <F8> :!clear && shellcheck %<CR>
  152. map <F9> :VimtexCompile<CR>:VimtexView<CR>
  153. " map <F9> :VimtexCompile<CR>
  154. nnoremap <F10> :set paste<CR>"+p:set nopaste<CR>
  155. " }}} function keys "
  156. map <S-Enter> O<ESC>
  157. " swap text visually
  158. vnoremap <C-P> <Esc>`.``gvP``P
  159. " splits {{{ "
  160. nnoremap <C-Down> <C-W><C-J>
  161. nnoremap <C-Up> <C-W><C-K>
  162. nnoremap <C-Right> <C-W><C-L>
  163. nnoremap <C-Left> <C-W><C-H>
  164. " Maximize height/width.
  165. nnoremap <C-g> <C-W>_
  166. nnoremap <C-w> <C-W>|
  167. " }}} splits "
  168. " leader mappings {{{ "
  169. let mapleader="\<Space>"
  170. " replace until end of line
  171. nnoremap <leader>c c$
  172. " delete entire buffer
  173. nnoremap <leader>d d$
  174. " delete entire buffer
  175. nnoremap <leader>dg ggdG
  176. " delete line into system clipboard
  177. nnoremap <leader>D "+dd
  178. " delete entire buffer into system clipboard
  179. nnoremap <leader>DA "+ggdG
  180. " find copied text
  181. nnoremap <leader>f q/p<CR>
  182. " find alias
  183. nnoremap <leader>fa /^ <Left>
  184. " find merge conflicts
  185. nnoremap <leader>fc /[<>=\|]\{7\}<CR>
  186. " reload folds
  187. nnoremap <leader>ff :set foldmethod=marker<CR> zM
  188. " find copied text
  189. nnoremap <leader>ft /TODO<CR>
  190. " toggle search highlighting
  191. nnoremap <leader>h :set hlsearch! hlsearch?<CR>
  192. " help
  193. nnoremap <leader>he :help
  194. nnoremap <leader>ht :set tabstop=2 shiftwidth=2 expandtab<CR>
  195. nnoremap <leader>vhe :vert help
  196. " move cursor to middle of line
  197. nnoremap <leader>m :call cursor(0, len(getline('.'))/2)<CR>
  198. " apply normal command to selection
  199. vnoremap <leader>n q:anorm
  200. " don't wrap lines
  201. nnoremap <leader>nw :set nowrap<CR>
  202. " check if in neovim
  203. nnoremap <leader>nv :echo has('nvim')<CR>
  204. " Plug commands
  205. nnoremap <leader>p "*p
  206. nnoremap <leader>pli :PlugInstall<CR>
  207. nnoremap <leader>plc :PlugClean<CR>
  208. nnoremap <leader>plu :PlugUpdate<CR>
  209. " don't break lines
  210. nnoremap <leader>py :set tw=0<CR>
  211. " reload file
  212. nnoremap <leader>r :e<CR>
  213. " replace in next x lines
  214. nnoremap <leader>re q:i.,.+s///g<ESC>Fsi
  215. " replace in line
  216. nnoremap <leader>rl q:i.s///g<left><left><left>
  217. " replace in visual selection
  218. vnoremap <leader>r q:is///g<ESC>3ha
  219. " reload vim config
  220. nnoremap <leader>rv :source $MYVIMRC<CR>
  221. " replace in entire file
  222. nnoremap <leader>R q:i%s///g<ESC>2F/i
  223. " sort lines until end of file
  224. vnoremap <leader>s :sort<CR>
  225. " run current file in shell
  226. nnoremap <leader>sh :!%:p<CR>
  227. " sort lines until end of file
  228. nnoremap <leader>so q:i.,$sort<CR>
  229. " sort lines
  230. nnoremap <leader>sol q:i.,.+sort<ESC>Fsi
  231. " set syntax to shell (for dotfiles)
  232. nnoremap <leader>sys :set syn=sh<CR>
  233. " open vimrc in vertical split
  234. nnoremap <leader>vv :vsp ~/.vimrc<CR>
  235. " format current line
  236. nnoremap <leader>ww Vgq
  237. " format this and next line
  238. nnoremap <leader>www Vjgq
  239. " copy next thing to system clipboard
  240. " nnoremap <leader>y "+
  241. " nnoremap <leader>Y "+Y
  242. nnoremap <leader>y y$
  243. " yank entire buffer
  244. nnoremap <leader>yg ggyG
  245. " toggle fold
  246. nnoremap <leader>z za
  247. " }}} leader mappings "
  248. " }}} Mappings "
  249. " Local Mappings {{{ "
  250. autocmd Filetype c nnoremap <localleader>g :YcmCompleter GoTo<CR>
  251. autocmd Filetype fish inoremap <localleader>1 $argv[1]
  252. autocmd Filetype fish inoremap <localleader>2 $argv[2]
  253. autocmd Filetype markdown nnoremap <localleader>x 0f[lrx
  254. " nnoremap <localleader>x 0f[lrx
  255. " tex {{{ "
  256. autocmd Filetype tex inoremap <localleader>bt \bowtie
  257. autocmd Filetype tex inoremap <localleader>c \checkmark
  258. autocmd Filetype tex inoremap <localleader>d \delta
  259. autocmd Filetype tex inoremap <localleader>D \Delta
  260. autocmd Filetype tex inoremap <localleader>e \exists
  261. autocmd Filetype tex inoremap <localleader>ep \epsilon
  262. autocmd Filetype tex inoremap <localleader>fa \forall
  263. autocmd Filetype tex inoremap <localleader>g \geq
  264. autocmd Filetype tex inoremap <localleader>i \in
  265. autocmd Filetype tex inoremap <localleader>l \leq
  266. autocmd Filetype tex inoremap <localleader>lr \Leftrightarrow
  267. " autocmd Filetype tex inoremap <localleader>n \neg
  268. autocmd Filetype tex inoremap <localleader>n \neq
  269. autocmd Filetype tex inoremap <localleader>N \mathbb{N}
  270. autocmd Filetype tex inoremap <localleader>q \qquad
  271. autocmd Filetype tex inoremap <localleader>r \rightarrow
  272. autocmd Filetype tex inoremap <localleader>R \Rightarrow
  273. autocmd Filetype tex inoremap <localleader>s \subset
  274. autocmd Filetype tex inoremap <localleader>st such that
  275. autocmd Filetype tex inoremap <localleader>S \Sigma
  276. autocmd Filetype tex inoremap <localleader>t \times
  277. " autocmd Filetype tex inoremap <localleader>T $T$
  278. autocmd Filetype tex inoremap <localleader>T \Theta
  279. " replace bars/underscores in URL
  280. autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
  281. autocmd Filetype tex inoremap <localleader>v \vee
  282. autocmd Filetype tex inoremap <localleader>w \wedge
  283. autocmd Filetype tex inoremap <localleader>x $x$-axis
  284. autocmd Filetype tex inoremap <localleader>y $y$-axis
  285. autocmd Filetype tex inoremap <localleader>Z \mathbb{Z}
  286. " par3
  287. autocmd Filetype tex inoremap <localleader>wx $w(x)$
  288. autocmd Filetype tex inoremap <localleader>tx $t(x)$
  289. " }}} tex "
  290. " }}} Local Mappings "