Skip to content

Instantly share code, notes, and snippets.

@ryanburgess
Created September 13, 2016 15:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanburgess/cee687f1d56357986888ee6a11968bc7 to your computer and use it in GitHub Desktop.
Save ryanburgess/cee687f1d56357986888ee6a11968bc7 to your computer and use it in GitHub Desktop.
.vimrc
"--------------------
" vundle
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'gmarik/Vundle.vim'
"------------------
" vundle plugins
" ----------------
"----------------
" The way that worked for React/es6
"
Plugin 'othree/yajs.vim'
Plugin 'jelera/vim-javascript-syntax'
Plugin 'othree/javascript-libraries-syntax.vim'
"----------------
" a slightly better js/react/es6 support
"
"Plugin 'pangloss/vim-javascript'
Plugin 'mxw/vim-jsx'
Plugin 'isRuslan/vim-es6'
Plugin 'ryanoasis/vim-devicons'
Plugin 'scrooloose/nerdtree'
Plugin 'kien/ctrlp.vim'
Plugin 'mattn/emmet-vim'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/nerdcommenter'
Plugin 'othree/html5.vim'
Plugin 'bling/vim-airline'
Plugin 'vim-airline/vim-airline-themes'
Plugin 'tpope/vim-fugitive'
Plugin 'marijnh/tern_for_vim'
Plugin 'groenewege/vim-less'
Plugin 'cakebaker/scss-syntax.vim'
Plugin 'jiangmiao/auto-pairs'
Plugin 'scrooloose/syntastic'
Plugin 'grep.vim'
Plugin 'groovy.vim'
Plugin 'matze/vim-move'
Plugin 'tpope/vim-surround'
Plugin 'suan/vim-instant-markdown'
Plugin 'kien/rainbow_parentheses.vim'
Plugin 'ap/vim-css-color'
Plugin 'tpope/vim-sleuth'
Plugin 'mbbill/undotree'
Plugin 'godlygeek/tabular'
Plugin 'mustache/vim-mustache-handlebars'
Plugin 'fatih/vim-go'
Plugin 'xolox/vim-easytags'
Plugin 'xolox/vim-misc'
Plugin 'leafgarland/typescript-vim'
Plugin 'majutsushi/tagbar'
Plugin 'HerringtonDarkholme/yats.vim'
"
"---------------------
" colors
Plugin 'd11wtq/tomorrow-theme-vim'
Plugin 'kristijanhusak/vim-hybrid-material'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" URL: http://vim.wikia.com/wiki/Example_vimrc
" Authors: http://vim.wikia.com/wiki/Vim_on_Freenode
" Description: A minimal, but feature rich, example .vimrc. If you are a
" newbie, basing your first .vimrc on this file is a good choice.
" If you're a more advanced user, building your own .vimrc based
" on this file is still a good idea.
"------------------------------------------------------------
" Features {{{1
"
" These options and cfommands enable some very useful features in Vim, that
" no user should have to live without.
" Set 'nocompatible' to ward off unexpected things that your distro might
" have made, as well as sanely reset options when re-sourcing .vimrc
set nocompatible
" Enable syntax highlighting
syntax on
"------------------------------------------------------------
" Must have options {{{1
"
" These are highly recommended options.
" Vim with default settings does not allow easy switching between multiple files
" in the same editor window. Users can use multiple split windows or multiple
" tab pages to edit multiple files, but it is still best to enable an option to
" allow easier switching between files.
"
" One such option is the 'hidden' option, which allows you to re-use the same
" window and switch from an unsaved buffer without saving it first. Also allows
" you to keep an undo history for multiple files when re-using the same window
" in this way. Note that using persistent undo also lets you undo in multiple
" files even in the same window, but is less efficient and is actually designed
" for keeping undo history after closing Vim entirely. Vim will complain if you
" try to quit without saving, and swap files will keep you safe if your computer
" crashes.
set hidden
" Note that not everyone likes working this way (with the hidden option).
" Alternatives include using tabs or split windows instead of re-using the same
" window as mentioned above, and/or either of the following options:
" set confirm
" set autowriteall
" Better command-line completion
set wildmenu
" Show partial commands in the last line of the screen
set showcmd
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the
" mapping of <C-L> below)
set hlsearch
"-------------------------------------------------------------
" set to auto read when a file is changed outside of vim
set autoread
"--------------------------------------------------------
" lets try some eader key mappings...
"
" With a map leader it's possible to do extra key combinations
" like <leader>w saves the current file
let mapleader = ","
let g:mapleader = ","
" Fast saving
nmap <leader>w :w!<cr>
" Modelines have historically been a source of security vulnerabilities. As
" such, it may be a good idea to disable them and use the securemodelines
" script, <http://www.vim.org/scripts/script.php?script_id=1876>.
" set nomodeline
"------------------------------------------------------------
" Usability options {{{1
"
" These are options that users frequently set in their .vimrc. Some of them
" change Vim's behaviour in ways which deviate from the true Vi way, but
" which are considered to add usability. Which, if any, of these options to
" use is very much a personal preference, but they are harmless.
" Use case insensitive search, except when using capital letters
set ignorecase
set smartcase
" Allow backspacing over autoindent, line breaks and start of insert action
set backspace=indent,eol,start
" When opening a new line and no filetype-specific indenting is enabled, keep
" the same indent as the line you're currently on. Useful for READMEs, etc.
set autoindent
set smartindent
" Stop certain movements from always going to the first character of a line.
" While this behaviour deviates from that of Vi, it does what most users
" coming from other editors would expect.
set nostartofline
" Display the cursor position on the last line of the screen or in the status
" line of a window
set ruler
" Always display the status line, even if only one window is displayed
set laststatus=2
" Instead of failing a command because of unsaved changes, instead raise a
" dialogue asking if you wish to save changed files.
set confirm
" Use visual bell instead of beeping when doing something wrong
set visualbell
" And reset the terminal code for the visual bell. If visualbell is set, and
" this line is also included, vim will neither flash nor beep. If visualbell
" is unset, this does nothing.
set t_vb=
" Enable use of the mouse for all modes
set mouse=a
" Set the command window height to 2 lines, to avoid many cases of having to
" "press <Enter> to continue"
set cmdheight=2
" Display line numbers on the left
set number
" show the soft return
"set colorcolumn=140
"highlight current line
set cursorline
" Quickly time out on keycodes, but never time out on mappings
set notimeout ttimeout ttimeoutlen=200
" Use <F11> to toggle between 'paste' and 'nopaste'
set pastetoggle=<F11>
" set swap directory
set backupdir=~/.vim/backup_files//
set directory=~/.vim/swap_files//
set undodir=~/.vim/undo_files//
"------------------------------------------------------------
" Indentation options {{{1
"
" Indentation settings according to personal preference.
" Indentation settings for using 2 spaces instead of tabs.
" Do not change 'tabstop' from its default value of 8 with this setup.
set shiftwidth=4
set softtabstop=4
set expandtab
"------------------------------
" whitespace
set nowrap
"------------------------------------------------------------
" Mappings {{{1
"
" Useful mappings
" Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy,
" which is the default
map Y y$
" Map <C-L> (redraw screen) to also turn off search highlighting until the
" next search
nnoremap <C-L> :nohl<CR><C-L>
"----------------------------------------------------------
" nerdtree
"
" guarantees that the NERDTrees for all tabs will be one and the same
let g:nerdtree_tabs_open_on_console_startup=1
map <leader>e :NERDTreeToggle<CR>
"automatically open nerdtree when vim opens
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
"-------------------------------------------------------------
" ctrlp
"
let g:ctrlp_user_command = ['.git/', 'git --git-dir=%s/.git ls-files -oc --exclude-standard']
let g:ctrlp_map = '<C-p>'
let g:ctrlp_cmd = 'CtrlP'
"base16
"
let base16colorspace=256 " Access colors present in 256 colorspae
"------------------------------
" gui config
"
set background=dark
set guifont=Knack\ Nerd\ Font:h16
colorscheme hybrid_material
let g:enable_bold_font=0
"-----------------------------------
"one dark colors
let g:onedark_termcolors=256
let g:onedark_terminal_italic=1
"-----------------------------
" airline
"
let g:airline_theme='tomorrow'
let g:airline_powerline_fonts = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.space = "\ua0"
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#buffer_idx_mode = 1
nmap <leader>1 <Plug>AirlineSelectTab1
nmap <leader>2 <Plug>AirlineSelectTab2
nmap <leader>3 <Plug>AirlineSelectTab3
nmap <leader>4 <Plug>AirlineSelectTab4
nmap <leader>5 <Plug>AirlineSelectTab5
nmap <leader>6 <Plug>AirlineSelectTab6
nmap <leader>7 <Plug>AirlineSelectTab7
nmap <leader>8 <Plug>AirlineSelectTab8
nmap <leader>9 <Plug>AirlineSelectTab9
"----------------------------
" Syntastic
"
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_typescript_tsc_args = "--jsx react"
let g:typescript_compiler_options = '--jsx react'
let g:syntastic_quiet_messages = { "level": "warning" }
"let g:syntastic_debug = 3
"
" Delete trailing white space on save
func! DeleteTrailingWS()
exe "normal mz"
%s/\s\+$//ge
exe "normal `z"
endfunc
autocmd BufWrite *.* :call DeleteTrailingWS()
"--------------------------------------
" You Complete Me
if !exists("g:ycm_semantic_triggers")
let g:ycm_semantic_triggers = {}
endif
let g:ycm_semantic_triggers['typescript'] = ['.']
" remove arrow keys
noremap <Up> <NOP>
noremap <Down> <NOP>
noremap <Left> <NOP>
noremap <Right> <NOP>
" show whitespace
set list!
set listchars=tab:>-
" setup relative lines
set relativenumber
function! NumberToggle()
if &nu == 1
set rnu
elseif &rnu == 1
set nornu
else
set nu
endif
endfunc
"ctrl n to toggle
nnoremap <C-n> :call NumberToggle()<cr>
"javascript librarie plugin support
let g:used_javascript_libs = 'underscore,react,fluxjasmine,chai'
"-----------------------------
" vim-move
"
let g:move_key_modifier = 'C'
" Map leader d to close the current buffer and leave the split
nmap <silent> <leader>d :bp\|bd #<CR>
"------------------------------
" surround
"
xmap <Leader>s <Plug>Vsurround
"json
"command Jsonf %!python -m json.tool
"----------------------------
"rainbow parens
"
let g:rbpt_colorpairs = [
\ ['brown', 'RoyalBlue3'],
\ ['Darkblue', 'SeaGreen3'],
\ ['darkgray', 'DarkOrchid3'],
\ ['darkgreen', 'firebrick3'],
\ ['darkcyan', 'RoyalBlue3'],
\ ['darkred', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['brown', 'firebrick3'],
\ ['gray', 'RoyalBlue3'],
\ ['black', 'SeaGreen3'],
\ ['darkmagenta', 'DarkOrchid3'],
\ ['Darkblue', 'firebrick3'],
\ ['darkgreen', 'RoyalBlue3'],
\ ['darkcyan', 'SeaGreen3'],
\ ['darkred', 'DarkOrchid3'],
\ ['red', 'firebrick3'],
\]
let g:rbpt_max = 16
let g:rbpt_loadcmd_toggle = 0
au VimEnter * RainbowParenthesesToggle
au Syntax * RainbowParenthesesLoadRound
au Syntax * RainbowParenthesesLoadSquare
au Syntax * RainbowParenthesesLoadBraces
"------------------------------------
" dash
"
nmap <silent> <leader>g <Plug>DashSearch
let g:dash_map={'javascript': ['javascript', 'react', 'nodejs', 'lodash']}
"-----------------------------------
" react
"
autocmd BufNewFile,BufRead *.jsx set filetype=javascript.jsx
"----------------------------------
" dux shit
autocmd BufNewFile,BufRead *.template set filetype=html.mustache syntax=mustache | runtime! ftplugin/mustache.vim ftplugin/mustache*.vim ftplugin/mustache/*.vim
"---------------------------------
" undo tree
if has("persistent_undo")
set undodir=~/.undodir/
set undofile
endif
nnoremap <leader>u :UndotreeToggle<cr>
"---------------------------------
" tabular
map <leader>t :Tabular /=<cr>
map <leader>j :Tabular /:<cr>
"--------------------------------
"jsctags
let g:easytags_languages = {
\ 'javascript': {
\ 'cmd': 'jsctags {} -f:',
\ 'args': [],
\ 'fileoutput_opt': '-f',
\ 'stdout_opt': '-f-',
\ 'recurse_flag': '-R'
\ }
\}
"------------------------------
" tagbar
nmap <C-\> :TagbarToggle<CR>
set backupcopy=yes
"------------------------------
"typescript
autocmd QuickFixCmdPost [^l]* nested cwindow
autocmd QuickFixCmdPost l* nested lwindow
let g:typescript_compiler_binary = 'tsc'
"-----------------------------------
"dont go out to shell for stuffs
set t_ti= t_te=
"---------------------------------
"devicons
set encoding=utf8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment