師走に訪れたphpstromさんへの浮ついた気持ち。
いまでも本命はneovimさん。
ガシガシphpstormを使えるようにvimの設定をphpstromに反映していく。
使ってないのもあるので整理もかねて。
init.vim(.vimrc)
init.vim
" setting
"文字コードをUFT-8に設定
set termencoding=utf-8
set enc=utf-8
"文字コード自動判別
" set fileencodings=iso-2022-jp,euc-jp,sjis,utf-8
set fileencodings=utf-8
"改行コード自動判別
set fileformats=unix,dos,mac
" undofileを作らない
set noundofile
" カレントディレクトリの自動変更
" set autochdir
" 起動時のメッセージを非表示
set shortmess+=I
" バックアップファイルを作らない
set nobackup
" スワップファイルを作らない
set noswapfile
" 編集中のファイルが変更されたら自動で読み直す
set autoread
" バッファが編集中でもその他のファイルを開けるように
set hidden
" 入力中のコマンドをステータスに表示する
set showcmd
" スペルチェック
" setlocal spell spelllang=en,cjk
" windowsのパスをスラッシュに対応する
" set shellslash
" コマンド履歴数
set history=200
" 見た目系
" 行番号を表示
set number
" 現在の行を強調表示
set cursorline
" 現在の行を強調表示(縦)
set cursorcolumn
" 行末の1文字先までカーソルを移動できるように
set virtualedit=onemore
" インデントはスマートインデント
set smartindent
" オートインデント
set autoindent
" ビープ音を可視化
set visualbell
" 括弧入力時の対応する括弧を表示
set showmatch
" ステータスラインを常に表示
set laststatus=2
" コマンドラインの補完
set wildmode=list:longest
set termguicolors
set background=dark
colorscheme hybrid
" Tab系
" 不可視文字を可視化(タブが「?-」と表示される)
set list listchars=tab:\>\-
" Tab文字を半角スペースにする
set expandtab
" 行頭以外のTab文字の表示幅(スペースいくつ分)
set tabstop=2
" 行頭でのTab文字の表示幅
set shiftwidth=2
augroup fileTypeIndent
autocmd!
autocmd BufNewFile,BufRead *.py setlocal tabstop=4 softtabstop=4 shiftwidth=4 fileencoding=UTF-8
autocmd BufNewFile,BufRead *.php setlocal tabstop=4 softtabstop=4 shiftwidth=4 fileencoding=UTF-8
autocmd BufNewFile,BufRead *.rb setlocal tabstop=2 softtabstop=2 shiftwidth=2 fileencoding=UTF-8
augroup END
"全角スペースをハイライト表示
function! ZenkakuSpace()
highlight ZenkakuSpace cterm=reverse ctermfg=DarkMagenta gui=reverse guifg=DarkMagenta
endfunction
if has('syntax')
augroup ZenkakuSpace
autocmd!
autocmd ColorScheme * call ZenkakuSpace()
autocmd VimEnter,WinEnter * match ZenkakuSpace / /
augroup END
call ZenkakuSpace()
endif
augroup BgHighlight
autocmd!
autocmd WinEnter * set number colorcolumn=80 cursorline
autocmd WinLeave * set nonumber colorcolumn=0 nocursorline
augroup END
" 検索系
" 検索文字列が小文字の場合は大文字小文字を区別なく検索する
set ignorecase
" 検索文字列に大文字が含まれている場合は区別して検索する
set smartcase
" 検索文字列入力時に順次対象文字列にヒットさせる
set incsearch
" 検索時に最後まで行ったら最初に戻る
set wrapscan
" 検索語をハイライト表示
set hlsearch
" 文字列置換をインタラクティブに表示
set inccommand=split
" very magic
nnoremap / /\v
" ヴィジュアルモードで選択した部分を検索する ※visual-star
function! s:VSetSearch(cmdtype)
let temp = @s
norm! gv"sy
let @/ = '\V' . substitute(escape(@s, a:cmdtype.'\'), '\n', '\\n', 'g')
let @s = temp
endfunction
xnoremap * :<C-u>call <SID>VSetSearch('/')<CR>/<C-R>=@/<CR><CR>
xnoremap # :<C-u>call <SID>VSetSearch('?')<CR>?<C-R>=@/<CR><CR>
" ESC連打でハイライト解除
nmap <Esc><Esc> :nohlsearch<CR><Esc>
nmap <C-c><C-c> :nohlsearch<CR><Esc>
nmap <C-[><C-[> :nohlsearch<CR><Esc>
"移動
noremap j gj
noremap k gk
noremap <S-h> ^
noremap <S-j> }
noremap <S-k> {
noremap <S-l> $
" 履歴からコマンドを呼び戻す時にカーソルキーを使わない
" set clipboard=unnamedplus,autoselectnoremap <C-p> <Up>
" cnoremap <C-n> <Down>
" バッファの移動
nnoremap <silent> [b :bprevious<CR>
nnoremap <silent> ]b :bnext<CR>
nnoremap <silent> [B :bfirst<CR>
nnoremap <silent> ]B :blast<CR>
noremap <C-h> :bprevious<CR>
noremap <C-l> :bnext<CR>
"新規バッファ
nnoremap <silent> <C-n> :enew<CR>
" terminal
command! Tnew :enew | :terminal
tnoremap <silent> <C-[> <C-\><C-n>
" クリップボードの使用
set clipboard+=unnamedplus
" return to normal mode
inoremap <C-c> <Esc>
nnoremap <C-c> <Esc>
" vim-plug
" https://github.com/junegunn/vim-plug#windows-powershell
call plug#begin('~/.local/share/nvim/plugged')
Plug 'easymotion/vim-easymotion'
Plug 'mattn/emmet-vim'
Plug 'w0rp/ale'
Plug 'vim-airline/vim-airline'
Plug 'vim-airline/vim-airline-themes'
Plug 'Shougo/denite.nvim'
if has('nvim')
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' }
else
Plug 'Shougo/deoplete.nvim'
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif
Plug 'Shougo/neosnippet.vim'
Plug 'Shougo/neosnippet-snippets'
Plug 'Shougo/neomru.vim'
Plug 'Shougo/neoyank.vim'
Plug 'Shougo/neco-syntax'
Plug 'tpope/vim-fugitive'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-rails'
Plug 'tpope/vim-endwise'
Plug '5t111111/denite-rails'
Plug 'scrooloose/nerdcommenter'
Plug 'scrooloose/nerdtree'
Plug 'Townk/vim-autoclose'
Plug 'rking/ag.vim'
Plug 'sheerun/vim-polyglot'
Plug 'majutsushi/tagbar/'
" Plug 'ludovicchabant/vim-gutentags'
Plug 'phpactor/phpactor', {'for': 'php', 'do': 'composer install'}
Plug 'kristijanhusak/deoplete-phpactor'
call plug#end()
" surround.vim
augroup SurroundVimGroups
autocmd!
autocmd FileType eruby let b:surround_{char2nr("c")} = "\n<%\n=begin\n%>\n\r\n<%\n=end\n%>\n"
autocmd FileType eruby let b:surround_{char2nr("i")} = "<% if 1confition: 1 %> \r <% end %>"
autocmd FileType eruby let b:surround_{char2nr("_")} = "<% \r %>"
autocmd FileType eruby let b:surround_{char2nr("=")} = "<%= \r %>"
autocmd FileType eruby let b:surround_{char2nr("g")} = "<%= _(\"\r\") %>"
autocmd FileType php let b:surround_{char2nr("p")} = "<?php \r ?>"
autocmd FileType blade let b:surround_{char2nr("b")} = "{{ \r }}"
augroup END
"ale
let g:ale_javascript_eslint_use_global = 1
let g:ale_ruby_rubocop_use_global = 1
let g:ale_fixers = {}
let g:ale_fixers['php'] = ['php_cs_fixer']
let g:ale_fix_on_save = 1
let g:ale_linters = {
\ 'javascript': ['eslint'],
\ 'jsx': ['stylelint', 'eslint'],
\ 'html': ['htmlhint'],
\ 'css': ['stylelint'],
\ 'scss': ['stylelint'],
\ 'ruby': ['rubocop'],
\}
let g:ale_sign_column_always = 1
highlight clear ALEErrorSign
highlight clear ALEWarningSign
" phpcsコマンドの設定
if has("mac")
let g:ale_php_phpcs_executable = $HOME . '/.composer/vendor/bin/phpcs'
elseif has("unix")
let g:ale_php_phpcs_executable = '/home/laradock/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs'
endif
" コーディング規約の指定
" phpcs -i で返ってきた値を使えます。
let g:ale_php_phpcs_standard = 'PSR2'
" グローバルで設定する
let g:ale_php_phpcs_use_global = 1
" コメントの後にスペースを追加
let g:NERDSpaceDelims=1
" コメント記号を左に揃える
let g:NERDDefaultAlign='left'
" 検索したら別バッファでリスト表示
augroup QuickFixCmdPostGroups
autocmd!
autocmd QuickFixCmdPost *grep* cwindow
augroup END
" Denite
nnoremap [Denite] <Nop>
nmap <Space>d [Denite]
nnoremap <silent> [Denite]b :<C-u>Denite buffer<CR>
nnoremap <silent> [Denite]p :<C-u>Denite file/rec<CR>
nnoremap <silent> [Denite]f :<C-u>DeniteBufferDir file/rec<CR>
nnoremap <silent> [Denite]u :<C-u>Denite file_mru<CR>
nnoremap <silent> [Denite]g :<C-u>Denite grep<CR>
nnoremap <silent> [Denite]y :<C-u>Denite neoyank<CR>
nnoremap <silent> [Denite]r :<C-u>Denite -resume<CR>
nnoremap <silent> [Denite]mv :<C-u>Denite menu:vimrc_nvim<CR>
nnoremap <silent> [Denite]md :<C-u>Denite menu:change_dir<CR>
" Define mappings
autocmd FileType denite call s:denite_my_settings()
function! s:denite_my_settings() abort
nnoremap <silent><buffer><expr> <CR>
\ denite#do_map('do_action')
nnoremap <silent><buffer><expr> d
\ denite#do_map('do_action', 'delete')
nnoremap <silent><buffer><expr> p
\ denite#do_map('do_action', 'preview')
nnoremap <silent><buffer><expr> q
\ denite#do_map('quit')
nnoremap <silent><buffer><expr> i
\ denite#do_map('open_filter_buffer')
nnoremap <silent><buffer><expr> <Space>
\ denite#do_map('toggle_select').'j'
endfunction
autocmd FileType denite-filter call s:denite_filter_my_settings()
function! s:denite_filter_my_settings() abort
imap <silent><buffer> <C-o> <Plug>(denite_filter_quit)
endfunction
" Change file/rec command.
call denite#custom#var('file/rec', 'command',
\ ['ag', '--follow', '--nocolor', '--nogroup', '-g', ''])
" Ag command on grep source
call denite#custom#var('grep', 'command', ['ag'])
call denite#custom#var('grep', 'default_opts',
\ ['-i', '--vimgrep'])
call denite#custom#var('grep', 'recursive_opts', [])
call denite#custom#var('grep', 'pattern_opt', [])
call denite#custom#var('grep', 'separator', ['--'])
call denite#custom#var('grep', 'final_opts', [])
" Change ignore_globs
call denite#custom#filter('matcher/ignore_globs', 'ignore_globs',
\ [ '.git/', '.ropeproject/', '__pycache__/',
\ 'venv/', 'images/', '*.min.*', 'img/', 'fonts/'])
" denite-rails
nnoremap [rails] <Nop>
nmap <Space>r [rails]
nnoremap [rails]r :Denite<Space>rails:
nnoremap <silent> [rails]r :<C-u>Denite<Space>rails:dwim<Return>
nnoremap <silent> [rails]m :<C-u>Denite<Space>rails:model<Return>
nnoremap <silent> [rails]c :<C-u>Denite<Space>rails:controller<Return>
nnoremap <silent> [rails]v :<C-u>Denite<Space>rails:view<Return>
nnoremap <silent> [rails]h :<C-u>Denite<Space>rails:helper<Return>
nnoremap <silent> [rails]t :<C-u>Denite<Space>rails:test<Return>
nnoremap <silent> [rails]s :<C-u>Denite<Space>rails:spec<Return>
" deopleate
let g:deoplete#enable_at_startup = 1
let g:deoplete#auto_complete_delay = 0
let g:deoplete#auto_complete_start_length = 1
let g:deoplete#enable_camel_case = 0
let g:deoplete#enable_ignore_case = 0
let g:deoplete#enable_refresh_always = 0
let g:deoplete#enable_smart_case = 1
let g:deoplete#file#enable_buffer_path = 1
let g:deoplete#max_list = 10000
" neosnippet
" Plugin key-mappings.
" Note: It must be "imap" and "smap". It uses <Plug> 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.
" Note: It must be "imap" and "smap". It uses <Plug> mappings.
"imap <expr><TAB>
" \ pumvisible() ? "\<C-n>" :
" \ neosnippet#expandable_or_jumpable() ?
" \ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
smap <expr><TAB> neosnippet#expandable_or_jumpable() ?
\ "\<Plug>(neosnippet_expand_or_jump)" : "\<TAB>"
" For conceal markers.
if has('conceal')
set conceallevel=2 concealcursor=niv
endif
" fugitive
nnoremap [fugitive] <Nop>
nmap <Space>g [fugitive]
nnoremap <silent> [fugitive]s :<C-u>Gstatus<CR>
nnoremap <silent> [fugitive]a :<C-u>Gwrite<CR>
nnoremap <silent> [fugitive]r :<C-u>Gread<CR>
nnoremap <silent> [fugitive]c :<C-u>Gcommit -v<CR>
nnoremap <silent> [fugitive]b :<C-u>Gblame<CR>
nnoremap <silent> [fugitive]d :<C-u>Gdiff<CR>
" tagbar
" let g:tagbar_ctags_bin = '/usr/bin/ctags'
" set tags=./tags;
" nmap <F8> :TagbarToggle<CR>
augroup RubyGroups
autocmd!
autocmd BufNewFile,BufRead *.{rb,erb} set fileencodings=utf-8 fileformat=unix
augroup END
" vim-easymotion
" s{char}{char} to move to {char}{char}
nmap s <Plug>(easymotion-overwin-f2)
" vim-airline
let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tagbar#enabled = 0
let g:airline_theme='murmur'
" NERDTree
" autocmd vimenter * NERDTree
nnoremap <silent><C-e> :NERDTreeToggle<CR>
let g:NERDTreeDirArrowExpandable = '▸'
let g:NERDTreeDirArrowCollapsible = '▾'
" 表示幅
let g:NERDTreeWinSize=40
" 隠しファイルを表示
let g:NERDTreeShowHidden=1
" ファイルが指定されていない場合vimの起動時にNERDTreeを自動的に開く
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
" 開いたままのウィンドウがNERDTreeだけの場合vimも閉じる
" autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
nnoremap bd :bp\|bd #<CR>
" relaod buffer
nnoremap <F5> :bufdo e!<CR>
if has("mac")
let g:python3_host_prog = '/usr/local/bin/python3'
elseif has("unix")
let g:python3_host_prog = '/home/laradock/bin/python'
endif
" phpactor
function! DefinitionJumpWithPhpactor()
vsplit
call phpactor#GotoDefinition()
endfunction
nnoremap [phpactor] <Nop>
nmap <Space>p [phpactor]
nnoremap <silent> [phpactor]u :call phpactor#UseAdd()<CR>
" Invoke the context menu
nnoremap <silent> [phpactor]mm :call phpactor#ContextMenu()<CR>
" Invoke the navigation menu
nnoremap <silent> [phpactor]nn :call phpactor#Navigate()<CR>
" Goto definition of class or class member under the cursor
nnoremap <silent> [phpactor]o :call phpactor#GotoDefinition()<CR>
" Goto definition of class or class member under the cursor
nnoremap <silent> [phpactor]os :call DefinitionJumpWithPhpactor()<CR>
" Show brief information about the symbol under the cursor
nnoremap <silent> [phpactor]k :call phpactor#Hover()<CR>
" Transform the classes in the current file
nnoremap <silent> [phpactor]tt :call phpactor#Transform()<CR>
" Generate a new class (replacing the current file)
nnoremap <silent> [phpactor]cn :<C-u>call phpactor#ClassNew()<CR>
" Extract expression (normal mode)
nnoremap <silent>[phpactor]ee :call phpactor#ExtractExpression(v:false)<CR>
" Extract expression from selection
vmap <silent>[phpactor]ee :<C-u>call phpactor#ExtractExpression(v:true)<CR>
" Extract method from selection
vmap <silent>[phpactor]em :<C-u>call phpactor#ExtractMethod()<CR>
" omni
autocmd FileType php setlocal omnifunc=phpactor#Complete
.ideavimrc
.init.vim
set surround
noremap j gj
noremap k gk
noremap <S-h> ^
noremap <S-j> }
noremap <S-k> {
noremap <S-l> $
set clipboard=unnamed
set iminsert=2
set hls
set ignorecase
set smartcase
set incsearch
set wrapscan
set inccommand=split
nnoremap / /\v
" ヴィジュアルモードで選択した部分を検索する ※visual-star
function! s:VSetSearch(cmdtype)
let temp = @s
norm! gv"sy
let @/ = '\V' . substitute(escape(@s, a:cmdtype.'\'), '\n', '\\n', 'g')
let @s = temp
endfunction
xnoremap * :<C-u>call <SID>VSetSearch('/')<CR>/<C-R>=@/<CR><CR>
xnoremap # :<C-u>call <SID>VSetSearch('?')<CR>?<C-R>=@/<CR><CR>
" ESC連打でハイライト解除
nmap <Esc><Esc> :nohlsearch<CR><Esc>
nmap <C-c><C-c> :nohlsearch<CR><Esc>
nmap <C-[><C-[> :nohlsearch<CR><Esc>
set showmatch
nnoremap <C-o> :<C-u>action Back<CR>
nnoremap <C-i> :<C-u>action Forward<CR>
nnoremap <C-S-o> <C-o>
nnoremap <C-S-i> <C-i>
nnoremap [m :<C-u>action MethodUp<CR>
nnoremap ]m :<C-u>action MethodDown<CR>
nnoremap [c :<C-u>action VcsShowPrevChangeMarker<CR>
nnoremap ]c :<C-u>action VcsShowNextChangeMarker<CR>
nnoremap [e :<C-u>action GotoPreviousError<CR>
nnoremap ]e :<C-u>action GotoNextError<CR>
nnoremap <C-w>o :<C-u>action CloseAllEditorsButActive<CR>
nnoremap gtd :<C-u>action GotoDeclaration<CR>
nnoremap gsm :<C-u>action GotoSuperMethod<CR>
nnoremap gi :<C-u>action GotoImplementation<CR>
nnoremap <space>dg :<C-u>action FindInPath<CR>
nnoremap \c<space> :<C-u>action CommentByLineComment<CR>
nnoremap <C-l> :<C-u>action NextTab<CR>
nnoremap <C-h> :<C-u>action PreviousTab<CR>