Skip to content

Instantly share code, notes, and snippets.

@yu-orz
Last active April 22, 2019 06:23
Show Gist options
  • Save yu-orz/5562370 to your computer and use it in GitHub Desktop.
Save yu-orz/5562370 to your computer and use it in GitHub Desktop.
vimrc
" Basic Settings {{{1
"”非互換
set nocompatible
"" swap作らない
set noswapfile
"" ランタイムのパス
set runtimepath+=$HOME/.vim
"" dein
" プラグインが実際にインストールされるディレクトリ
let s:dein_dir = expand('~/.vim/dein')
" dein.vim 本体
let s:dein_repo_dir = s:dein_dir . '/repos/github.com/Shougo/dein.vim'
" dein.vim がなければ github から落としてくる
if &runtimepath !~# '/dein.vim'
if !isdirectory(s:dein_repo_dir)
execute '!git clone https://github.com/Shougo/dein.vim' s:dein_repo_dir
endif
execute 'set runtimepath^=' . fnamemodify(s:dein_repo_dir, ':p')
endif
" 設定開始
if dein#load_state(s:dein_dir)
call dein#begin(s:dein_dir)
" プラグインリストを収めた TOML ファイル
" 予め TOML ファイル(後述)を用意しておく
let g:rc_dir = expand('~/.vim/dein/')
let s:toml = g:rc_dir . '/dein.toml'
"let s:lazy_toml = g:rc_dir . '/dein_lazy.toml'
" TOML を読み込み、キャッシュしておく
call dein#load_toml(s:toml, {'lazy': 0})
"call dein#load_toml(s:lazy_toml, {'lazy': 1})
" 設定終了
call dein#end()
call dein#save_state()
endif
filetype plugin indent on
syntax enable
" もし、未インストールものものがあったらインストール
if dein#check_install()
call dein#install()
endif
" Encode {{{2
set encoding=utf-8
set fenc=utf-8
set termencoding=utf-8
" filetype {{{2
autocmd BufNewFile,BufRead *.{md,mdwn,mkd,mkdn,mark*} set filetype=markdown
autocmd Filetype json setl conceallevel=0
autocmd Filetype markdown setl conceallevel=0
" 見た目
" 行番号の色を設定
autocmd ColorScheme * highlight LineNr ctermfg=250
" カーソルがある行の強調
"hi CursorLineNr ctermbg=4 ctermfg=5
"set cursorline
"hi clear CursorLine
"
" カラースキーマ
let g:hybrid_use_iTerm_colors = 1
"set background=dark
colorscheme desert
"colorscheme pyte
syntax on
set statusline=%F%m%r%h%w\%=%{fugitive#statusline()}%y[format=%{&ff}](%l,%c)[%P][encoding=%{&fenc}]%=[%c,\%l/%L]
set number
set showmode
set title
set ruler
set showcmd
set showmatch
set laststatus=2
"" インデントガイド
let g:indent_guides_enable_on_vim_startup = 1
"" 無駄な行末の空白を消す
autocmd BufWritePre * :%s/\s\+$//ge
" 挿入モード時、ステータスラインの色を変更
" ここから
let g:hi_insert = 'highlight StatusLine guifg=darkblue guibg=darkyellow gui=none ctermfg=blue ctermbg=yellow cterm=none'
if has('syntax')
augroup InsertHook
autocmd!
autocmd InsertEnter * call s:StatusLine('Enter')
autocmd InsertLeave * call s:StatusLine('Leave')
augroup END
endif
let s:slhlcmd = ''
function! s:StatusLine(mode)
if a:mode == 'Enter'
silent! let s:slhlcmd = 'highlight ' . s:GetHighlight('StatusLine')
silent exec g:hi_insert
else
highlight clear StatusLine
silent exec s:slhlcmd
endif
endfunction
function! s:GetHighlight(hi)
redir => hl
exec 'highlight '.a:hi
redir END
let hl = substitute(hl, '[\r\n]', '', 'g')
let hl = substitute(hl, 'xxx', '', '')
return hl
endfunction
" ここまで
" edit {{{2
set autoindent
set backspace=indent,eol,start "Backspace key
set expandtab
set ts=2 sw=2 sts=0
set ignorecase
set smartcase
set wrapscan
set noincsearch
set nohlsearch
set wildmenu
set ambiwidth=double
set clipboard=unnamed
" Mapping {{{1
" 縦に連番
" http://d.hatena.ne.jp/fuenor/20090907/1252315621
nnoremap <silent> co :ContinuousNumber <C-a><CR>
vnoremap <silent> co :ContinuousNumber <C-a><CR>
command! -count -nargs=1 ContinuousNumber let c = col('.')|for n in range(1, <count>?<count>-line('.'):1)|exec 'normal! j' . n . <q-args>|call cursor('.', c)|endfor
" ESC2回で nohlsearch
nmap <Esc><Esc> :nohlsearch<CR><Esc>
" vimrc系
nnoremap <Space>. :<C-u>edit ~/.vimrc<Enter>
nnoremap <Space>s. :<C-u>source ~/.vimrc<Enter>
" set nopaste
nnoremap <Space>,ns :<C-u>set nopaste<Enter>
nnoremap <Space>,s :<C-u>set paste<Enter>
" 日時の入力補完
inoremap <expr> ,df strftime('%Y-%m-%d %H:%M:%S')
inoremap <expr> ,dd strftime('%Y-%m-%d')
inoremap <expr> ,dt strftime('%Y:%m:%S')
" Memo
map <Space>,mn :MemoNew<CR>
map <Space>,ml :MemoList<CR>
map <Space>,mg :MemoGrep<CR>
"" previm
let g:previm_open_cmd = 'open -a Google\ Chrome'
" Autoload {{{2
autocmd QuickFixCmdPost *grep* cwindow
let g:hi_insert = 'highlight StatusLine guifg=darkblue guibg=darkyellow gui=none ctermfg=blue ctermbg=yellow cterm=none'
let g:is_bash = 1
" Ctags
let g:vim_tags_project_tags_command = "ctags -f tags -R . 2>/dev/null"
let g:vim_tags_gems_tags_command = "ctags -R -f Gemfile.lock.tags `bundle show --paths` 2>/dev/null"
set tags+=tags,Gemfile.lock.tags
"" deoplete
"Syntastic Config
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_wq = 0
" (Optional)Remove Info(Preview) window
set completeopt-=preview
" (Optional)Hide Info(Preview) window after completions
autocmd CursorMovedI * if pumvisible() == 0|pclose|endif
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
" (Optional) Enable terraform plan to be include in filter
let g:syntastic_terraform_tffilter_plan = 0
" (Optional) Default: 0, enable(1)/disable(0) plugin's keymapping
let g:terraform_completion_keys = 0
" (Optional) Default: 1, enable(1)/disable(0) terraform module registry completion
let g:terraform_registry_module_completion = 0
let g:deoplete#omni_patterns = {}
let g:deoplete#omni_patterns.terraform = '[^ *\t"{=$]\w*'
let g:deoplete#enable_at_startup = 1
call deoplete#custom#option('omni_patterns', {
\ 'complete_method': 'omnifunc',
\ 'terraform': '[^ *\t"{=$]\w*',
\})
call deoplete#initialize()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment