Last active
October 20, 2015 03:17
-
-
Save pddg/a0d02800153aec4a5514 to your computer and use it in GitHub Desktop.
pudding's .vimrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" release autogroup in MyAutoCmd | |
augroup MyAutoCmd | |
autocmd! | |
augroup END | |
"-----------表示設定---------- | |
set number "行番号表示 | |
set showmatch "括弧入力時の対応する括弧を表示 | |
syntax on "コードの色分け | |
set matchtime=3 "ハイライト時間を3秒に | |
set tabstop=4 "インデントをスペース4つ分に設定 | |
set hlsearch | |
set backspace=indent,eol,start | |
set wrap "文字列折り返し | |
set shiftwidth=2 | |
"スクリーンベル無効化 | |
set t_vb= | |
set novisualbell | |
"lightline用の設定 | |
set laststatus=2 | |
set t_Co=256 | |
"----------編集系----------- | |
set matchpairs& matchpairs+=<:> | |
"SwapとBackUpの無効化 | |
set nowritebackup | |
set nobackup | |
set noswapfile | |
"キーバインド | |
let mapleader = "\<Space>" | |
" 入力モード中に素早くjjと入力した場合はESCとみなす | |
inoremap jj <Esc> | |
" ESCを二回押すことでハイライトを消す | |
nmap <silent> <Esc><Esc> :nohlsearch<CR> | |
" 検索後にジャンプした際に検索単語を画面中央に持ってくる | |
nnoremap n nzz | |
nnoremap N Nzz | |
nnoremap * *zz | |
nnoremap # #zz | |
nnoremap g* g*zz | |
nnoremap g# g#zz | |
" j, k による移動を折り返されたテキストでも自然に振る舞うように変更 | |
nnoremap j gj | |
nnoremap k gk | |
" vを二回で行末まで選択 | |
vnoremap v $h | |
" Shift + 矢印でウィンドウサイズを変更 | |
nnoremap <S-Left> <C-w><<CR> | |
nnoremap <S-Right> <C-w>><CR> | |
nnoremap <S-Up> <C-w>-<CR> | |
nnoremap <S-Down> <C-w>+<CR> | |
"pyenvのパスを追加 | |
let PATH = expand("~/.pyenv/shims") . ":" . $PATH | |
"----------NeoBundle---------- | |
if 0 | endif | |
if has('vim_starting') | |
if &compatible | |
set nocompatible | |
endif | |
set runtimepath+=~/.vim/bundle/neobundle.vim | |
endif | |
call neobundle#begin(expand('~/.vim/bundle/')) | |
"NeoBundleに自身を管理させる | |
NeoBundleFetch 'Shougo/neobundle.vim' | |
"--------ここからプラグインを記述-------- | |
"統合インターフェース | |
NeoBundle 'Shougo/unite.vim', { | |
\ "autoload": { | |
\ "commands": ["Unite", "UniteWithBufferDir"] | |
\}} | |
NeoBundle 'h1mesuke/unite-outline', { | |
\ "autoload": { | |
\ "unite_sources": ["outline"], | |
\}} | |
"ファイラーはvimfilerかNERDTreeがいいと思います | |
NeoBundle 'Shougo/vimfiler',{ | |
\"depends":["Shougo/unite.vim"], | |
\"autoload": { | |
\ "commands":["VimFilterTab", "VimFilter", "VimFileExplorer"], | |
\ "mappings":['<Plug>(vimfiler_switch)'], | |
\ "explorer":1, | |
\}} | |
NeoBundle 'Shougo/vimproc', { | |
\"build": { | |
\"mac":"make -f make_mac.mak", | |
\"unix":"make -f make_unix.mak", | |
\}} | |
"NeoBundle 'scrooloose/nerdtree' | |
"テキスト編集系 | |
NeoBundle 'Townk/vim-autoclose' "括弧とかを自動で入れてくれる | |
NeoBundle 'tomtom/tcomment_vim' "複数行一気にコメントアウトとか | |
NeoBundle 'tpope/vim-surround' "括弧入力 | |
"シンタックスチェック | |
NeoBundle 'scrooloose/syntastic' | |
"ステータス表示 | |
NeoBundle 'itchyny/lightline.vim' | |
"補完機能 | |
if has('lua') && v:version >= 703 && has('patch885') | |
NeoBundleLazy "Shougo/neocomplete.vim", { | |
\ "autoload": { | |
\ "insert": 1, | |
\ }} | |
"neocompleteの設定 | |
let g:neocomplete#enable_at_startup = 1 | |
let s:hooks = neobundle#get_hooks("neocomplete.vim") | |
function! s:hooks.on_source(bundle) | |
let g:acp_enableAtStartup = 0 | |
let g:neocomplete#enable_smart_case = 1 | |
endfunction | |
else | |
NeoBundleLazy "Shougo/neocomplcache.vim", { | |
\"autoload": { | |
\ "insert": 1, | |
\}} | |
"neocomplacheの設定 | |
let g:neocomplcache_enable_at_startup = 1 | |
let s:hooks = neobundle#get_hooks("neocomplcache.vim") | |
function! s:hooks.on_source(bundle) | |
let g:acp_enableAtStartup = 0 | |
let g:neocomplcache_enable_smart_case = 1 | |
endfunction | |
endif | |
"Python用の補完プラグイン | |
NeoBundleLazy 'davidhalter/jedi-vim', { | |
\"autoload": { | |
\ "filetypes": ["python", "python3", "djangohtml"], | |
\}, | |
\"build": { | |
\"mac":"pip install jedi", | |
\"unix":"pip install jedi", | |
\}} | |
"indent guide | |
"NeoBundle 'nathanaelkane/vim-indent-guides' | |
"半透明にするとインデント部分のみが透過せず気持ち悪い | |
NeoBundleLazy 'lambdalisue/vim-pyenv',{ | |
\"depends": ['davidhalter/jedi-vim'], | |
\"autoload": { | |
\ "filetypes": ["python", "python3", "djangohtml"] | |
\}} | |
"colorscheme 使いやすいものを | |
NeoBundle 'nanotech/jellybeans.vim' | |
NeoBundle 'altercation/vim-colors-solarized' | |
NeoBundle 'w0ng/vim-hybrid' | |
NeoBundle 'vim-scripts/Wombat' | |
NeoBundle 'tomasr/molokai' | |
NeoBundle 'vim-scripts/rdark' | |
call neobundle#end() | |
filetype plugin indent on | |
NeoBundleCheck | |
"-------------NeoBundle end---------------- | |
" "NERDTreeの設定 | |
" let NERDTreeShowHidden=1 | |
"lightlineの設定 | |
let g:lightline = { | |
\ 'colorscheme': 'wombat', | |
\ 'mode_map': {'c': 'NORMAL'}, | |
\ 'active': { | |
\ 'left': [ [ 'mode', 'paste' ], ['pyenv'], [ 'fugitive', 'filename' ] ], | |
\ 'right': [ ['percent'], | |
\ ['fileformat', 'fileencoding', 'filetype'], | |
\ ['syntastic', 'lineinfo'], | |
\ ] | |
\ }, | |
\ 'component_function': { | |
\ 'modified': 'LightLineModified', | |
\ 'readonly': 'LightLineReadonly', | |
\ 'fugitive': 'LightLineFugitive', | |
\ 'filename': 'LightLineFilename', | |
\ 'fileformat': 'LightLineFileformat', | |
\ 'filetype': 'LightLineFiletype', | |
\ 'fileencoding': 'LightLineFileencoding', | |
\ 'mode': 'LightLineMode', | |
\ 'pyenv': 'pyenv#statusline#component' | |
\ }, | |
\ 'component_expand': { | |
\ 'syntastic': 'SyntasticStatuslineFlag', | |
\}, | |
\'component_type': { | |
\ 'syntastic': 'error', | |
\}} | |
"syntasticをパッシブに | |
let g:syntastic_mode_map = { 'mode': 'passive' } | |
":w時にシンタックスチェック | |
augroup AutoSyntastic | |
autocmd! | |
autocmd BufWritePost *.py call s:syntastic() | |
augroup END | |
function! s:syntastic() | |
SyntasticCheck | |
call lightline#update() | |
endfunction | |
"lightlineの設定 | |
function! LightLineModified() | |
return &ft =~ 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-' | |
endfunction | |
function! LightLineReadonly() | |
return &ft !~? 'help\|vimfiler\|gundo' && &readonly ? 'x' : '' | |
endfunction | |
function! LightLineFilename() | |
return ('' != LightLineReadonly() ? LightLineReadonly() . ' ' : '') . | |
\ (&ft == 'vimfiler' ? vimfiler#get_status_string() : | |
\ &ft == 'unite' ? unite#get_status_string() : | |
\ &ft == 'vimshell' ? vimshell#get_status_string() : | |
\ '' != expand('%:t') ? expand('%:t') : '[No Name]') . | |
\ ('' != LightLineModified() ? ' ' . LightLineModified() : '') | |
endfunction | |
function! LightLineFugitive() | |
try | |
if &ft !~? 'vimfiler\|gundo' && exists('*fugitive#head') | |
return fugitive#head() | |
endif | |
catch | |
endtry | |
return '' | |
endfunction | |
function! LightLineFileformat() | |
return winwidth(0) > 70 ? &fileformat : '' | |
endfunction | |
function! LightLineFiletype() | |
return winwidth(0) > 70 ? (strlen(&filetype) ? &filetype : 'no ft') : '' | |
endfunction | |
function! LightLineFileencoding() | |
return winwidth(0) > 70 ? (strlen(&fenc) ? &fenc : &enc) : '' | |
endfunction | |
function! LightLineMode() | |
return winwidth(0) > 60 ? lightline#mode() : '' | |
endfunction | |
"syntasticの設定 | |
let g:syntastic_python_checkers = ['flake8'] | |
"うまく動作しない時は以下のようにflake8の場所を直接指定してやると良い | |
"let g:flake8_cmd="~/.pyenv/shims/flake8" | |
"jedi-vimの設定 | |
let s:hooks = neobundle#get_hooks("jedi-vim") | |
function! s:hooks.on_source(bundle) | |
let g:jedi#auto_vim_configuletion = 0 | |
let g:jedi#popup_select_first = 0 | |
let g:jedi#rename_command = '<Leader>R' | |
endfunction | |
" docstringは表示しない | |
autocmd FileType python setlocal completeopt-=preview | |
"*.pyをいじるときはjediに補完させる | |
autocmd FileType python setlocal omnifunc=jedi#completions | |
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*' | |
"jedi-vimの公式に載ってたバージョン切り替えの関数 | |
"うまく動作しないので断念 | |
" function! s:jedi_auto_force_py_version() abort | |
" let major_version = pyenv#python#get_internal_major_version() | |
" call jedi#forec_py_version(major_version) | |
" endfunction | |
" augroup vim-pyenv-custom-augroup | |
" autocmd! * | |
" autocmd User vim-pyenv-activate-post call s:jedi_auto_force_py_version() | |
" autocmd User vim-pyenv-deactivate-post call s:jedi_auto_force_py_version() | |
" augroup END | |
"Unite.vimの設定 | |
nnoremap [unite] <Nop> | |
nmap U [unite] | |
nnoremap <silent> [unite]f :<C-u>UniteWithBufferDir -buffer-name=files file<CR> | |
nnoremap <silent> [unite]b :<C-u>Unite buffer<CR> | |
nnoremap <silent> [unite]r :<C-u>Unite register<CR> | |
nnoremap <silent> [unite]m :<C-u>Unite file_mru<CR> | |
nnoremap <silent> [unite]c :<C-u>Unite bookmark<CR> | |
nnoremap <silent> [unite]o :<C-u>Unite outline<CR> | |
nnoremap <silent> [unite]t :<C-u>Unite tab<CR> | |
nnoremap <silent> [unite]w :<C-u>Unite window<CR> | |
let s:hooks = neobundle#get_hooks("unite.vim") | |
function! s:hooks.on_source(bundle) | |
" start unite in insert mode | |
let g:unite_enable_start_insert = 1 | |
" use vimfiler to open directory | |
call unite#custom_default_action("source/bookmark/directory", "vimfiler") | |
call unite#custom_default_action("directory", "vimfiler") | |
call unite#custom_default_action("directory_mru", "vimfiler") | |
autocmd MyAutoCmd FileType unite call s:unite_settings() | |
function! s:unite_settings() | |
imap <buffer> <Esc><Esc> <Plug>(unite_exit) | |
nmap <buffer> <Esc> <Plug>(unite_exit) | |
nmap <buffer> <C-n> <Plug>(unite_select_next_line) | |
nmap <buffer> <C-p> <Plug>(unite_select_previous_line) | |
endfunction | |
endfunction | |
"vimfilerの設定 | |
nnoremap <Leader>e :VimFilerExplorer<CR> | |
" close vimfiler automatically when there are only vimfiler open | |
autocmd MyAutoCmd BufEnter * if (winnr('$') == 1 && &filetype ==# 'vimfiler') | q | endif | |
let s:hooks = neobundle#get_hooks("vimfiler") | |
function! s:hooks.on_source(bundle) | |
let g:vimfiler_as_default_explorer = 1 | |
let g:vimfiler_enable_auto_cd = 1 | |
" .から始まるファイルおよび.pycで終わるファイルを不可視パターンに | |
let g:vimfiler_ignore_pattern = "\%(^\..*\|\.pyc$\)" | |
" vimfiler specific key mappings | |
autocmd MyAutoCmd FileType vimfiler call s:vimfiler_settings() | |
function! s:vimfiler_settings() | |
" ^^ to go up | |
nmap <buffer> ^^ <Plug>(vimfiler_switch_to_parent_directory) | |
" use R to refresh | |
nmap <buffer> R <Plug>(vimfiler_redraw_screen) | |
" overwrite C-l | |
nmap <buffer> <C-l> <C-w>l | |
endfunction | |
endfunction | |
"カラー設定 | |
colorscheme solarized | |
set background=dark | |
highlight Normal ctermbg=none |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment