From bfdf5705bdb99ef650464769af39a507b3bdccdc Mon Sep 17 00:00:00 2001 From: hSATAC Date: Thu, 25 Apr 2013 12:06:57 +0800 Subject: [PATCH] Add ctrlp, vim-rails. Remove command-t --- .gitignore | 1 + .gitmodules | 6 + bundle/command-t | 1 - bundle/ctrlp | 1 + bundle/vim-rails | 1 + vimrc | 557 +++++++++++++++++++++++++---------------------- 6 files changed, 300 insertions(+), 267 deletions(-) delete mode 160000 bundle/command-t create mode 160000 bundle/ctrlp create mode 160000 bundle/vim-rails diff --git a/.gitignore b/.gitignore index 0d20b648..91994123 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *.pyc +.netrwhist diff --git a/.gitmodules b/.gitmodules index 774f114f..d9e9af39 100644 --- a/.gitmodules +++ b/.gitmodules @@ -70,3 +70,9 @@ path = bundle/vim-gitgutter url = https://github.com/airblade/vim-gitgutter.git ignore = untracked +[submodule "bundle/vim-rails"] + path = bundle/vim-rails + url = https://github.com/tpope/vim-rails.git +[submodule "bundle/ctrlp"] + path = bundle/ctrlp + url = https://github.com/kien/ctrlp.vim.git diff --git a/bundle/command-t b/bundle/command-t deleted file mode 160000 index d30099ca..00000000 --- a/bundle/command-t +++ /dev/null @@ -1 +0,0 @@ -Subproject commit d30099cac79dfdbc4a16d8279c5a2304b1494b2c diff --git a/bundle/ctrlp b/bundle/ctrlp new file mode 160000 index 00000000..287b9c12 --- /dev/null +++ b/bundle/ctrlp @@ -0,0 +1 @@ +Subproject commit 287b9c12aad2420269576504d1c05d36111a4562 diff --git a/bundle/vim-rails b/bundle/vim-rails new file mode 160000 index 00000000..74f407e2 --- /dev/null +++ b/bundle/vim-rails @@ -0,0 +1 @@ +Subproject commit 74f407e2f8d02dc6ff39ed370a25731d723e5cef diff --git a/vimrc b/vimrc index d0e3946d..b37f6fd9 100644 --- a/vimrc +++ b/vimrc @@ -19,6 +19,7 @@ set autoread " auto read when file is changed from outside set nu " display line number set ts=4 " tabstop 4 set wak=no " disable GUI alt menu +set noswapfile filetype on " Enable filetype detection filetype indent on " Enable filetype-specific indenting @@ -33,18 +34,18 @@ syntax on " syntax highlight set hlsearch " search highlighting if has("gui_running") " GUI color and font settings - if has("gui_gtk2") - set guifont=Bitstream\ Vera\ Sans\ Mono\ 13 - else - set guifont=Bitstream_Vera_Sans_Mono:h13 - endif - set background=dark - set t_Co=256 " 256 color mode - set cursorline " highlight current line - colors railscasts + if has("gui_gtk2") + set guifont=Bitstream\ Vera\ Sans\ Mono\ 13 + else + set guifont=Bitstream_Vera_Sans_Mono:h13 + endif + set background=dark + set t_Co=256 " 256 color mode + set cursorline " highlight current line + colors railscasts else - " terminal color settings - colors vgod + " terminal color settings + colors vgod endif set clipboard=unnamed " yank to the system register (*) by default @@ -69,12 +70,12 @@ set noerrorbells set novisualbell set t_vb= set tm=500 - + " TAB setting{ "set expandtab "replace with spaces set softtabstop=4 set shiftwidth=4 - + au FileType Makefile set noexpandtab "} @@ -86,16 +87,16 @@ set statusline+=\ \ \ %<%20.30(%{hostname()}:%{CurDir()}%)\ set statusline+=%=%-10.(%l,%c%V%)\ %p%%/%L function! CurDir() - let curdir = substitute(getcwd(), $HOME, "~", "") - return curdir + let curdir = substitute(getcwd(), $HOME, "~", "") + return curdir endfunction function! HasPaste() - if &paste - return '[PASTE]' - else - return '' - endif + if &paste + return '[PASTE]' + else + return '' + endif endfunction "} @@ -104,256 +105,280 @@ endfunction " C/C++ specific settings autocmd FileType c,cpp,cc set cindent comments=sr:/*,mb:*,el:*/,:// cino=>s,e0,n0,f0,{0,}0,^-1s,:0,=s,g0,h1s,p2,t0,+2,(2,)20,*30 + " Python "autocmd BufNewFile,BufRead *.py set ts=2 sts=2 sw=2 noet +" Ruby +autocmd FileType ruby,eruby,yaml set softtabstop=2 shiftwidth=2 tabstop=2 + "Restore cursor to file position in previous editing session set viminfo='10,\"100,:20,%,n~/.viminfo au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif - "--------------------------------------------------------------------------- - " Tip #382: Search for and replace with input() in all open buffers - "--------------------------------------------------------------------------- - fun! Replace() - let s:word = input("Replace " . expand('') . " with:") - :exe 'bufdo! %s/\<' . expand('') . '\>/' . s:word . '/ge' - :unlet! s:word - endfun - - - "--------------------------------------------------------------------------- - " USEFUL SHORTCUTS - "--------------------------------------------------------------------------- - " set leader to , - let mapleader="," - let g:mapleader="," - - "replace the current word in all opened buffers - map r :call Replace() - - " --- move around splits { - " move to and maximize the below split - map j_ - " move to and maximize the above split - map k_ - " move to and maximize the left split - nmap h - " move to and maximize the right split - nmap l - set wmw=0 " set the min width of a window to 0 so we can maximize others - set wmh=0 " set the min height of a window to 0 so we can maximize others - " } - - " move around tabs. conflict with the original screen top/bottom - " comment them out if you want the original H/L - " go to prev tab - map gT - " go to next tab - map gt - map gt - - " new tab - map :tabnew - " close tab - map :tabclose - - if(has("gui_running") && !has("mac")) " gvim win 32 and gvim linux - map ÷ :tabclose - endif - if(has("gui_macvim") && !has("gui_running")) " macvim console - map w :tabclose - endif - - " ,/ turn off search highlighting - nmap / :nohl - - " Bash like keys for the command line - cnoremap - cnoremap - cnoremap - - " ,p toggles paste mode - nmap p :set paste!set paste? - - " allow multiple indentation/deindentation in visual mode - vnoremap < >gv - - " :cd. change working directory to that of the current file - cmap cd. lcd %:p:h - - " Writing Restructured Text (Sphinx Documentation) { - " Ctrl-u 1: underline Parts w/ #'s - noremap 1 yyPVr#yyjp - inoremap 1 yyPVr#yyjpA - " Ctrl-u 2: underline Chapters w/ *'s - noremap 2 yyPVr*yyjp - inoremap 2 yyPVr*yyjpA - " Ctrl-u 3: underline Section Level 1 w/ ='s - noremap 3 yypVr= - inoremap 3 yypVr=A - " Ctrl-u 4: underline Section Level 2 w/ -'s - noremap 4 yypVr- - inoremap 4 yypVr-A - " Ctrl-u 5: underline Section Level 3 w/ ^'s - noremap 5 yypVr^ - inoremap 5 yypVr^A - "} - - - - - "--------------------------------------------------------------------------- - " PROGRAMMING SHORTCUTS - "--------------------------------------------------------------------------- - - " Ctrl-[ jump out of the tag stack (undo Ctrl-]) - map :po - - " ,g generates the header guard - map g :call IncludeGuard() - fun! IncludeGuard() - let basename = substitute(bufname(""), '.*/', '', '') - let guard = '_' . substitute(toupper(basename), '\.', '_', "H") - call append(0, "#ifndef " . guard) - call append(1, "#define " . guard) - call append( line("$"), "#endif // for #ifndef " . guard) - endfun - - - - " enable omni completion. (ctrl-x ctrl-o) - set cot=menuone,preview - autocmd insertleave * if pumvisible() == 0|pclose|endif - autocmd filetype html,markdown setlocal omnifunc=htmlcomplete#Completetags - autocmd filetype javascript setlocal omnifunc=javascriptcomplete#CompleteJS - autocmd filetype python setlocal omnifunc=pythoncomplete#Complete - autocmd filetype xml setlocal omnifunc=xmlcomplete#completetags - autocmd filetype css set omnifunc=csscomplete#CompleteCSS - autocmd filetype c set omnifunc=ccomplete#Complete - autocmd filetype java set omnifunc=javacomplete#Complete - autocmd filetype php set omnifunc=phpcomplete#CompletePHP - autocmd FileType ruby set omnifunc=rubycomplete#Complete - - " use syntax complete if nothing else available - if has("autocmd") && exists("+omnifunc") - autocmd Filetype * - \ if &omnifunc == "" | - \ setlocal omnifunc=syntaxcomplete#Complete | - \ endif - endif - - - " make CSS omnicompletion work for SASS and SCSS - autocmd BufNewFile,BufRead *.scss set ft=scss.css - autocmd BufNewFile,BufRead *.sass set ft=sass.css - - "--------------------------------------------------------------------------- - " ENCODING SETTINGS - "--------------------------------------------------------------------------- - - set encoding=utf-8 - set fileencodings=utf-8,chinese,latin-1 - "if has("win32") - " set fileencoding=chinese - "else - " set fileencoding=utf-8 - "endif - set fileencoding=utf-8 - source $VIMRUNTIME/delmenu.vim - source $VIMRUNTIME/menu.vim - "language messages zh_TW.utf-8 - - "--------------------------------------------------------------------------- - " PLUGIN SETTINGS - "--------------------------------------------------------------------------- - - " --- AutoClose - Inserts matching bracket, paren, brace or quote - " fixed the arrow key problems caused by AutoClose - if !has("gui_running") - set term=linux - set t_k1=[11~ - set t_k2=[11~ - set t_k3=[11~ - set t_k4=[11~ - imap OA ki - imap OB ji - imap OC li - imap OD hi - - nmap OA k - nmap OB j - nmap OC l - nmap OD h - if $TERM =~ 'xterm' - set =OP - set =OQ - set =OR - set =OS - set =OH - set =OF - endif - if $TERM =~ 'screen' - set =OP - set =OQ - set =OR - set =OS - endif - endif - - - " --- SuperTab - "let g:SuperTabDefaultCompletionType = "context" - let g:SuperTabDefaultCompletionType = "" - - " --- Command-T - let g:CommandTMaxHeight = 15 - if(has("gui_running")) - if(has("win32")) " win32 gvim - map :CommandTFlush\|:CommandT - elseif(has("mac")) "mac gvim - map :CommandTFlush\|:CommandT - else " linux gvim - map ô :CommandTFlush\|:CommandT - endif - endif - if(!has("gui_running")) - map t :CommandTFlush\|:CommandT - endif - " double percentage sign in command mode is expanded - " to directory of current file - http://vimcasts.org/e/14 - cnoremap %% =expand('%:h').'/' - - map f :CommandTFlush\|:CommandT - map F :CommandTFlush\|:CommandT %% - - " switch between files - nnoremap - - " --- taglist - nmap :TlistToggle - imap :TlistToggle - let Tlist_Use_SingleClick = 1 - let Tlist_Use_Right_Window = 1 - let Tlist_Show_One_File = 1 - let tlist_php_settings = 'php;c:class;d:constant;f:function' - " --- tagbar - nnoremap :TagbarToggle - let g:tagbar_autofocus = 1 - - " --- nerdtree - nnoremap :NERDTreeToggle - - " --- Zoom.vim - - if(has("gui_running") && has("win32")) " gvim win 32 - map :ZoomIn - map :ZoomOut - map :ZoomReset - endif - if(has("gui_macvim") && !has("gui_running")) " macvim console - endif - - " --- SingleCompile - nmap :SCCompile - nmap :SCCompileRun + "--------------------------------------------------------------------------- + " Tip #382: Search for and replace with input() in all open buffers + "--------------------------------------------------------------------------- + fun! Replace() + let s:word = input("Replace " . expand('') . " with:") + :exe 'bufdo! %s/\<' . expand('') . '\>/' . s:word . '/ge' + :unlet! s:word + endfun + + + "--------------------------------------------------------------------------- + " USEFUL SHORTCUTS + "--------------------------------------------------------------------------- + " set leader to , + let mapleader="," + let g:mapleader="," + + "replace the current word in all opened buffers + map r :call Replace() + + " --- move around splits { + " move to and maximize the below split + map j_ + " move to and maximize the above split + map k_ + " move to and maximize the left split + nmap h + " move to and maximize the right split + nmap l + set wmw=0 " set the min width of a window to 0 so we can maximize others + set wmh=0 " set the min height of a window to 0 so we can maximize others + " } + + " move around tabs. conflict with the original screen top/bottom + " comment them out if you want the original H/L + " go to prev tab + map gT + " go to next tab + map gt + map gt + + " new tab + map :tabnew + " close tab + map :tabclose + + if(has("gui_running") && !has("mac")) " gvim win 32 and gvim linux + map ÷ :tabclose + endif + if(has("gui_macvim") && !has("gui_running")) " macvim console + map w :tabclose + endif + + " ,/ turn off search highlighting + nmap / :nohl + + " Bash like keys for the command line + cnoremap + cnoremap + cnoremap + + " ,p toggles paste mode + nmap p :set paste!set paste? + + " allow multiple indentation/deindentation in visual mode + vnoremap < >gv + + " :cd. change working directory to that of the current file + cmap cd. lcd %:p:h + + " Writing Restructured Text (Sphinx Documentation) { + " Ctrl-u 1: underline Parts w/ #'s + noremap 1 yyPVr#yyjp + inoremap 1 yyPVr#yyjpA + " Ctrl-u 2: underline Chapters w/ *'s + noremap 2 yyPVr*yyjp + inoremap 2 yyPVr*yyjpA + " Ctrl-u 3: underline Section Level 1 w/ ='s + noremap 3 yypVr= + inoremap 3 yypVr=A + " Ctrl-u 4: underline Section Level 2 w/ -'s + noremap 4 yypVr- + inoremap 4 yypVr-A + " Ctrl-u 5: underline Section Level 3 w/ ^'s + noremap 5 yypVr^ + inoremap 5 yypVr^A + "} + + + + + "--------------------------------------------------------------------------- + " PROGRAMMING SHORTCUTS + "--------------------------------------------------------------------------- + + " Ctrl-[ jump out of the tag stack (undo Ctrl-]) + map :po + + " ,g generates the header guard + map g :call IncludeGuard() + fun! IncludeGuard() + let basename = substitute(bufname(""), '.*/', '', '') + let guard = '_' . substitute(toupper(basename), '\.', '_', "H") + call append(0, "#ifndef " . guard) + call append(1, "#define " . guard) + call append( line("$"), "#endif // for #ifndef " . guard) + endfun + + + + " enable omni completion. (ctrl-x ctrl-o) + set cot=menuone,preview + autocmd insertleave * if pumvisible() == 0|pclose|endif + autocmd filetype html,markdown setlocal omnifunc=htmlcomplete#Completetags + autocmd filetype javascript setlocal omnifunc=javascriptcomplete#CompleteJS + autocmd filetype python setlocal omnifunc=pythoncomplete#Complete + autocmd filetype xml setlocal omnifunc=xmlcomplete#completetags + autocmd filetype css set omnifunc=csscomplete#CompleteCSS + autocmd filetype c set omnifunc=ccomplete#Complete + autocmd filetype java set omnifunc=javacomplete#Complete + autocmd filetype php set omnifunc=phpcomplete#CompletePHP + autocmd FileType ruby set omnifunc=rubycomplete#Complete + + " use syntax complete if nothing else available + if has("autocmd") && exists("+omnifunc") + autocmd Filetype * + \ if &omnifunc == "" | + \ setlocal omnifunc=syntaxcomplete#Complete | + \ endif + endif + + + " make CSS omnicompletion work for SASS and SCSS + autocmd BufNewFile,BufRead *.scss set ft=scss.css + autocmd BufNewFile,BufRead *.sass set ft=sass.css + + "--------------------------------------------------------------------------- + " ENCODING SETTINGS + "--------------------------------------------------------------------------- + + set encoding=utf-8 + set fileencodings=utf-8,chinese,latin-1 + "if has("win32") + " set fileencoding=chinese + "else + " set fileencoding=utf-8 + "endif + set fileencoding=utf-8 + source $VIMRUNTIME/delmenu.vim + source $VIMRUNTIME/menu.vim + "language messages zh_TW.utf-8 + + "--------------------------------------------------------------------------- + " PLUGIN SETTINGS + "--------------------------------------------------------------------------- + + " --- AutoClose - Inserts matching bracket, paren, brace or quote + " fixed the arrow key problems caused by AutoClose + if !has("gui_running") + set term=linux + set t_k1=[11~ + set t_k2=[11~ + set t_k3=[11~ + set t_k4=[11~ + imap OA ki + imap OB ji + imap OC li + imap OD hi + + nmap OA k + nmap OB j + nmap OC l + nmap OD h + if $TERM =~ 'xterm' + set =OP + set =OQ + set =OR + set =OS + set =OH + set =OF + endif + if $TERM =~ 'screen' + set =OP + set =OQ + set =OR + set =OS + endif + endif + + + " --- SuperTab + "let g:SuperTabDefaultCompletionType = "context" + "let g:SuperTabDefaultCompletionType = "" + + " --- Command-T + let g:CommandTMaxHeight = 15 + if(has("gui_running")) + if(has("win32")) " win32 gvim + map :CommandTFlush\|:CommandT + elseif(has("mac")) "mac gvim + map :CommandTFlush\|:CommandT + else " linux gvim + map ô :CommandTFlush\|:CommandT + endif + endif + if(!has("gui_running")) + map t :CommandTFlush\|:CommandT + endif + " double percentage sign in command mode is expanded + " to directory of current file - http://vimcasts.org/e/14 + cnoremap %% =expand('%:h').'/' + + "map f :CommandTFlush\|:CommandT + "map F :CommandTFlush\|:CommandT %% + + " switch between files + nnoremap + + " --- ctrlp + map f :CtrlP + + " --- taglist + nmap :TlistToggle + imap :TlistToggle + let Tlist_Use_SingleClick = 1 + let Tlist_Use_Right_Window = 1 + let Tlist_Show_One_File = 1 + let tlist_php_settings = 'php;c:class;d:constant;f:function' + " --- tagbar + nnoremap :TagbarToggle + let g:tagbar_autofocus = 1 + + " --- nerdtree + nnoremap :NERDTreeToggle + + " --- Zoom.vim + + if(has("gui_running") && has("win32")) " gvim win 32 + map :ZoomIn + map :ZoomOut + map :ZoomReset + endif + if(has("gui_macvim") && !has("gui_running")) " macvim console + endif + + " --- SingleCompile + nmap :SCCompile + nmap :SCCompileRun + + " --- VimRails + + let g:rails_projections = { + \ "app/presenters/*.rb": { "command": "presenters" }, + \ "spec/factories/*.rb": {"command": "factories"}, + \ "spec/factories/fields/*.rb": {"command": "factories"}, + \ "spec/features/*.rb": {"command": "features"}, + \ "spec/support/*.rb": {"command": "supports"}, + \ "app/extras/form_object/*.rb": {"command": "forms"}, + \ "app/extras/service/*.rb": {"command": ["services", "forms", "models"]}, + \ "app/extras/view_object/*.rb": {"command": "views"}, + \ "app/models/fields/*.rb": {"command": "fields"}, + \ "app/models/fields_data/*.rb": {"command": "fields"}, + \ "app/models/reports/*.rb": {"command": "reports"} + \ } +