Skip to content

Instantly share code, notes, and snippets.

@alpaca-tc
Created January 13, 2013 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alpaca-tc/4521414 to your computer and use it in GitHub Desktop.
Save alpaca-tc/4521414 to your computer and use it in GitHub Desktop.
" neobundle"{{{
filetype plugin indent off " required!
" initialize"{{{
if has('vim_starting')
let bundle_dir = '~/.bundle'
if !isdirectory(bundle_dir.'/neobundle.vim')
call system( 'git clone https://github.com/Shougo/neobundle.vim.git '.bundle_dir.'/neobundle.vim')
endif
exe 'set runtimepath+='.bundle_dir.'/neobundle.vim'
call neobundle#rc(bundle_dir)
endif
augroup MyNeobundle
au!
au Syntax vim syntax keyword vimCommand NeoBundle NeoBundleLazy NeoBundleSource NeoBundleFetch
augroup END
"}}}
" 暫定customize {{{
function! Neo_al(ft) "{{{
return { 'autoload' : {
\ 'filetype' : a:ft
\ }}
endfunction"}}}
function! Neo_operator(mappings) "{{{
return {
\ 'depends' : 'kana/vim-textobj-user',
\ 'autoload' : {
\ 'mappings' : a:mappings
\ }}
endfunction"}}}
function! BundleLoadDepends(bundle_names) "{{{
if !exists('g:loaded_bundles')
let g:loaded_bundles = {}
endif
" bundleの読み込み
if !has_key( g:loaded_bundles, a:bundle_names )
execute 'NeoBundleSource '.a:bundle_names
let g:loaded_bundles[a:bundle_names] = 1
endif
endfunction"}}}
"}}}
" コマンドを伴うやつの遅延読み込み
function! BundleWithCmd(bundle_names, cmd) "{{{
call BundleLoadDepends(a:bundle_names)
" コマンドの実行
if !empty(a:cmd)
execute a:cmd
endif
endfunction "}}}
"bundle"{{{
" その他 {{{
NeoBundle 'Shougo/vimproc', {
\ 'build' : {
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
NeoBundleLazy 'taichouchou2/vim-endwise.git', {
\ 'autoload' : {
\ 'insert' : 1,
\ } }
" }}}
" 補完 {{{
NeoBundleLazy 'Shougo/neocomplcache', {
\ 'autoload' : {
\ 'insert' : 1,
\ }}
NeoBundleLazy 'Shougo/neosnippet', {
\ 'autoload' : {
\ 'insert' : 1,
\ }}
" TODO
NeoBundle 'Shougo/neocomplcache-rsense', {
\ 'depends': 'Shougo/neocomplcache',
\ 'autoload': { 'filetypes': 'ruby' }}
" }}}
" 便利 {{{
" 範囲指定のコマンドが使えないので、tcommentのLazy化はNeoBundleのアップデートを待ちましょう...
NeoBundle 'tomtom/tcomment_vim'
NeoBundleLazy 'tpope/vim-surround', {
\ 'autoload' : {
\ 'mappings' : [
\ ['nx', '<Plug>Dsurround'], ['nx', '<Plug>Csurround'],
\ ['nx', '<Plug>Ysurround'], ['nx', '<Plug>YSurround'],
\ ['nx', '<Plug>Yssurround'], ['nx', '<Plug>YSsurround'],
\ ['nx', '<Plug>YSsurround'], ['vx', '<Plug>VgSurround'],
\ ['vx', '<Plug>VSurround']
\ ]}}
" }}}
" ruby / railsサポート {{{
NeoBundle 'tpope/vim-rails'
NeoBundleLazy 'ujihisa/unite-rake', {
\ 'depends' : 'Shougo/unite.vim' }
NeoBundleLazy 'basyura/unite-rails', {
\ 'depends' : 'Shjkougo/unite.vim' }
NeoBundleLazy 'taichouchou2/unite-rails_best_practices', {
\ 'depends' : 'Shougo/unite.vim',
\ 'build' : {
\ 'mac': 'gem install rails_best_practices',
\ 'unix': 'gem install rails_best_practices',
\ }
\ }
NeoBundleLazy 'taichouchou2/unite-reek', {
\ 'build' : {
\ 'mac': 'gem install reek',
\ 'unix': 'gem install reek',
\ },
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] },
\ 'depends' : 'Shougo/unite.vim' }
NeoBundleLazy 'taichouchou2/alpaca_complete', {
\ 'depends' : 'tpope/vim-rails',
\ 'build' : {
\ 'mac': 'gem install alpaca_complete',
\ 'unix': 'gem install alpaca_complete',
\ }
\ }
let s:bundle_rails = 'unite-rails unite-rails_best_practices unite-rake alpaca_complete'
function! s:bundleLoadDepends(bundle_names) "{{{
" bundleの読み込み
execute 'NeoBundleSource '.a:bundle_names
au! MyAutoCmd
endfunction"}}}
aug MyAutoCmd
au User Rails call <SID>bundleLoadDepends(s:bundle_rails)
aug END
" reference環境
NeoBundleLazy 'vim-ruby/vim-ruby', {
\ 'autoload' : { 'filetypes': ['ruby', 'eruby', 'haml'] } }
NeoBundleLazy 'taka84u9/vim-ref-ri', {
\ 'depends': ['Shougo/unite.vim', 'thinca/vim-ref'],
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] } }
NeoBundleLazy 'skwp/vim-rspec', {
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] } }
NeoBundleLazy 'ruby-matchit', {
\ 'autoload' : { 'filetypes': ['ruby', 'eruby', 'haml'] } }
" }}}
" }}}
" Installation check. "{{{
if neobundle#exists_not_installed_bundles()
echomsg 'Not installed bundles : ' .
\ string(neobundle#get_not_installed_bundle_names())
echomsg 'Install Plugins'
NeoBundleInstall
endif
"}}}
filetype plugin indent on
"}}}
" plugin settings"{{{
"------------------------------------
" endwise.vim
"------------------------------------
"{{{
let g:endwise_no_mappings=1
"}}}
"------------------------------------
" vim-surround
"------------------------------------
" {{{
nmap ds <Plug>Dsurround
nmap cs <Plug>Csurround
nmap ys <Plug>Ysurround
nmap yS <Plug>YSurround
nmap yss <Plug>Yssurround
nmap ySs <Plug>YSsurround
nmap ySS <Plug>YSsurround
xmap S <Plug>VSurround
xmap gS <Plug>VgSurround
vmap s <Plug>VSurround
" surround_custom_mappings.vim"{{{
let g:surround_custom_mapping = {}
let g:surround_custom_mapping._ = {
\ 'p': "<pre> \r </pre>",
\ 'w': "%w(\r)",
\ }
let g:surround_custom_mapping.help = {
\ 'p': "> \r <",
\ }
let g:surround_custom_mapping.ruby = {
\ '-': "<% \r %>",
\ '=': "<%= \r %>",
\ '9': "(\r)",
\ '5': "%(\r)",
\ '%': "%(\r)",
\ 'w': "%w(\r)",
\ '#': "#{\r}",
\ '3': "#{\r}",
\ 'e': "begin \r end",
\ 'E': "<<EOS \r EOS",
\ 'i': "if \1if\1 \r end",
\ 'u': "unless \1unless\1 \r end",
\ 'c': "class \1class\1 \r end",
\ 'm': "module \1module\1 \r end",
\ 'd': "def \1def\1\2args\r..*\r(&)\2 \r end",
\ 'p': "\1method\1 do \2args\r..*\r|&| \2\r end",
\ 'P': "\1method\1 {\2args\r..*\r|&|\2 \r }",
\ }
let g:surround_custom_mapping.javascript = {
\ 'f': "function(){ \r }"
\ }
let g:surround_custom_mapping.lua = {
\ 'f': "function(){ \r }"
\ }
let g:surround_custom_mapping.python = {
\ 'p': "print( \r)",
\ '[': "[\r]",
\ }
let g:surround_custom_mapping.vim= {
\'f': "function! \r endfunction"
\ }
"}}}
"}}}
"------------------------------------
" neocomplcache
"------------------------------------
" 補完・履歴 neocomplcache "{{{
set infercase
"----------------------------------------
" neocomplcache
let g:neocomplcache_enable_at_startup = 1
" default config"{{{
let g:neocomplcache_force_overwrite_completefunc = 1
let g:neocomplcache#sources#rsense#home_directory = expand('~/.bundle/rsense-0.3')
let g:neocomplcache_enable_camel_case_completion = 1
let g:neocomplcache_enable_underbar_completion = 1
let g:neocomplcache_skip_auto_completion_time = '0.3'
"}}}
" keymap {{{
imap <expr><C-g> neocomplcache#undo_completion()
imap <expr><CR> neocomplcache#smart_close_popup() . "<CR>" . "<Plug>DiscretionaryEnd"
imap <silent><expr><S-TAB> pumvisible() ? "\<C-P>" : "\<S-TAB>"
" imap <silent><expr><TAB> pumvisible() ? "\<C-N>" : "\<TAB>"
imap <expr><TAB> neosnippet#expandable() ? "\<Plug>(neosnippet_jump_or_expand)" : pumvisible() ? "\<C-n>" : "\<TAB>"
" }}}
"}}}
"------------------------------------
" neosnippet
"------------------------------------
" neosnippet "{{{
" snippetを保存するディレクトリを設定してください
" example
" let s:default_snippet = neobundle#get_neobundle_dir() . '/neosnippet/autoload/neosnippet/snippets' " 本体に入っているsnippet
" let s:my_snippet = '~/snippet' " 自分のsnippet
" let g:neosnippet#snippets_directory = s:my_snippet
" let g:neosnippet#snippets_directory = s:default_snippet . ',' . s:my_snippet
imap <silent><C-F> <Plug>(neosnippet_expand_or_jump)
inoremap <silent><C-U> <ESC>:<C-U>Unite snippet<CR>
nnoremap <silent><Space>e :<C-U>NeoSnippetEdit -split<CR>
smap <silent><C-F> <Plug>(neosnippet_expand_or_jump)
" xmap <silent>o <Plug>(neosnippet_register_oneshot_snippet)
"}}}
"------------------------------------
" vim-rails
"------------------------------------
""{{{
"有効化
let g:rails_default_file='config/database.yml'
let g:rails_level = 4
let g:rails_mappings=1
let g:rails_modelines=0
" let g:rails_some_option = 1
" let g:rails_statusline = 1
" let g:rails_subversion=0
" let g:rails_syntax = 1
" let g:rails_url='http://localhost:3000'
" let g:rails_ctags_arguments='--languages=-javascript'
" let g:rails_ctags_arguments = ''
function! SetUpRailsSetting()
nnoremap <buffer><Space>r :R<CR>
nnoremap <buffer><Space>a :A<CR>
nnoremap <buffer><Space>m :Rmodel<Space>
nnoremap <buffer><Space>c :Rcontroller<Space>
nnoremap <buffer><Space>v :Rview<Space>
nnoremap <buffer><Space>p :Rpreview<CR>
endfunction
aug MyAutoCmd
au User Rails call SetUpRailsSetting()
aug END
aug RailsDictSetting
au!
aug END
"}}}
"------------------------------------
" Unite-rails.vim
"------------------------------------
"{{{
function! UniteRailsSetting()
nnoremap <buffer>[hoge]<C-H><C-H> :<C-U>Unite rails/view<CR>
nnoremap <buffer>[hoge]<C-H> :<C-U>Unite rails/model<CR>
nnoremap <buffer>[hoge] :<C-U>Unite rails/controller<CR>
nnoremap <buffer>[hoge]c :<C-U>Unite rails/config<CR>
nnoremap <buffer>[hoge]s :<C-U>Unite rails/spec<CR>
nnoremap <buffer>[hoge]m :<C-U>Unite rails/db -input=migrate<CR>
nnoremap <buffer>[hoge]l :<C-U>Unite rails/lib<CR>
nnoremap <buffer><expr>[hoge]g ':e '.b:rails_root.'/Gemfile<CR>'
nnoremap <buffer><expr>[hoge]r ':e '.b:rails_root.'/config/routes.rb<CR>'
nnoremap <buffer><expr>[hoge]se ':e '.b:rails_root.'/db/seeds.rb<CR>'
nnoremap <buffer>[hoge]ra :<C-U>Unite rails/rake<CR>
nnoremap <buffer>[hoge]h :<C-U>Unite rails/heroku<CR>
endfunction
aug MyAutoCmd
au User Rails call UniteRailsSetting()
aug END
"}}}
"----------------------------------------
" vim-ref
"----------------------------------------
"{{{
let g:ref_open = 'split'
let g:ref_refe_cmd = expand('~/.vim/ref/ruby-ref1.9.2/refe-1_9_2')
nnoremap rr :<C-U>Unite ref/refe -default-action=split -input=
nnoremap ri :<C-U>Unite ref/ri -default-action=split -input=
aug MyAutoCmd
au FileType ruby,eruby,ruby.rspec nnoremap <silent><buffer>KK :<C-U>Unite -no-start-insert ref/ri -input=<C-R><C-W><CR>
au FileType ruby,eruby,ruby.rspec nnoremap <silent><buffer>K :<C-U>Unite -no-start-insert ref/refe -input=<C-R><C-W><CR>
aug END
"}}}
"------------------------------------
" Unite-reek, Unite-rails_best_practices
"------------------------------------
" {{{
nnoremap <silent> [unite]<C-R> :<C-u>Unite -no-quit reek<CR>
nnoremap <silent> [unite]<C-R><C-R> :<C-u>Unite -no-quit rails_best_practices<CR>
" }}}
"}}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment