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.

519 lines
15 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
5 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 ignorecase
  15. set linebreak
  16. set linespace=5
  17. set mouse=a
  18. " set mouse=c
  19. " set noswapfile
  20. set relativenumber
  21. set shiftwidth=4
  22. set smartcase
  23. set tabstop=4
  24. " set t_Co=256
  25. " set termguicolors
  26. " set timeoutlen=350
  27. set timeoutlen=200
  28. " set tw=80
  29. set tw=75
  30. set undodir=~/.vim/undo
  31. set undofile
  32. " set updatetime=1000
  33. " set updatetime=500
  34. set updatetime=0
  35. autocmd VimResized * wincmd =
  36. filetype plugin on
  37. filetype indent on
  38. syntax on
  39. autocmd CursorHold * if !bufexists("[Command Line]") | checktime | endif
  40. " cursor indicator [[[ "
  41. " set listchars=tab:\|\
  42. " set list
  43. " set cursorcolumn
  44. " set cursorline
  45. " ]]] cursor indicator "
  46. " ]]] set x=y "
  47. " commands for file types [[[ "
  48. autocmd BufNewFile,BufRead .* set syntax=sh
  49. autocmd FileType *css,htmldjango,html,javascript,json,markdown,tex,text,yaml set tabstop=2 shiftwidth=2
  50. " autocmd BufNewFile,BufRead *.md set filetype=markdown
  51. " autocmd Filetype markdown set textwidth=0
  52. " autocmd Filetype html set foldmarker=0
  53. autocmd BufNewFile,BufRead *.gd set expandtab!
  54. autocmd Filetype go set expandtab! sw=4
  55. autocmd Filetype markdown set commentstring=<!---\ %s\ -->
  56. autocmd Filetype markdown map <F8> :LivedownToggle<CR>
  57. autocmd Filetype markdown nnoremap <Tab> <Esc>>>A
  58. autocmd Filetype markdown inoremap <S-Tab> <Esc><<A
  59. autocmd Filetype markdown inoremap < <Esc><<A
  60. autocmd Filetype markdown inoremap << <
  61. autocmd Filetype markdown inoremap > <Esc>>>A
  62. autocmd Filetype markdown inoremap >> >
  63. autocmd FileType markdown,tex,text set spell spelllang=en_us
  64. autocmd FileType python set fdm=indent
  65. autocmd Filetype json nnoremap <leader>j :%!python -m json.tool<CR>
  66. autocmd Filetype json set foldmethod=marker
  67. autocmd FileType sh map <F8> :!clear && shellcheck %<CR>
  68. autocmd FileType tex set updatetime=1000 timeoutlen=300
  69. autocmd FileType tex map <F8> :VimtexCompile<CR>
  70. autocmd VimEnter *.tex VimtexCompile
  71. autocmd VimLeave *.tex !tex-clean %:p
  72. autocmd BufNewFile,BufRead *.tmpl set tw=0 sw=2 ft=go-template fmr=[[[,]]]
  73. " " auto-reload vimrc [[[ "
  74. " augroup myvimrc
  75. " au!
  76. " au BufWritePost .vimrc,_vimrc,vimrc,.gvimrc,_gvimrc,gvimrc so $MYVIMRC | if has('gui_running') | so $MYGVIMRC | endif
  77. " augroup END
  78. " " ]]] auto-reload vimrc "
  79. " ]]] commands for file types "
  80. " commands for specific files [[[ "
  81. autocmd BufNewFile,BufRead watson*.fish set tabstop=2 shiftwidth=2 expandtab
  82. autocmd BufWritePost config.def.h silent !cd %:p:h; sudo rm config.h; sudo bear make install
  83. " autocmd BufRead config.def.h map <F8> :silent !cd %:p:h; sudo rm config.h; sudo bear make install<CR>
  84. autocmd BufRead config.def.h map <F10> :silent !cd %:p:h<CR>:!sudo rm config.h; sudo bear make install<CR>
  85. autocmd BufRead config.def.h set updatetime=3000
  86. autocmd BufRead commit-msg.txt set filetype=gitcommit tw=72
  87. autocmd VimLeave /etc/default/grub !sudo grub-mkconfig -o /boot/grub/grub.cfg
  88. " autocmd BufWritePost key_* !sync-shortcuts
  89. autocmd BufNewFile,BufRead key_* map <F1> :w<CR>:silent !sync-shortcuts<CR>
  90. " map <F1> :silent !scp %:p k@192.168.0.17:/home/k/a1<CR>
  91. " map <F2> :silent !scp -P 2222 e1.html e1_style.css kevin@127.0.0.1:/home/kevin/Downloads/e1<CR>
  92. " map <F6> :make -C ~/Documents/resume cv<CR>
  93. " ]]] commands for specific files "
  94. " vim-plug [[[
  95. " plug auto-install
  96. if empty(glob('~/.vim/autoload/plug.vim'))
  97. silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
  98. \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  99. autocmd VimEnter * PlugInstall --sync | source $MYVIMRC
  100. endif
  101. call plug#begin('~/.vim/plugged')
  102. " prequisite for other plugins
  103. Plug 'vim-scripts/L9'
  104. " find files from within Vim
  105. " Plug 'vim-scripts/FuzzyFinder'
  106. {{ if not .gui }}
  107. " Gotham color scheme
  108. Plug 'whatyouhide/vim-gotham'
  109. {{ end }}
  110. " " collection of Vim color schemes
  111. " Plug 'flazz/vim-colorschemes'
  112. " " preview Vim color scheme easily within Vim
  113. " Plug 'xolox/vim-colorscheme-switcher'
  114. " " prerequisite for above plugin
  115. " Plug 'xolox/vim-misc'
  116. " automatically save buffers upon returning to normal mode
  117. Plug '907th/vim-auto-save'
  118. let g:auto_save = 1
  119. " let g:auto_save_events = ["CursorHold", "CursorHoldI"]
  120. let g:auto_save_events = ["CursorHold"]
  121. " autocmd VimEnter *.tex let g:auto_save = 0
  122. " provides various functionality for writing LaTeX in Vim
  123. Plug 'lervag/vimtex'
  124. " au BufWritePost *.tex silent call Tex_RunLaTeX()
  125. au BufWritePost *.tex silent !pkill -USR1 xdvi.bin
  126. let g:Tex_MultipleCompileFormats = 'dvi,pdf'
  127. let g:vimtex_view_general_viewer = 'zathura'
  128. let g:vimtex_quickfix_latexlog = {
  129. \ 'overfull' : 0,
  130. \ 'underfull' : 0,
  131. \ 'global' : 0,
  132. \ 'references' : 0,
  133. \ 'unused' : 0,
  134. \}
  135. let g:vimtex_quickfix_autoclose_after_keystrokes = 5
  136. " let g:vimtex_compiler_latexmk = {
  137. " \ 'continuous' : 0,
  138. " \}
  139. {{ if not (eq .chezmoi.username "root") }}
  140. " auto-completion for various languages
  141. Plug 'Valloric/YouCompleteMe'
  142. let g:ycm_filetype_blacklist = {
  143. \ 'tagbar': 1,
  144. \ 'qf': 1,
  145. \ 'notes': 1,
  146. \ 'unite': 1,
  147. \ 'vimwiki': 1,
  148. \ 'pandoc': 1,
  149. \ 'infolog': 1,
  150. \ 'mail': 1
  151. \}
  152. {{ end }}
  153. " wrote short bits of text that expand into whatever you want
  154. " demo: https://www.youtube.com/watch?v=Zik6u0klD40
  155. Plug 'SirVer/ultisnips'
  156. " better key bindings for UltiSnipsExpandTrigger
  157. let g:UltiSnipsExpandTrigger = "<tab>"
  158. let g:UltiSnipsJumpForwardTrigger = "<tab>"
  159. let g:UltiSnipsJumpBackwardTrigger = "<C-tab>"
  160. let g:ultisnips_javascript = {
  161. \ 'keyword-spacing': 'always',
  162. \ 'semi': 'never',
  163. \ 'space-before-function-paren': 'never',
  164. \ }
  165. " custom snippets
  166. Plug 'Kevin-Mok/vim-snippets'
  167. " to make YouCompleteMe work with UltiSnips (both use Tab)
  168. Plug 'ervandew/supertab'
  169. " make YCM compatible with UltiSnips (using supertab)
  170. let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
  171. let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
  172. let g:SuperTabDefaultCompletionType = '<C-n>'
  173. " easily comment/uncomment lines
  174. Plug 'scrooloose/nerdcommenter'
  175. let g:NERDTrimTrailingWhitespace = 1
  176. let g:NERDSpaceDelims = 1
  177. " add quotes/brackets around chunks of text easily
  178. Plug 'tpope/vim-surround'
  179. nmap S ys
  180. " navigate around file easily and precisely
  181. Plug 'easymotion/vim-easymotion'
  182. map <Space> <Plug>(easymotion-prefix)
  183. " status bar displaying various info about the current buffer
  184. Plug 'vim-airline/vim-airline'
  185. let g:airline_section_c = '%F'
  186. Plug 'vim-airline/vim-airline-themes'
  187. let g:airline_powerline_fonts = 1
  188. " continue Markdown lists when started
  189. Plug 'dkarter/bullets.vim'
  190. " coordinate Vim color scheme with terminal color scheme
  191. Plug 'dylanaraps/wal.vim'
  192. " repeat plugin commands
  193. Plug 'tpope/vim-repeat'
  194. " better Django support
  195. Plug 'tweekmonster/django-plus.vim'
  196. " auto-close brackets
  197. Plug 'jiangmiao/auto-pairs'
  198. let g:AutoPairsMapSpace = 0
  199. Plug 'henrik/vim-indexed-search'
  200. Plug 'PotatoesMaster/i3-vim-syntax'
  201. " vim file explorer
  202. Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
  203. Plug 'terryma/vim-multiple-cursors'
  204. " let g:multi_cursor_select_all_word_key='<C-a>'
  205. let g:multi_cursor_exit_from_visual_mode=0
  206. let g:multi_cursor_exit_from_insert_mode=0
  207. Plug 'dag/vim-fish'
  208. Plug 'shime/vim-livedown'
  209. Plug 'tpope/vim-fugitive'
  210. " auto reload file
  211. Plug 'djoshea/vim-autoread'
  212. " Plug 'mustache/vim-mustache-handlebars'
  213. " Plug 'trapd00r/vim-syntax-vidir-ls'
  214. Plug 'calviken/vim-gdscript3'
  215. " display hex colors in Vim
  216. Plug 'RRethy/vim-hexokinase'
  217. Plug 'junegunn/goyo.vim'
  218. " prevent commands being executed through modelines "
  219. Plug 'ciaranm/securemodelines/'
  220. " different colors for each layer of surrounding brackets
  221. Plug 'luochen1990/rainbow'
  222. let g:rainbow_active = 1
  223. " easy custom text objects
  224. Plug 'kana/vim-textobj-user'
  225. " latex custom text objects
  226. Plug 'rbonvall/vim-textobj-latex'
  227. " swap words
  228. Plug 'tommcdo/vim-exchange'
  229. Plug 'scrooloose/nerdtree'
  230. let NERDTreeQuitOnOpen=1
  231. let NERDTreeShowHidden=1
  232. Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' }
  233. Plug 'junegunn/fzf.vim'
  234. Plug 'christoomey/vim-tmux-navigator'
  235. " mappings [[[ "
  236. let g:tmux_navigator_no_mappings = 1
  237. {{ if eq .linux_os "arch" }}
  238. nnoremap <A-j> :TmuxNavigateDown<cr>
  239. nnoremap <A-k> :TmuxNavigateUp<cr>
  240. nnoremap <A-h> :TmuxNavigateLeft<cr>
  241. nnoremap <A-l> :TmuxNavigateRight<cr>
  242. {{ end }}
  243. " nnoremap <C-Down> :TmuxNavigateDown<cr>
  244. " nnoremap <C-Up> :TmuxNavigateUp<cr>
  245. " nnoremap <C-Left> :TmuxNavigateLeft<cr>
  246. " nnoremap <C-Right> :TmuxNavigateRight<cr>
  247. " ]]] mappings "
  248. " ]]] vim-plug "
  249. " Mappings [[[ "
  250. call plug#end()
  251. {{ if .gui }}
  252. colorscheme wal
  253. {{ else }}
  254. colorscheme gotham256
  255. {{ end }}
  256. " normal mappings [[[ "
  257. nnoremap v <C-V>
  258. nnoremap Q @@
  259. nnoremap , za
  260. " indenting
  261. nnoremap > >>
  262. nnoremap < <<
  263. inoremap << <Esc><<A
  264. " ]]] normal mappings "
  265. " leader mappings [[[ "
  266. let mapleader="\<Space>"
  267. " find alias
  268. nnoremap <leader>a /^ <Left>
  269. nnoremap <leader>ac :.s/\(\w\w\)/\u\1\U\2/g<CR>
  270. " replace until end of line
  271. nnoremap <leader>c c$
  272. " delete until end of line
  273. nnoremap <leader>d d$
  274. " delete entire buffer
  275. nnoremap <leader>dg ggdG
  276. " delete entire line
  277. nnoremap <leader>dl 0d$
  278. " delete lines matching pattern
  279. nnoremap <leader>dls :g//d<left><left>
  280. " show docstring for cur word
  281. nnoremap <leader>do :YcmCompleter GetDoc<CR>
  282. " delete line into system clipboard
  283. nnoremap <leader>D "+dd
  284. " delete entire buffer into system clipboard
  285. nnoremap <leader>DA "+ggdG
  286. " find copied text
  287. nnoremap <leader>f q/p<CR>
  288. " find merge conflicts
  289. nnoremap <leader>fc /[<>=\|]\{7\}<CR>
  290. " reload folds
  291. nnoremap <leader>fmi :set foldmethod=indent<CR> zM
  292. nnoremap <leader>fmm :set foldmethod=marker<CR> zM
  293. " add marker foldmethod modeline
  294. nnoremap <leader>fi :YcmCompleter FixIt<CR>
  295. " check filetype
  296. nnoremap <leader>ft :se ft?<CR>
  297. " check todo's
  298. nnoremap <leader>ftd /TODO<CR>
  299. nnoremap <leader>g :YcmCompleter GoTo<CR>
  300. " vimdiff split
  301. nnoremap <leader>gd :Gvdiff
  302. nnoremap <leader>gdh :Gvdiff HEAD~
  303. nnoremap <leader>gdm :Gvdiff master<CR>
  304. " toggle search highlighting
  305. nnoremap <leader>h :set hlsearch! hlsearch?<CR>
  306. " help
  307. nnoremap <leader>he :help
  308. nnoremap <leader>ht :set tabstop=2 shiftwidth=2 expandtab<CR>
  309. nnoremap <leader>vhe :vert help
  310. " format current line
  311. nnoremap <leader>l Vgq
  312. " format this and next line
  313. nnoremap <leader>ll Vjgq
  314. " move cursor to middle of line
  315. nnoremap <leader>m :call cursor(0, len(getline('.'))/2)<CR>
  316. " apply normal command to selection
  317. vnoremap <leader>n q:anorm
  318. nnoremap <leader>nt :NERDTree<CR>
  319. " check if in neovim
  320. nnoremap <leader>nv :echo has('nvim')<CR>
  321. " don't wrap lines
  322. nnoremap <leader>nw :set nowrap<CR>
  323. " recursively open fold
  324. nnoremap <leader>o zO
  325. " Plug commands
  326. nnoremap <leader>p "*p
  327. nnoremap <leader>pli :PlugInstall<CR>
  328. nnoremap <leader>plc :PlugClean<CR>
  329. nnoremap <leader>plu :PlugUpdate<CR>
  330. " don't break lines
  331. nnoremap <leader>py :set tw=0<CR>
  332. " replace in next x lines
  333. nnoremap <leader>r q:i.,.+s///g<ESC>Fsi
  334. " replace in line
  335. nnoremap <leader>rl q:i.s///g<left><left><left>
  336. " replace in visual selection
  337. vnoremap <leader>r q:is///g<ESC>3ha
  338. " reload vim config
  339. nnoremap <leader>rv :source $MYVIMRC<CR>
  340. " replace in entire file
  341. nnoremap <leader>R q:i%s///g<ESC>2F/i
  342. vnoremap <leader>s :sort<CR>
  343. nnoremap <leader>sc :set spell spelllang=en_us<CR>
  344. " run current file in shell
  345. nnoremap <leader>sh :!%:p
  346. " sort lines until end of file
  347. nnoremap <leader>so q:i.,$sort<CR>
  348. " sort lines
  349. nnoremap <leader>sol q:i.,.+sort<ESC>Fsi
  350. " set syntax to shell (for dotfiles)
  351. nnoremap <leader>sys :set syn=sh<CR>
  352. vnoremap <leader>t :!tac<CR>
  353. " capitalize letter
  354. nnoremap <leader>u vU
  355. " open vimrc in vertical split
  356. nnoremap <leader>vv :vsp ~/.vimrc<CR>
  357. " copy next thing to system clipboard
  358. " nnoremap <leader>y "+
  359. " nnoremap <leader>Y "+Y
  360. nnoremap <leader>y y$
  361. nnoremap <leader>yo :Goyo<CR>
  362. " yank entire buffer
  363. nnoremap <leader>yg ggyG
  364. " toggle fold
  365. nnoremap <leader>z za
  366. " close all folds
  367. nnoremap <leader>zm zM
  368. " open all folds
  369. nnoremap <leader>zr zR
  370. " ]]] leader mappings "
  371. " function keys [[[ "
  372. map <F3> :wa<CR>
  373. map <F4> :xa<CR>
  374. map <F5> :q!<CR>
  375. map <F6> :qa!<CR>
  376. map <F7> :AutoSaveToggle<CR>
  377. " reload file
  378. nnoremap <F9> :e<CR>
  379. nnoremap <F10> :set paste<CR>"+p:set nopaste<CR>
  380. nnoremap <F11> :set paste<CR>"*p:set nopaste<CR>
  381. " ]]] function keys "
  382. map <S-Enter> O<ESC>
  383. " swap text visually
  384. vnoremap <C-P> <Esc>`.``gvP``P
  385. ino <C-A> <C-O>yiW<End>=<C-R>=<C-R>0<CR>
  386. " splits [[[ "
  387. nnoremap <C-Down> <C-W><C-J>
  388. nnoremap <C-Up> <C-W><C-K>
  389. nnoremap <C-Right> <C-W><C-L>
  390. nnoremap <C-Left> <C-W><C-H>
  391. " Maximize height/width.
  392. nnoremap <C-g> <C-W>_
  393. nnoremap <C-w> <C-W>|
  394. " ]]] splits "
  395. " ]]] Mappings "
  396. " Local Mappings [[[ "
  397. let maplocalleader="\\"
  398. " tex [[[ "
  399. autocmd Filetype tex inoremap <localleader>bt \bowtie
  400. autocmd Filetype tex inoremap <localleader>c \checkmark
  401. autocmd Filetype tex inoremap <localleader>d \delta
  402. autocmd Filetype tex inoremap <localleader>D \Delta
  403. autocmd Filetype tex inoremap <localleader>e \exists
  404. autocmd Filetype tex inoremap <localleader>ep \epsilon
  405. autocmd Filetype tex inoremap <localleader>fa \forall
  406. autocmd Filetype tex inoremap <localleader>g \geq
  407. autocmd Filetype tex inoremap <localleader>i \in
  408. autocmd Filetype tex inoremap <localleader>le \leq
  409. autocmd Filetype tex inoremap <localleader>ln \log n
  410. autocmd Filetype tex inoremap <localleader>lr \Leftrightarrow
  411. " autocmd Filetype tex inoremap <localleader>n \neg
  412. autocmd Filetype tex inoremap <localleader>n \neq
  413. autocmd Filetype tex inoremap <localleader>N \mathbb{N}
  414. autocmd Filetype tex inoremap <localleader>pg \pagebreak<Enter>
  415. autocmd Filetype tex inoremap <localleader>ph [,phantom]
  416. autocmd Filetype tex inoremap <localleader>q \qquad
  417. autocmd Filetype tex inoremap <localleader>r \rightarrow
  418. autocmd Filetype tex inoremap <localleader>R \Rightarrow
  419. autocmd Filetype tex inoremap <localleader>s \subset
  420. autocmd Filetype tex inoremap <localleader>st such that
  421. autocmd Filetype tex inoremap <localleader>S \Sigma
  422. autocmd Filetype tex inoremap <localleader>t \times
  423. " autocmd Filetype tex inoremap <localleader>T $T$
  424. autocmd Filetype tex inoremap <localleader>T \Theta
  425. " replace bars/underscores in URL
  426. autocmd Filetype tex inoremap <localleader>url :.s/\([-_]\)/\\\1/g<CR>
  427. autocmd Filetype tex inoremap <localleader>v \vee
  428. autocmd Filetype tex inoremap <localleader>w \wedge
  429. autocmd Filetype tex inoremap <localleader>x $x$-axis
  430. autocmd Filetype tex inoremap <localleader>y $y$-axis
  431. autocmd Filetype tex inoremap <localleader>Z \mathbb{Z}
  432. " par3
  433. autocmd Filetype tex inoremap <localleader>wx $w(x)$
  434. autocmd Filetype tex inoremap <localleader>tx $t(x)$
  435. " ]]] tex "
  436. autocmd Filetype c inoremap <localleader>uc unsigned char
  437. autocmd BufNewFile,BufRead *.h nnoremap <localleader>x 0iextern <Esc>f{hc$;<Esc>
  438. autocmd Filetype fish inoremap <localleader>1 $argv[1]
  439. autocmd Filetype fish inoremap <localleader>2 $argv[2]
  440. autocmd Filetype javascript inoremap <localleader>x process.exit()
  441. autocmd Filetype markdown inoremap <localleader>cb - [ ]
  442. autocmd Filetype markdown nnoremap <localleader>x 0f[lrx
  443. " nnoremap <localleader>x 0f[lrx
  444. autocmd Filetype go-template inoremap <localleader>e {{"{{ else }}"}}
  445. autocmd Filetype go-template inoremap <localleader>hd {{"{{ .chezmoi.homedir }}"}}
  446. autocmd Filetype go-template nnoremap <localleader>fp :%s/{{"{{{"}}/[[[/g<CR>:%s/}}}/]]]/g<CR>
  447. autocmd Filetype python inoremap <localleader>bp breakpoint()
  448. autocmd Filetype python inoremap <localleader>s self.
  449. " ]]] Local Mappings "