PhysixCat

vimrc

Jul 24th, 2019
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.47 KB | None | 0 0
  1. " vim: fdm=marker:foldlevel=0 foldenable sw=4 ts=4 sts=4
  2. " Vim configuration
  3.  
  4. " {{{ Clear Autocommands
  5.  
  6. au!
  7.  
  8. " }}}
  9.  
  10. " {{{ Plugins
  11.  
  12. " {{{ Summon Vundle
  13.  
  14. set nocompatible
  15. filetype off
  16. set rtp+=~/.vim/bundle/Vundle.vim
  17. call vundle#begin()
  18. Plugin 'VundleVim/Vundle.vim'
  19.  
  20. " }}}
  21.  
  22. " Plugins go here
  23. Plugin 'morhetz/gruvbox'
  24. Plugin 'dylanaraps/wal.vim'
  25. Plugin 'JuliaEditorSupport/julia-vim'
  26.  
  27. " {{{ Dismiss Vundle
  28.  
  29. call vundle#end()
  30. filetype plugin indent on
  31.  
  32. " }}}
  33.  
  34. " }}}
  35.  
  36. " {{{ Basic Settings
  37.  
  38. " Clever :find completion. Searches subfolders, tab-completion for file tasks
  39. set path+=**
  40.  
  41. " Always use bash syntax for sh filetype
  42. let g:is_bash=1
  43.  
  44. " Color scheme
  45. "set termguicolors
  46. let g:gruvbox_italic=1
  47. colorscheme gruvbox
  48. "set background=light
  49. set background=dark
  50.  
  51. " Search is case insensitive unless we include capital letters
  52. set ignorecase smartcase
  53.  
  54. " Window display
  55. set showcmd ruler laststatus=2
  56. set number
  57.  
  58. " Open new windows by splitting to the right
  59. set splitright
  60.  
  61. " Buffers
  62. set history=500
  63. set hidden
  64.  
  65. " Spelling
  66. set dictionary+=/usr/share/dict/words thesaurus+=$HOME/.thesaurus
  67.  
  68. " Text display
  69. set listchars=trail:.,tab:>-,extends:>,precedes:<,nbsp:¬
  70. set list
  71.  
  72. " Typing behavior
  73. set backspace=indent,eol,start
  74. set showmatch
  75. set wildmode=full
  76. " Display all matching files when we tab complete
  77. " Now we can hit tab ":find by partial match and use * to make it fuzzy
  78. " :ls shows buffer of files that are already open
  79. " :b letsyou autocomplete any open buffer
  80. set wildmenu
  81. set complete-=i
  82.  
  83. " Formatting
  84. set nowrap expandtab smarttab shiftround
  85. set tabstop=4
  86. set softtabstop=4
  87. set shiftwidth=4
  88. set foldlevelstart=2
  89.  
  90. " Call custom function for status line
  91. set statusline=%!MyStatusLine()
  92.  
  93. " Session saving
  94. set sessionoptions=blank,buffers,curdir,folds,help,tabpages,winsize,localoptions
  95.  
  96. " }}}
  97.  
  98. " {{{ Autocommands
  99.  
  100. " Make modification indicator [+] white on red background
  101. au ColorScheme * hi User1 gui=bold term=bold cterm=bold guifg=white guibg=red ctermfg=white ctermbg=red
  102.  
  103. " Tweak the color of the fold display column
  104. au ColorScheme * hi FoldColumn cterm=bold ctermbg=233 ctermfg=146
  105.  
  106. " }}}
  107.  
  108. " {{{ Syntax Highlighting
  109.  
  110. syntax enable
  111.  
  112. " }}}
  113.  
  114. " {{{ Backup, Swap, Undo
  115.  
  116. set backupdir=$HOME/.vim/backup//
  117. set directory=$HOME/.vim/swap//
  118. set undodir=$HOME/.vim/undo//
  119.  
  120. " }}}
  121.  
  122. " {{{ Key Mappings
  123.  
  124. " Set leader key
  125. let mapleader = ","
  126.  
  127. " Newlines
  128. nnoremap <C-j> o<ESC>k
  129. nnoremap <C-k> O<ESC>j
  130.  
  131. " Call custom function for sane pasting
  132. command! Paste call SmartPaste()
  133.  
  134. " Create 'tags' file
  135. "command! MakeTags !ctags -R .
  136.  
  137. " Fix whitespace
  138. nnoremap <F4> :retab<CR>:%s/\s\+$//e<CR><C-o>
  139.  
  140. " Fix syntax highlighting
  141. nnoremap <F3> :syn sync fromstart<CR>
  142.  
  143. " Edit .vimrc
  144. nnoremap ,e :edit $MYVIMRC<CR>
  145. nnoremap ,v :source $MYVIMRC<CR>
  146.  
  147. " Toggle search highlighting
  148. nnoremap <silent> ; :set invhlsearch<CR>
  149.  
  150. " Call custom function to move between tabs OR buffers
  151. nnoremap <silent> L :call MyNext()<CR>
  152. nnoremap <silent> H :call MyPrev()<CR>
  153.  
  154. " Insert timestamp
  155. "nnoremap <C-d> "=strftime("%-l:%M%p")<CR>P
  156. "inoremap <C-d> <C-r>=strftime("%-l:%M%p")<CR>
  157.  
  158. " URLview
  159. noremap <leader>u :w<Home>silent <End> !urlview<CR>
  160.  
  161. " }}}
  162.  
  163. " {{{ Custom Functions
  164.  
  165. " {{{ MyStatusLine()
  166.  
  167. function! MyStatusLine()
  168. let statusline = ""
  169. " Filename (F -> full, f-> relative)
  170. let statusline .= "%f"
  171. " Buffer flags
  172. let statusline .= "%( %h%1*%m%*%r%w%) "
  173. " File format and type
  174. let statusline .= "(%{&ff}%(\/%Y%))"
  175. " Left/right separator
  176. let statusline .= "%="
  177. " Line & column
  178. let statusline .= "(%l,%c%V) "
  179. " Character under cursor (decimal)
  180. let statusline .= "%03.3b "
  181. " Character under cursor (hexadecimal)
  182. let statusline .= "0x%02.2B "
  183. " File progress
  184. let statusline .= "| %P/%L"
  185. return statusline
  186. endfunction
  187.  
  188. " }}}
  189.  
  190. " {{{ MyNext() and MyPrev()
  191.  
  192. function! MyNext()
  193. if exists( '*tabpagenr' ) && tabpagenr('$') != 1
  194. " Tab support && tabs open
  195. normal gt
  196. else
  197. " No tab support, or no tabs open
  198. execute ":bnext"
  199. endif
  200. endfunction
  201. function! MyPrev()
  202. if exists( '*tabpagenr' ) && tabpagenr('$') != '1'
  203. " Tab support && tabs open
  204. normal gT
  205. else
  206. " No tab suport, or no tabs open
  207. execute ":bprev"
  208. endif
  209. endfunction
  210.  
  211. " }}}
  212.  
  213. " {{{ SmartPaste()
  214. function! SmartPaste()
  215. setl paste
  216. normal "+p
  217. setl nopaste
  218. endfunction
  219. " }}}
  220.  
  221. " }}}
Advertisement
Add Comment
Please, Sign In to add comment