Skip to content

Instantly share code, notes, and snippets.

@yasuharu519
Last active August 29, 2015 14:01
Show Gist options
  • Save yasuharu519/18b9f4b577d18ea1215c to your computer and use it in GitHub Desktop.
Save yasuharu519/18b9f4b577d18ea1215c to your computer and use it in GitHub Desktop.
.vimrc
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
" _ "
" _ __(_)___ ___ __________ "
" | | / / / __ `__ \/ ___/ ___/ "
" | |/ / / / / / / / / / /__ "
" |___/_/_/ /_/ /_/_/ \___/ "
" "
"+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
"==============================================================================
" 一般設定
"==============================================================================
"{{{
set nocompatible " use Vim in more useful way"
set clipboard+=unnamed " share clipboard with other systems
let mapleader=',' " Lead with ,
nnoremap <space>v :<C-u>edit $HOME/dotfiles/dot_vimrc<CR> " vimファイルを開く
nnoremap <space>s :<C-u>source $HOME/.vimrc<CR> " vimファイルを反映する
"" Character encoding
set encoding=utf-8 " Use utf-8
set termencoding=utf-8 " ..
set fileencodings=utf-8 " ..
" Automatic end-of-file format detection
set fileformats=unix,mac,dos
"}}}
" プラグイン設定 "{{{
let $LUA_DLL="/your/path/to/lua_dll"
"}}}
" キーマッピングの変更
imap <C-j> <ESC>
"==============================================================================
" テキスト編集
"==============================================================================
"{{{
set autoindent " 改行時に自動インデント
set smartindent " {}などを入力時に同じ行にインデント
set wrap " テキストを改行して表示
" タブ関連
set tabstop=8 " Tabが対応する空白の数
set expandtab " Tabをスペースに変換
set nosmarttab " fuck tabs
set softtabstop=2 " Tab入力時の表示幅
set shiftwidth=2
set shiftround " インデントをshiftwidthの倍数に丸める
set infercase " 補完時に大文字小文字を区別しない
set formatoptions+=n " テキスト整形時に番号付きリストをサポート
set wrapmargin=0
set virtualedit=block " allow virtual edit in visual block ..
set listchars=tab:▸\ ,eol:¬,extends:»,precedes:«,nbsp:%
set nolist
set ambiwidth=double " 全角文字をASCIIの2倍の幅で表示する
set textwidth=0 " 改行が入らないようにする
if v:version >= 703
set colorcolumn=80 " 80字の部分でラインが表示されるように
endif
set foldmethod=marker " マーカーで折りたたみを行えるように
"}}}
"==============================================================================
" Undo機能
"==============================================================================
"{{{
"" Persistent undo
if has('persistent_undo')
set undodir=~/.vim/undo
set undofile
endif
"}}}
"==============================================================================
" タブ関連
"==============================================================================
"{{{
" Create new tab
cnoremap <C-t> <C-u>tabnew<CR>
nnoremap <C-h> :<C-u>tabprevious<CR>
nnoremap <C-l> :<C-u>tabnext<CR>
map <D-1> 1gt
map <D-2> 2gt
map <D-3> 3gt
map <D-4> 4gt
map <D-5> 5gt
map <D-6> 6gt
map <D-7> 7gt
map <D-8> 8gt
map <D-9> 9gt
map <D-0> :tablast<CR>
"}}}
"==============================================================================
" UI関連
"==============================================================================
"{{{
set ruler " show the cursor position all the time
" highlight cursor line in current window
augroup cch
autocmd!
autocmd WinLeave * set nocursorline
autocmd WinEnter,BufRead * set cursorline
augroup END
highlight clear CursorLine
highlight CursorLine ctermbg=black
set showcmd " コマンドの一部を画面下に表示
set number " 行番号の表示
set nolazyredraw " don't redraw while executing macros
set wildmenu " turn on wild menu
set wildmode=list:longest,full
set cmdheight=1 " コマンドライン行を1行に
" カーソルを左右させるキーのうち、ここで指定したものでは、
" カーソルが行頭/末にあるときに前/次行に移動できるようになる。
set whichwrap=b,s,h,l,<,>,[,]
" インサートモードですべて消す
set backspace=indent,eol,start
set shortmess=filtoOA " shorten messages
set report=0 " tell us about changes
set nostartofline " don't jump to the start of line when scrolling
set showmatch " brackets/braces that is
set matchtime=3 " duration to show matching brace (1/10 sec)
set laststatus=2 " The last window always have status line
set scrolloff=5 " Keep at least 5 lines above and below the cursor
set visualbell t_vb= " No beep sound
" Treat octal and hexadecimal number as decimal number
" octal Numbers that start with a zero will be considered to be octal
" Example: Using CTRL-A on "007" results in "010"
" hex Numbers starting with "0x" or "0X" will be considered to be hexadecimal
" Example: Using CTRL-X on "0x100" results in "0x0ff"
set nrformats-=octal,hex,alpha
if has("mouse") " Enable the use of the mouse in all modes
set mouse=a
endif
" フォーカスが移った場合に常にredraw
augroup Redraw
autocmd!
autocmd FocusGained * redraw!
augroup END
"}}}
"==============================================================================
" ウィンドウ操作
"==============================================================================
" ウィンドウの移動関連
" nnoremap <C-W><C-H> <C-W>H
" nnoremap <C-W><C-J> <C-W>J
" nnoremap <C-W><C-K> <C-W>K
" nnoremap <C-W><C-L> <C-W>L
" 横分割時は下へ、 縦分割時は右へ新しいウィンドウが開くようにする
set splitbelow
set splitright
"==============================================================================
" ハイライト関連
"==============================================================================
"{{{
syntax on
" 行末にスペースをハイライト
function! WhiteSpaceEOL()
highlight WhiteSpaceEOL ctermbg=red guibg=red
endfunction
" 全角文字をハイライト
function! ZenkakuSpace()
highlight ZenkakuSpace ctermbg=green guibg=green
endfunction
if has('syntax')
augroup WhiteSpaceEol
autocmd!
autocmd ColorScheme * call WhiteSpaceEOL()
autocmd VimEnter,WinEnter * match WhiteSpaceEOL /\s\+$/
augroup END
call WhiteSpaceEOL()
augroup ZenkakuSpace
autocmd!
autocmd ColorScheme * call ZenkakuSpace()
autocmd VimEnter,WinEnter * match ZenkakuSpace / /
augroup END
call ZenkakuSpace()
endif
"}}}
"==============================================================================
" バックアップ関連
"==============================================================================
"{{{
"" Backup
" backup current file, deleted afterwards
set backup
set writebackup
if !filewritable($HOME."/.vim-backup")
call mkdir($HOME."/.vim-backup", "p")
endif
set backupdir=$HOME/.vim-backup
if !filewritable($HOME."/.vim-swap")
call mkdir($HOME."/.vim-swap", "p")
endif
set directory=$HOME/.vim-swap
"}}}
"==============================================================================
" 検索関連
"==============================================================================
"{{{
"" Search
set history=100 " keep 100 lines of command line histories
set ignorecase
set smartcase
set wrapscan " Searches wrap around the end of the file
" While typing a search command, show where the pattern matches
set incsearch
set hlsearch " highlighting matches
" turn off highlight by Esc x 2
nmap <ESC><ESC> :<C-u>nohlsearch<CR><ESC>
augroup Search
autocmd!
autocmd QuickFixCmdPost *grep cwindow
augroup END
"}}}
"==============================================================================
" ファイル別設定
"==============================================================================
"" ftdetects
augroup FileTypeDetect "{{{
autocmd!
autocmd BufRead,BufNewFile *.java setfiletype java
autocmd BufRead,BufNewFile Capfile,Gemfile,Rakefile setfiletype ruby
autocmd BufRead,BufNewFile *.json setfiletype javascript
autocmd BufRead,BufNewFile *.md setfiletype markdown
autocmd BufRead,BufNewFile *.PL,*.psgi,*.t setfiletype perl
autocmd BufRead,BufNewFile .tmux.conf,tmux.conf setfiletype tmux
autocmd BufRead,BufNewFile *.jade setfiletype jade
autocmd BufRead,BufNewFile *.less setfiletype less
autocmd BufRead,BufNewFile *.coffee setfiletype coffee
autocmd BufRead,BufNewFile *.hatena setfiletype markdown
autocmd BufRead,BufNewFile *.pp setfiletype puppet
autocmd BufRead,BufNewFile *.scss setfiletype scss
autocmd BufRead,BufNewFile *.py setfiletype python
autocmd BufRead,BufNewFile *.html setfiletype html
autocmd BufRead,BufNewFile *.go setfiletype go
autocmd BufWritePre *.go Fmt
autocmd BufRead,BufNewFile *.tex setfiletype tex
autocmd BufWinEnter,BufNewFile *_spec.rb setfiletype ruby.rspec
augroup END
"}}}
augroup FileTypePlugin "{{{
autocmd!
autocmd FileType htmldjango setlocal ts=4 sts=4 sw=4
autocmd FileType int-gosh setlocal nonu
autocmd FileType int-pry setlocal nonu
autocmd FileType int-python setlocal nonu
autocmd FileType java setlocal ts=4 sts=4 sw=4
autocmd FileType markdown setlocal tw=0
autocmd FileType perl setlocal ts=4 sts=4 sw=4
autocmd FileType python setlocal completeopt-=preview ts=4 sts=4 sw=4 si cinw=if,elif,else,for,while,try,except,finally,def,class
autocmd FileType rst setlocal tw=0
autocmd FileType vim setlocal ts=4 sts=4 sw=4
autocmd FileType scss setlocal ts=4 sts=4 sw=4
autocmd FileType css setlocal ts=4 sts=4 sw=4
autocmd FileType vimfiler setlocal nonu
autocmd FileType vimshell setlocal nonu
autocmd FileType gitcommit setlocal textwidth=69
autocmd FileType tex setlocal spell
autocmd FileType cpp call s:cpp()
augroup END
"}}}
"==============================================================================
" NeoBundle設定
"=============================================================================
" {{{
filetype off
"""""""""" NeoBundle "{{{
if has('vim_starting')
set runtimepath+=~/.vim/bundle/neobundle.vim/
endif
call neobundle#rc(expand('~/.vim/bundle/'))
" Let NeoBundle manage NeoBundle
NeoBundleFetch 'Shougo/neobundle.vim'
NeoBundle 'Shougo/vimproc', {
\'build': {
\ 'windows' : 'make -f make_wingw32.mak',
\ 'cygwin' : 'make -f make_cygwin.mak',
\ 'mac' : 'make -f make_mac.mak',
\ 'unix' : 'make -f make_unix.mak',
\ },
\ }
" }}}
"==============================================================================
" カラースキーム
"=============================================================================
"""""""""" "{{{
NeoBundle "chriskempson/vim-tomorrow-theme"
colorscheme Tomorrow-night-bright
"}}}
"""""""""" Unite"{{{
NeoBundle 'Shougo/unite.vim'
NeoBundle 'taka84u9/unite-git'
NeoBundle 'Shougo/unite-outline'
NeoBundle 'Shougo/unite-help'
NeoBundle 'Shougo/neomru.vim'
let g:unite_enable_split_vertically = 1
let g:unite_winwidth = 50
let g:unite_enable_start_insert = 0
let g:unite_source_file_mru_ignore_pattern = '.*\/$\|.*Application\ Data.*'
nnoremap [unite] <Nop>
nmap <space>u [unite]
" カレントディレクトリ以下のファイル一覧
nnoremap <silent> [unite]u :<C-u>UniteWithBufferDir -start-insert -horizontal -buffer-name=files file file/new<CR>
" 最近開いたファイル一覧
nnoremap <silent> [unite]c :<C-u>UniteWithCurrentDir -horizontal -buffer-name=files buffer file_mru<CR>
" バッファ一覧
nnoremap <silent> [unite]i :<C-u>Unite -horizontal -buffer-name=files buffer_tab<CR>
" ブックマーク一覧
nnoremap <silent> [unite]b :<C-u>Unite -horizontal -buffer-name=files bookmark<CR>
" レジスタ内一覧
nnoremap <silent> [unite]r :<C-u>Unite -horizontal -buffer-name=register register<CR>
" nnoremap <silent> [unite]o :<C-u>Unite -vertical -no-quit -winwidth=30 -no-start-insert outline<CR>
" nnoremap <silent> [unite]t :<C-u>Unite -horizontal -immediately -horizontal tab:no-current<CR>
" 全部乗せ
nnoremap <silent> [unite]a :<C-u>UniteWithBufferDir -buffer-name=files buffer file_mru bookmark file<CR>
" アウトライン表示
nnoremap <silent> [unite]o :<C-u>Unite outline<CR>
" gitで変更された部分?
nnoremap <silent> [unite]m :<C-u>Unite -horizontal -no-empty git_modified<CR>
" grep検索
nnoremap <silent> [unite]g :<C-u>Unite grep:. -buffer-name=search-buffer -horizontal<CR>
" カーソル位置の単語をgrep検索
nnoremap <silent> [unite]wg :<C-u>Unite grep:. -buffer-name=search-buffer<CR><C-R><C-W>
" grep検索結果の再呼び出し
nnoremap <silent> [unite]rg :<C-u>UniteResume search-buffer<CR>
" nnoremap <silent> <C-g> :<C-u>Unite vcs_grep/git<CR>
" ヘルプの表示?
nnoremap <silent> [unite]<C-h> :<C-u>Unite -start-insert help<CR>
augroup UniteFileType
" ヘルプの表示
autocmd!
autocmd FileType vim nnoremap <silent><buffer> K :<C-u>Unite -start-insert -default-action=vsplit help<CR>
autocmd FileType sh nnoremap <silent><buffer> K :<C-u>Unite -start-insert -default-action=vsplit ref/man<CR>
autocmd FileType erlang nnoremap <silent><buffer> K :<C-u>Unite -start-insert -default-action=vsplit ref/erlang<CR>
autocmd FileType ruby nnoremap <silent><buffer> K :<C-u>Unite -start-insert -default-action=vsplit ref/ri<CR>
autocmd FileType python nnoremap <silent><buffer> K :<C-u>Unite -start-insert -default-action=vsplit ref/pydoc<CR>
autocmd FileType perl nnoremap <silent><buffer> K :<C-u>Unite -start-insert -default-action=vsplit ref/perldoc<CR>
autocmd FileType unite call s:unite_my_settings()
augroup END
function! s:unite_my_settings()
" Overwrite settings
nmap <buffer><ESC> <Plug>(unite_exit)
nmap <buffer><C-c> <Plug>(unite_exit)
"imap <buffer>jj <Plug>(unite_insert_leave)
imap <buffer><C-w> <Plug>(unite_delete_backward_path)
" <C-l>: manual neocomplecache completion.
inoremap <buffer><C-l> <C-x><C-u><C-p><Down>
nmap <buffer><expr><C-d> unite#do_action('delete')
imap <buffer><expr><C-d> unite#do_action('delete')
nmap <buffer><expr><C-b> unite#do_action('bookmark')
imap <buffer><expr><C-b> unite#do_action('bookmark')
nmap <buffer><expr><C-k> unite#do_action('above')
imap <buffer><expr><C-k> unite#do_action('above')
nmap <buffer><expr><C-i> unite#do_action('left')
imap <buffer><expr><C-i> unite#do_action('left')
endfunction
let g:unite_source_grep_max_candidates = 200
" unite grep に ag(The Silver Searcher) を使う
if executable('ag')
let g:unite_source_grep_command = 'ag'
let g:unite_source_grep_default_opts = '--nogroup --nocolor --column'
let g:unite_source_grep_recursive_opt = ''
endif
"}}}
""""""" Neocomplecache"{{{
if has('lua')
NeoBundle 'Shougo/neocomplete.vim'
NeoBundle 'Shougo/neosnippet'
NeoBundle 'Shougo/neosnippet-snippets'
nnoremap <leader>sp :NeoSnippetEdit<CR>
""""" NeoCompleteの設定"{{{
let g:neocompelte#ctags_command = '/your/path/to/ctags'
" Disable AutoComplPop.
let g:acp_enableAtStartup = 0
" Use neocomplete.
let g:neocomplete#enable_at_startup = 1
" Use smartcase.
let g:neocomplete#enable_smart_case = 1
" 補完を始めるキーワード長を長くする
let g:neocomplete#auto_completion_start_length = 4
let g:neocomplete#sources#syntax#min_keyword_length = 4
" 補完が止まった際に、スキップする長さを短くする
let g:neocomplete#skip_auto_completion_time = '0.2'
" let g:neocomplete#skip_auto_completion_time = ""
let g:neocomplete#lock_buffer_name_pattern = '\*ku\*'
" Define dictionary.
let g:neocomplete#dictionary_filetype_lists = {
\ 'default' : '',
\ 'perl' : $HOME.'/.vim/dict/perl.dict',
\ 'javascrip' : $HOME.'/.vim/dict/javascript.dict'
\ }
" Define keyword.
if !exists('g:neocomplete_keyword_patterns')
let g:neocomplete#keyword_patterns = {}
endif
let g:neocomplete#keyword_patterns['default'] = '\h\w*'
" Plugin key-mappings.
inoremap <expr><C-g> neocomplete#undo_completion()
inoremap <expr><C-l> neocomplete#complete_common_string()
" Recommended key-mappings.
" <CR>: close popup and save indent.
inoremap <silent> <CR> <C-r>=<SID>my_cr_function()<CR>
function! s:my_cr_function()
return neocomplete#smart_close_popup() . "\<CR>"
" For no inserting <CR> key.
"return pumvisible() ? neocomplete#close_popup() : "\<CR>"
endfunction
" <TAB>: completion
inoremap <expr><TAB> pumvisible() ? "\<C-n>" : "\<TAB>"
" <C-h>, <BS>: close popup and delete backword char.
inoremap <expr><C-h> neocomplete#smart_close_popup()."\<C-h>"
inoremap <expr><BS> neocomplete#smart_close_popup()."\<C-h>"
"inoremap <expr><C-y> neocomplete#close_popup()
inoremap <expr><C-k> neocomplete#close_popup()
inoremap <expr><C-e> neocomplete#cancel_popup()
" Enable omni completion.
autocmd FileType css setlocal omnifunc=csscomplete#CompleteCSS
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
" Enable heavy omni completion.
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
let g:neocomplete#sources#omni#input_patterns.perl = '\h\w*->\h\w*\|\h\w*::'
" 変換候補がなかった場合にエラーが出るのを非表示に
hi WarningMsg guifg=bg
"}}}
"""""""""" Javaの設定"{{{
" NeoBundleLazy 'vim-scripts/javacomplete', {
" \ 'build': {
" \ 'cygwin': 'javac autoload/Reflection.java',
" \ 'mac': 'javac autoload/Reflection.java',
" \ 'unix': 'javac autoload/Reflection.java',
" \ },
" \}
"}}}
""""" NeoSnippetの設定"{{{
" Plugin key-mappings.
imap <C-k> <Plug>(neosnippet_expand_or_jump)
smap <C-k> <Plug>(neosnippet_expand_or_jump)
xmap <C-k> <Plug>(neosnippet_expand_target)
" SuperTab like snippets behavior.
imap <expr><TAB> neosnippet#expandable() ? "\<Plug>(neosnippet_expand_or_jump)" : pumvisible() ? "\<C-n>" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable() ? "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For snippet_complete marker.
if has('conceal')
set conceallevel=2 concealcursor=i
endif
let g:neosnippet#snippets_directory='~/.vim/bundle/neosnippet-snippets/neosnippets/'
"}}}
else
NeoBundle 'Shougo/neocomplcache'
endif
"}}}
"""""""""" vimfiler"{{{
NeoBundle 'Shougo/vimfiler', {'depends': 'Shougo/unite.vim'}
let g:vimfiler_as_default_explorer = 1
let g:vimfiler_safe_mode_by_default = 0
nnoremap <silent><space>e :<C-u>VimFilerBufferDir -split -simple -winwidth=35 -toggle -no-quit<CR>
"}}}
"""""""""" choosewin"{{{
" http://d.hatena.ne.jp/t9md/20140112/1389542181
NeoBundle 't9md/vim-choosewin'
" '-' で呼び出し
nmap - <Plug>(choosewin)
" オーバーレイ機能を有効にする。
let g:choosewin_overlay_enable = 1
" オーバーレイ時、マルチバイト文字を含むバッファで、ラベル文字が崩れるのを防ぐ
let g:choosewin_overlay_clear_multibyte = 1
" tmux の色に雰囲気を合わせる。
let g:choosewin_color_overlay = {
\ 'gui': ['DodgerBlue3', 'DodgerBlue3' ],
\ 'cterm': [ 25, 25 ]
\ }
let g:choosewin_color_overlay_current = {
\ 'gui': ['firebrick1', 'firebrick1' ],
\ 'cterm': [ 124, 124 ]
\ }
let g:choosewin_blink_on_land = 0 " 頼むから着地時にカーソル点滅をさせないでくれ!
let g:choosewin_statusline_replace = 0 " どうかステータスラインリプレイスしないで下さい!
let g:choosewin_tabline_replace = 0 " どうかタブラインもリプレイスしないでいただきたい!
"}}}
NeoBundle 'thinca/vim-ref'
NeoBundle 'thinca/vim-localrc'
"""""""""" vim-surround"{{{
" 囲みタグの変更などを簡単に行うことができる
" cs"' : change surround " -> '
" cs'<q> : change surround ' -> <q>
" cst" : change surround tag -> "
" ds" : delete surround
NeoBundle "tpope/vim-surround"
"}}}
"""""""""" vim-unimpaired"{{{
" マッピングのペアを作成?
" ]q : :cnext
" [q : :cprevious
" ]a : :next
" [b : :bprevious
" [<Space> : addnewline
" ]<Space> : addnewline
" [os : :set spell
" ]os : :set nospel
" [x : encode XML(HTML)
" ]x : decode XML(HTML)
" [u : encode URL
" ]u : decode URL
" [y : C string style escaping
" ]y : C string style escaping
" [f : go to the previous file in the dictonary
" ]f : go to the next file in the directory
" [n : jump conflict marker
" ]n : jump conflict marker
NeoBundle 'tpope/vim-unimpaired'
"}}}
"""""""""" git関連"{{{
NeoBundle 'tpope/vim-fugitive'
NeoBundle 'airblade/vim-gitgutter'
let g:gitgutter_enabled = 0
let g:gitgutter_eager = 0
nnoremap <silent> ,gg :<C-u>GitGutterToggle<CR>
nnoremap <silent> ,gh :<C-u>GitGutterLineHighlightsToggle<CR>
nnoremap <silent> ,ga :<C-u>Gwrite<CR>
nnoremap <silent> ,gc :<C-u>Gcommit<CR>
nnoremap <silent> ,gs :<C-u>Gstatus<CR>
NeoBundle 'gregsexton/gitv'
augroup Gitv
autocmd!
autocmd FileType gitv call s:my_gitv_settings()
autocmd FileType git setlocal nofoldenable foldlevel=0
augroup END
function! s:gitv_get_current_hash()
return matchstr(getline('.'), '\[\zs.\{7\}\ze\]$')
endfunction
function! s:toggle_gitv_folding()
if &filetype ==# 'git'
setlocal foldenable!
endif
endfunction
function! s:my_gitv_settings()
setlocal iskeyword+=/,-,.
nnoremap <silent><buffer> C :<C-u>Git checkout <C-r><C-w><CR>
nnoremap <buffer> <Space>rb :<C-u>Git rebase <C-r>=<SID>gitv_get_current_hash()<CR><Space>
nnoremap <buffer> <Space>R :<C-u>Git revert <C-r>=<SID>gitv_get_current_hash()<CR><CR>
nnoremap <buffer> <Space>h :<C-u>Git cherry-pick <C-r>=<SID>gitv_get_current_hash()<CR><CR>
nnoremap <buffer> <Space>rh :<C-u>Git reset --hard <C-r>=<SID>gitv_get_current_hash()<CR>
nnoremap <silent><buffer> t :<C-u>windo call <SID>toggle_gitv_folding()<CR>1<C-w>w
endfunction
"}}}
"""""""""" vim-indent-guide"{{{
" インデントの数で色を変更する
NeoBundle 'nathanaelkane/vim-indent-guides'
" 自動カラーを無効にする
let g:indent_guides_auto_colors = 1
" 立ち上げ時にvim-indent-guidをオンにする
let g:indent_guides_enable_on_vim_startup = 1
let g:indent_guides_start_level = 2
let g:indent_guides_guide_size = 1
let g:indent_guides_color_change_percent = 10
let g:indent_guides_exclude_filetypes = ['help', 'nerdtree']"}}}
"""""""""" vim-easymotion"{{{
" 目的の行に相対的に素早く移動する
NeoBundle 'Lokaltog/vim-easymotion'
" ホームポジションに近いキーを使う
let g:EasyMotion_keys='hjklasdfgyuiopqwertnmzxcvbHJKLASDFGYUIOPQWERTNMZXCVB'
" 「;」 + 何かにマッピング
let g:EasyMotion_leader_key="<Space><Space>"
" 1 ストローク選択を優先する
let g:EasyMotion_grouping=1
" カラー設定変更
hi EasyMotionTarget ctermbg=none ctermfg=red
hi EasyMotionShade ctermbg=none ctermfg=blue
" let g:EasyMotion_mapping_j = '<C-<>'
" let g:EasyMotion_mapping_k = '<C->>'"}}}
"""""""""" powerline/lightline "{{{
" vim-powerline がdeprecatedになったということで、lightlineに変更
" NeoBundle 'Lokaltog/vim-powerline', 'develop'
" let g:Powerline_symbols = 'fancy'
NeoBundle 'cocopon/lightline-hybrid.vim'
NeoBundle 'itchyny/lightline.vim'
let g:lightline = {
\ 'colorscheme': 'hybrid',
\ 'component': {
\ 'readonly': '%{&filetype=="help"?"":&readonly?"⭤":""}',
\ 'modified': '%{&filetype=="help"?"":&modified?"+":&modifiable?"":"-"}'
\ },
\ 'separator': { 'left': '⮀', 'right': '⮂' },
\ 'subseparator': { 'left': '⮁', 'right': '⮃' }
\ }
"}}}
"""""""""" syntastic"{{{
" ファイルの構文エラーを確認してくれるプラグイン
" TODO: 動いているかあやしい
NeoBundle 'scrooloose/syntastic'
let g:syntastic_mode_map = { 'mode': 'passive',
\ 'active_filetypes': ['ruby', 'javascript', 'python', 'perl'],
\ 'passive_filetypes': [] }
let g:syntastic_ruby_checkers = ['mri', 'rubocop']
let g:syntastic_cpp_compiler = 'clang++'
let g:syntastic_cpp_compiler_options = ' -std=c++11 -stdlib=libc++'
"}}}
""""""""""" vim-seek"{{{
" f みたいに s で探してくれる
" sho で ho を探すみたいな
" 同じ行でしか動かないみたい
NeoBundle 'goldfeld/vim-seek'
"}}}
NeoBundle "Align"
"""""""""" ファイルシンタックス関連"{{{
""" ruby
NeoBundleLazy 'vim-ruby/vim-ruby', {'autoload': {'filetypes': ['ruby', 'eruby', 'haml']}}
NeoBundleLazy 'ruby-matchit', {'autoload': {'filetypes': ['ruby', 'eruby', 'haml']}}
NeoBundleLazy 'skwp/vim-rspec', {'autoload': {'filetypes': ['ruby']}}
NeoBundleLazy 'Keithbsmiley/rspec.vim', {'autoload': {'filetypes': ['ruby']}}
NeoBundleLazy 'taka84u9/vim-ref-ri', {
\ 'depends': ['Shougo/unite.vim', 'thinca/vim-ref'],
\ 'autoload': { 'filetypes': ['ruby', 'eruby', 'haml'] } }
""" html/sass/scss/javascript
" 書いた後にctrl+y,で展開
" 例えばhtml:5 など
NeoBundleLazy 'mattn/emmet-vim', {'autoload': {'filetypes': ['html', 'erb']}}
let g:user_emmet_settings = {
\ 'lang':'ja'
\ }
let g:user_emmet_leader_key=','
NeoBundleLazy 'pangloss/vim-javascript', {'autoload': {'filetypes': ['javascript']}}
let g:html_indent_inctags = "html,body,head,tbody"
let g:html_indent_script1 = "inc"
let g:html_indent_style1 = "inc"
NeoBundleLazy 'briancollins/vim-jst', {
\ 'autoload': {'filetypes': ['jst', 'ejs']},
\ 'depends': 'pangloss/vim-javascript' }
NeoBundleLazy 'groenewege/vim-less', {'autoload': {'filetypes': ['less']}}
NeoBundleLazy 'digitaltoad/vim-jade', {'autoload': {'filetypes': ['jade']}}
NeoBundleLazy 'cakebaker/scss-syntax.vim', {'autoload': {'filetypes': ['scss']}}
NeoBundleLazy 'kchmck/vim-coffee-script', {'autoload': {'filetypes': ['coffee']}}
augroup CoffeeScript
autocmd!
autocmd FileType coffee call s:my_coffee_settings()
augroup END
function! s:my_coffee_settings()
nnoremap <silent><buffer> <leader>c :<C-u>CoffeeCompile watch vertical<CR>
vnoremap <silent><buffer> <leader>c :<C-u>'<,'>CoffeeCompile vertical<CR>
endfunction
""" perl
NeoBundleLazy 'petdance/vim-perl', {'autoload': {'filetypes': ['perl']}}
""" document
NeoBundleLazy 'tpope/vim-markdown', {'autoload': {'filetypes': ['markdown']}}
""" others
NeoBundleLazy 'motemen/xslate-vim', {'autoload': {'filetypes': ['xslate']}}
NeoBundleLazy 'motemen/hatena-vim', {'autoload': {'filetypes': ['hatena']}}
NeoBundleLazy 'nginx.vim', {'autoload': {'filetypes': ['nginx']}}
NeoBundleLazy 'rodjek/vim-puppet', {'autoload': {'filetypes': ['puppet']}}
"}}}
"""""""""" vim-quickrun"{{{
NeoBundleLazy 'thinca/vim-quickrun', {'autoload': {'filetypes': ['ruby', 'python', 'perl', 'sh', 'go', 'cpp', 'c']}}
nmap <Leader>r <plug>(quickrun)
let g:quickrun_config = {}
let g:quickrun_config.perl = {'command': 'perl', 'cmdopt': '-MProject::Libs'}
let g:quickrun_config['ruby.rspec'] = {'command' : 'rspec'}
let g:quickrun_config.go = {
\ 'command': 'go',
\ 'exec': '%c run %s:p:t %a',
\ 'tempfile': '%{tempname()}.go',
\ 'hook/output_encode/encoding': 'utf-8',
\ 'hook/cd/directory': '%S:p:h'}
" let g:quickrun_config["java"] = {
" \ 'exec' : ['javac -J-Dfile.encoding=UTF8 %o %s', '%c -Dfile.encoding=UTF8 %s:t:r %a']
" \}
"}}}
"""""""""" vim-rails"{{{
" Railsのmodel, view, controllerなどを行き来できる
" TODO: コマンドなどを見る
NeoBundle 'tpope/vim-rails'
"}}}
"""""""""" vimdoc-ja"{{{
"" vim日本語helpを利用する
NeoBundle 'vim-jp/vimdoc-ja'
helptags ~/.vim/bundle/vimdoc-ja/doc
"}}}
"""""""""" VimShell"{{{
NeoBundle 'Shougo/vimshell'
" ,is: シェルを起動
nnoremap <silent> ,is :VimShell<CR>
" ,ipy: pythonを非同期で起動
nnoremap <silent> ,ipy :VimShellInteractive python<CR>
" ,irb: irbを非同期で起動
nnoremap <silent> ,irb :VimShellInteractive irb<CR>
" ,ss: 非同期で開いたインタプリタに現在の行を評価させる
vmap <silent> ,ss :VimShellSendString<CR>
" 選択中に,ss: 非同期で開いたインタプリタに選択行を評価させる
nnoremap <silent> ,ss <S-v>:VimShellSendString<CR>
"}}}
"""""""""" vim-gocode"{{{
NeoBundleLazy 'Blackrush/vim-gocode', {'autoload': {'filetypes': ['go']}}
"}}}
"""""""""" gocode"{{{
if $GOROOT != ''
set rtp+=$GOROOT/misc/vim
endif
exe "set rtp+=" . globpath($GOPATH, "src/github.com/golang/lint/misc/vim")
set completeopt=menu,preview
"}}}
"""""""""" TaskList.vim "{{{
NeoBundleLazy "vim-scripts/TaskList.vim", {
\ "autoload" : {
\ "mappings" : ['<Plug>TaskList'],
\ }}
nmap <Leader>t <plug>TaskList
" nnoremap <Leader>tn <ESC>O% TODO:
" noremap <silent> <Leader>tn :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
" }}}
"""""""""" tagbar {{{
NeoBundleLazy 'majutsushi/tagbar', {
\ "autoload": {
\ "commands": ["TagbarToggle"],
\ },
\ "build": {
\ "mac": "sudo port install ctags",
\ }}
let g:tagbar_ctags_bin='/your/path/to/ctags' " TODO: ctagをMacPortからインストール
nmap <Leader>T :TagbarToggle<CR>
" }}}
"""""""""" vim-repeat "{{{
NeoBundle 'tpope/vim-repeat.git'
silent! call repeat#set("\<Plug>MyWonderfulMap", v:count)
" }}}
"""""""""" vim-altr "{{{
NeoBundle 'kana/vim-altr'
nmap <F3> <Plug>(altr-forward)
nmap <F2> <Plug>(altr-back)
augroup VimAltrFileType
" ヘルプの表示
autocmd!
autocmd FileType ruby call altr#define('%.rb', 'spec/%_spec.rb')
autocmd FileType cpp call altr#define('%.cpp', '%.h')
augroup END
"}}}
"""""""""" sudo.vim "{{{
NeoBundle 'sudo.vim'
"}}}
"""""""""" jedi-vim "{{{
" NeoBundle 'davidhalter/jedi-vim'
" autocmd FileType python setlocal omnifunc=jedi#complete
"
" let g:jedi#auto_vim_configuration = 0
"
" if !exists('g:neocomplete#force_omni_input_patterns')
" let g:neocomplete#force_omni_input_patterns = {}
" endif
"
" let g:neocomplete#force_omni_input_patterns.python = '\h\w*\|[^. \t]\.\w*'
"}}}
"""""""""" vim-virtualenv "{{{
NeoBundleLazy 'jmcantrell/vim-virtualenv', {'autoload': {'filetypes': ['python']}}
"}}}
"""""""""" vim-over "{{{
NeoBundle 'osyo-manga/vim-over'
" over.vimの起動
nnoremap <silent> <Leader>m :OverCommandLine<CR>
" カーソル下の単語をハイライト付きで置換
nnoremap sub :OverCommandLine<CR>%s/<C-r><C-w>//g<Left><Left>
" コピーした文字列をハイライト付きで置換
nnoremap subp y:OverCommandLine<CR>%s!<C-r>=substitute(@0, '!', '\\!', 'g')<CR>!!gI<Left><Left><Left>
"}}}
"""""""""" yankround, ctrlp "{{{
NeoBundle 'LeafCage/yankround.vim'
NeoBundle 'kien/ctrlp.vim'
"" ctrlpの設定
" ctrlpを使用しない = yankroundのために使用する
let g:loaded_ctrlp = 1
"" キーマップ
nmap p <Plug>(yankround-p)
nmap P <Plug>(yankround-P)
nmap <C-p> <Plug>(yankround-prev)
nmap <C-n> <Plug>(yankround-next)
"" 履歴取得数
let g:yankround_max_history = 50
""履歴一覧(kien/ctrlp.vim)
nnoremap <silent>g<C-p> :<C-u>CtrlPYankRound<CR>
"}}}
"""""""""" hatenablog-vim "{{{
" $HOMEに.hateblo.vimを置いていてそこで設定
NeoBundle 'moznion/hateblo.vim', {
\ 'depends': ['mattn/webapi-vim', 'Shougo/unite.vim']
\ }
" "}}}
"""""""""" memolist.vim "{{{
NeoBundle 'glidenote/memolist.vim', {'depends': 'fuenor/qfixgrep'}
" qfixgrep の設定"{{{
"デフォルトで使用する外部grep
set grepprg=grep
"grepに含めたくない拡張子
let MyGrep_ExcludeReg = '[~#]$\|\.dll$\|\.exe$\|\.lnk$\|\.o$\|\.obj$\|\.pdf$\|\.xls$'
"大文字、小文字を気にせずに検索する。
let g:MyGrepDefault_Ignorecase = 1
""""}}}
nnoremap <Leader>mn :MemoNew<CR>
nnoremap <Leader>ml :MemoList<CR>
nnoremap <Leader>mg :MemoGrep<CR>
let g:memolist_path = $HOME."/VimMemo" "TODO: Dropboxに変更
let g:memolist_template_dir_path = $HOME."/VimMemo" "TODO: Dropboxに変更
" let g:memolist_vimfiler = 1
let g:memolist_qfixgrep = 1
let g:memolist_memo_suffix = "markdown"
let g:memolist_memo_date = "%Y-%m-%d %H:%M"
let g:memolist_prompt_tags = 1
let g:memolist_prompt_categories = 1
let g:memolist_unite = 1
let g:memolist_unite_source = "file_rec"
let g:memolist_unite_option = "-auto-preview -horizontal"
"}}}
"""""""""" previm"{{{
" :PreVimOpenで開く
NeoBundleLazy 'kannokanno/previm', {
\ 'autoload': {'filetypes': ['markdown']},
\ 'depends': 'tyru/open-browser.vim' }
"}}}
"""""""""" goyo.vim"{{{
NeoBundle 'junegunn/goyo.vim'
" lightlineのdisable
function! g:goyo_before()
call lightline#disable()
set statusline=
endfunction
function! g:goyo_after()
call lightline#enable()
endfunction
let g:goyo_callbacks = [function('g:goyo_before'), function('g:goyo_after')]
nnoremap <silent> <leader>z :Goyo<cr>
"}}}
"""""""""" vim-skuld"{{{
NeoBundle "l04m33/vim-skuld"
"}}}
"""""""""" threes.vim"{{{
NeoBundle "thinca/vim-threes"
"}}}
"""""""""" mrtazz/simplenote"{{{
NeoBundle "mrtazz/simplenote.vim"
" TODO: パスワードの設定行う必要あり
"}}}
"""""""""" mattn/sonictemplate-vim"{{{
NeoBundle "mattn/sonictemplate-vim"
let g:sonictemplate_vim_template_dir = $HOME."/.vim/template"
let g:sonictemplate_key = '<leader>it'
let g:sonictemplate_intelligent_key = '<leader>iT'
"}}}
"""""""""" postmail.vim"{{{
NeoBundle "vim-scripts/postmail.vim"
"}}}
"""""""""" t9md/vim-quickhl"{{{
NeoBundle "t9md/vim-quickhl"
" <Space>m でカーソル下の単語、もしくは選択した範囲のハイライトを行う
" 再度 <Space>m を行うとカーソル下のハイライトを解除する
" これは複数の単語のハイライトを行う事もできる
" <Space>M で全てのハイライトを解除する
nmap <Space>m <Plug>(quickhl-manual-this)
xmap <Space>m <Plug>(quickhl-manual-this)
nmap <Space>M <Plug>(quickhl-manual-reset)
xmap <Space>M <Plug>(quickhl-manual-reset)
"}}}
"""""""""" osyo-manga/vim-marching"{{{
" " http://d.hatena.ne.jp/osyo-manga/20131219/1387465034
NeoBundle "osyo-manga/vim-marching", {
\ 'depends' : ['Shougo/vimproc.vim', 'osyo-manga/vim-reunions'],
\ 'autoload' : {'filetypes' : ['c', 'cpp']}
\ }
let g:marching_clang_command="/your/path/to/clang"
let g:marching_clang_command_option="-std=c++1y"
let g:marching_include_paths = filter(
\ split(glob('/usr/include/c++/*'), '\n') +
\ split(glob('/usr/include/*/c++/*'), '\n') +
\ split(glob('/usr/lib/c++/*'), '\n'),
\ 'isdirectory(v:val)')
" neocomplete.vim と併用して使用する場合
" neocomplete.vim を使用すれば自動補完になる
let g:marching_enable_neocomplete=1
let g:marching_enable_refresh_always=1
let g:marching_enable_auto_select=0
if !exists('g:neocomplete#force_omni_input_patterns')
let g:neocomplete#force_omni_input_patterns = {}
endif
let g:neocomplete#force_omni_input_patterns.cpp =
\ '[^.[:digit:] *\t]\%(\.\|->\)\w*\|\h\w*::\w*'
" オムニ補完時に補完ワードを挿入したくない場合
imap <buffer> <C-x><C-o> <Plug>(marching_start_omni_complete)
" キャッシュを削除してからオムに補完を行う
imap <buffer> <C-x><C-x><C-o> <Plug>(marching_force_start_omni_complete)
set updatetime=200
"}}}
"""""""""" 名前空間の入力を簡単にする"{{{
" http://rhysd.hatenablog.com/entry/2013/12/10/233201#clang_complete
augroup cpp-namespace
autocmd!
autocmd FileType cpp inoremap <buffer><expr>; <SID>expand_namespace()
augroup END
function! s:expand_namespace()
let s = getline('.')[0:col('.')-1]
if s =~# '\<b;$'
return "\<BS>oost::"
elseif s =~# '\<s;$'
return "\<BS>td::"
elseif s =~# '\<d;$'
return "\<BS>etail::"
elseif s =~# '\<c;$'
return "\<BS>ocos2d::"
else
return ';'
endif
endfunction
"}}}
"""""""""" supermomonga/projectlocal.vim"{{{
NeoBundle 'supermomonga/projectlocal.vim'
"}}}
" =============================================================================
" C++ 用設定
" =============================================================================
" シンタックスハイライト
NeoBundleLazy 'vim-jp/cpp-vim', {
\ 'autoload' : {'filetypes': 'cpp'}
\ }
" フォーマッタ
" http://rhysd.hatenablog.com/entry/2013/12/10/233201#clang_format_py
NeoBundleLazy 'rhysd/vim-clang-format', {
\ 'autoload' : {'filetypes' : ['c', 'cpp', 'objc']},
\ 'depends' : ['kana/vim-operator-user', 'Shougo/vimproc.vim']
\ }
let g:clang_format#style_options = {
\ 'AccessModifierOffset' : -4,
\ 'AllowShortIfStatementsOnASingleLine' : 'true',
\ 'AlwaysBreakTemplateDeclarations' : 'true',
\ 'Standard' : 'C++11',
\ 'BreakBeforeBraces' : 'Stroustrup',
\ }
let g:clang_format#command = $HOME."/your/path/to/clang-format"
let g:clang_format#auto_format = 0
" Vim で C++ の設定例
" filetype=cpp が設定された時に呼ばれる関数
"Vim で C++ の設定を行う場合はこの関数内で記述する
" ここで設定する項目は各自好きに行って下さい
function! s:cpp()
" map to <Leader>cf in C++ code
nnoremap <buffer><Leader>cf :<C-u>ClangFormat<CR>
vnoremap <buffer><Leader>cf :ClangFormat<CR>
" if you install vim-operator-user
map <buffer><Leader>x <Plug>(operator-clang-format)
" 括弧を構成する設定に <> を追加する
setlocal matchpairs+=<:>
" 最後に定義された include 箇所へ移動してを挿入モードへ
nnoremap <buffer><silent> <Space>ii :execute "?".&include<CR> :noh<CR> o
inoremap <C-l> ->
endfunction
" 標準ライブラリへのパスを設定
let $CPP_STDLIB = "/usr/lib/c++/v1"
augroup vimrc-set_filetype_cpp
autocmd!
" $CPP_STDLIB よりも下の階層のファイルが開かれて
" filetype が設定されていない場合に filetype=cpp を設定する
autocmd BufReadPost $CPP_STDLIB/* if empty(&filetype) | set filetype=cpp | endif
augroup END
filetype plugin indent on
" Installation check
NeoBundleCheck
"}}}
"==============================================================================
" コメント設定
"=============================================================================
" Commenting blocks of code."{{{
autocmd FileType c,cpp,java,scala let b:comment_leader = '// '
autocmd FileType sh,ruby,python let b:comment_leader = '# '
autocmd FileType conf,fstab let b:comment_leader = '# '
autocmd FileType tex let b:comment_leader = '% '
autocmd FileType mail let b:comment_leader = '> '
autocmd FileType vim let b:comment_leader = '" '
autocmd FileType sql let b:comment_leader = '-- '
noremap <silent> ,cc :<C-B>silent <C-E>s/^/<C-R>=escape(b:comment_leader,'\/')<CR>/<CR>:nohlsearch<CR>
noremap <silent> ,cu :<C-B>silent <C-E>s/^\V<C-R>=escape(b:comment_leader,'\/')<CR>//e<CR>:nohlsearch<CR>
"}}}
"==============================================================================
" 個人用スクリプト
"=============================================================================
""" カレントディレクトリの移動"{{{
" Vim-users.jp - Hack #69: 簡単にカレントディレクトリを変更する http://vim-users.jp/2009/09/hack69/
command! -nargs=? -complete=dir -bang CD call s:ChangeCurrentDir('<args>', '<bang>')
function! s:ChangeCurrentDir(directory, bang)
if a:directory == ''
lcd %:p:h
else
execute 'lcd' . a:directory
endif
if a:bang == ''
pwd
endif
endfunction
" Change current directory.
nnoremap <silent> <Space>cd :<C-u>CD<CR>
"}}}
""" 選択位置で改行
nnoremap ,jj <ESC>i<CR><ESC>
""" 行の先頭、最後まで移動
inoremap <C-a> <ESC>0i
inoremap <C-e> <ESC>$a
""" vimのカーソル移動を表示行単位で行うように
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
nnoremap <Down> gj
nnoremap <Up> gk
nnoremap <C-j> j
nnoremap <C-k> k
""" sudo w
cabbrev sudo w !sudo tee %
""
" inoremap <C-l> ->
" vim: set filetype=vim :
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment