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.

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