" BASIC OPTS ---------------------------- {{{
set shell=/bin/bash
" Disable VI compat
set nocompatible
" color scheme
colorscheme torte
" Detect file types
filetype on
" Plugins Enable
filetype plugin on
" Indents
filetype indent on
" Syntax highlighting
syntax on
" Line numbers
set number
set relativenumber
" Hilight cursor Horizontally & Vertically
set cursorline
set cursorcolumn
set shiftwidth=2
set tabstop=2
set softtabstop=2
set expandtab
" Don't save backups
set nobackup
" Do not let cursor scroll below or above N lines
set scrolloff=15
set nowrap
" incremental Search
set incsearch
set ignorecase
set smartcase
" Show partial commands
set showcmd
" Show current mode
set showmode
" Show matching words
set showmatch
" Highlight matches when searching
set hlsearch
" Cmd history
set history=1000
" Wildmenu Tab completion
"set wildmenu
set wildmode=list:longest
" Never open these in VIM
set wildignore=*.docx,*.jpg,*.png,*.gif,*.pdf,*.pyc,*.exe,*.flv,*.img,*.xlsx,*.mp3
" runtimepath & packpath -- mostly for windows
set runtimepath^="~/.vim/plugged"
let &packpath = &runtimepath
" vim-plug logs
let g:plug_log_on = 1
" }}}
" PLUGINS ------------------------------- {{{
" using built-in package manager
" git clone https://github.com/catppuccin/vim.git ~/.vim/pack/vendor/start/catppuccin
" using vim-plug
call plug#begin('~/.vim/plugged')
Plug 'preservim/nerdtree'
Plug 'ap/vim-css-color' "CSS Color Preview
Plug 'tpope/vim-commentary'
Plug 'mattn/emmet-vim'
Plug 'nathanaelkane/vim-indent-guides'
Plug 'romainl/vim-cool'
Plug 'ryanoasis/vim-devicons'
call plug#end()
" }}}
" MAPPINGS ------------------------------ {{{
" }}}
" VIMSCRIPT ----------------------------- {{{
" This will enable code folding.
" User the marker method of folding.
" zO = open single, zc = close fold
" zR = open all folds, zM = close all folds
augroup filetype_vim
autocmd!
autocmd FileType vim setlocal foldmethod=marker
augroup END
if has("autocmd")
" HTML indentation
autocmd FileType html setlocal tabstop=2 shiftwidth=2 expandtab
autocmd FileType css setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType javascript setlocal ts=2 sts=2 sw=2 expandtab
autocmd FileType make setlocal ts=8 sts=8 sw=8 noexpandtab
autocmd FileType php setlocal ts=4 sts=4 sw=4 expandtab
endif
" Enable undo
if version >= 703
set undodir=~/.vim/backup
set undofile
set undoreload=10000
endif
" Split window using :split or :vsplit
" Display cursorline and cursorcolumn ONLY in active window
augroup cursor_off
autocmd!
autocmd WinLeave * set nocursorline nocursorcolumn
autocmd WinEnter * set cursorline cursorcolumn
augroup END
" Some GUI Options
if has('gui_running')
set background=dark
colorscheme molokai
" Font syntax: <font_name>\ <weight>\ <size>
set guifont=Monospace\ Regular\ 12
" hide toolbar
set guioptions-=T
" Hide Left-side scroll bars
set guioptions-=L
set guioptions-=r
" Hide menu
set guioptions-=m
" Hide bottom scroll
set guioptions-=b
" Set a keymap for F4 to toggle
" <Bar> is | character
nnoremap <F4> :if &guioptions=~#'mTr'<Bar>
\set guioptions-=mTr<Bar>
\else<Bar>
\set guioptions+=mTr<Bar>
\endif<CR>
endif
" Maps jk to <ESC>, credit:
" https://reddit.com/r/vim/comments/ufgrl8/journey_to_the_ultimate_imap_jk_esc/
" Comment by /u/lervag
function JKescape(key) abort
if a:key ==# 'j'
let b:esc_j_lasttime = reltimefloat(reltime())
return a:key
endif
let l:timediff = reltimefloat(reltime()) - get(b:, 'esc_j_lasttime')
let b:esc_j_lasttime = 0.0
return l:timediff <= 0.1 && l:timediff > 0.001 ? "\b\e" : a:key
endfunction
inoremap <expr> j JKescape('j')
inoremap <expr> k JKescape('k')
" }}}
" STATUS LINE --------------------------- {{{
" Scripts that get used for status line
function! GitBranch()
return system("git rev-parse --abbrev-ref HEAD 2>/dev/null | tr -d '\n'")
endfunction
function! StatuslineGit()
let l:branchname = GitBranch()
return strlen(l:branchname) > 0?' '.l:branchname.' ':''
endfunction
" Clear on reload
set statusline=
" Left Side
"set statusline+=\ %F\ %M\ %Y\ %R
" Divider
"set statusline+=%=
" Right Side
"set statusline+=\ ascii:\ %b\ hex:\ 0x%B\ row:\ %1\ col:\ %c\ percent:\ %p%%
set statusline+=%#PmenuSel#
set statusline+=%=
set statusline+=%{StatuslineGit()}
set statusline+=%#LineNr#
set statusline+=\ %f
set statusline+=%m\
set statusline+=%#CursorColumn#
set statusline+=\ %y
set statusline+=\ %{&fileencoding?&fileencoding:&encoding}
set statusline+=\[%{&fileformat}\]
set statusline+=\ %p%%
set statusline+=\ %l:%c
set statusline+=\
" Move status
set laststatus=2
" }}}
Comments
0 B
|0 👍
/0 👎
0 B
|👍
/👎