Advertisement
onejdc

vimrc

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