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.

400 lines
11 KiB

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