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.

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