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.

413 lines
12 KiB

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