Skip to content

Instantly share code, notes, and snippets.

@nik-garg
Last active May 5, 2021 21:09
Show Gist options
  • Save nik-garg/7a2c139fb9a9d211b0a56a4f9d779e4f to your computer and use it in GitHub Desktop.
Save nik-garg/7a2c139fb9a9d211b0a56a4f9d779e4f to your computer and use it in GitHub Desktop.
Vimrc using Vim Plug
" required before initialization
set nocompatible " disable compatibility mode with vi
" Calling plugin system
call plug#begin('~/.vim/plugged')
Plug 'nanotech/jellybeans.vim' " Vim color scheme
Plug 'pangloss/vim-javascript' " JavaScript bundle for vim, this bundle provides syntax highlighting and improved indentation
Plug 'digitaltoad/vim-pug' " Vim syntax highlighting for Pug (formerly Jade) templates
Plug 'Raimondi/delimitMate' " Provides insert mode auto-completion for quotes, parens, brackets, etc.
Plug 'preservim/nerdcommenter' " Vim plugin for intensely nerdy commenting powers
Plug 'groenewege/vim-less' " Vim bundle adds syntax highlighting, indenting and autocompletion
Plug 'maxmellon/vim-jsx-pretty' " React syntax highlighting and indenting plugin for vim
Plug 'w0rp/ale' " Plugin providing linting (syntax checking and semantic errors)
Plug 'yggdroot/indentline' " Indent line used for displaying thin vertical lines at each indentation level for code indented with spaces
Plug 'godlygeek/tabular' " Vim script for text filtering and alignment
Plug 'scrooloose/syntastic' " Syntastic is a syntax checking plugin for Vim
Plug 'scrooloose/nerdtree' " NERDTree is a file system explorer for the Vim editor
Plug 'vim-airline/vim-airline' " Lean & mean status/tabline for vim that's light as air
Plug 'vim-airline/vim-airline-themes' " Official theme repository for vim-airline
Plug 'kien/ctrlp.vim' " Full path fuzzy file, buffer, mru, tag, ... finder for Vim
" Initialize plugin system
call plug#end()
" If you have vim >=8.0 or Neovim >= 0.1.5
if (has("termguicolors"))
set termguicolors
endif
" Color scheme (terminal)
set background=dark
syntax enable
silent! colorscheme jellybeans
hi Normal guibg=NONE ctermbg=NONE
hi NonText guibg=NONE ctermbg=NONE
" Hihlighting
highlight Comment cterm=italic
highlight Todo cterm=bold,italic
"if, else etc
highlight Conditional cterm=italic
highlight Keyword cterm=italic
highlight Character cterm=italic
"return, let, const etc
highlight Statement cterm=italic,bold
highlight Identifier cterm=italic,bold
"console, function args etc
highlight Special cterm=italic,bold
" edit settings
set backspace=indent,eol,start " backspacing over everything in insert mode
set nojoinspaces " no extra space after '.' when joining lines
set shiftwidth=4 " set indentation depth to 8 columns
set softtabstop=4 " backspacing over 8 spaces like over tabs
set tabstop=4 " set tabulator length to 8 columns
set autoindent " copy indent from current line when starting a new line
set smartindent " even better autoindent (e.g. add indent after '{')
"set textwidth=80 " wrap lines automatically at 80th column
"set expandtab " fill tabs with spaces
" ui config
set number " show line numbers
set noshowmode " to get rid of thing like --INSERT--
set noshowcmd " to get rid of display of last command
set shortmess+=F " to get rid of the file name displayed in the command line bar
set cursorline " highlight current line
set wildmenu " visual autocomplete for command menu
set lazyredraw " redraw only when we need to.
set showmatch " highlight matching [{()}]
set ruler " show file stats
set visualbell " blink cursor on error instead of beeping (grr)
set modelines=0 " vim only use these settings for this file (set to 1 for enabling)
set encoding=utf-8 " encoding
set completeopt-=preview
" Searching
set incsearch " search as characters are entered
set hlsearch " highlight matches
set ignorecase
set smartcase
set showmatch
" folding
set foldenable " enable folding
set foldlevelstart=10 " open most folds by default
set foldnestmax=10 " 10 nested fold max
" space open/closes folds
nnoremap <space> za
set foldmethod=manual " fold level is manual
" turn off search highlight
nnoremap <leader><space> :nohlsearch<CR>
" move to beginning/end of line
nnoremap B ^
nnoremap E $
" $/^ doesn't do anything
nnoremap $ <nop>
nnoremap ^ <nop>
" Leader Shortcuts
let mapleader="\\" " leader is back slash
" TMUX
" allows cursor change in tmux mode
if exists('$TMUX')
let &t_SI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=1\x7\<Esc>\\"
let &t_EI = "\<Esc>Ptmux;\<Esc>\<Esc>]50;CursorShape=0\x7\<Esc>\\"
else
let &t_SI = "\<Esc>]50;CursorShape=1\x7"
let &t_EI = "\<Esc>]50;CursorShape=0\x7"
endif
"
" Some settings for different plugins
"
" Nerd Tree
map <C-n> :NERDTreeToggle<CR>
" Vim tabs
nnoremap th :tabfirst<CR>
nnoremap tk :tabnext<CR>
nnoremap tj :tabprev<CR>
nnoremap tn :tabnew<CR>
nnoremap tl :tablast<CR>
nnoremap te :tabedit<Space>
nnoremap tm :tabm<Space>
nnoremap tw :tabclose<CR>d
" Vim splits
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>
" Nerd commenter
let g:NERDSpaceDelims = 1 " Add spaces after comment delimiters by default
let g:NERDCompactSexyComs = 1 " Use compact syntax for prettified multi-line comments
let g:NERDCommentEmptyLines = 1 " Allow commenting and inverting empty lines (useful when commenting a region)
let g:NERDTrimTrailingWhitespace = 1 " Enable trimming of trailing whitespace when uncommenting
let g:NERDToggleCheckAllLines = 1 " Enable NERDCommenterToggle to check all selected lines is commented or not
" Jsx pretty
let g:vim_jsx_pretty_colorful_config = 1 " colorful config flag (vim-javascript only)
let g:vim_jsx_pretty_highlight_close_tag = 1 " highlight the close tag separately from the open tag
" Ale
let b:ale_fixers = ['prettier', 'eslint'] " Fix files with prettier, and then ESLint
let g:ale_fix_on_save = 1
" Indent Line
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_tab_guides = 1
let g:indentLine_color_term = 239
let g:indentLine_bgcolor_term = 202
" let g:indentLine_bgcolor_gui = '#FF5F00'
let g:indentLine_char_list = ['|', '¦', '┆', '┊']
" Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_javascript_eslint_exec = 'eslint_d'
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" Airline
let g:airline_theme = 'onedark'
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
let g:airline#extensions#tabline#formatter = 'unique_tail_improved'
" this is to enable italic highlights on mac
let &t_ZH="\e[3m"
let &t_ZR="\e[23m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment