├── .gitignore ├── .vimrc ├── README.md └── install /.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/barretlee/autoconfig-mac-vimrc/0ce4a5466b2ac58a5853fe604e2a12ac07806486/.gitignore -------------------------------------------------------------------------------- /.vimrc: -------------------------------------------------------------------------------- 1 | "{vundle setup 2 | set nocompatible 3 | filetype off 4 | set rtp+=~/.vim/bundle/Vundle.vim 5 | "vim-go | go settings `go get -u github.com/golang/lint` 6 | set rtp+=$GOPATH/src/github.com/golang/lint/misc/vim 7 | call vundle#begin() 8 | "{plugins 9 | Plugin 'gmarik/Vundle.vim' 10 | Plugin 'FelikZ/ctrlp-py-matcher' 11 | Plugin 'Raimondi/delimitMate' 12 | Plugin 'Shougo/neocomplete.vim' 13 | Plugin 'Shougo/unite.vim' 14 | Plugin 'Shougo/vimproc.vim' 15 | Plugin 'Shougo/deoplete.nvim' 16 | Plugin 'Valloric/MatchTagAlways' 17 | Plugin 'Xuyuanp/nerdtree-git-plugin' 18 | Plugin 'airblade/vim-gitgutter' 19 | Plugin 'bling/vim-airline' 20 | Plugin 'vim-airline/vim-airline-themes' 21 | Plugin 'bufexplorer.zip' 22 | Plugin 'ctrlpvim/ctrlp.vim' 23 | Plugin 'dhruvasagar/vim-vinegar' 24 | Plugin 'docunext/closetag.vim' 25 | Plugin 'editorconfig/editorconfig-vim' 26 | Plugin 'einars/js-beautify' 27 | Plugin 'godlygeek/tabular' 28 | Plugin 'groenewege/vim-less' 29 | Plugin 'itchyny/calendar.vim' 30 | Plugin 'jaxbot/semantic-highlight.vim' 31 | Plugin 'jaxbot/syntastic-react' 32 | Plugin 'kshenoy/vim-signature' 33 | Plugin 'juneedahamed/svnj.vim' 34 | Plugin 'maksimr/vim-jsbeautify' 35 | Plugin 'marijnh/tern_for_vim' 36 | Plugin 'Valloric/YouCompleteMe' 37 | Plugin 'mattn/emmet-vim' 38 | Plugin 'mhinz/vim-startify' 39 | Plugin 'michalliu/jsruntime.vim' 40 | Plugin 'michalliu/sourcebeautify.vim' 41 | Plugin 'mileszs/ack.vim' 42 | Plugin 'moll/vim-node' 43 | Plugin 'mxw/vim-jsx' 44 | Plugin 'noscripter/tabman.vim' 45 | Plugin 'othree/javascript-libraries-syntax.vim' 46 | Plugin 'rking/ag.vim' 47 | Plugin 'scrooloose/nerdtree' 48 | Plugin 'scrooloose/syntastic' 49 | Plugin 'myint/syntastic-extras' 50 | Plugin 'sheerun/vim-polyglot' 51 | Plugin 'tomtom/tcomment_vim' 52 | Plugin 'tpope/vim-endwise' 53 | Plugin 'tpope/vim-fugitive' 54 | Plugin 'tpope/vim-surround' 55 | Plugin 'vim-scripts/matchit.zip' 56 | Plugin 'NLKNguyen/papercolor-theme' 57 | Plugin 'fatih/vim-go' 58 | Plugin 'Yggdroot/indentLine' 59 | Plugin 'Shougo/vimshell.vim' 60 | Plugin 'xolox/vim-shell' 61 | Plugin 'xolox/vim-easytags' 62 | Plugin 'xolox/vim-misc' 63 | Plugin 'vim-scripts/Conque-Shell' 64 | Plugin 'edkolev/promptline.vim' 65 | Plugin 'sjl/clam.vim' 66 | Plugin 'ervandew/screen' 67 | "Plugin 'idbrii/AsyncCommand' 68 | Plugin 'sjl/gundo.vim' 69 | Plugin 'mattn/webapi-vim' 70 | Plugin 'pangloss/vim-javascript' 71 | "Plugin 'airblade/vim-rooter' 72 | "Plugin 'sidorares/node-vim-debugger' 73 | "Plugin 'ryanoasis/vim-devicons' 74 | "Plugin 'jelera/vim-javascript-syntax' 75 | "Plugin 'othree/html5-syntax.vim' 76 | "Plugin 'othree/html5.vim' 77 | "Plugin 'claco/jasmine.vim' 78 | "Plugin 'Shougo/vimfiler.vim' 79 | "Plugin 'rdnetto/YCM-Generator' 80 | "Plugin 'Shougo/neocomplcache.vim' 81 | "Plugin 'othree/yajs.vim' 82 | "Plugin 'othree/es.next.syntax.vim' 83 | "Plugin 'hail2u/vim-css3-syntax' 84 | "Plugin 'cakebaker/scss-syntax.vim' 85 | "Plugin 'honza/vim-snippets' 86 | "Plugin 'Shougo/neosnippet-snippets' 87 | "Plugin 'Shougo/neosnippet.vim' 88 | "Plugin 'SirVer/ultisnips' 89 | "Plugin 'zenorocha/dracula-theme' 90 | "Plugin 'jdkanani/vim-material-theme' 91 | "Plugin 'kristijanhusak/vim-hybrid-material' 92 | "Plugin 'google/vim-colorscheme-primary' 93 | "Plugin 'flazz/vim-colorschemes' 94 | "Plugin 'terryma/vim-multiple-cursors' 95 | "Plugin 'Chun-Yang/vim-action-ag' 96 | "Plugin 'tpope/vim-haml' 97 | "Plugin 'gregsexton/gitv' 98 | "Plugin 'Lokaltog/vim-easymotion' 99 | "Plugin 'justinmk/vim-dirvish' 100 | "Plugin 'ddollar/nerdcommenter' 101 | "Plugin 'AndrewRadev/splitjoin.vim' 102 | "Plugin 'davidhalter/jedi-vim' 103 | "Plugin 'ervandew/supertab' 104 | "Plugin 'tpope/vim-rails' 105 | "Plugin 'tpope/vim-scriptease' 106 | "Plugin 'ynkdir/vim-vimlparser' "required by vimlint 107 | "Plugin 'tacahiroy/ctrlp-funky' 108 | "Plugin 'chemzqm/unite-js-func' 109 | "Plugin 'syngan/vim-vimlint' 110 | "Plugin 'chrisbra/NrrwRgn' 111 | "Plugin 'mhinz/vim-signify' 112 | "Plugin 'mhinz/vim-grepper' 113 | "Plugin 'mhinz/vim-sayonara' 114 | "Plugin 'greyblake/vim-preview' 115 | "Plugin 'guileen/vim-node-dict' 116 | "Plugin 'HerringtonDarkholme/yats.vim' 117 | "Plugin 'junegunn/vim-easy-align' 118 | "Plugin 'klen/python-mode' 119 | "Plugin 'mattn/excelview-vim' 120 | "Plugin 'mattn/vim-maketable' 121 | "Plugin 'michalliu/jsoncodecs.vim' 122 | "Plugin 'vim-scripts/JavaScript-Indent' 123 | "Plugin 'ntpeters/vim-better-whitespace' 124 | "Plugin 'nvie/vim-flake8' 125 | "Plugin 'ryanss/vim-hackernews' 126 | "Plugin 'tpope/vim-obsession' 127 | "Plugin 'dhruvasagar/vim-prosession' 128 | "Plugin 'digitaltoad/vim-jade' 129 | "Plugin 'majutsushi/tagbar' 130 | "Plugin 'garyburd/go-explorer' 131 | "Plugin 'zchee/deoplete-go' 132 | "} 133 | call vundle#end() 134 | "} 135 | 136 | "{Basic settings 137 | set nospell 138 | set nu 139 | set relativenumber 140 | set ffs=unix,dos,mac 141 | set hlsearch 142 | set incsearch 143 | set ignorecase 144 | set smartcase 145 | set encoding=utf-8 146 | set termencoding=utf-8 147 | set fileencodings=utf-8,gbk,utf-16le,cp1252,iso-8859-15,ucs-bom 148 | set fileformats=unix,dos,mac 149 | set linespace=0 " No extra spaces between rows 150 | set showmatch " Show matching brackets/parenthesis 151 | set confirm " Confirm before vim exit 152 | if has('clipboard') 153 | if has('unnamedplus') " When possible use + register for copy-paste 154 | set clipboard=unnamed,unnamedplus 155 | else " On mac and Windows, use * register for copy-paste 156 | set clipboard=unnamed 157 | endif 158 | endif 159 | set nobackup 160 | set noswapfile 161 | set nowritebackup 162 | set iskeyword-=_,.,=,-,:, 163 | set foldmethod=indent 164 | set tabstop=2 softtabstop=2 shiftwidth=2 expandtab 165 | set guifont=Source\ Code\ Pro\ for\ Powerline:h16 166 | set autoread 167 | set wildignore=*.o,*~,*.pyc,*.swp,*.bak,*.class 168 | if has("win16") || has("win32") 169 | set wildignore+=*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store 170 | else 171 | set wildignore+=.git\*,.hg\*,.svn\* 172 | endif 173 | set lazyredraw " don't update the display while executing macros 174 | set switchbuf=useopen " reveal already opened files from the 175 | " quickfix window instead of opening new 176 | " buffers 177 | set wildmenu 178 | set copyindent 179 | set wildmode=list:longest,full 180 | set whichwrap=b,s,h,l,<,>,>h,[,] " Backspace and cursor keys wrap too 181 | if !&scrolloff 182 | set scrolloff=1 " Minimum lines to keep above and below cursor 183 | endif 184 | if !&sidescrolloff 185 | set scrolloff=5 186 | endif 187 | set display+=lastline 188 | set nowrap " Do not wrap long lines 189 | set backspace=eol,start,indent 190 | if has('syntax') 191 | syntax enable 192 | endif 193 | set textwidth=80 194 | let &colorcolumn=join(range(81,999),",") 195 | let &colorcolumn="80,".join(range(120,999),",") 196 | set colorcolumn=+1 197 | set autoindent 198 | set smartindent 199 | set smarttab 200 | set ruler 201 | if has("gui_macvim") "autocmd GUIEnter * set fullscreen 202 | set fuoptions=maxvert,maxhorz 203 | endif 204 | set cursorcolumn 205 | set cursorline 206 | set autochdir 207 | set laststatus=2 " always show statusline 208 | set showtabline=2 " always show tabline 209 | set hidden 210 | " enables filetype based indentation 211 | " Enable file type detection. 212 | " Use the default filetype settings, so that mail gets 'tw' set to 72, 213 | " 'cindent' is on in C files, etc. 214 | " Also load indent files, to automatically do language-dependent indenting. 215 | filetype plugin indent on 216 | set noerrorbells novisualbell t_vb= 217 | set autowrite 218 | set autowriteall "Auto-write all file changes 219 | " autocompletion with dictionary help 220 | set dictionary+=/usr/share/dict/words 221 | set dictionary+=~/.vim/dict/ 222 | set statusline+=%* 223 | set statusline+=%#warningmsg# 224 | filetype on 225 | set shortmess+=filmnrxoOtT " Abbrev. of messages (avoids 'hit enter') 226 | set showmode " Display current mode 227 | set showcmd " Show partial commands in status line and 228 | " Selected characters/lines in visual mode 229 | set viewoptions=folds,options,cursor,unix,slash " Better Unix / Windows compatibility 230 | set virtualedit=onemore " used with caution of breaking plugins 231 | set completeopt=menuone,menu,preview,longest 232 | set tags=./tags;/,~/.vimtags 233 | " Make tags placed in .git/tags file available in all levels of a repository 234 | let gitroot = substitute(system('git rev-parse --show-toplevel'), '[\n\r]', '', 'g') 235 | if gitroot != '' 236 | let &tags = &tags . ',' . gitroot . '/.git/tags' 237 | endif 238 | colorscheme PaperColor 239 | set t_Co=256 240 | set nofoldenable " Auto fold code 241 | set foldlevel=1 242 | set foldlevelstart=99 243 | set nomodeline " disable mode lines (security measure) 244 | " allow mouse select and etc operation 245 | set mouse=a 246 | set history=1000 247 | " no annoying sound on errors 248 | set timeoutlen=500 249 | set formatoptions+=t 250 | if v:version > 703 || v:version == 703 && has("patch541") 251 | set formatoptions+=j " Delete comment chars when join comment lines 252 | endif 253 | set formatoptions-=l " wrap long lines 254 | set wrapmargin=2 " 2 chars wrap margin from the right window border, hard wrap 255 | "set conceallevel=0 256 | set list 257 | set guioptions=e "only show guitablabel 258 | "set guioptions= 259 | syntax on 260 | highlight CursorLine term=reverse 261 | highlight CursorColumn term=reverse 262 | "} 263 | 264 | "{Mappings 265 | let mapleader=',' 266 | nnoremap 2 :set tabstop=2 softtabstop=2 shiftwidth=2 267 | nnoremap 4 :set tabstop=4 softtabstop=4 shiftwidth=4 268 | nnoremap eg :e ++enc=gbk 269 | nnoremap eu :e ++enc=utf8 270 | nnoremap h :nohlsearch 271 | " Use to clear the highlighting of :set hlsearch 272 | if maparg('', 'n') ==# '' 273 | nnoremap :nohlsearch=has('diff')?'diffupdate':'' 274 | endif 275 | nnoremap l :set list! 276 | nnoremap w :set wrap! 277 | nnoremap f :%!js-beautify -j -q -B -f - 278 | nnoremap :w 279 | "noremap W :w !sudo tee % > /dev/null 280 | " Quickly edit/reload the vimrc file 281 | nnoremap ev :tabe $MYVIMRC 282 | nnoremap sv :so $MYVIMRC 283 | nnoremap za 284 | vnoremap zf 285 | " tab switch key mappings 286 | " http://vim.wikia.com/wiki/Alternative_tab_navigation 287 | "nnoremap 1gt 288 | "nnoremap 2gt 289 | "nnoremap 3gt 290 | "nnoremap 4gt 291 | "nnoremap 5gt 292 | "nnoremap 6gt 293 | "nnoremap 7gt 294 | "nnoremap 8gt 295 | "nnoremap 9gt 296 | "nnoremap 10gt 297 | " map for xxd editing 298 | nnoremap xd :%!xxd 299 | nnoremap xr :%!xxd -r 300 | nnoremap t :tabe 301 | nnoremap tm :echo strftime('%c') 302 | nnoremap v :vnew 303 | nnoremap to :tabonly 304 | nnoremap x :q 305 | nnoremap tx :tabclose 306 | "nnoremap :tabnext 307 | "imap :tabnext 308 | "map :tabprev 309 | "imap :tabprev 310 | "Simplify help navigation 311 | "http://vim.wikia.com/wiki/Learn_to_use_help 312 | "Press Enter to jump to the subject (topic) under the cursor. 313 | "Press Backspace to return from the last jump. 314 | "Press s to find the next subject, or S to find the previous subject. 315 | "Press o to find the next option, or O to find the previous option. 316 | "nnoremap 317 | "nnoremap 318 | "nnoremap o /'\l\{2,\}' 319 | "nnoremap O ?'\l\{2,\}' 320 | "nnoremap s /\|\zs\S\+\ze\| 321 | "nnoremap S ?\|\zs\S\+\ze\| 322 | "} 323 | 324 | "{Plugin settings 325 | "scrooloose/syntastic 326 | set statusline+=%{SyntasticStatuslineFlag()} 327 | let g:syntastic_check_on_open=0 328 | let g:syntastic_always_populate_loc_list=1 329 | let g:syntastic_auto_loc_list=1 330 | let g:syntastic_check_on_wq=1 331 | let g:syntastic_enable_signs=1 332 | let g:syntastic_aggregate_errors=1 333 | let g:syntastic_error_symbol="E" 334 | let g:syntastic_warning_symbol="W" 335 | highlight SyntasticError guibg=#2F0000 336 | nnoremap n :lnext 337 | nnoremap p :lprevious 338 | "prerequisite: 339 | " npm packages: 340 | " eslint jsxhint babel-eslint eslint-plugin-react json-lint jshint 341 | "let g:syntastic_javascript_checkers = ['eslint', 342 | " \'jsxhint', 'babel-eslint', 'eslint-plugin-react', 'json-lint', 343 | " \'jshint', 'jscs'] 344 | let g:syntastic_json_checkers=['jsonlint'] 345 | let g:syntastic_javascript_checkers = ['eslint'] 346 | "let g:syntastic_javascript_jsxhint_exec = 'jsx-jshint-wrapper' 347 | let g:syntastic_python_checkers = ['pylint'] 348 | "let g:syntastic_python_python_exec="/usr/local/bin/python3" 349 | let g:syntastic_sass_checkers = ['sass', 'sassc'] 350 | "let g:syntastic_scss_checkers = ['sass', 'sassc', 'scsslint'] 351 | let g:syntastic_php_checkers = ['php'] 352 | "let g:syntastic_ruby_checkers = ['robocop'] 353 | "let g:syntastic_coffee_checkes = ['coffeelint'] 354 | let g:syntastic_shell_checkers = ['shellcheck'] 355 | " Set up the arrays to ignore for later 356 | if !exists('g:syntastic_html_tidy_ignore_errors') 357 | let g:syntastic_html_tidy_ignore_errors = [] 358 | endif 359 | if !exists('g:syntastic_html_tidy_blocklevel_tags') 360 | let g:syntastic_html_tidy_blocklevel_tags = [] 361 | endif 362 | " Try to use HTML5 Tidy for better checking? 363 | let g:syntastic_html_tidy_exec = '/usr/local/bin/tidy5' 364 | " AP: honestly can't remember if this helps or not 365 | " installed with homebrew locally 366 | 367 | " Ignore ionic tags in HTML syntax checking 368 | " See http://stackoverflow.com/questions/30366621 369 | " ignore errors about Ionic tags 370 | let g:syntastic_html_tidy_ignore_errors += [ 371 | \ "ne :NERDTreeFind 411 | nnoremap nt :NERDTreeToggle 412 | let g:NERDTreeShowLineNumbers=1 413 | let g:NERDTreeChDirMode=2 414 | let NERDTreeWinPos="left" 415 | 416 | "noscripter/tabman.vim 417 | let g:tabman_side="right" 418 | let g:tabman_specials=1 419 | let g:tabman_number = 1 420 | 421 | "mhinz/vim-startify 422 | noremap s :Startify 423 | let g:startify_list_order = [ 424 | \ [' Bookmarks'], 'bookmarks', 425 | \ [' MRU'], 'files' , 426 | \ [' MRU '.getcwd()], 'dir', 427 | \ [' Sessions'], 'sessions', 428 | \ ] 429 | let g:startify_bookmarks = [ 430 | \ '~/projects/assets/daily.md', 431 | \ '~/projects/assets/', 432 | \ '~/downloads/', 433 | \ '~/projects/node/', 434 | \ '~/projects/daily/', 435 | \ '~/projects/daily/fe-learning/', 436 | \ '~/projects/assets/item-detail/', 437 | \ '~/projects/assets/noscripter.github.io/', 438 | \ '~/projects/assets/noscripter.github.io/_posts/', 439 | \ '~/projects/assets/noscripter.github.io/lab/', 440 | \ '~/projects/daily/fe-learning/playground/'] 441 | let g:startify_change_to_dir = 0 442 | let g:startify_enable_special = 0 443 | let g:startify_files_number = 8 444 | let g:startify_session_autoload = 1 445 | let g:startify_session_delete_buffers = 1 446 | let g:startify_session_persistence = 1 447 | let g:startify_use_env = 1 448 | 449 | "CtrlP 450 | """"""""""""""""""""""""" 451 | if exists(':CtrplP') 452 | let g:ctrlp_custom_ignore = { 453 | \ 'dir': '\v[\/]\.(git|hg|svn)$', 454 | \ 'dir': 'node_modules\|bower_components', 455 | \ 'file': '\v\.(exe|so|dll)$', 456 | \ 'link': 'some_bad_symbolic_links', 457 | \ } 458 | " Use ag in CtrlP for listing files. Lightning fast and respects .gitignore 459 | " modify for spf13 460 | let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' 461 | " ag is fast enough that CtrlP doesn't need to cache 462 | let g:ctrlp_use_caching = 0 463 | endif 464 | 465 | "YouCompleteMe 466 | let g:ycm_min_num_of_chars_for_completion = 3 467 | let g:ycm_autoclose_preview_window_after_completion=1 468 | let g:ycm_complete_in_comments = 1 469 | "leave '', '' for ultisnips 470 | let g:ycm_key_list_select_completion = ['', ''] 471 | "leave '', '' for ultisnips 472 | let g:ycm_key_list_previous_completion = ['', ''] 473 | let g:ycm_confirm_extra_conf = 0 474 | let g:ycm_global_ycm_extra_conf='~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py' 475 | " http://www.alexeyshmalko.com/2014/youcompleteme-ultimate-autocomplete-plugin-for-vim/ 476 | let g:ycm_key_list_select_completion=[] 477 | let g:ycm_key_list_previous_completion=[] 478 | let g:ycm_filetype_blacklist = { 479 | \ 'tagbar' : 1, 480 | \ 'qf' : 1, 481 | \ 'notes' : 1, 482 | \ 'markdown' : 1, 483 | \ 'unite' : 1, 484 | \ 'text' : 1, 485 | \ 'vimwiki' : 1, 486 | \ 'pandoc' : 1, 487 | \ 'infolog' : 1, 488 | \ 'mail' : 1 489 | \} 490 | let g:ycm_semantic_triggers = { 491 | \ 'c' : ['->', '.'], 492 | \ 'objc' : ['->', '.'], 493 | \ 'ocaml' : ['.', '#'], 494 | \ 'cpp,objcpp' : ['->', '.', '::'], 495 | \ 'perl' : ['->'], 496 | \ 'php' : ['->', '::'], 497 | \ 'cs,java,javascript,d,python,perl6,scala,vb,elixir,go' : ['.'], 498 | \ 'vim' : ['re![_a-zA-Z]+[_\w]*\.'], 499 | \ 'ruby' : ['.', '::'], 500 | \ 'lua' : ['.', ':'], 501 | \ 'erlang' : [':'], 502 | \} 503 | 504 | "mileszs/ack.vim 505 | " Use The Silver Searcher over grep, iff possible 506 | if executable('ag') 507 | " Use ag over grep 508 | set grepprg=ag\ --nogroup\ --nocolor 509 | endif 510 | 511 | "gitgutter 512 | let g:gitgutter_max_signs=900 513 | 514 | "editorconfig-vim 515 | let g:EditorConfig_exclude_patterns = ['fugitive://.*', 'scp://.*'] 516 | let g:EditorConfig_verbose = 0 517 | "optional values are: ['fill', 'line', 'none'] 518 | let g:EditorConfig_max_line_indicator = "fill" 519 | let g:EditorConfig_exec_path = "/usr/local/bin/editorconfig" 520 | 521 | "maksimr/vim-jsbeautify 522 | map :call JsBeautify() 523 | autocmd FileType javascript noremap :call JsBeautify() 524 | autocmd FileType json noremap :call JsonBeautify() 525 | autocmd FileType jsx noremap :call JsxBeautify() 526 | autocmd FileType html noremap :call HtmlBeautify() 527 | autocmd FileType css noremap :call CSSBeautify() 528 | autocmd FileType javascript vnoremap :call RangeJsBeautify() 529 | autocmd FileType json vnoremap :call RangeJsonBeautify() 530 | autocmd FileType jsx vnoremap :call RangeJsxBeautify() 531 | autocmd FileType html vnoremap :call RangeHtmlBeautify() 532 | autocmd FileType css vnoremap :call RangeCSSBeautify() 533 | 534 | "ctrlp-py-matcher 535 | let g:ctrlp_match_func = { 'match': 'pymatcher#PyMatch' } 536 | 537 | "neosnippet 538 | "disables all runtime snippets 539 | let g:neosnippet#disable_runtime_snippets = { 540 | \ '_' : 1 541 | \ } 542 | 543 | "SirVer/ultisnips 544 | "customize python and keymapping 545 | "ref:https://gist.github.com/lencioni/dff45cd3d1f0e5e23fe6 546 | "ref:https://stackoverflow.com/questions/14896327/ultisnips-and-youcompleteme 547 | let g:UltiSnipsUsePythonVersion = 2 548 | let g:UltiSnipsExpandTrigger = "" 549 | let g:UltiSnipsListSnippets = "" 550 | let g:UltiSnipsJumpForwardTrigger = "" 551 | let g:UltiSnipsJumpBackwardTrigger = "" 552 | 553 | "ervandew/supertab 554 | "let g:SuperTabDefaultCompletionType = '' 555 | "let g:SuperTabMappingForward = '' 556 | "let g:SuperTabMappingBackward = '' 557 | "let g:SuperTabCrMapping = 0 558 | 559 | "moll/vim-node 560 | autocmd User Node 561 | \ if &filetype == "javascript" | 562 | \ nmap f NodeVSplitGotoFile | 563 | \ nmap NodeVSplitGotoFile | 564 | \ endif 565 | 566 | "othree/javascript-libraries-syntax.vim 567 | let g:used_javascript_libs = 'react,angularjs,flux' 568 | 569 | "pangloss/vim-javascript 570 | let g:javascript_conceal_function = "ƒ" 571 | let g:javascript_conceal_null = "ø" 572 | let g:javascript_conceal_this = "@" 573 | let g:javascript_conceal_return = "⇚" 574 | let g:javascript_conceal_undefined = "¿" 575 | let g:javascript_conceal_NaN = "ℕ" 576 | let g:javascript_conceal_prototype = "¶" 577 | let g:javascript_conceal_static = "•" 578 | let g:javascript_conceal_super = "Ω" 579 | 580 | "groenewege/vim-less 581 | autocmd BufNewFile,BufRead *.less set filetype=less 582 | autocmd FileType less set omnifunc=csscomplete#CompleteCSS 583 | 584 | "vim-airline/vim-airline-themes 585 | "let g:airline_theme='dark' 586 | 587 | "fatih/vim-go 588 | let g:go_highlight_functions = 1 589 | let g:go_highlight_methods = 1 590 | let g:go_highlight_structs = 1 591 | let g:go_highlight_interfaces = 1 592 | let g:go_highlight_operators = 1 593 | let g:go_highlight_build_constraints = 1 594 | let g:syntastic_go_checkers = ['golint', 'govet', 'errcheck'] 595 | "let g:syntastic_mode_map = { 'mode': 'active', 'passive_filetypes': ['go'] } 596 | let g:go_fmt_command = "goimports" 597 | let g:go_fmt_autosave = 0 598 | au FileType go set expandtab 599 | 600 | "vim-action-ag 601 | " use * to search current word in normal mode 602 | "nmap * AgActionWord 603 | " use * to search selected text in visual mode 604 | " vmap * AgActionVisual 605 | 606 | "Yggdroot/indentLine 607 | let g:indentLine_enabled=1 608 | "let g:indentLine_conceallevel=0 609 | 610 | "mhinz/vim-grepper 611 | " Mimic :grep and make ag the default tool. 612 | let g:grepper = { 613 | \ 'tools': ['ag', 'git', 'grep'], 614 | \ 'open': 0, 615 | \ 'jump': 1, 616 | \ } 617 | 618 | "} 619 | 620 | "{helper functions 621 | " Set tabstop, softtabstop and shiftwidth to the same value 622 | command! -nargs=* Stab call Stab() 623 | function! Stab() 624 | let l:tabstop = 1 * input('set tabstop = softtabstop = shiftwidth = ') 625 | if l:tabstop > 0 626 | let &l:sts = l:tabstop 627 | let &l:ts = l:tabstop 628 | let &l:sw = l:tabstop 629 | endif 630 | call SummarizeTabs() 631 | endfunction 632 | 633 | function! SummarizeTabs() 634 | try 635 | echohl ModeMsg 636 | echon 'tabstop='.&l:ts 637 | echon ' shiftwidth='.&l:sw 638 | echon ' softtabstop='.&l:sts 639 | if &l:et 640 | echon ' expandtab' 641 | else 642 | echon ' noexpandtab' 643 | endif 644 | finally 645 | echohl None 646 | endtry 647 | endfunction 648 | 649 | function! GuiTabLabel() 650 | let label = '' 651 | let bufnrlist = tabpagebuflist(v:lnum) 652 | " Add '+' if one of the buffers in the tab page is modified 653 | for bufnr in bufnrlist 654 | if getbufvar(bufnr, "&modified") 655 | let label = '+' 656 | break 657 | endif 658 | endfor 659 | " Append the tab number 660 | let label .= v:lnum.': ' 661 | " Append the buffer name 662 | let name = bufname(bufnrlist[tabpagewinnr(v:lnum) - 1]) 663 | if name == '' 664 | " give a name to no-name documents 665 | if &buftype=='quickfix' 666 | let name = '[Quickfix List]' 667 | else 668 | let name = '[No Name]' 669 | endif 670 | else 671 | " get only the file name 672 | let name = fnamemodify(name,":t") 673 | endif 674 | let label .= name 675 | " Append the number of windows in the tab page 676 | let wincount = tabpagewinnr(v:lnum, '$') 677 | return label . ' [' . wincount . ']' 678 | endfunction 679 | function! SetTabLabel() 680 | set guitablabel=%{GuiTabLabel()} 681 | endfunction 682 | 683 | " http://vimdoc.sourceforge.net/htmldoc/gui.html 684 | "echom "May The FORCE be with U!" 685 | if exists("+showtabline") 686 | function! MyTabLine() 687 | let s = '' 688 | let t = tabpagenr() 689 | let i = 1 690 | while i <= tabpagenr('$') 691 | let buflist = tabpagebuflist(i) 692 | let winnr = tabpagewinnr(i) 693 | let s .= '%' . i . 'T' 694 | let s .= (i == t ? '%1*' : '%2*') 695 | let s .= ' ' 696 | let s .= i . ':' 697 | let s .= ' %*' 698 | let s .= (i == t ? '%#TabLineSel#' : '%#TabLine#') 699 | let file = bufname(buflist[winnr - 1]) 700 | let file = fnamemodify(file, ':p:t') 701 | if file == '' 702 | let file = '[No Name]' 703 | endif 704 | let s .= file 705 | let i = i + 1 706 | endwhile 707 | let s .= '%T%#TabLineFill#%=' 708 | let s .= (tabpagenr('$') > 1 ? '%999XX' : 'X') 709 | return s 710 | endfunction 711 | set stal=2 712 | set tabline=%!MyTabLine() 713 | endif 714 | 715 | "http://vim.wikia.com/wiki/Show_tab_number_in_your_tab_line 716 | " set up tab tooltips with every buffer name 717 | function! GuiTabToolTip() 718 | let tip = '' 719 | let bufnrlist = tabpagebuflist(v:lnum) 720 | for bufnr in bufnrlist 721 | " separate buffer entries 722 | if tip != '' 723 | let tip .= " \n " 724 | endif 725 | " Add name of buffer 726 | let name = bufname(bufnr) 727 | " add modified/modifiable flags 728 | if getbufvar(bufnr, "&modified") 729 | let tip .= ' [+]' 730 | endif 731 | endfor 732 | return tip 733 | endfunction 734 | set guitabtooltip=%{GuiTabToolTip()} 735 | 736 | " url:http://vimcasts.org/episodes/tidying-whitespace/ 737 | function! Preserve(command) 738 | " Preparation: save last search, and cursor position. 739 | let _s=@/ 740 | let l = line(".") 741 | let c = col(".") 742 | " Do the business: 743 | execute a:command 744 | " Clean up: restore previous search history, and cursor position 745 | let @/=_s 746 | call cursor(l, c) 747 | endfunction 748 | nnoremap _$ :call Preserve("%s/\\s\\+$//e") 749 | nnoremap _= :call Preserve("normal gg=G") 750 | 751 | "Allow to toggle background 752 | function! ToggleBG() 753 | let s:tbg = &background 754 | " Inversion 755 | if s:tbg == 'dark' 756 | set background=light 757 | else 758 | set background=dark 759 | endif 760 | endfunction 761 | noremap bg :call ToggleBG() 762 | "} 763 | 764 | "{auto commands 765 | " Return to last edit position when opening files (You want this!) 766 | autocmd BufReadPost * 767 | \ if line("'\"") > 0 && line("'\"") <= line("$") | 768 | \ exe "normal! g`\"" | 769 | \ endif 770 | autocmd! BufRead,BufNewFile *.markdown set filetype=mkd 771 | autocmd! BufRead,BufNewFile *.md set filetype=mkd 772 | autocmd! BufRead,BufNewFile,BufReadPost *.snippets set filetype=snippets 773 | autocmd! BufRead,BufNewFile *.json set filetype=json 774 | autocmd! BufRead,BufNewFile *.ts set filetype=typescript 775 | autocmd BufNewFile,BufRead *.vm set filetype=html 776 | autocmd BufNewFile,BufRead *.html.twig set filetype=html.twig 777 | autocmd BufNewFile,BufRead *.conf set filetype=config 778 | au BufRead,BufNewFile *.scss set filetype=scss.css 779 | autocmd BufNewFile,BufRead *.vm set filetype=html 780 | autocmd BufNewFile,BufRead *.coffee set filetype=coffee 781 | autocmd FileType haskell setlocal commentstring=--\ %s 782 | autocmd BufNewFile,BufRead *.rss setfiletype xml 783 | autocmd FileType xhtml,xml ru ftplugin/html/autoclosetag.vim 784 | " Instead of reverting the cursor to the last position in the buffer, we 785 | " set it to the first line when editing a git commit message 786 | au FileType gitcommit au! BufEnter COMMIT_EDITMSG 787 | \ call setpos('.', [0, 1, 1, 0]) 788 | au VimEnter * :call SetTabLabel() 789 | autocmd BufNewFile,BufReadPost *.md set filetype=markdown 790 | autocmd BufRead,BufNewFile *.json setf json 791 | autocmd BufNewFile,BufReadPost *.xtpl set filetype=html 792 | autocmd BufNewFile,BufRead *.vm set ft=velocity 793 | autocmd BufNewFile,BufRead *.xtpl set ft=html 794 | autocmd BufNewFile,BufRead *.ejs set ft=html 795 | autocmd FileType css set omnifunc=csscomplete#CompleteCSS 796 | autocmd FileType xtpl set ft=html 797 | autocmd BufNewFile,BufRead *.rss,*.atom setfiletype xml 798 | autocmd FocusGained, BufEnter * :silent! ! 799 | autocmd FileType python syn keyword pythonDecorator True None False self 800 | autocmd BufNewFile,BufRead *.jinja set syntax=htmljinja 801 | autocmd BufNewFile,BufRead *.mako set ft=mako 802 | autocmd BufRead,BufNewFile *.md set filetype=markdown 803 | au! BufRead,BufNewFile *.bat 804 | \ if getline(1) =~ '--\*-Perl-\*--' | setf perl | endif 805 | autocmd WinEnter call SetTabLabel() 806 | autocmd BufEnter call SetTabLabel() 807 | "https://superuser.com/questions/195022/vim-how-to-synchronize-nerdtree-with-current-opened-tab-file-path 808 | if expand("%:p") 809 | autocmd BufEnter * lcd %:p:h 810 | endif 811 | "http://inlehmansterms.net/2014/09/04/sane-vim-working-directories/ 812 | "http://vim.wikia.com/wiki/Set_working_directory_to_the_current_file 813 | autocmd BufEnter * silent! lcd %:p:h 814 | autocmd BufEnter * if expand("%:p:h") !~ '^/tmp' | silent! lcd %:p:h | endif 815 | let s:default_path = escape(&path, '\ ') " store default value of 'path' 816 | 817 | " Always add the current file's directory to the path and tags list if not 818 | " already there. Add it to the beginning to speed up searches. 819 | autocmd BufRead * 820 | \ let s:tempPath=escape(escape(expand("%:p:h"), ' '), '\ ') | 821 | \ exec "set path-=".s:tempPath | 822 | \ exec "set path-=".s:default_path | 823 | \ exec "set path^=".s:tempPath | 824 | \ exec "set path^=".s:default_path 825 | autocmd Filetype * 826 | \if &omnifunc == "" | 827 | \setlocal omnifunc=syntaxcomplete#Complete | 828 | \endif 829 | " Automatically open and close the popup menu / preview window 830 | au CursorMovedI,InsertLeave * if pumvisible() == 0|silent! pclose|endif 831 | " Restore cursor position upon reopening files {{{ 832 | autocmd BufReadPost * 833 | \ if &filetype != "gitcommit" && line("'\"") > 0 && line("'\"") <= line("$") | 834 | \ exe "normal! g`\"" | 835 | \ endif 836 | " }}} 837 | " gnuplot syntax highlighting 838 | au BufNewFile,BufRead *.plt,.gnuplot setf gnuplot 839 | autocmd ColorScheme * highlight ExtraWhitespace ctermbg=red guibg=red 840 | autocmd FileType ruby set dictionary+=~/.vim/dict/ruby.dict 841 | au FileType javascript set dictionary+=$HOME/.vim/dict/node.dict 842 | "} 843 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # autoconfig-mac-vimrc 2 | 3 | I'm a front-end engineer, and also a vimer, maybe the config file is suitable for you. This file did lots of things, such as: 4 | 5 | - install brew if not exist. 6 | - install fonts 7 | - install colorschemes 8 | - install ack 9 | - install all listed bundle plugins, if exist, try update. 10 | - install YouComplete for nodejs 11 | - and so on. 12 | 13 | ![pic](http://ww3.sinaimg.cn/large/6c0378f8gw1f2vlasl7e5j21kw0zkanh.jpg) 14 | 15 | The `` key is `,`,use `,ne` open folders, use `,bg` toggle background (light/dark). 16 | 17 | ## Install 18 | 19 | The first approach: 20 | 21 | - copy the bash code at the bottom to `install.sh` 22 | - run command `chmod +x install.sh` 23 | - run command `./install.sh` 24 | 25 | The second approach: 26 | 27 | ```bash 28 | git clone https://github.com/barretlee/autoconfig-mac-vimrc.git; 29 | cd autoconfig-mac-vimrc; 30 | chmod +x install; 31 | ./install; 32 | ``` 33 | 34 | __Attention:__ This shell script contains lots of plugins and tools, if you have never installed, it may takes a little long time, about 15+ mins in good network. 35 | 36 | __bash code__ 37 | ```bash 38 | #!/bin/bash 39 | # @author Barret Lee 40 | 41 | [[ -d ~/.vim ]] || mkdir ~/.vim; 42 | 43 | # tmp dir 44 | [[ -d ~/v-tmp ]] || mkdir ~/v-tmp; 45 | 46 | # .vimrc 47 | cd ~/v-tmp; 48 | [[ -d ~/v-tmp/rc ]] || git clone https://github.com/barretlee/autoconfig-mac-vimrc.git; 49 | 50 | # backup origin vimrc file 51 | [[ -f ~/.vimrc-bak ]] || cp ~/.vimrc ~/.vimrc-bak; 52 | mv ~/v-tmp/autoconfig-mac-vimrc/.vimrc ~/.vimrc; 53 | 54 | # vim pulgin controller - vundle 55 | [[ -d ~/.vim/bundle/Vundle.vim ]] || git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim; 56 | 57 | # colors schemes 58 | cd ~/v-tmp; 59 | [[ -d ~/v-tmp/vim-colorschemes ]] || git clone https://github.com/flazz/vim-colorschemes.git; 60 | [[ -d ~/.vim/colors ]] || mv ~/v-tmp/vim-colorschemes/colors ~/.vim/; 61 | 62 | # fonts for airline 63 | cd ~/v-tmp; 64 | [[ -d ~/v-tmp/fonts ]] || git clone https://github.com/powerline/fonts.git; 65 | cd fonts; 66 | sh ./install.sh; 67 | 68 | if type brew > /dev/null; then 69 | echo "Homebrew Exists"; 70 | else 71 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; 72 | fi; 73 | 74 | # ack supported 75 | brew install ack ag; 76 | 77 | # YouCompleteMe supported 78 | if [[ -d ~/.vim/bundle/YouCompleteMe ]]; then 79 | echo "YouCompleteMe Exists"; 80 | else 81 | git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe; 82 | cd ~/.vim/bundle/YouCompleteMe; 83 | # for nodejs 84 | ./install.py --tern-completer; 85 | fi; 86 | 87 | # update vim, replace the origin 88 | # brew install vim --override-system-vi --with-lua --HEAD; 89 | 90 | # install vim plugins 91 | vim +PluginInstall! +qall; 92 | 93 | # rm tmp dir 94 | # rm -rf ~/v-tmp; 95 | echo "You can remove the temporary directory ~/v-tmp"; 96 | ``` 97 | 98 | ## Thanks & LICENSE 99 | 100 | Thanks for @noscripter. 101 | 102 | MIT LICENSE. 103 | 104 | -------------------------------------------------------------------------------- /install: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # @author Barret Lee 3 | 4 | [[ -d ~/.vim ]] || mkdir ~/.vim; 5 | 6 | # tmp dir 7 | [[ -d ~/v-tmp ]] || mkdir ~/v-tmp; 8 | 9 | # .vimrc 10 | cd ~/v-tmp; 11 | [[ -d ~/v-tmp/rc ]] || git clone https://github.com/barretlee/autoconfig-mac-vimrc.git; 12 | 13 | # backup origin vimrc file 14 | [[ -f ~/.vimrc-bak ]] || cp ~/.vimrc ~/.vimrc-bak; 15 | mv ~/v-tmp/autoconfig-mac-vimrc/.vimrc ~/.vimrc; 16 | 17 | # vim pulgin controller - vundle 18 | [[ -d ~/.vim/bundle/Vundle.vim ]] || git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim; 19 | 20 | # colors schemes 21 | cd ~/v-tmp; 22 | [[ -d ~/v-tmp/vim-colorschemes ]] || git clone https://github.com/flazz/vim-colorschemes.git; 23 | [[ -d ~/.vim/colors ]] || mv ~/v-tmp/vim-colorschemes/colors ~/.vim/; 24 | 25 | # fonts for airline 26 | cd ~/v-tmp; 27 | [[ -d ~/v-tmp/fonts ]] || git clone https://github.com/powerline/fonts.git; 28 | cd fonts; 29 | sh ./install.sh; 30 | 31 | if type brew > /dev/null; then 32 | echo "Homebrew Exists"; 33 | else 34 | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"; 35 | fi; 36 | 37 | # ack supported 38 | brew install ack ag; 39 | 40 | # YouCompleteMe supported 41 | if [[ -d ~/.vim/bundle/YouCompleteMe ]]; then 42 | echo "YouCompleteMe Exists"; 43 | else 44 | git clone https://github.com/Valloric/YouCompleteMe.git ~/.vim/bundle/YouCompleteMe; 45 | cd ~/.vim/bundle/YouCompleteMe; 46 | git submodule update --init --recursive 47 | # for nodejs 48 | ./install.py --tern-completer; 49 | fi; 50 | 51 | # update vim, replace the origin 52 | # brew install vim --override-system-vi --with-lua --HEAD; 53 | 54 | # install vim plugins 55 | vim +PluginInstall! +qall; 56 | 57 | # rm tmp dir 58 | rm -rf ~/v-tmp; 59 | # echo "You can remove the temporary directory ~/v-tmp"; 60 | --------------------------------------------------------------------------------