Skip to content

Instantly share code, notes, and snippets.

@vibhavsinha
Last active October 16, 2022 14:47
Show Gist options
  • Save vibhavsinha/1c41cc1ebf6dd1573975ea31b45a7ed5 to your computer and use it in GitHub Desktop.
Save vibhavsinha/1c41cc1ebf6dd1573975ea31b45a7ed5 to your computer and use it in GitHub Desktop.
vimrc file
set nocompatible " be iMproved, required
filetype off " required
syntax on
set ignorecase
set smartcase
let mapleader=','
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" alternatively, pass a path where Vundle should install plugins
"call vundle#begin('~/some/path/here')
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'tpope/vim-fugitive'
Plugin 'ctrlpvim/ctrlp.vim'
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files -co --exclude-standard']
" https://github.com/kien/ctrlp.vim/issues/646
let g:ctrlp_prompt_mappings = {
\ 'AcceptSelection("e")': ['<2-LeftMouse>'],
\ 'AcceptSelection("t")': ['<cr>'],
\ }
Plugin 'rstacruz/sparkup', {'rtp': 'vim/'}
Plugin 'Valloric/YouCompleteMe'
Plugin 'SirVer/ultisnips'
" Snippets are separated from the engine. Add this if you want them:
Plugin 'honza/vim-snippets'
Plugin 'airblade/vim-gitgutter'
Plugin 'altercation/vim-colors-solarized'
" Plugin 'powerline/powerline', {'rtp': 'powerline/bindings/vim'}
" powerline setup
"set laststatus=2
"let g:Powerline_symbols = 'fancy'
" Plugin 'vim-airline/vim-airline'
" Plugin 'vim-airline/vim-airline-themes'
Plugin 'scrooloose/syntastic'
" syntastic setup
" Syntastic has numerous options that can be configured, and the defaults are
" not particularly well suitable for new users. It is recommended that you
" start by adding the following lines to your vimrc file, and return to them
" after reading the manual
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
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
let g:syntastic_javascript_checkers = ['eslint']
let g:syntastic_mode_map = { 'passive_filetypes': ['java'] }
" auto pair to complete the brackets
Plugin 'jiangmiao/auto-pairs'
" when adding brackets, do not add extra space. this was probably done to add
" airbnb style brackets with spaces. But it causes problem when entering todo
let g:AutoPairsMapSpace = 0
Plugin 'tpope/vim-surround'
" comments
let g:surround_{char2nr("*")} = "/* \r */"
" commentary plugin
Plugin 'tpope/vim-commentary'
" repeat plugin actions with
Plugin 'tpope/vim-repeat'
" json vim
Plugin 'elzr/vim-json'
" advanced js
Plugin 'pangloss/vim-javascript'
" support jsx
Plugin 'mxw/vim-jsx'
" By default, JSX syntax highlighting and indenting will be enabled only for
" files with the .jsx extension. If you would like JSX in .js files, add
let g:jsx_ext_required = 0
" typescript
Plugin 'leafgarland/typescript-vim'
Plugin 'Shougo/vimproc.vim'
let g:tsuquyomi_completion_detail = 1
" local_vimrc https://github.com/LucHermitte/local_vimrc
Plugin 'LucHermitte/lh-vim-lib'
Plugin 'LucHermitte/local_vimrc'
" https://github.com/vim-scripts/SQLUtilities
Plugin 'SQLUtilities'
Plugin 'Align'
Plugin 'mtscout6/syntastic-local-eslint.vim'
" https://www.reddit.com/r/vim/comments/3vx9sp/what_plugins_are_recommended_for_jsx_development/
" JSX
Plugin 'Valloric/MatchTagAlways'
let g:mta_filetypes = { 'html' : 1, 'xhtml' : 1, 'xml' : 1, 'jinja' : 1, 'javascript': 1, 'php': 1 }
Plugin 'alvan/vim-closetag'
let g:closetag_filenames = "*.html,*.xhtml,*.phtml,*.js,*.jsx"
Plugin 'shawncplus/phpcomplete.vim'
Plugin 'majutsushi/tagbar'
" auto save on files if needed. Disabled by default
Plugin '907th/vim-auto-save'
" rust vim settings
Plugin 'rust-lang/rust.vim'
let g:rustfmt_autosave = 1
Plugin 'racer-rust/vim-racer'
set hidden
let g:racer_experimental_completer = 1
Plugin 'ruanyl/vim-fixmyjs'
noremap <Leader><Leader>l :Fixmyjs<CR>
let g:fixmyjs_engine = 'eslint'
" use linting tool installed locally in node_modules folder
let g:fixmyjs_use_local = 1
Plugin 'christoomey/vim-system-copy'
Plugin 'kana/vim-textobj-user'
Plugin 'kana/vim-textobj-indent'
Plugin 'kana/vim-textobj-function'
Plugin 'thinca/vim-textobj-function-javascript'
Plugin 'michaeljsmith/vim-indent-object' " ai, ii, aI
Plugin 'kana/vim-textobj-entire' "ae ie
Plugin 'andrewradev/linediff.vim' " :LineDiff diff two separate blocks of text
Plugin 'junegunn/fzf'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
" Close the extra buffers after insertion of ycm completes
let g:ycm_autoclose_preview_window_after_insertion = 1
" map some keys
nmap <F5> :update<CR>
" YCM and ultisnips together need some work
" https://github.com/SirVer/ultisnips/issues/376#issuecomment-69033351
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
" let g:UltiSnipsExpandTrigger="<c-j>"
" let g:UltiSnipsJumpForwardTrigger="<c-j>"
" let g:UltiSnipsJumpBackwardTrigger="<c-k>"
let g:UltiSnipsExpandTrigger="<c-j>"
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
let g:ulti_expand_or_jump_res = 0
function! <SID>ExpandSnippetOrReturn()
let snippet = UltiSnips#ExpandSnippetOrJump()
if g:ulti_expand_or_jump_res > 0
return snippet
else
return "\<CR>"
endif
endfunction
inoremap <expr> <CR> pumvisible() ? "<C-R>=<SID>ExpandSnippetOrReturn()<CR>" : "\<CR>"
" If you want :UltiSnipsEdit to split your window.
let g:UltiSnipsEditSplit="vertical"
" relative numbers
set nu
set relativenumber
" folding
set foldmethod=syntax
let javaScript_fold=1 " JavaScript
let perl_fold=1 " Perl
let php_folding=1 " PHP
let r_syntax_folding=1 " R
let ruby_fold=1 " Ruby
let sh_fold_enabled=1 " sh
let vimsyn_folding='af' " Vim script
let xml_syntax_folding=1 " XML
set nofoldenable
" solarized theme config
set background=light
colorscheme solarized
" netrw styles
let g:netrw_liststyle=3 " Use tree-mode as default view
let g:netrw_winsize=20 " when you preview the new file takes up 80% and the file explorer the other 20%
let g:netrw_list_hide = netrw_gitignore#Hide() " hide the items in gitignore
" faster searching
set incsearch hlsearch
" Clear last search highlighting
nmap <Space> :noh<cr>
" disable arrow keys
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" add F2 to pastetoggle
set pastetoggle=<F2>
" I may switch to spaces because that is what most standards are written in
" but still believe that tabs are better for indentation. Spaces
" should only be used for alignment. Indentation should be the property of an
" editor based on developer's choice, not the property of a code file.
set expandtab
set softtabstop=2
set shiftwidth=2
set tabstop=2
" PHP PSR2 recommend 4 spaces for indentation
autocmd FileType php setlocal shiftwidth=4 tabstop=4 softtabstop=4
" always follow hyperlinks in new tab
" http://stackoverflow.com/a/24234138/1615721
nnoremap gf <C-w>gf
" easy tab traversal
" http://stackoverflow.com/a/34033865/1615721
nnoremap <C-l> gt
nnoremap <C-h> gT
" show menu when completion
" https://www.youtube.com/watch?v=XA2WjJbmmoM
set wildmenu
set autoindent
" disable all beeping: https://vim.fandom.com/wiki/Disable_beeping
set noeb vb t_vb=
" Don't add new line at the end of a file
" https://vi.stackexchange.com/a/9809/6230
set nofixeol
" open omnijs file as javascript
autocmd BufNewFile,BufRead *.omnijs,*.omnifocusjs set syntax=javascript
autocmd BufNewFile,BufRead *.puml set syntax=plantuml
autocmd FileType markdown setlocal textwidth=80
@vibhavsinha
Copy link
Author

vibhavsinha commented Feb 12, 2017

Setup

cd ~
git clone https://gist.github.com/vibhavsinha/1c41cc1ebf6dd1573975ea31b45a7ed5 .vim
ln -s .vim/.vimrc .vimrc
git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
# sudo apt install python3 cmake python3-dev g++ # as needed
vim +PluginInstall +qall
cd ~/.vim/bundle/YouCompleteMe && python3 ./install.py  --all # better to be selective here instead of all
cd ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment