onejdc

vimrc

Aug 31st, 2023 (edited)
3,231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 4.80 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 built-in package manager
  89. " git clone https://github.com/catppuccin/vim.git ~/.vim/pack/vendor/start/catppuccin
  90.  
  91. " using vim-plug
  92. call plug#begin('~/.vim/plugged')
  93.   Plug 'preservim/nerdtree'
  94.   Plug 'ap/vim-css-color' "CSS Color Preview
  95.   Plug 'tpope/vim-commentary'
  96.   Plug 'mattn/emmet-vim'
  97.   Plug 'nathanaelkane/vim-indent-guides'
  98.   Plug 'romainl/vim-cool'
  99.   Plug 'ryanoasis/vim-devicons'
  100. call plug#end()
  101. " }}}
  102.  
  103.  
  104. " MAPPINGS ------------------------------ {{{
  105.  
  106. " }}}
  107.  
  108.  
  109. " VIMSCRIPT ----------------------------- {{{
  110.  
  111. " This will enable code folding.
  112. " User the marker method of folding.
  113. " zO = open single, zc = close fold
  114. " zR = open all folds, zM = close all folds
  115. augroup filetype_vim
  116.     autocmd!
  117.     autocmd FileType vim setlocal foldmethod=marker
  118. augroup END
  119.  
  120.  
  121. if has("autocmd")
  122.   " HTML indentation
  123.   autocmd FileType html setlocal tabstop=2 shiftwidth=2 expandtab
  124.   autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
  125.   autocmd FileType javascript setlocal ts=2 sts=2 sw=2 expandtab
  126.  
  127.   autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
  128.   autocmd FileType php setlocal ts=4 sts=4 sw=4 expandtab
  129. endif
  130. " Enable undo
  131. if version >= 703
  132.     set undodir=~/.vim/backup
  133.     set undofile
  134.     set undoreload=10000
  135. endif
  136.  
  137. " Split window using :split or :vsplit
  138. " Display cursorline and cursorcolumn ONLY in active window
  139. augroup cursor_off
  140.     autocmd!
  141.     autocmd WinLeave * set nocursorline nocursorcolumn
  142.     autocmd WinEnter * set cursorline cursorcolumn
  143. augroup END
  144.  
  145. " Some GUI Options
  146. if has('gui_running')
  147.  
  148.     set background=dark
  149.  
  150.     colorscheme molokai
  151.  
  152.     " Font syntax: <font_name>\ <weight>\ <size>
  153.     set guifont=Monospace\ Regular\ 12
  154.  
  155.     " hide toolbar
  156.     set guioptions-=T
  157.  
  158.     " Hide Left-side scroll bars
  159.     set guioptions-=L
  160.     set guioptions-=r
  161.  
  162.     " Hide menu
  163.     set guioptions-=m
  164.  
  165.     " Hide bottom scroll
  166.     set guioptions-=b
  167.  
  168.     " Set a keymap for F4 to toggle
  169.     " <Bar> is | character
  170.     nnoremap <F4> :if &guioptions=~#'mTr'<Bar>
  171.         \set guioptions-=mTr<Bar>
  172.         \else<Bar>
  173.         \set guioptions+=mTr<Bar>
  174.         \endif<CR>
  175. endif
  176.  
  177.  
  178.  
  179. " Maps jk to <ESC>, credit:
  180. "     https://reddit.com/r/vim/comments/ufgrl8/journey_to_the_ultimate_imap_jk_esc/
  181. "     Comment by /u/lervag
  182. function JKescape(key) abort
  183.   if a:key ==# 'j'
  184.     let b:esc_j_lasttime = reltimefloat(reltime())
  185.     return a:key
  186.   endif
  187.   let l:timediff = reltimefloat(reltime()) - get(b:, 'esc_j_lasttime')
  188.   let b:esc_j_lasttime = 0.0
  189.   return l:timediff <= 0.1 && l:timediff > 0.001 ? "\b\e" : a:key
  190. endfunction
  191.  
  192. inoremap <expr> j JKescape('j')
  193. inoremap <expr> k JKescape('k')
  194. " }}}
  195.  
  196.  
  197. " STATUS LINE --------------------------- {{{
  198.  
  199. " Scripts that get used for status line
  200. function! GitBranch()
  201.   return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
  202. endfunction
  203.  
  204. function! StatuslineGit()
  205.   let l:branchname = GitBranch()
  206.   return strlen(l:branchname) > 0?'  '.l:branchname.' ':''
  207. endfunction
  208.  
  209.  
  210. " Clear on reload
  211. set statusline=
  212.  
  213. " Left Side
  214. "set statusline+=\ %F\ %M\ %Y\ %R
  215.  
  216. " Divider
  217. "set statusline+=%=
  218.  
  219. " Right Side
  220. "set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %1\ col:\ %c\ percent:\ %p%%
  221.  
  222.  
  223. set statusline+=%#PmenuSel#
  224. set statusline+=%=
  225. set statusline+=%{StatuslineGit()}
  226. set statusline+=%#LineNr#
  227. set statusline+=\ %f
  228. set statusline+=%m\
  229. set statusline+=%#CursorColumn#
  230. set statusline+=\ %y
  231. set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
  232. set statusline+=\[%{&fileformat}\]
  233. set statusline+=\ %p%%
  234. set statusline+=\ %l:%c
  235. set statusline+=\
  236.  
  237.  
  238. " Move status
  239. set laststatus=2
  240. " }}}
  241.  
Advertisement