Advertisement
onejdc

vimrc

Aug 31st, 2023 (edited)
1,672
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 4.68 KB | None | 0 0
  1. " BASIC OPTS ---------------------------- {{{
  2.  
  3. set shell=/bin/bash
  4.  
  5. " Disable VI compat
  6. set nocompatible
  7.  
  8.  
  9. " color scheme
  10. colorscheme torte
  11. " Detect file types
  12. filetype on
  13.  
  14. " Plugins Enable
  15. filetype plugin on
  16.  
  17. " Indents
  18. filetype indent on
  19.  
  20. " Syntax highlighting
  21. syntax on
  22.  
  23. " Line numbers
  24. set number
  25. set relativenumber
  26.  
  27. " Hilight cursor Horizontally & Vertically
  28. set cursorline
  29. set cursorcolumn
  30.  
  31. set shiftwidth=2
  32. set tabstop=2
  33. set softtabstop=2
  34. set expandtab
  35.  
  36. " Don't save backups
  37. set nobackup
  38.  
  39. " Do not let cursor scroll below or above N lines
  40. set scrolloff=15
  41.  
  42. set nowrap
  43.  
  44. " incremental Search
  45. set incsearch
  46.  
  47. set ignorecase
  48.  
  49. set smartcase
  50.  
  51. " Show partial commands
  52. set showcmd
  53.  
  54. " Show current mode
  55. set showmode
  56.  
  57. " Show matching words
  58. set showmatch
  59.  
  60. " Highlight matches when searching
  61. set hlsearch
  62.  
  63. " Cmd history
  64. set history=1000
  65.  
  66. " Wildmenu Tab completion
  67. "set wildmenu
  68.  
  69. set wildmode=list:longest
  70.  
  71. " Never open these in VIM
  72. set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx,*.mp3
  73.  
  74.  
  75. " runtimepath & packpath -- mostly for windows
  76. set runtimepath^="~/.vim/plugged"
  77. let &packpath = &runtimepath
  78.  
  79. " vim-plug logs
  80. let g:plug_log_on = 1
  81. " }}}
  82.  
  83.  
  84.  
  85.  
  86. " PLUGINS ------------------------------- {{{
  87.  
  88. " using vim-plug
  89. call plug#begin('~/.vim/plugged')
  90.   Plug 'preservim/nerdtree'
  91.   Plug 'ap/vim-css-color' "CSS Color Preview
  92.   Plug 'tpope/vim-commentary'
  93.   Plug 'mattn/emmet-vim'
  94.   Plug 'nathanaelkane/vim-indent-guides'
  95.   Plug 'romainl/vim-cool'
  96.   Plug 'ryanoasis/vim-devicons'
  97. call plug#end()
  98. " }}}
  99.  
  100.  
  101. " MAPPINGS ------------------------------ {{{
  102.  
  103. " }}}
  104.  
  105.  
  106. " VIMSCRIPT ----------------------------- {{{
  107.  
  108. " This will enable code folding.
  109. " User the marker method of folding.
  110. " zO = open single, zc = close fold
  111. " zR = open all folds, zM = close all folds
  112. augroup filetype_vim
  113.     autocmd!
  114.     autocmd FileType vim setlocal foldmethod=marker
  115. augroup END
  116.  
  117.  
  118. if has("autocmd")
  119.   " HTML indentation
  120.   autocmd FileType html setlocal tabstop=2 shiftwidth=2 expandtab
  121.   autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
  122.   autocmd FileType javascript setlocal ts=2 sts=2 sw=2 expandtab
  123.  
  124.   autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
  125.   autocmd FileType php setlocal ts=4 sts=4 sw=4 expandtab
  126. endif
  127. " Enable undo
  128. if version >= 703
  129.     set undodir=~/.vim/backup
  130.     set undofile
  131.     set undoreload=10000
  132. endif
  133.  
  134. " Split window using :split or :vsplit
  135. " Display cursorline and cursorcolumn ONLY in active window
  136. augroup cursor_off
  137.     autocmd!
  138.     autocmd WinLeave * set nocursorline nocursorcolumn
  139.     autocmd WinEnter * set cursorline cursorcolumn
  140. augroup END
  141.  
  142. " Some GUI Options
  143. if has('gui_running')
  144.  
  145.     set background=dark
  146.  
  147.     colorscheme molokai
  148.  
  149.     " Font syntax: <font_name>\ <weight>\ <size>
  150.     set guifont=Monospace\ Regular\ 12
  151.  
  152.     " hide toolbar
  153.     set guioptions-=T
  154.  
  155.     " Hide Left-side scroll bars
  156.     set guioptions-=L
  157.     set guioptions-=r
  158.  
  159.     " Hide menu
  160.     set guioptions-=m
  161.  
  162.     " Hide bottom scroll
  163.     set guioptions-=b
  164.  
  165.     " Set a keymap for F4 to toggle
  166.     " <Bar> is | character
  167.     nnoremap <F4> :if &guioptions=~#'mTr'<Bar>
  168.         \set guioptions-=mTr<Bar>
  169.         \else<Bar>
  170.         \set guioptions+=mTr<Bar>
  171.         \endif<CR>
  172. endif
  173.  
  174.  
  175.  
  176. " Maps jk to <ESC>, credit:
  177. "     https://reddit.com/r/vim/comments/ufgrl8/journey_to_the_ultimate_imap_jk_esc/
  178. "     Comment by /u/lervag
  179. function JKescape(key) abort
  180.   if a:key ==# 'j'
  181.     let b:esc_j_lasttime = reltimefloat(reltime())
  182.     return a:key
  183.   endif
  184.   let l:timediff = reltimefloat(reltime()) - get(b:, 'esc_j_lasttime')
  185.   let b:esc_j_lasttime = 0.0
  186.   return l:timediff <= 0.1 && l:timediff > 0.001 ? "\b\e" : a:key
  187. endfunction
  188.  
  189. inoremap <expr> j JKescape('j')
  190. inoremap <expr> k JKescape('k')
  191. " }}}
  192.  
  193.  
  194. " STATUS LINE --------------------------- {{{
  195.  
  196. " Scripts that get used for status line
  197. function! GitBranch()
  198.   return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
  199. endfunction
  200.  
  201. function! StatuslineGit()
  202.   let l:branchname = GitBranch()
  203.   return strlen(l:branchname) > 0?'  '.l:branchname.' ':''
  204. endfunction
  205.  
  206.  
  207. " Clear on reload
  208. set statusline=
  209.  
  210. " Left Side
  211. "set statusline+=\ %F\ %M\ %Y\ %R
  212.  
  213. " Divider
  214. "set statusline+=%=
  215.  
  216. " Right Side
  217. "set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %1\ col:\ %c\ percent:\ %p%%
  218.  
  219.  
  220. set statusline+=%#PmenuSel#
  221. set statusline+=%=
  222. set statusline+=%{StatuslineGit()}
  223. set statusline+=%#LineNr#
  224. set statusline+=\ %f
  225. set statusline+=%m\
  226. set statusline+=%#CursorColumn#
  227. set statusline+=\ %y
  228. set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
  229. set statusline+=\[%{&fileformat}\]
  230. set statusline+=\ %p%%
  231. set statusline+=\ %l:%c
  232. set statusline+=\
  233.  
  234.  
  235. " Move status
  236. set laststatus=2
  237. " }}}
  238.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement