Skip to content

Instantly share code, notes, and snippets.

@d0nkeyBOB
Created January 15, 2018 14:15
Show Gist options
  • Save d0nkeyBOB/f29977e709bf8c64ed66d9044e743180 to your computer and use it in GitHub Desktop.
Save d0nkeyBOB/f29977e709bf8c64ed66d9044e743180 to your computer and use it in GitHub Desktop.
if 0 | endif
if &compatible
set nocompatible " Be iMproved
endif
filetype off " required
" not a vi
set encoding=utf-8
"NeoBundle Scripts-----------------------------
" Required:
set runtimepath^=~/.vim/bundle/neobundle.vim/
" Required:
call neobundle#begin(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
" Required:
NeoBundleFetch 'Shougo/neobundle.vim'
" core plugins
NeoBundle 'flazz/vim-colorschemes'
NeoBundle 'kien/ctrlp.vim'
" vim main plugins
NeoBundle 'sjl/gundo.vim'
NeoBundle 'vim-airline/vim-airline'
NeoBundle 'vim-airline/vim-airline-themes'
NeoBundle 'jlanzarotta/bufexplorer'
NeoBundle 'scrooloose/syntastic.git'
NeoBundle 'vim-scripts/tComment'
NeoBundle 'tpope/vim-surround'
NeoBundle 'mileszs/ack.vim'
NeoBundle 'rking/ag.vim'
NeoBundle 'edsono/vim-matchit'
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'henrik/vim-indexed-search'
NeoBundle 'tpope/vim-abolish'
NeoBundle 'tpope/vim-repeat'
NeoBundle 'jiangmiao/auto-pairs'
NeoBundle 'xolox/vim-session'
NeoBundle 'xolox/vim-misc'
NeoBundle 'editorconfig/editorconfig-vim'
NeoBundle 'godlygeek/tabular'
NeoBundle 'airblade/vim-gitgutter'
NeoBundle 'Lokaltog/vim-easymotion'
NeoBundle 'rhysd/clever-f.vim'
NeoBundle 'nathanaelkane/vim-indent-guides'
NeoBundle 'moll/vim-bbye'
NeoBundle 'AndrewRadev/splitjoin.vim'
" togglable panels
NeoBundle 'scrooloose/nerdtree'
NeoBundle 'tpope/vim-vinegar'
NeoBundle 'vim-scripts/taglist.vim'
NeoBundle 'majutsushi/tagbar'
" language vundles
NeoBundle 'pangloss/vim-javascript'
NeoBundle 'othree/yajs.vim'
NeoBundle 'gavocanov/vim-js-indent'
NeoBundle 'othree/javascript-libraries-syntax.vim'
NeoBundle 'othree/es.next.syntax.vim'
NeoBundle 'dart-lang/dart-vim-plugin'
NeoBundle 'elzr/vim-json'
NeoBundle 'fatih/vim-go'
" NeoBundle 'klen/python-mode'
NeoBundle 'godlygeek/tabular'
NeoBundle 'plasticboy/vim-markdown'
let g:vim_markdown_folding_disabled = 1
NeoBundle 'shime/vim-livedown'
NeoBundle 'wakatime/vim-wakatime'
NeoBundle 'vim-scripts/c.vim'
" databases
NeoBundle 'vim-scripts/SQLUtilities'
NeoBundle 'NagatoPain/AutoSQLUpperCase.vim'
" autocomplete
NeoBundle 'MarcWeber/vim-addon-mw-utils'
NeoBundle 'tomtom/tlib_vim'
" snippets
NeoBundle 'SirVer/ultisnips'
NeoBundle 'honza/vim-snippets'
NeoBundle 'justinj/vim-react-snippets'
NeoBundle 'mattn/emmet-vim'
NeoBundle 'ervandew/supertab'
"
NeoBundle 'maksimr/vim-jsbeautify'
NeoBundle 'terryma/vim-multiple-cursors'
NeoBundle 'isRuslan/vim-es6'
NeoBundle 'mxw/vim-jsx'
NeoBundle 'leafgarland/typescript-vim'
NeoBundle 'HerringtonDarkholme/yats.vim'
" REST
NeoBundle 'diepm/vim-rest-console'
NeoBundle 'Valloric/YouCompleteMe'
autocmd QuickFixCmdPost [^1]* nested cwindow
autocmd QuickFixCmdPost 1* nested lwindow
"" Include user's extra bundle
if filereadable(expand("~/.vimrc.local.bundles"))
source ~/.vimrc.local.bundles
endif
" You can specify revision/branch/tag.
NeoBundle 'Shougo/vimshell', { 'rev' : '3787e5' }
let g:neobundle#install_process_timeout = 1500
" Required:
call neobundle#end()
" Required:
filetype plugin indent on
" If there are uninstalled bundles found on startup,
" this will conveniently prompt you to install them.
NeoBundleCheck
"End Plug Scripts-------------------------
"*****************************************************************************
"" Basic Setup
"*****************************************************************************"
"" Encoding
set encoding=utf-8
set fileencoding=utf-8
set fileencodings=utf-8
"" Fix backspace indent
set backspace=indent,eol,start
"" Tabs. May be overriten by autocmd rules
set tabstop=4
set softtabstop=0
set shiftwidth=4
set expandtab
"" Map leader to ,
let mapleader=','
"" Enable hidden buffers
set hidden
"" Searching
set hlsearch
set incsearch
set ignorecase
set smartcase
"" Encoding
set bomb
set binary
set ttyfast
"" Directories for swp files
set undodir=~/.vim/tmp/undo/
set directory=~/.vim/tmp/swap/
set nobackup
set noswapfile
" persist (g)undo tree between sessions
set undofile
set history=100
set undolevels=100
set fileformats=unix,dos,mac
set showcmd
set shell=/bin/bash
"" Paste Toggle
set pastetoggle=<F3>
set wildmenu
set clipboard=unnamed
set path=.
nnoremap <leader>f :find *
" session management
let g:session_directory = "~/.vim/session"
let g:session_autoload = "no"
let g:session_autosave = "no"
let g:session_command_aliases = 1
" Open session
nnoremap <leader>so :OpenSession
" Save Session
nnoremap <leader>ss :SaveSession
" Delete Session
nnoremap <leader>sd :DeleteSession<CR>
" Close Session
nnoremap <leader>sc :CloseSession<CR>
"*****************************************************************************
"" Visual Settings
"*****************************************************************************
syntax on
set ruler
set number
set lazyredraw
set showmatch
let no_buffers_menu=1
colorscheme hybrid
set background=dark
set mousemodel=popup
set cmdheight=2
set t_Co=256
set nocursorline
set guioptions=egmrti
set guifont=Monaco:h20
if has("gui_running")
if has("gui_mac") || has("gui_macvim")
set guifont=Hack:h14
endif
else
let g:CSApprox_loaded = 1
if $COLORTERM == 'gnome-terminal'
set term=gnome-256color
else
if $TERM == 'xterm'
set term=xterm-256color
endif
endif
endif
if &term =~ '256color'
set t_ut=
endif
"" Disable the blinking cursor.
set gcr=a:blinkon0
set scrolloff=3
"" Status bar
set laststatus=2
"" Use modeline overrides
set modeline
set modelines=10
set title
set titleold="Terminal"
set titlestring=%F
set statusline=%F%m%r%h%w%=(%{&ff}/%Y)\ (line\ %l\/%L,\ col\ %c)\
if exists("*fugitive#statusline")
set statusline+=%{fugitive#statusline()}
endif
" vim-airline
let g:airline_theme = 'hybrid'
let g:airline#extensions#syntastic#enabled = 1
let g:airline#extensions#branch#enabled = 1
let g:airline#extensions#tabline#enabled = 1
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
if !exists('g:airline_powerline_fonts')
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'
else
let g:airline#extensions#tabline#left_sep = ''
let g:airline#extensions#tabline#left_alt_sep = ''
" powerline symbols
let g:airline_left_sep = ''
let g:airline_left_alt_sep = ''
let g:airline_right_sep = ''
let g:airline_right_alt_sep = ''
let g:airline_symbols.branch = ''
let g:airline_symbols.readonly = ''
let g:airline_symbols.linenr = ''
endif
set foldmethod=indent
set foldlevelstart=20
" let g:netrw_banner = 0
" let g:netrw_liststyle = 3
" let g:netrw_browse_split = 4
" let g:netrw_altv = 1
" let g:netrw_winsize = 25
" augroup ProjectDrawer
" autocmd!
" autocmd VimEnter * :Vexplore
" augroup END
"*****************************************************************************
"" Abbreviations
"*****************************************************************************
"" no one is really happy until you have this shortcuts
cnoreabbrev W! w!
cnoreabbrev Q! q!
cnoreabbrev Qall! qall!
cnoreabbrev Wq wq
cnoreabbrev Wa wa
cnoreabbrev wQ wq
cnoreabbrev WQ wq
cnoreabbrev W w
cnoreabbrev Q q
cnoreabbrev Qall qall
nmap :W :w
nmap :Q :q
nmap :wQ :wq
nmap :WQ :wq
"" NERDTree configuration
let g:NERDTreeChDirMode=2
let g:NERDTreeIgnore=['\.rbc$', '\~$', '\.pyc$', '\.db$', '\.sqlite$', '__pycache__']
let g:NERDTreeSortOrder=['^__\.py$', '\/$', '*', '\.swp$', '\.bak$', '\~$']
let g:NERDTreeShowBookmarks=1
let g:NERDTreeMapOpenInTabSilent = '<RightMouse>'
let g:NERDTreeWinSize = 31
set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*.pyc,*.db,*.sqlite,*/node_modules/*
nnoremap <silent> <leader>2 :NERDTreeFind<CR>
noremap <leader>1 :NERDTreeToggle<CR>
" YouCompleteMe
let g:ycm_filetype_blacklist = {}
let g:ycm_key_list_select_completion = []
let g:ycm_key_list_previous_completion = []
let g:ycm_key_invoke_completion = "<C-j>"
let g:ycm_collect_identifiers_from_tags_files = 1
if !exists("g:ycm_semantic_triggers")
let g:ycm_semantic_triggers = {}
endif
let g:ycm_semantic_triggers['typescript'] = ['.']
" terminal emulation
nnoremap <silent> <leader>sh :VimShellCreate<CR>
" Open up .vimrc quickly in a new buffer
nnoremap <leader>ev :vsp $MYVIMRC<cr>
" Source .vimrc explitly
nnoremap <leader>sv :source $MYVIMRC<cr>
" faster movement
nmap J 10j
nmap K 10k
xmap J 10j
xmap K 10k
" Disabling arrow keys in normal and insert mode
nnoremap <up> <nop>
nnoremap <down> <nop>
nnoremap <left> <nop>
nnoremap <right> <nop>
inoremap <up> <nop>
inoremap <down> <nop>
inoremap <left> <nop>
inoremap <right> <nop>
" Disable arrow keys in command mode
cnoremap <Up> <nop>
cnoremap <Down> <nop>
nmap <silent> <Leader>ig <Plug>IndentGuidesToggle
let g:indent_guides_guide_size = 1
" jsx settings
let g:jsx_ext_required=0
"*****************************************************************************
"" Functions
"*****************************************************************************
if !exists('*s:setupWrapping')
function s:setupWrapping()
set wrap
set wm=2
set textwidth=79
endfunction
endif
"*****************************************************************************
"" Autocmd Rules
"*****************************************************************************
"" The PC is fast enough, do syntax highlight syncing from start
augroup vimrc-sync-fromstart
autocmd!
autocmd BufEnter * :syntax sync fromstart
augroup END
"" Remember cursor position
augroup vimrc-remember-cursor-position
autocmd!
autocmd BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif
augroup END
"" txt
augroup vimrc-wrapping
autocmd!
autocmd BufRead,BufNewFile *.txt call s:setupWrapping()
augroup END
"" make/cmake
augroup vimrc-make-cmake
autocmd!
autocmd FileType make setlocal noexpandtab
autocmd BufNewFile,BufRead CMakeLists.txt setlocal filetype=cmake
augroup END
augroup javascript
autocmd!
autocmd FileType javascript setlocal foldmethod=indent foldlevelstart=20
augroup END
augroup html
autocmd!
autocmd FileType html setlocal foldmethod=indent foldlevelstart=20
augroup END
set autoread
"*****************************************************************************
"" Mappings
"*****************************************************************************
"" Split
" Horizontal split
noremap <Leader>h :<C-u>split<CR>
" Vertical split
noremap <Leader>v :<C-u>vsplit<CR>
nnoremap <tab>j <C-W><C-J>
nnoremap <tab>k <C-W><C-K>
nnoremap <tab>l <C-W><C-L>
nnoremap <tab>h <C-W><C-H>
"" Maps Alt-[h,j,k,l] to resizing a window split
nnoremap <space>h <C-w><
nnoremap <space>j <C-W>-
nnoremap <space>k <C-W>+
nnoremap <space>l <C-w>>
"" Git
" Git Write
noremap <Leader>ga :Gwrite<CR>
" Git commit
noremap <Leader>gc :Gcommit<CR>
" Git push
noremap <Leader>gsh :Gpush<CR>
" Git pull
noremap <Leader>gll :Gpull<CR>
" Git status
noremap <Leader>gs :Gstatus<CR>
" Git blame
noremap <Leader>gb :Gblame<CR>
" Git version diff
noremap <Leader>gd :Gvdiff<CR>
" Git remove
noremap <Leader>gr :Gremove<CR>
"" Tabs
nnoremap <Tab> gt
nnoremap <S-Tab> gT
nnoremap <silent> <S-t> :tabnew<CR>
"" Move Lines
nnoremap <D-Down> :m .+1<CR>==
nnoremap <D-Up> :m .-2<CR>==
inoremap <D-Down> <Esc>:m .+1<CR>==gi
vnoremap <D-Down> :m '>+1<CR>gv=gv
inoremap <D-Up> <Esc>:m .-2<CR>==gi
vnoremap <D-Up> :m '<-2<CR>gv=gv
""Duplicate Line
nnoremap <D-d> yy p
"" Set working directory
nnoremap <leader>. :lcd %:p:h<CR>
"" Opens an edit command with the path of the currently edited file filled in
noremap <Leader>e :e <C-R>=expand("%:p:h") . "/" <CR>
"" Opens a tab edit command with the path of the currently edited file filled
noremap <Leader>te :tabe <C-R>=expand("%:p:h") . "/" <CR>
"" ctrlp.vim
set wildmode=list:longest,list:full
set wildignore+=*.o,*.obj,.git,*.rbc,*.pyc,__pycache__
let g:ctrlp_custom_ignore = '\v[\/](node_modules|target|dist)|(\.(swp|tox|ico|git|hg|svn))$'
let g:ctrlp_user_command = "find %s -type f | grep -Ev '"+ g:ctrlp_custom_ignore +"'"
let g:ctrlp_use_caching = 0
cnoremap <leader>e =expand("%:p:h") . "/" <CR>
noremap <leader>b :CtrlPBuffer<CR>
noremap <leader>r :CtrlPMRU<CR>
noremap <leader>m :CtrlPMixed<CR>
let g:ctrlp_map = '<leader>p'
let g:ctrlp_open_new_file = 'ra'
" snippets
" YouCompleteMe and UltiSnips compatibility, with the helper of supertab
" (via http://stackoverflow.com/a/22253548/1626737)
let g:SuperTabDefaultCompletionType = '<C-n>'
let g:SuperTabCrMapping = 0
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger = '<tab>'
let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'
let g:ycm_key_list_select_completion = ['<C-j>', '<C-n>', '<Down>']
let g:ycm_key_list_previous_completion = ['<C-k>', '<C-p>', '<Up>']
"" Fast window kill
nnoremap <Leader>k <C-w>c
" Fast buffer close
nnoremap <silent><Leader>K :bd<CR>
"" Syntastic
nnoremap <silent> <C-d> :lclose<CR>:bdelete<CR>
cabbrev <silent> bd <C-r>=(getcmdtype()==#':' && getcmdpos()==1 ? 'lclose\|bdelete' : 'bd')<CR>
let g:syntastic_mode_map = { 'mode': 'passive', 'active_filetypes': [],'passive_filetypes': [] }
nnoremap <leader>E :SyntasticCheck<CR>
nnoremap <leader>S :SyntasticToggleMode<CR>
nnoremap <silent> fe :<C-u>VimFiler<CR>
nnoremap <silent> fa :<C-u>VimFiler -find<CR>
" --- type ° to search the word in all files in the current dir
nmap ° :Ag <c-r>=expand("<cword>")<cr><cr>
nnoremap <space>/ :Ag
" Clear whitespace
noremap <leader>fw :FixWhitespace<CR>
" syntastic
let g:syntastic_always_populate_loc_list=1
let g:syntastic_error_symbol='✗'
let g:syntastic_warning_symbol='⚠'
let g:syntastic_style_error_symbol = '✗'
let g:syntastic_style_warning_symbol = '⚠'
let g:syntastic_auto_loc_list=1
let g:syntastic_aggregate_errors = 1
let g:syntastic_html_tidy_ignore_errors=[" proprietary attribute \"ng-", "trimming empty <", " proprietary attribute \"hm-"]
let g:syntastic_javascript_checkers = []
autocmd FileType javascript let b:syntastic_checkers = findfile('.eslintrc', '.;') !=# '' ? ['eslint'] : ['jshint']
"" Copy/Paste/Cut
if has('unnamedplus')
set clipboard=unnamed,unnamedplus
endif
noremap YY "+y<CR>
noremap P "+gP<CR>
noremap XX "+x<CR>
if has('macunix')
" pbcopy for OSX copy/paste
vmap <C-x> :!pbcopy<CR>
vmap <C-c> :w !pbcopy<CR><CR>
endif
"" Buffer nav
" Buffer previous
noremap <leader>z :bp<CR>
" Buffer next
noremap <leader>x :bn<CR>
noremap <leader>q :bufdo :Bdelete<CR>
noremap <leader>w :Bdelete<CR>
"" Close buffer
noremap <D-w> :bd<CR>
"" Clean search (highlight)
nnoremap <silent> <leader><space> :noh<cr>
"" Vmap for maintain Visual Mode after shifting > and <
vmap < <gv
vmap > >gv
"" Move visual block
vnoremap J :m '>+1<CR>gv=gv
vnoremap K :m '<-2<CR>gv=gv
"" Markdown Livedown
nmap gm :LivedownToggle<CR>
"" JsBeautify
map <c-f> :call JsBeautify()<cr>
autocmd FileType javascript noremap <buffer> <space>f :call JsBeautify()<cr>
" for html
autocmd FileType html noremap <buffer> <space>f :call HtmlBeautify()<cr>
" for css or scss
autocmd FileType css noremap <buffer> <space>f :call CSSBeautify()<cr>
autocmd FileType javascript vnoremap <buffer> <space>f :call RangeJsBeautify()<cr>
autocmd FileType html vnoremap <buffer> <sapce>f :call RangeHtmlBeautify()<cr>
autocmd FileType css vnoremap <buffer> <space>f :call RangeCSSBeautify()<cr>
"" Custom configs
let g:javascript_enable_domhtmlcss = 1
" Toggle Numbers
nnoremap <silent><leader>3 :call ToggleRelativeAbsoluteNumber()<CR>
function! ToggleRelativeAbsoluteNumber()
if !&number && !&relativenumber
set number
set norelativenumber
elseif &number && !&relativenumber
set nonumber
set relativenumber
elseif !&number && &relativenumber
set number
set relativenumber
elseif &number && &relativenumber
set nonumber
set norelativenumber
endif
endfunction
" Close all buffers except one
nnoremap <silent><leader>bd :BufOnly<CR>
command! -nargs=? -complete=buffer -bang Bonly
\ :call BufOnly('<args>', '<bang>')
command! -nargs=? -complete=buffer -bang BOnly
\ :call BufOnly('<args>', '<bang>')
command! -nargs=? -complete=buffer -bang Bufonly
\ :call BufOnly('<args>', '<bang>')
command! -nargs=? -complete=buffer -bang BufOnly
\ :call BufOnly('<args>', '<bang>')
function! BufOnly(buffer, bang)
if a:buffer == ''
" No buffer provided, use the current buffer.
let buffer = bufnr('%')
elseif (a:buffer + 0) > 0
" A buffer number was provided.
let buffer = bufnr(a:buffer + 0)
else
" A buffer name was provided.
let buffer = bufnr(a:buffer)
endif
if buffer == -1
echohl ErrorMsg
echomsg "No matching buffer for" a:buffer
echohl None
return
endif
let last_buffer = bufnr('$')
let delete_count = 0
let n = 1
while n <= last_buffer
if n != buffer && buflisted(n)
if a:bang == '' && getbufvar(n, '&modified')
echohl ErrorMsg
echomsg 'No write since last change for buffer'
\ n '(add ! to override)'
echohl None
else
silent exe 'bdel' . a:bang . ' ' . n
if ! buflisted(n)
let delete_count = delete_count+1
endif
endif
endif
let n = n+1
endwhile
if delete_count == 1
echomsg delete_count "buffer deleted"
elseif delete_count > 1
echomsg delete_count "buffers deleted"
endif
endfunction
"" Include user's local vim config
if filereadable(expand("~/.vimrc.local"))
source ~/.vimrc.local
endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment