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.

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