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.

392 lines
11 KiB

6 years ago
6 years ago
6 years ago
5 years ago
6 years ago
7 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
5 years ago
6 years ago
6 years ago
5 years ago
5 years ago
6 years ago
5 years ago
5 years ago
6 years ago
6 years ago
5 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
5 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 undodir=~/.vim/undo
  26. set undofile
  27. set updatetime=1000
  28. autocmd VimResized * wincmd =
  29. filetype plugin on
  30. filetype indent on
  31. syntax on
  32. au CursorHold,CursorHoldI * checktime
  33. " cursor indicator {{{ "
  34. " set listchars=tab:\|\
  35. " set list
  36. " set cursorcolumn
  37. " set cursorline
  38. " }}} cursor indicator "
  39. " }}} set x=y "
  40. " commands for file types {{{ "
  41. autocmd BufNewFile,BufRead .* set syntax=sh
  42. autocmd FileType *css,htmldjango,html,javascript,markdown,tex,text,yaml set tabstop=2 shiftwidth=2
  43. " autocmd BufNewFile,BufRead *.md set filetype=markdown
  44. autocmd Filetype markdown set textwidth=0
  45. " autocmd Filetype html set foldmarker=0
  46. autocmd Filetype markdown map <F8> :LivedownToggle<CR>
  47. autocmd Filetype json nnoremap <leader>j :%!python -m json.tool<CR>
  48. autocmd Filetype json set foldmethod=marker
  49. autocmd FileType sh map <F8> :!clear && shellcheck %<CR>
  50. " autocmd FileType tex map <F8> :VimtexCompile<CR>:VimtexView<CR>
  51. autocmd VimEnter *.tex VimtexCompile
  52. autocmd VimLeave *.tex !tex-clean %:p
  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. let g:multi_cursor_exit_from_visual_mode=0
  168. let g:multi_cursor_exit_from_insert_mode=0
  169. Plug 'dag/vim-fish'
  170. Plug 'shime/vim-livedown'
  171. Plug 'tpope/vim-fugitive'
  172. " auto reload file
  173. Plug 'djoshea/vim-autoread'
  174. call plug#end()
  175. " }}} vim-plug "
  176. " colorscheme gotham256
  177. colorscheme wal
  178. " Mappings {{{ "
  179. " function keys {{{ "
  180. map <F3> :wa<CR>
  181. map <F4> :xa<CR>
  182. map <F5> :q!<CR>
  183. map <F6> :qa!<CR>
  184. map <F7> :AutoSaveToggle<CR>
  185. " reload file
  186. nnoremap <F9> :e<CR>
  187. nnoremap <F10> :set paste<CR>"+p:set nopaste<CR>
  188. nnoremap <F11> :set paste<CR>"*p:set nopaste<CR>
  189. " }}} function keys "
  190. map <S-Enter> O<ESC>
  191. " swap text visually
  192. vnoremap <C-P> <Esc>`.``gvP``P
  193. ino <C-A> <C-O>yiW<End>=<C-R>=<C-R>0<CR>
  194. " splits {{{ "
  195. nnoremap <C-Down> <C-W><C-J>
  196. nnoremap <C-Up> <C-W><C-K>
  197. nnoremap <C-Right> <C-W><C-L>
  198. nnoremap <C-Left> <C-W><C-H>
  199. " Maximize height/width.
  200. nnoremap <C-g> <C-W>_
  201. nnoremap <C-w> <C-W>|
  202. " }}} splits "
  203. " leader mappings {{{ "
  204. let mapleader="\<Space>"
  205. " find alias
  206. nnoremap <leader>a /^ <Left>
  207. " replace until end of line
  208. nnoremap <leader>c c$
  209. " delete entire buffer
  210. nnoremap <leader>d d$
  211. " delete entire buffer
  212. nnoremap <leader>dg ggdG
  213. " delete line into system clipboard
  214. nnoremap <leader>D "+dd
  215. " delete entire buffer into system clipboard
  216. nnoremap <leader>DA "+ggdG
  217. " find copied text
  218. nnoremap <leader>f q/p<CR>
  219. " find merge conflicts
  220. nnoremap <leader>fc /[<>=\|]\{7\}<CR>
  221. " reload folds
  222. nnoremap <leader>fmi :set foldmethod=indent<CR> zM
  223. nnoremap <leader>fmm :set foldmethod=marker<CR> zM
  224. " add marker foldmethod modeline
  225. nnoremap <leader>fi :YcmCompleter FixIt<CR>
  226. " find copied text
  227. nnoremap <leader>ft /TODO<CR>
  228. nnoremap <leader>g :YcmCompleter GoTo<CR>
  229. " vimdiff split
  230. nnoremap <leader>gd :Gvdiff HEAD
  231. " toggle search highlighting
  232. nnoremap <leader>h :set hlsearch! hlsearch?<CR>
  233. " help
  234. nnoremap <leader>he :help
  235. nnoremap <leader>ht :set tabstop=2 shiftwidth=2 expandtab<CR>
  236. nnoremap <leader>vhe :vert help
  237. " format current line
  238. nnoremap <leader>l Vgq
  239. " format this and next line
  240. nnoremap <leader>ll Vjgq
  241. " move cursor to middle of line
  242. nnoremap <leader>m :call cursor(0, len(getline('.'))/2)<CR>
  243. " apply normal command to selection
  244. vnoremap <leader>n q:anorm
  245. " don't wrap lines
  246. nnoremap <leader>nw :set nowrap<CR>
  247. " check if in neovim
  248. nnoremap <leader>nv :echo has('nvim')<CR>
  249. " Plug commands
  250. nnoremap <leader>p "*p
  251. nnoremap <leader>pli :PlugInstall<CR>
  252. nnoremap <leader>plc :PlugClean<CR>
  253. nnoremap <leader>plu :PlugUpdate<CR>
  254. " don't break lines
  255. nnoremap <leader>py :set tw=0<CR>
  256. " replace in next x lines
  257. nnoremap <leader>r q:i.,.+s///g<ESC>Fsi
  258. " replace in line
  259. nnoremap <leader>rl q:i.s///g<left><left><left>
  260. " replace in visual selection
  261. vnoremap <leader>r q:is///g<ESC>3ha
  262. " reload vim config
  263. nnoremap <leader>rv :source $MYVIMRC<CR>
  264. " replace in entire file
  265. nnoremap <leader>R q:i%s///g<ESC>2F/i
  266. vnoremap <leader>s :sort<CR>
  267. nnoremap <leader>sc :set spell spelllang=en_us<CR>
  268. " run current file in shell
  269. nnoremap <leader>sh :!%:p
  270. " sort lines until end of file
  271. nnoremap <leader>so q:i.,$sort<CR>
  272. " sort lines
  273. nnoremap <leader>sol q:i.,.+sort<ESC>Fsi
  274. " set syntax to shell (for dotfiles)
  275. nnoremap <leader>sys :set syn=sh<CR>
  276. vnoremap <leader>t :!tac<CR>
  277. " open vimrc in vertical split
  278. nnoremap <leader>vv :vsp ~/.vimrc<CR>
  279. " copy next thing to system clipboard
  280. " nnoremap <leader>y "+
  281. " nnoremap <leader>Y "+Y
  282. nnoremap <leader>y y$
  283. " yank entire buffer
  284. nnoremap <leader>yg ggyG
  285. " toggle fold
  286. nnoremap <leader>z za
  287. " }}} leader mappings "
  288. " }}} Mappings "
  289. " Local Mappings {{{ "
  290. let maplocalleader="\\"
  291. " tex {{{ "
  292. autocmd Filetype tex inoremap <localleader>bt \bowtie
  293. autocmd Filetype tex inoremap <localleader>c \checkmark
  294. autocmd Filetype tex inoremap <localleader>d \delta
  295. autocmd Filetype tex inoremap <localleader>D \Delta
  296. autocmd Filetype tex inoremap <localleader>e \exists
  297. autocmd Filetype tex inoremap <localleader>ep \epsilon
  298. autocmd Filetype tex inoremap <localleader>fa \forall
  299. autocmd Filetype tex inoremap <localleader>g \geq
  300. autocmd Filetype tex inoremap <localleader>i \in
  301. autocmd Filetype tex inoremap <localleader>l \leq
  302. autocmd Filetype tex inoremap <localleader>lr \Leftrightarrow
  303. " autocmd Filetype tex inoremap <localleader>n \neg
  304. autocmd Filetype tex inoremap <localleader>n \neq
  305. autocmd Filetype tex inoremap <localleader>N \mathbb{N}
  306. autocmd Filetype tex inoremap <localleader>q \qquad
  307. autocmd Filetype tex inoremap <localleader>r \rightarrow
  308. autocmd Filetype tex inoremap <localleader>R \Rightarrow
  309. autocmd Filetype tex inoremap <localleader>s \subset
  310. autocmd Filetype tex inoremap <localleader>st such that
  311. autocmd Filetype tex inoremap <localleader>S \Sigma
  312. autocmd Filetype tex inoremap <localleader>t \times
  313. " autocmd Filetype tex inoremap <localleader>T $T$
  314. autocmd Filetype tex inoremap <localleader>T \Theta
  315. " replace bars/underscores in URL
  316. autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
  317. autocmd Filetype tex inoremap <localleader>v \vee
  318. autocmd Filetype tex inoremap <localleader>w \wedge
  319. autocmd Filetype tex inoremap <localleader>x $x$-axis
  320. autocmd Filetype tex inoremap <localleader>y $y$-axis
  321. autocmd Filetype tex inoremap <localleader>Z \mathbb{Z}
  322. " par3
  323. autocmd Filetype tex inoremap <localleader>wx $w(x)$
  324. autocmd Filetype tex inoremap <localleader>tx $t(x)$
  325. " }}} tex "
  326. autocmd Filetype c inoremap <localleader>uc unsigned char
  327. autocmd BufNewFile,BufRead *.h nnoremap <localleader>x 0iextern <Esc>f{hc$;<Esc>
  328. autocmd Filetype fish inoremap <localleader>1 $argv[1]
  329. autocmd Filetype fish inoremap <localleader>2 $argv[2]
  330. autocmd Filetype markdown nnoremap <localleader>x 0f[lrx
  331. " nnoremap <localleader>x 0f[lrx
  332. " }}} Local Mappings "