Another copy of my dotfiles. Because I don't completely trust GitHub.
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.

204 lines
6.2 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. " XDG Base Directory Specification
  2. set runtimepath^=$XDG_CONFIG_HOME/vim
  3. set runtimepath+=$XDG_DATA_HOME/vim
  4. set runtimepath+=$XDG_CONFIG_HOME/vim/after
  5. set packpath^=$XDG_DATA_HOME/vim,$XDG_CONFIG_HOME/vim
  6. set packpath+=$XDG_CONFIG_HOME/vim/after,$XDG_DATA_HOME/vim/after
  7. let g:netrw_home = $XDG_DATA_HOME."/vim"
  8. call mkdir($XDG_DATA_HOME."/vim/spell", 'p')
  9. set viewdir=$XDG_DATA_HOME/vim/view | call mkdir(&viewdir, 'p')
  10. set backupdir=$XDG_CACHE_HOME/vim/backup | call mkdir(&backupdir, 'p')
  11. set directory=$XDG_CACHE_HOME/vim/swap | call mkdir(&directory, 'p')
  12. set undodir=$XDG_CACHE_HOME/vim/undo | call mkdir(&undodir, 'p')
  13. let s:MRU_File = $XDG_CACHE_HOME."/vim/mru"
  14. if !has('nvim') | set viminfofile=$XDG_CACHE_HOME/vim/viminfo | endif
  15. source ~/.config/vim/plugin/plugins.vim
  16. " Set leader
  17. let mapleader = ","
  18. noh
  19. " Leader Mappings
  20. map <Leader>w :update<CR>
  21. map <Leader>q :qall<CR>
  22. map <Leader>gs :Gstatus<CR>
  23. " Recently edited files
  24. map <Leader>h :History<CR>
  25. " map gj and gk to j and k for seamless movement in tex
  26. map j gj
  27. map k gk
  28. " CtrlP use FZF (faster!)
  29. nnoremap <C-p> :Files<CR>
  30. nnoremap <leader>b :Buffers<CR>
  31. noremap <leader>u :w<Home>silent <End> !urlview<CR>
  32. syntax on
  33. filetype plugin on
  34. autocmd Filetype scss if getfsize(@%) > 300 | setlocal syntax=OFF | endif
  35. augroup twig_ft
  36. au!
  37. autocmd BufNewFile,BufRead *.html.inky set syntax=eruby
  38. augroup END
  39. set autoread " Auto reload changed files
  40. set wildmenu " Tab autocomplete in command mode
  41. set backspace=indent,eol,start " http://vi.stackexchange.com/a/2163
  42. set laststatus=2 " Show status line on startup
  43. set splitright " Open new splits to the right
  44. set splitbelow " Open new splits to the bottom
  45. set lazyredraw " Reduce the redraw frequency
  46. set ttyfast " Send more characters in fast terminals
  47. set nowrap " Don't wrap long lines
  48. set listchars=extends:→ " Show arrow if line continues rightwards
  49. set listchars+=precedes:← " Show arrow if line continues leftwards
  50. set nobackup nowritebackup noswapfile " Turn off backup files
  51. set noerrorbells novisualbell " Turn off visual and audible bells
  52. set expandtab shiftwidth=2 tabstop=2 " Two spaces for tabs everywhere
  53. set history=500
  54. set hidden " Save buffers automatically
  55. set ignorecase smartcase " Search queries intelligently set case
  56. set incsearch " Show search results as you type
  57. set timeoutlen=1000 ttimeoutlen=0 " Remove timeout when hitting escape
  58. set showcmd " Show size of visual selection
  59. set cmdheight=2
  60. set t_Co=256
  61. set clipboard=unnamedplus
  62. set shortmess+=c
  63. set updatetime=300
  64. if has("patch-8.1.1564")
  65. " Recently vim can merge signcolumn and number column into one
  66. set signcolumn=number
  67. else
  68. set signcolumn=yes
  69. endif
  70. " Persistent undo
  71. set undodir=~/.local/share/vim/undo/
  72. set undofile
  73. set undolevels=1000
  74. set undoreload=10000
  75. " Ignored files/directories from autocomplete (and CtrlP)
  76. set wildignore+=*/tmp/*
  77. set wildignore+=*.so
  78. set wildignore+=*.zip
  79. set wildignore+=*/vendor/bundle/*
  80. set wildignore+=*/node_modules/
  81. "-------------------------------------------------------------------------------
  82. " Interface
  83. "-------------------------------------------------------------------------------
  84. set number " Enable line numbers
  85. set scrolloff=5 " Leave 5 lines of buffer when scrolling
  86. set sidescrolloff=10 " Leave 10 characters of horizontal buffer when scrolling
  87. "-------------------------------------------------------------------------------
  88. " Colors & Formatting
  89. "-------------------------------------------------------------------------------
  90. let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
  91. let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
  92. if (has("termguicolors"))
  93. set termguicolors
  94. endif
  95. let g:material_theme_style='ocean-community'
  96. let g:material_style='ocean'
  97. set background=dark
  98. try
  99. colorscheme material
  100. catch /^Vim\%((\a\+)\)\=:E185/
  101. colorscheme default
  102. endtry
  103. " Showcase comments in italics
  104. highlight Comment cterm=italic gui=italic
  105. " Easy tab navigation
  106. nnoremap <C-Left> :tabprevious<CR>
  107. nnoremap <C-Right> :tabnext<CR>
  108. " Golang specific settings
  109. let g:go_highlight_build_constraints = 1
  110. let g:go_highlight_extra_types = 1
  111. let g:go_highlight_fields = 1
  112. let g:go_highlight_functions = 1
  113. let g:go_highlight_methods = 1
  114. let g:go_highlight_operators = 1
  115. let g:go_highlight_structs = 1
  116. let g:go_highlight_types = 1
  117. let g:go_auto_type_info = 1
  118. let g:go_fmt_command = "goimports"
  119. " Find/replace
  120. vnoremap <C-r> "hy:%s/<C-r>h//g<left><left><left>
  121. " Disable highlight
  122. nnoremap <leader>e :noh<CR>
  123. " let g:auto_save = 1 " enable AutoSave on Vim startup
  124. " let g:auto_save_in_insert_mode = 0 " do not save in insert mode
  125. " Get off my lawn - helpful when learning Vim :)
  126. nnoremap <C-c> :echoe "Use Esc"<CR>
  127. nnoremap <Left> :echoe "Use h"<CR>
  128. nnoremap <Right> :echoe "Use l"<CR>
  129. nnoremap <Up> :echoe "Use k"<CR>
  130. nnoremap <Down> :echoe "Use j"<CR>
  131. nnoremap <silent> <Leader>+ :exe "resize " . (winheight(0) * 3/2)<CR>
  132. nnoremap <silent> <Leader>- :exe "resize " . (winheight(0) * 2/3)<CR>
  133. let g:Tlist_WinWidth = 40
  134. " Syntastic max file size for python
  135. let g:syntastic_python_pylint_post_args="--max-line-length=120"
  136. "-------------------------------------------------------------------------------
  137. " Neovim-specific configurations
  138. "-------------------------------------------------------------------------------
  139. if has('nvim')
  140. let $NVIM_TUI_ENABLE_TRUE_COLOR=1
  141. set termguicolors
  142. " Fix vim-tmux-navigator <C-h> https://git.io/viGRU
  143. nmap <BS> <C-W>h
  144. " Fix vim-tmux-navigator <C-h> https://git.io/vS5QH
  145. nmap <BS> :<C-u>TmuxNavigateLeft<CR>
  146. endif
  147. " Don't clear clipboard on exit
  148. autocmd VimLeave * call system("xsel -ib", getreg('+'))
  149. " Useful for GDB debugging
  150. packadd termdebug
  151. " Use skeleton files
  152. if has("autocmd")
  153. augroup templates
  154. autocmd BufNewFile *.* silent! execute '0r ~/.local/share/vim/templates/skeleton.'.expand("<afile>:e")
  155. autocmd BufNewFile * %substitute#\[:VIM_EVAL:\]\(.\{-\}\)\[:END_EVAL:\]#\=eval(submatch(1))#ge
  156. augroup END
  157. autocmd BufWinLeave *.tex !texclear %:p
  158. endif