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.

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