From 16b03e574fb8f2e9ec8773ac069d04e55cdbfb83 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Tue, 29 Jul 2014 17:46:52 -0400 Subject: [PATCH] Combine rcfiles + add gvimrc --- gvimrc | 117 ++++++++++++++++++++ vim/rc/keymaps.vim | 167 ---------------------------- vim/rc/plugins.vim | 150 ------------------------- vim/rc/util.vim | 0 vimrc | 270 ++++++++++++++++++++++++++++++++++++++++++--- 5 files changed, 374 insertions(+), 330 deletions(-) create mode 100644 gvimrc delete mode 100644 vim/rc/keymaps.vim delete mode 100644 vim/rc/plugins.vim delete mode 100644 vim/rc/util.vim diff --git a/gvimrc b/gvimrc new file mode 100644 index 00000000..10c2db49 --- /dev/null +++ b/gvimrc @@ -0,0 +1,117 @@ +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" gvimrc " +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Say neigh to UI cruft! +set go-=T +set go-=l +set go-=L +set go-=r +set go-=R +" No GUI tabs! +set go-=e +" Don't show dialogues, use text prompts +set go+=c + +" Sets File>Open to start in current file's path +set browsedir=buffer + +" Share a clipboard with OS and vim terminal sessions +if has('unnamedplus') + set clipboard=unnamedplus +else + set clipboard=unnamed +endif + +" For macvim +if has('gui_macvim') + + " j doesn't seem to work from terminal + set formatoptions+=j + + " set guifont=Ubuntu\ Mono:h14 + " set guifont=Monaco:h12 + set guifont=Inconsolata:h16 + + " Replace some CMD shortcuts + macmenu &File.Open\.\.\. key= + macmenu &Tools.Make key= + + " Switching buffers + nmap ]b + nmap [b + + " Textmate-like CMD+Enter + inoremap o + inoremap O + + " Fast scrolling + map 5j + map 5k + imap 5j + imap 5k + + " Commenting using CMD+/" + nmap gcc + vmap gc + + " Tab navigation + nmap 1gt + nmap 2gt + nmap 3gt + nmap 4gt + nmap 5gt + nmap 6gt + nmap 7gt + nmap 8gt + nmap 9gt + + map r + " Replace :make + map :Dispatch + + " Shortcuts to outside apps {{{ + " Open in finder + nnoremap f :silent !open "%:p:h" + nnoremap F :silent !open . + + " Open in terminal + nnoremap t :silent !open -a iTerm "%:p:h" + nnoremap T :silent !open -a iTerm . + + " Send to transmit + nnoremap u :silent !open -a Transmit "%" + + " Send to launchbar (project and file, respectively) + nnoremap [ :call LaunchBarSelect(expand("%:p:h")) + nnoremap ] :call LaunchBarSelect(expand("%:p")) + + func LaunchBarSelect(arg) + silent! let l:arg = substitute(a:arg, '[^A-Za-z0-9_.~-/]','\="%".printf("%02X",char2nr(submatch(0)))','g') + if l:arg ==# "" + let l:arg = expand("%:p:h") + endif + exec 'silent !open "x-launchbar:select?file=' . l:arg . '"' + endfunc + " }}} + +else + + " For unix only + inoremap * + cnoremap * + + set go-=m + set novisualbell + + " For gvim + set guifont=Monospace\ 10 + + " Commenting using Ctrl+/ + map gcc + + " Textmate-like CMD+Enter + inoremap o + inoremap O + +endif diff --git a/vim/rc/keymaps.vim b/vim/rc/keymaps.vim deleted file mode 100644 index b9d6dfc4..00000000 --- a/vim/rc/keymaps.vim +++ /dev/null @@ -1,167 +0,0 @@ - -" Shortcut to vimrc and gvimrc -nnoremap v :CtrlP ~/.vim - -" Comma get some... sorry. -let mapleader = ',' -let maplocalleader = '\' -noremap ; : - -" Trigger to preserve indentation on pastes -set pastetoggle= -" Easier than escape. Pinnacle of laziness. -imap jk -" Turn off search highlighting -noremap ? :nohlsearch - -" Navigation {{{ - " Normalize all the navigation keys to move by row/col despite any wrapped text - noremap j gj - noremap k gk - " % matchit shortcut, but only in normal mode! - nmap % - " Easier fold toggle - nnoremap 5j - vnoremap 5j - nnoremap 5k - vnoremap 5k - - " f: Find. Also support repeating with . - nnoremap OriginalSemicolon ; - nnoremap f :call repeat#set("\Plug>OriginalSemicolon")f - nnoremap t :call repeat#set("\Plug>OriginalSemicolon")t - nnoremap F :call repeat#set("\Plug>OriginalSemicolon")F - nnoremap T :call repeat#set("\Plug>OriginalSemicolon")T -" }}} - -" Editing {{{ - nnoremap - " Insert-mode navigation - " Go to end of line - inoremap A - " Go to start of line - inoremap I - - " Make Y act consistant with C and D - nnoremap Y y$ - - " Don't leave visual mode after indenting - vnoremap < >gv - - " Textmate-like CMD+Enter (O in insert mode) - inoremap o - inoremap O - - " Enabling repeat in visual mode - vmap . :normal . -" }}} - -" Buffers {{{ - " Change CWD to current file's directory - nnoremap cd :cd %:p:h:pwd - - " Next/prev buffer - nnoremap ]b :bnext - nnoremap [b :bprevious -" }}} - -" Command {{{ - " Annoying command mistakes - com! -bang -nargs=* -complete=file E e - com! -bang -nargs=* -complete=file W w - com! -bang -nargs=* -complete=file Wq wq - com! -bang -nargs=* -complete=file WQ wq - com! -bang Wa wa - com! -bang WA wa - com! -bang Q q - com! -bang QA qa - com! -bang Qa qa - " Forget to sudo? - com! WW w !sudo tree % >/dev/null - - " Shortcuts - cnoremap ;/ =expand('%:p:h').'/' - cnoremap ;; =expand("%:t") - cnoremap ;. =expand("%:p:r") - - " Mimic shortcuts in the terminal - cnoremap - cnoremap -" }}} - -" External Tools {{{ - " Send cwd to tmux - nnoremap x :Tmux cd =expand("%:p:h") - nnoremap X :Tmux cd =expand("%:p:r") -" }}} - -" Plugins {{{ - " bufkill - nnoremap zx :Bdelete - - " CtrlP - let g:ctrlp_map = '' - " Only open CtrlP if the cwd ISN'T $HOME - nnoremap / getcwd() != $HOME ? ":CtrlPCurWD" : ":echoe 'Cannot open CtrlP in HOME'" - nnoremap . :CtrlPCurFile - nnoremap , :CtrlPBuffer - nnoremap ; :CtrlPFunky - nnoremap m :CtrlPMRU - nnoremap M :CtrlPModified - nnoremap t :CtrlPBufTag - nnoremap T :CtrlPBufTagAll - - " NERDTree - map \ :NERDTreeCWD - map . :NERDTreeFind - - " Tabularize - nmap a= :Tabularize /= - vmap a= :Tabularize /= - nmap a> :Tabularize /=> - vmap a> :Tabularize /=> - nmap a: :Tabularize /: - vmap a: :Tabularize /: - nmap a:: :Tabularize /:\zs - vmap a:: :Tabularize /:\zs - nmap a, :Tabularize /, - vmap a, :Tabularize /, - nmap a :Tabularize / - vmap a :Tabularize / - - " UltiSnips - let g:UltiSnipsExpandTrigger = "" - let g:UltiSnipsJumpForwardTrigger = "" - let g:UltiSnipsJumpBackwardTrigger = "" - " Ignore the default snippets so I (and others) can define their own - let g:UltiSnipsSnippetDirectories = ["snips"] - - " Emmet - imap emmet#expandAbbrIntelligent("\") - - " YCM - map g] :YcmCompleter GoToDefinitionElseDeclaration - let g:ycm_key_list_select_completion = ['', ''] - let g:ycm_key_list_previous_completion = ['', ''] - - " vim-surround - " I turned the keymappings around to restore the 'feedback' - " I get from operator mode after common vim commands, like d - " and c. - let g:surround_no_mappings = 1 - nmap sd Dsurround - nmap sc Csurround - nmap s Ysurround - nmap S YSurround - nmap ss Yssurround - nmap Ss YSsurround - nmap SS YSsurround - xmap S VSurround - xmap Sg VgSurround - - " vim-switch - nnoremap :Switch -" }}} - -" vim:set ft=vim: diff --git a/vim/rc/plugins.vim b/vim/rc/plugins.vim deleted file mode 100644 index 6f1c3963..00000000 --- a/vim/rc/plugins.vim +++ /dev/null @@ -1,150 +0,0 @@ -" Appearance {{{ - NeoBundle 'reedes/vim-colors-pencil' - - " Pretty indent indicators - " NeoBundle 'Yggdroot/indentLine' - " let g:indentLine_color_gui = '#4a514f' -" }}} - -" File search {{{ - " More powerful file searching - if executable('ag') - NeoBundle 'rking/ag.vim' - elseif executable('ack') - NeoBundle 'mileszs/ack.vim' - endif - - " Project-wide search and replace - " NeoBundle 'skwp/greplace.vim' - - " Netrw improvements - NeoBundle 'scrooloose/nerdtree' - let NERDTreeMinimalUI = 1 - let NERDTreeChDirMode = 2 - " let NERDTreeBookmarksFile = "$HOME/.vim/tmp/NERDtreeBookmarks" - let NERDTreeIgnore = ['\~$', '\.swo$', '\.swp$', '\.git$', '\.hg', '\.svn', '\.bzr', '\.settings', '\.project', '\.DS_Store'] - let NERDTreeShowHidden = 1 - - " Command-T, Peepopen or Goto-anything, but for vim, written in VimL - NeoBundle 'kien/ctrlp.vim' - " Ctrlp extension for jumping to functions - NeoBundle 'tacahiroy/ctrlp-funky' - " Ctrlp extension for listing git modified files - NeoBundle 'jasoncodes/ctrlp-modified.vim' - let g:ctrlp_extensions = ['tag', 'buffertag', 'funky'] - " let g:ctrlp_max_height = 10 - let g:ctrlp_cache_dir = "~/.vim/tmp/ctrlp" - let g:ctrlp_custom_ignore = { - \ 'dir': '\.(git|hg|svn|settings)$|tmp$', - \ 'file': '\.(exe|so|dll|sass-cache|classpaths|project|cache|jpg|png|gif|swf)$' - \ } - let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' - let g:ctrlp_match_window = 'bottom,order:btt,min:10,max:10,results:10' -" }}} - -" Editing {{{ - " Extended visual mode commands, substitutes and searches - NeoBundle 'vis' - - " Auto-closes delimiters like (),{},[],etc. - NeoBundle 'Raimondi/delimitMate' - let g:delimitMate_expand_cr = 1 - let g:delimitMate_expand_space = 1 - - " HTML & CSS emmet goodness; Zen coding's successor - NeoBundle 'mattn/emmet-vim' - - " Clean way to close buffers without altering window layout - " NeoBundle 'mattdbridges/bufkill.vim' - NeoBundle 'moll/vim-bbye' - - " For aligning text - NeoBundle 'godlygeek/tabular' - - " Comment out code with native comment syntax - NeoBundle 'tomtom/tcomment_vim' - let g:tcomment_types = {'blade': '{-- %s --}', 'twig': '{# %s #}'} - - " Offers some plugins better compatibility with repeat ('.') - NeoBundle 'tpope/vim-repeat' - - " Easy changing and insertion of surrounding delimiters (e.g. quotes, - " parenthesis, etc.) - NeoBundle 'tpope/vim-surround' - - " Snippets system - if has("python") - NeoBundle 'SirVer/ultisnips' - - " My snippets - NeoBundle 'hlissner/vim-ultisnips-snippets' - endif - - " One-key switching between true/false, yes/no, etc - NeoBundle 'AndrewRadev/switch.vim' -" }}} - -" Remote resources {{{ - " Visual git diffs in the gutter - NeoBundle 'airblade/vim-gitgutter' - let g:gitgutter_realtime = 0 - let g:gitgutter_eager = 0 - - " 'a Git wrapper so awesome, it should be illegal' - " NeoBundle 'tpope/vim-fugitive' - - " Async compiler plugins - " NeoBundle 'tpope/vim-dispatch' -" } - -" Programming {{{ - " Syntax checkers for a multitude of languages - " NeoBundle 'scrooloose/syntastic' - " let g:syntastic_auto_loc_list=0 - " " let g:syntastic_quiet_messages={'level': 'warnings'} - " let g:syntastic_phpcs_disable=1 - " let g:syntastic_echo_current_error=1 - " let g:syntastic_enable_balloons = 0 - " - " let g:syntastic_error_symbol = '►' - " let g:syntastic_warning_symbol = '►' - " - " let g:syntastic_loc_list_height = 5 - " let g:syntastic_mode_map = {'mode': 'active', 'active_filetypes': [], 'passive_filetypes': ['html']} - - " Running code inline for testing purposes - NeoBundle 'notalex/vim-run-live' -" }}} - -" Syntax {{{ - " HTML - " NeoBundle 'othree/html5.vim' - - " CSS/SCSS/LESS - NeoBundle 'cakebaker/scss-syntax.vim' - - " PHP - NeoBundleLazy 'StanAngeloff/php.vim', {'autoload': {'filetypes': ['php', 'blade']}} - NeoBundleLazy '2072/PHP-Indenting-for-VIm', {'autoload': {'filetypes': ['php']}} - " NeoBundleLazy 'stephpy/vim-phpdoc', {'autoload': {'filetypes': ['php']}} - - " Python - NeoBundleLazy 'indentpython.vim--nianyang', {'autoload': {'filetypes': ['python']}} - NeoBundleLazy 'python_match.vim', {'autoload': {'filetypes': ['python']}} - - " Javascript/Node - NeoBundleLazy 'pangloss/vim-javascript', {'autoload': {'filetypes': ['javascript']}} - " NeoBundleLazy 'moll/vim-node', {'autoload': {'filetypes': ['javascript']}} - NeoBundleLazy 'marijnh/tern_for_vim', {'autoload': {'filetypes': ['javascript']}, 'build': {'mac' : 'npm install'}} - - " C/C++ - "NeoBundle 'octol/vim-cpp-enhanced-highlight' - - " Other - NeoBundle 'tpope/vim-markdown' -" }}} - -" NeoBundleCheck -filetype indent plugin on - -" vim:set ft=vim: diff --git a/vim/rc/util.vim b/vim/rc/util.vim deleted file mode 100644 index e69de29b..00000000 diff --git a/vimrc b/vimrc index 21174a8a..c0e29a93 100644 --- a/vimrc +++ b/vimrc @@ -1,8 +1,5 @@ - set nocompatible -let g:is_ssh = ($SSH_TTY != "") - " Initialize NeoBundle set rtp+=~/.vim/bundle/neobundle.vim/ call neobundle#rc(expand('~/.vim/bundle')) @@ -164,17 +161,264 @@ NeoBundleFetch 'Shougo/neobundle.vim' au BufRead,BufNewFile *.scss set filetype=scss " }}} -" Bundles and their settings are specified externally. -source $HOME/.vim/rc/plugins.vim +""""""""""""""""""""""""""""""""""""""""" +" Packages/Bundles and their settings " +""""""""""""""""""""""""""""""""""""""""" +" {{{ + " File search {{{ + " More powerful file searching + if executable('ag') + NeoBundle 'rking/ag.vim' + elseif executable('ack') + NeoBundle 'mileszs/ack.vim' + endif -" rcfiles -source $HOME/.vim/rc/keymaps.vim -source $HOME/.vim/rc/util.vim + " Project-wide search and replace + " NeoBundle 'skwp/greplace.vim' -" If one exists, this is where you'll want local settings -try - source $HOME/.vimrc.local -catch -endtry + " Netrw improvements + NeoBundle 'scrooloose/nerdtree' + let NERDTreeMinimalUI = 1 + let NERDTreeChDirMode = 2 + " let NERDTreeBookmarksFile = "$HOME/.vim/tmp/NERDtreeBookmarks" + let NERDTreeIgnore = ['\~$', '\.swo$', '\.swp$', '\.git$', '\.hg', '\.svn', '\.bzr', '\.settings', '\.project', '\.DS_Store'] + let NERDTreeShowHidden = 1 + + " Command-T, Peepopen or Goto-anything, but for vim, written in VimL + NeoBundle 'kien/ctrlp.vim' + " Ctrlp extension for jumping to functions + NeoBundle 'tacahiroy/ctrlp-funky' + " Ctrlp extension for listing git modified files + NeoBundle 'jasoncodes/ctrlp-modified.vim' + let g:ctrlp_extensions = ['tag', 'buffertag', 'funky'] + " let g:ctrlp_max_height = 10 + let g:ctrlp_cache_dir = "~/.vim/tmp/ctrlp" + let g:ctrlp_custom_ignore = { + \ 'dir': '\.(git|hg|svn|settings)$|tmp$', + \ 'file': '\.(exe|so|dll|sass-cache|classpaths|project|cache|jpg|png|gif|swf)$' + \ } + let g:ctrlp_user_command = 'ag %s -l --nocolor -g ""' + let g:ctrlp_match_window = 'bottom,order:btt,min:10,max:10,results:10' + " }}} + + " Editing {{{ + " Extended visual mode commands, substitutes and searches + NeoBundle 'vis' + + " Auto-closes delimiters like (),{},[],etc. + NeoBundle 'Raimondi/delimitMate' + let g:delimitMate_expand_cr = 1 + let g:delimitMate_expand_space = 1 + + " HTML & CSS emmet goodness; Zen coding's successor + NeoBundle 'mattn/emmet-vim' + + " Clean way to close buffers without altering window layout + " NeoBundle 'mattdbridges/bufkill.vim' + NeoBundle 'moll/vim-bbye' + + " For aligning text + NeoBundle 'godlygeek/tabular' + + " Comment out code with native comment syntax + NeoBundle 'tomtom/tcomment_vim' + let g:tcomment_types = {'blade': '{-- %s --}', 'twig': '{# %s #}'} + + " Offers some plugins better compatibility with repeat ('.') + NeoBundle 'tpope/vim-repeat' + + " Easy changing and insertion of surrounding delimiters (e.g. quotes, + " parenthesis, etc.) + NeoBundle 'tpope/vim-surround' + + " Snippets system + if has("python") + NeoBundle 'SirVer/ultisnips' + + " My snippets + NeoBundle 'hlissner/vim-ultisnips-snippets' + endif + + " One-key switching between true/false, yes/no, etc + NeoBundle 'AndrewRadev/switch.vim' + " }}} + + " Remote resources {{{ + " Visual git diffs in the gutter + NeoBundle 'airblade/vim-gitgutter' + let g:gitgutter_realtime = 0 + let g:gitgutter_eager = 0 + " }}} + + " Programming {{{ + " Running code inline for testing purposes + NeoBundle 'notalex/vim-run-live' + " }}} + + " Syntax {{{ + " CSS/SCSS/LESS + NeoBundle 'cakebaker/scss-syntax.vim' + + " PHP + NeoBundleLazy 'StanAngeloff/php.vim', {'autoload': {'filetypes': ['php', 'blade']}} + NeoBundleLazy '2072/PHP-Indenting-for-VIm', {'autoload': {'filetypes': ['php']}} + " NeoBundleLazy 'stephpy/vim-phpdoc', {'autoload': {'filetypes': ['php']}} + + " Python + NeoBundleLazy 'klen/python-mode', {'autoload': {'filetypes': ['python']}} + + " Javascript/Node + NeoBundleLazy 'pangloss/vim-javascript', {'autoload': {'filetypes': ['javascript']}} + + " Other + NeoBundle 'tpope/vim-markdown' + " }}} + + " NeoBundleCheck + filetype indent plugin on +" }}} + +""""""""""""""""" +" Keymappings " +""""""""""""""""" +" {{{ + nnoremap v :CtrlP ~/.vim + + " Comma get some... sorry. + let mapleader = ',' + let maplocalleader = '\' + noremap ; : + + " Trigger to preserve indentation on pastes + set pastetoggle= + " Easier than escape. Pinnacle of laziness. + imap jk + " Turn off search highlighting + noremap ? :nohlsearch + + " Navigation {{{ + " Normalize all the navigation keys to move by row/col despite any wrapped text + noremap j gj + noremap k gk + " % matchit shortcut, but only in normal mode! + nmap % + " Easier fold toggle + nnoremap 5j + vnoremap 5j + nnoremap 5k + vnoremap 5k + + " f: Find. Also support repeating with . + nnoremap OriginalSemicolon ; + nnoremap f :call repeat#set("\Plug>OriginalSemicolon")f + nnoremap t :call repeat#set("\Plug>OriginalSemicolon")t + nnoremap F :call repeat#set("\Plug>OriginalSemicolon")F + nnoremap T :call repeat#set("\Plug>OriginalSemicolon")T + " }}} + + " Editing {{{ + nnoremap + " Insert-mode navigation + " Go to end of line + inoremap A + " Go to start of line + inoremap I + + " Make Y act consistant with C and D + nnoremap Y y$ + + " Don't leave visual mode after indenting + vnoremap < >gv + + " Textmate-like CMD+Enter (O in insert mode) + inoremap o + inoremap O + + " Enabling repeat in visual mode + vmap . :normal . + " }}} + + " Buffers {{{ + " Change CWD to current file's directory + nnoremap cd :cd %:p:h:pwd + + " Next/prev buffer + nnoremap ]b :bnext + nnoremap [b :bprevious + " }}} + + " Command {{{ + " Annoying command mistakes + com! -bang -nargs=* -complete=file E e + com! -bang -nargs=* -complete=file W w + com! -bang -nargs=* -complete=file Wq wq + com! -bang -nargs=* -complete=file WQ wq + com! -bang Wa wa + com! -bang WA wa + com! -bang Q q + com! -bang QA qa + com! -bang Qa qa + " Forget to sudo? + com! WW w !sudo tree % >/dev/null + + " Shortcuts + cnoremap ;/ =expand('%:p:h').'/' + cnoremap ;; =expand("%:t") + cnoremap ;. =expand("%:p:r") + + " Mimic shortcuts in the terminal + cnoremap + cnoremap + " }}} + + " External Tools {{{ + " Send cwd to tmux + nnoremap x :Tmux cd =expand("%:p:h") + nnoremap X :Tmux cd =expand("%:p:r") + " }}} + + " Plugins {{{ + " bufkill + nnoremap zz :Bdelete + + " CtrlP + let g:ctrlp_map = '' + " Only open CtrlP if the cwd ISN'T $HOME + nnoremap / getcwd() != $HOME ? ":CtrlPCurWD" : ":echoe 'Cannot open CtrlP in HOME'" + nnoremap . :CtrlPCurFile + nnoremap , :CtrlPBuffer + nnoremap ; :CtrlPFunky + nnoremap m :CtrlPMRU + nnoremap M :CtrlPModified + nnoremap t :CtrlPBufTag + nnoremap T :CtrlPBufTagAll + + " NERDTree + map \ :NERDTreeCWD + map . :NERDTreeFind + + " Tabularize + nmap = :Tabularize / + + " UltiSnips + let g:UltiSnipsExpandTrigger = "" + let g:UltiSnipsJumpForwardTrigger = "" + let g:UltiSnipsJumpBackwardTrigger = "" + " Ignore the default snippets so I (and others) can define their own + let g:UltiSnipsSnippetDirectories = ["snips"] + + " Emmet + imap emmet#expandAbbrIntelligent("\") + + " YCM + map g] :YcmCompleter GoToDefinitionElseDeclaration + let g:ycm_key_list_select_completion = ['', ''] + let g:ycm_key_list_previous_completion = ['', ''] + + " vim-switch + nnoremap ! :Switch + " }}} +" }}} " vim:set fdl=0 fdm=marker: