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.

445 lines
13 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
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
6 years ago
6 years ago
  1. " vim: fdm=marker ft=vim.go-template
  2. " set x=y [[[ "
  3. set autoindent
  4. set autoread
  5. set background=dark
  6. " set colorcolumn=80
  7. set clipboard+=unnamedplus
  8. set diffopt=filler,context:3
  9. set encoding=utf-8
  10. set expandtab
  11. " set foldmethod=indent
  12. set foldmethod=marker
  13. set hlsearch
  14. set linebreak
  15. set linespace=5
  16. set mouse=a
  17. " set mouse=c
  18. " set noswapfile
  19. set relativenumber
  20. set shiftwidth=4
  21. set tabstop=4
  22. " set t_Co=256
  23. " set termguicolors
  24. " set timeoutlen=350
  25. set timeoutlen=200
  26. " set tw=80
  27. set tw=75
  28. set undodir=~/.vim/undo
  29. set undofile
  30. " set updatetime=1000
  31. set updatetime=500
  32. autocmd VimResized * wincmd =
  33. filetype plugin on
  34. filetype indent on
  35. syntax on
  36. autocmd CursorHold * if !bufexists("[Command Line]") | checktime | endif
  37. " cursor indicator [[[ "
  38. " set listchars=tab:\|\
  39. " set list
  40. " set cursorcolumn
  41. " set cursorline
  42. " ]]] cursor indicator "
  43. " ]]] set x=y "
  44. " commands for file types [[[ "
  45. autocmd BufNewFile,BufRead .* set syntax=sh
  46. autocmd FileType *css,htmldjango,html,javascript,json,markdown,tex,text,yaml set tabstop=2 shiftwidth=2
  47. " autocmd BufNewFile,BufRead *.md set filetype=markdown
  48. " autocmd Filetype markdown set textwidth=0
  49. " autocmd Filetype html set foldmarker=0
  50. autocmd BufNewFile,BufRead *.gd set expandtab!
  51. autocmd Filetype go set expandtab! sw=4
  52. autocmd Filetype markdown map <F8> :LivedownToggle<CR>
  53. autocmd Filetype markdown nnoremap <Tab> <Esc>>>A
  54. autocmd Filetype markdown inoremap <S-Tab> <Esc><<A
  55. autocmd Filetype markdown inoremap > <Esc>>>A
  56. autocmd Filetype markdown inoremap >> >
  57. autocmd FileType markdown,tex,text set spell spelllang=en_us
  58. autocmd FileType python set fdm=indent
  59. autocmd Filetype json nnoremap <leader>j :%!python -m json.tool<CR>
  60. autocmd Filetype json set foldmethod=marker
  61. autocmd FileType sh map <F8> :!clear && shellcheck %<CR>
  62. autocmd FileType tex set updatetime=1000
  63. autocmd FileType tex map <F8> :VimtexCompile<CR>
  64. autocmd VimEnter *.tex VimtexCompile
  65. autocmd VimLeave *.tex !tex-clean %:p
  66. autocmd BufNewFile,BufRead *.tmpl set tw=0 sw=2 ft=go-template fmr=[[[,]]]
  67. " " auto-reload vimrc [[[ "
  68. " augroup myvimrc
  69. " au!
  70. " au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
  71. " augroup END
  72. " " ]]] auto-reload vimrc "
  73. " ]]] commands for file types "
  74. " commands for specific files [[[ "
  75. autocmd BufNewFile,BufRead watson*.fish set tabstop=2 shiftwidth=2 expandtab
  76. autocmd BufWritePost config.def.h silent !cd %:p:h; sudo rm config.h; sudo bear make install
  77. " autocmd BufRead config.def.h map <F8> :silent !cd %:p:h; sudo rm config.h; sudo bear make install<CR>
  78. autocmd BufRead config.def.h map <F10> :silent !cd %:p:h<CR>:!sudo rm config.h; sudo bear make install<CR>
  79. autocmd BufRead config.def.h set updatetime=3000
  80. autocmd BufRead commit-msg.txt set filetype=gitcommit tw=72
  81. autocmd VimLeave /etc/default/grub !sudo grub-mkconfig -o /boot/grub/grub.cfg
  82. " autocmd BufWritePost key_* !sync-shortcuts
  83. autocmd BufNewFile,BufRead key_* map <F1> :w<CR>:silent !sync-shortcuts<CR>
  84. " map <F1> :silent !scp %:p k@192.168.0.17:/home/k/a1<CR>
  85. " map <F2> :silent !scp -P 2222 e1.html e1_style.css kevin@127.0.0.1:/home/kevin/Downloads/e1<CR>
  86. " map <F6> :make -C ~/Documents/resume cv<CR>
  87. " ]]] commands for specific files "
  88. " vim-plug [[[
  89. " plug auto-install
  90. if empty(glob('~/.vim/autoload/plug.vim'))
  91. silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  92. \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  93. autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  94. endif
  95. call plug#begin('~/.vim/plugged')
  96. " prequisite for other plugins
  97. Plug 'vim-scripts/L9'
  98. " find files from within Vim
  99. " Plug 'vim-scripts/FuzzyFinder'
  100. " Gotham color scheme
  101. " Plug 'whatyouhide/vim-gotham'
  102. " " collection of Vim color schemes
  103. " Plug 'flazz/vim-colorschemes'
  104. " " preview Vim color scheme easily within Vim
  105. " Plug 'xolox/vim-colorscheme-switcher'
  106. " " prerequisite for above plugin
  107. " Plug 'xolox/vim-misc'
  108. " automatically save buffers upon returning to normal mode
  109. Plug '907th/vim-auto-save'
  110. let g:auto_save = 1
  111. " let g:auto_save_events = ["CursorHold", "CursorHoldI"]
  112. let g:auto_save_events = ["CursorHold"]
  113. " autocmd VimEnter *.tex let g:auto_save = 0
  114. " provides various functionality for writing LaTeX in Vim
  115. Plug 'lervag/vimtex'
  116. " au BufWritePost *.tex silent call Tex_RunLaTeX()
  117. au BufWritePost *.tex silent !pkill -USR1 xdvi.bin
  118. let g:vimtex_view_general_viewer = 'zathura'
  119. let g:vimtex_quickfix_latexlog = {
  120. \ 'overfull' : 0,
  121. \ 'underfull' : 0,
  122. \ 'global' : 0,
  123. \ 'unused' : 0,
  124. \}
  125. " let g:vimtex_compiler_latexmk = {
  126. " \ 'continuous' : 0,
  127. " \}
  128. {{ if not (eq .chezmoi.username "root") }}
  129. " auto-completion for various languages
  130. Plug 'Valloric/YouCompleteMe'
  131. let g:ycm_filetype_blacklist = {
  132. \ 'tagbar': 1,
  133. \ 'qf': 1,
  134. \ 'notes': 1,
  135. \ 'unite': 1,
  136. \ 'vimwiki': 1,
  137. \ 'pandoc': 1,
  138. \ 'infolog': 1,
  139. \ 'mail': 1
  140. \}
  141. {{ end }}
  142. " wrote short bits of text that expand into whatever you want
  143. " demo: https://www.youtube.com/watch?v=Zik6u0klD40
  144. Plug 'SirVer/ultisnips'
  145. " better key bindings for UltiSnipsExpandTrigger
  146. let g:UltiSnipsExpandTrigger = "<tab>"
  147. let g:UltiSnipsJumpForwardTrigger = "<tab>"
  148. let g:UltiSnipsJumpBackwardTrigger = "<C-tab>"
  149. let g:ultisnips_javascript = {
  150. \ 'keyword-spacing': 'always',
  151. \ 'semi': 'never',
  152. \ 'space-before-function-paren': 'never',
  153. \ }
  154. " custom snippets
  155. Plug 'Kevin-Mok/vim-snippets'
  156. " to make YouCompleteMe work with UltiSnips (both use Tab)
  157. Plug 'ervandew/supertab'
  158. " make YCM compatible with UltiSnips (using supertab)
  159. let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
  160. let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
  161. let g:SuperTabDefaultCompletionType = '<C-n>'
  162. " easily comment/uncomment lines
  163. Plug 'scrooloose/nerdcommenter'
  164. let g:NERDTrimTrailingWhitespace = 1
  165. let g:NERDSpaceDelims = 1
  166. " add quotes/brackets around chunks of text easily
  167. Plug 'tpope/vim-surround'
  168. nmap S ys
  169. " navigate around file easily and precisely
  170. Plug 'easymotion/vim-easymotion'
  171. map <Space> <Plug>(easymotion-prefix)
  172. " status bar displaying various info about the current buffer
  173. Plug 'vim-airline/vim-airline'
  174. let g:airline_section_c = '%F'
  175. Plug 'vim-airline/vim-airline-themes'
  176. let g:airline_powerline_fonts = 1
  177. " continue Markdown lists when started
  178. Plug 'dkarter/bullets.vim'
  179. " coordinate Vim color scheme with terminal color scheme
  180. Plug 'dylanaraps/wal.vim'
  181. " repeat plugin commands
  182. Plug 'tpope/vim-repeat'
  183. " better Django support
  184. Plug 'tweekmonster/django-plus.vim'
  185. " auto-close brackets
  186. Plug 'jiangmiao/auto-pairs'
  187. let g:AutoPairsMapSpace = 0
  188. Plug 'henrik/vim-indexed-search'
  189. Plug 'PotatoesMaster/i3-vim-syntax'
  190. " vim file explorer
  191. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  192. Plug 'terryma/vim-multiple-cursors'
  193. " let g:multi_cursor_select_all_word_key='<C-a>'
  194. let g:multi_cursor_exit_from_visual_mode=0
  195. let g:multi_cursor_exit_from_insert_mode=0
  196. Plug 'dag/vim-fish'
  197. Plug 'shime/vim-livedown'
  198. Plug 'tpope/vim-fugitive'
  199. " auto reload file
  200. Plug 'djoshea/vim-autoread'
  201. " Plug 'mustache/vim-mustache-handlebars'
  202. " Plug 'trapd00r/vim-syntax-vidir-ls'
  203. Plug 'calviken/vim-gdscript3'
  204. " display hex colors in Vim
  205. Plug 'RRethy/vim-hexokinase'
  206. Plug 'junegunn/goyo.vim'
  207. " ]]] vim-plug "
  208. " Mappings [[[ "
  209. call plug#end()
  210. " colorscheme gotham256
  211. colorscheme wal
  212. nnoremap v <C-V>
  213. nnoremap > >>
  214. nnoremap < <<
  215. inoremap << <Esc><<A
  216. " leader mappings [[[ "
  217. let mapleader="\<Space>"
  218. " find alias
  219. nnoremap <leader>a /^ <Left>
  220. " replace until end of line
  221. nnoremap <leader>c c$
  222. " delete entire buffer
  223. nnoremap <leader>d d$
  224. " delete entire buffer
  225. nnoremap <leader>dg ggdG
  226. " delete line into system clipboard
  227. nnoremap <leader>D "+dd
  228. " delete entire buffer into system clipboard
  229. nnoremap <leader>DA "+ggdG
  230. " find copied text
  231. nnoremap <leader>f q/p<CR>
  232. " find merge conflicts
  233. nnoremap <leader>fc /[<>=\|]\{7\}<CR>
  234. " reload folds
  235. nnoremap <leader>fmi :set foldmethod=indent<CR> zM
  236. nnoremap <leader>fmm :set foldmethod=marker<CR> zM
  237. " add marker foldmethod modeline
  238. nnoremap <leader>fi :YcmCompleter FixIt<CR>
  239. " find copied text
  240. nnoremap <leader>ft :se ft?
  241. nnoremap <leader>ftd /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. nnoremap <leader>yo :Goyo<CR>
  302. " yank entire buffer
  303. nnoremap <leader>yg ggyG
  304. " toggle fold
  305. nnoremap <leader>z za
  306. " ]]] leader mappings "
  307. " function keys [[[ "
  308. map <F3> :wa<CR>
  309. map <F4> :xa<CR>
  310. map <F5> :q!<CR>
  311. map <F6> :qa!<CR>
  312. map <F7> :AutoSaveToggle<CR>
  313. " reload file
  314. nnoremap <F9> :e<CR>
  315. nnoremap <F10> :set paste<CR>"+p:set nopaste<CR>
  316. nnoremap <F11> :set paste<CR>"*p:set nopaste<CR>
  317. " ]]] function keys "
  318. map <S-Enter> O<ESC>
  319. " swap text visually
  320. vnoremap <C-P> <Esc>`.``gvP``P
  321. ino <C-A> <C-O>yiW<End>=<C-R>=<C-R>0<CR>
  322. " splits [[[ "
  323. nnoremap <C-Down> <C-W><C-J>
  324. nnoremap <C-Up> <C-W><C-K>
  325. nnoremap <C-Right> <C-W><C-L>
  326. nnoremap <C-Left> <C-W><C-H>
  327. " Maximize height/width.
  328. nnoremap <C-g> <C-W>_
  329. nnoremap <C-w> <C-W>|
  330. " ]]] splits "
  331. " ]]] Mappings "
  332. " Local Mappings [[[ "
  333. let maplocalleader="\\"
  334. " tex [[[ "
  335. autocmd Filetype tex inoremap <localleader>bt \bowtie
  336. autocmd Filetype tex inoremap <localleader>c \checkmark
  337. autocmd Filetype tex inoremap <localleader>d \delta
  338. autocmd Filetype tex inoremap <localleader>D \Delta
  339. autocmd Filetype tex inoremap <localleader>e \exists
  340. autocmd Filetype tex inoremap <localleader>ep \epsilon
  341. autocmd Filetype tex inoremap <localleader>fa \forall
  342. autocmd Filetype tex inoremap <localleader>g \geq
  343. autocmd Filetype tex inoremap <localleader>i \in
  344. autocmd Filetype tex inoremap <localleader>le \leq
  345. autocmd Filetype tex inoremap <localleader>lo \log
  346. autocmd Filetype tex inoremap <localleader>lr \Leftrightarrow
  347. " autocmd Filetype tex inoremap <localleader>n \neg
  348. autocmd Filetype tex inoremap <localleader>n \neq
  349. autocmd Filetype tex inoremap <localleader>N \mathbb{N}
  350. autocmd Filetype tex inoremap <localleader>q \qquad
  351. autocmd Filetype tex inoremap <localleader>r \rightarrow
  352. autocmd Filetype tex inoremap <localleader>R \Rightarrow
  353. autocmd Filetype tex inoremap <localleader>s \subset
  354. autocmd Filetype tex inoremap <localleader>st such that
  355. autocmd Filetype tex inoremap <localleader>S \Sigma
  356. autocmd Filetype tex inoremap <localleader>t \times
  357. " autocmd Filetype tex inoremap <localleader>T $T$
  358. autocmd Filetype tex inoremap <localleader>T \Theta
  359. " replace bars/underscores in URL
  360. autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
  361. autocmd Filetype tex inoremap <localleader>v \vee
  362. autocmd Filetype tex inoremap <localleader>w \wedge
  363. autocmd Filetype tex inoremap <localleader>x $x$-axis
  364. autocmd Filetype tex inoremap <localleader>y $y$-axis
  365. autocmd Filetype tex inoremap <localleader>Z \mathbb{Z}
  366. " par3
  367. autocmd Filetype tex inoremap <localleader>wx $w(x)$
  368. autocmd Filetype tex inoremap <localleader>tx $t(x)$
  369. " ]]] tex "
  370. autocmd Filetype c inoremap <localleader>uc unsigned char
  371. autocmd BufNewFile,BufRead *.h nnoremap <localleader>x 0iextern <Esc>f{hc$;<Esc>
  372. autocmd Filetype fish inoremap <localleader>1 $argv[1]
  373. autocmd Filetype fish inoremap <localleader>2 $argv[2]
  374. autocmd Filetype javascript inoremap <localleader>x process.exit()
  375. autocmd Filetype markdown inoremap <localleader>cb - [ ]
  376. autocmd Filetype markdown nnoremap <localleader>x 0f[lrx
  377. " nnoremap <localleader>x 0f[lrx
  378. autocmd Filetype go-template inoremap <localleader>e {{"{{ else }}"}}
  379. autocmd Filetype go-template inoremap <localleader>hd {{"{{ .chezmoi.homedir }}"}}
  380. autocmd Filetype go-template nnoremap <localleader>fp :%s/{{"{{{"}}/[[[/g<CR>:%s/}}}/]]]/g<CR>
  381. autocmd Filetype python inoremap <localleader>bp breakpoint()
  382. autocmd Filetype python inoremap <localleader>s self.
  383. " ]]] Local Mappings "