" encoding and color {{{
if has('vim_starting')
    set encoding=utf-8
    scriptencoding utf-8
    
    if !has('gui_running') && exists(&termguicolors) && $COLORTERM ==# 'truecolor'
        let &t_8f = "\e[38;2;%lu;%lu;%lum"
        let &t_8b = "\e[48;2;%lu;%lu;%lum"
        set termguicolors
    endif
endif
" }}}
" augroup {{{
augroup vimrc
    autocmd!
augroup END
" }}}
" echomsg startup time {{{

if has('vim_starting') && has('reltime')
    let g:startuptime = reltime()
    autocmd vimrc VimEnter * let g:startuptime = reltime(g:startuptime) | redraw | echomsg 'startuptime: ' . reltimestr(g:startuptime)
endif
" }}}
" define variable {{{
let s:env = {}
let s:env.path = {}
let s:env.path.cache = expand('~/.cache')
let s:env.path.dein = s:env.path.cache . '/dein'
let s:env.dein = {
            \ 'repo' : 'https://github.com/Shougo/dein.vim',
            \ 'path' : s:env.path.dein . '/repos/github.com/Shougo/dein.vim'}
" }}}

" clone vim-plug if needed {{{
if !filereadable(expand('~/.vim/autoload/plug.vim'))
    execute '!curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'
endif
" }}}

" plugins {{{

call plug#begin('~/.vim/plugged')

Plug 'nanotech/jellybeans.vim'
Plug 'Shougo/vimproc.vim', { 'do': 'make' }
Plug 'tpope/vim-dispatch'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'FelikZ/ctrlp-py-matcher'
Plug 'fisadev/vim-ctrlp-cmdpalette'
Plug 'tpope/vim-fugitive'
Plug 'thinca/vim-qfreplace'
Plug 'itchyny/lightline.vim'
Plug 'tyru/caw.vim'
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' }
Plug 'ryanoasis/vim-devicons'
Plug 'osyo-manga/vim-anzu'
Plug 'cohama/vim-insert-linenr'
Plug 'glidenote/memolist.vim'
Plug 'wakatime/vim-wakatime'
Plug 'christoomey/vim-tmux-navigator'
Plug 'gregsexton/VimCalc'
Plug 'junegunn/vim-easy-align'
Plug 'sheerun/vim-polyglot'
Plug 'koron/codic-vim'
Plug 'osyo-manga/vim-watchdogs'
Plug 'cohama/vim-hier'
Plug 'osyo-manga/shabadou.vim'
Plug 'thinca/vim-quickrun'
Plug 'majutsushi/tagbar'

" completion
Plug 'Valloric/YouCompleteMe', { 'do': './install.py --cs-completer --clang-completer' }
Plug 'artur-shaik/vim-javacomplete2', { 'for': 'java' }
Plug 'fatih/vim-go', { 'for': 'go' }                  
Plug 'vim-ruby/vim-ruby', { 'for': 'ruby' }          
Plug 'SirVer/ultisnips'
Plug 'honza/vim-snippets'

" syntax
Plug 'OrangeT/vim-csharp', { 'for': ['cs', 'csi', 'csx' ] }
Plug 'octol/vim-cpp-enhanced-highlight', { 'for': 'cpp' }
Plug 'b4winckler/vim-objc', { 'for': 'objc' }
Plug 'keith/swift.vim', { 'for': 'swift' }   
Plug 'aklt/plantuml-syntax', { 'for': 'uml' } 
Plug 'vim-scripts/ShaderHighLight'

" other
Plug 'hananana/lilycomment.vim', { 'for': 'cs' }
Plug 'vim-scripts/DoxygenToolkit.vim', { 'for': ['cpp', 'objcpp', 'objc'] } 
Plug 'kana/vim-altr', { 'for' : ['cpp', 'objcpp', 'objc'] }
Plug 'elzr/vim-json', { 'for' : ['json']}
Plug 'stephpy/vim-yaml', { 'for' : [ 'yaml' ] }
Plug 'chrisbra/csv.vim', { 'for' : [ 'csv' ] }
Plug 'vim-scripts/Align', { 'for' : [ 'csv' ] }

if has('mac')
    Plug 'iamcco/markdown-preview.vim', { 'for' : [ 'markdown' ] }
endif

call plug#end()
" }}}

filetype plugin indent on

" colorscheme {{{
syntax enable
colorscheme jellybeans
set background=dark
" }}}
" basic setting  {{{

" leaderをspaceにする
let g:mapleader = "\<Space>"
let g:maplocalleader = '\'
" tmuxで色を有効にする
set t_Co=256
" airlineを常時表示するよ
set laststatus=2
"キーのリマップ
nnoremap [ %
" 想定される改行コードの指定する
set fileformats=unix,dos,mac
" インデントまわり
set tabstop=4
set shiftwidth=4
set softtabstop=4
set expandtab
set smarttab
set cindent
" /検索でbottomからtopに戻らない
set nowrapscan
" ビープ音いらん
set visualbell t_vb=
"コマンド表示
set showcmd
"バックアップファイルをとらない
set nobackup
" チルダファイル作成を完全無効化
set noundofile
"スワップファイル用のディレクトリを指定する
set noswapfile
" コマンドライン補完をshellと同一にする
set wildmode=list:longest
"クリップボードを連携する
set clipboard=unnamed
"変更中のファイルでも、保存しないで他のファイルを表示する
set hidden
"インクリメンタルサーチを行う
set incsearch
"検索したらハイライト
set hlsearch
" 大文字小文字を区別しないで検索する
set ignorecase
set smartcase
" escした時日本語入力をやめる
inoremap <ESC> <ESC>:set iminsert=0<CR>
"行番号を表示する
set number
" バックスペースでインデント削除
set backspace=indent,eol,start
"閉括弧が入力された時、対応する括弧を強調する
set showmatch
" マクロ実行中は再描画しない
set lazyredraw
" くそ長い行を値までで略しちゃう
set synmaxcol=300
" 他のエディタなどで変更があった場合チェックする
set autoread
" 他のエディタなどで変更があった場合チェックする
set autowrite
" focusした時に外部から更新があったかチェック
autocmd vimrc WinEnter * checktime
" vimdiffを縦で割る
set diffopt=vertical
" previewを表示する
set completeopt=menuone,preview
" マーカー折りたたみ
set foldmethod=marker
" 補完ウィンドウは10項目まで
set pumheight=10 
" neovimの文字化け対策
set ttimeout
set ttimeoutlen=50

set helplang=ja,en

set previewheight=4
autocmd vimrc BufEnter ?* call PreviewHeightWorkAround()
function! PreviewHeightWorkAround()
    if &previewwindow
        exec 'set local winheight='.&previewheight
    endif
endfunction

autocmd vimrc BufNewFile,BufRead *.{md,mdwn,mkd,mkdn,mark*} set filetype=markdown

autocmd vimrc QuickFixCmdPost make,grepadd,grep,vimgrep if len(getqflist()) != 0 | copen | endif
"}}}
" keymaps {{{

"矢印キー無効
noremap <Up> <Nop>
noremap <Down> <Nop>
noremap <Left> <Nop>
noremap <Right> <Nop>
" 移動を常にgjに
nnoremap j gj
nnoremap k gk
" 検索結果のハイライトをEsc連打でクリアする
nnoremap <ESC><ESC> :nohlsearch<CR>
"検索結果を画面中央にもってきてstatuslineに位置表示
nmap n <Plug>(anzu-n-with-echo)zz
nmap N <Plug>(anzu-N-with-echo)zz
nmap * <Plug>(anzu-star-with-echo)zz
nmap # <Plug>(anzu-sharp-with-echo)zz
" こっから<Leader>関連いくぜ!
" タブとウィンドウ分割"
nnoremap <Leader>s :<C-u>sp<CR>
nnoremap <Leader>v :<C-u>vs<CR>
" ヘッダーとの移動
autocmd vimrc FileType cpp,objc,objcpp nmap <Leader>i <Plug>(altr-forward)
" コメントテンプレ展開
autocmd vimrc FileType cs nnoremap <Leader>/ :LilyComment<CR>
autocmd vimrc FileType cpp,objc,objcpp nnoremap <Leader>/ :Dox<CR>
"コメントアウト
nmap <Leader>c <Plug>(caw:zeropos:toggle)
vmap <Leader>c <Plug>(caw:zeropos:toggle)
" レジスタ汚染防止
nnoremap x "_x
nnoremap s "_s
" help
nnoremap <Leader>h :<C-u>vertical belowright help<Space>
" Oで改行
nnoremap O :<C-u>call append(expand('.'), '')<Cr>j
" Yで現在のカーソルから行末までヤンク
nnoremap Y y$

nnoremap <Leader>gg :grep 
nnoremap <Leader>gc :grep <cword>
" }}}
" plugins {{{
" itchyny/lightline.vim {{{
let g:lightline = {
            \ 'colorscheme' : 'jellybeans',
            \ 'active': {
            \   'left': [ [ 'mode', 'paste' ],
            \             [ 'fugitive', 'filename', 'anzu' ] ]
            \ },
            \ 'component' : {
            \   'anzu' : '%{anzu#search_status()}',
            \ },
            \ 'component_function': {
            \   'readonly': 'MyReadOnly',
            \   'modified': 'MyModified',
            \   'filename' : 'MyFilename',
            \   'fugitive': 'MyFugitive',
            \ },
            \ 'component_visible_condition': {
            \   'readonly': '(&filetype!="help"&& &readonly)',
            \   'modified': '(&filetype!="help"&&(&modified||!&modifiable))',
            \ },
            \ 'separator': { 'left': '', 'right': '' },
            \ 'subseparator': { 'left': '', 'right': '' }
            \ }

function! MyModified()
  return &filetype =~# 'help\|vimfiler\|gundo' ? '' : &modified ? '+' : &modifiable ? '' : '-'
endfunction

function! MyReadonly()
  return &filetype !~? 'help\|vimfiler\|gundo' && &readonly ? '⭤' : ''
endfunction

function! MyFilename()
  return ('' !=# MyReadonly() ? MyReadonly() . ' ' : '') .
        \ (&filetype ==# 'vimfiler' ? vimfiler#get_status_string() :
        \  &filetype ==# 'unite' ? unite#get_status_string() :
        \  &filetype ==# 'vimshell' ? substitute(b:vimshell.current_dir,expand('~'),'~','') :
        \ '' !=# expand('%:t') ? expand('%:t') : '[No Name]') .
        \ ('' !=# MyModified() ? ' ' . MyModified() : '')
endfunction

function! MyFugitive()
   try
    if &filetype !~? 'vimfiler\|gundo' && exists('*fugitive#head')
      let l:_ = fugitive#head()
      return strlen(l:_) ? '⭠ '.l:_ : ''
    endif
  catch
  endtry
  return ''
endfunction
" }}}
" ctrlp/ctrlp.vim {{{
nnoremap <Leader>b :CtrlPBuffer<CR>
nnoremap <Leader>m :CtrlPMRUFiles<CR>
nnoremap <Leader>q :CtrlPQuickfix<CR>

let g:ctrlp_map = '<Leader><Leader>'
let g:ctrlp_show_hidden = 0
let g:ctrlp_user_command = 'rg %s --files --color=never --glob ""'
let g:ctrlp_use_caching = 1
let g:ctrlp_working_path_mode = 0
let g:ctrlp_match_func = { 'match' : 'pymatcher#PyMatch' }

let g:ctrlp_prompt_mappings = {
            \ 'PrtBS()':              ['<bs>'],
            \ 'PrtDelete()':          ['<del>'],
            \ 'PrtDeleteWord()':      ['<nop>'],
            \ 'PrtClear()':           ['<nop>'],
            \ 'PrtSelectMove("j")':   ['<c-n>'],
            \ 'PrtSelectMove("k")':   ['<c-p>'],
            \ 'PrtSelectMove("t")':   ['<nop>'],
            \ 'PrtSelectMove("b")':   ['<nop>'],
            \ 'PrtSelectMove("u")':   ['<nop>'],
            \ 'PrtSelectMove("d")':   ['<nop>'],
            \ 'PrtHistory(-1)':       ['<nop>'],
            \ 'PrtHistory(1)':        ['<nop>'],
            \ 'AcceptSelection("e")': ['<cr>'],
            \ 'AcceptSelection("h")': ['<c-h>'],
            \ 'AcceptSelection("t")': ['<nop>'],
            \ 'AcceptSelection("v")': ['<c-v>'],
            \ 'ToggleFocus()':        ['<nop>'],
            \ 'ToggleRegex()':        ['<nop>'],
            \ 'ToggleByFname()':      ['<c-d>'],
            \ 'ToggleType(1)':        ['<c-k>'],
            \ 'ToggleType(-1)':       ['<c-j>'],
            \ 'PrtExpandDir()':       ['<nop>'],
            \ 'PrtInsert("c")':       ['<nop>'],
            \ 'PrtInsert()':          ['<nop>'],
            \ 'PrtCurStart()':        ['<nop>'],
            \ 'PrtCurEnd()':          ['<nop>'],
            \ 'PrtCurLeft()':         ['<nop>'],
            \ 'PrtCurRight()':        ['<nop>'],
            \ 'PrtClearCache()':      ['<c-l>'],
            \ 'PrtDeleteEnt()':       ['<nop>'],
            \ 'CreateNewFile()':      ['<nop>'],
            \ 'MarkToOpen()':         ['<nop>'],
            \ 'OpenMulti()':          ['<nop>'],
            \ 'PrtExit()':            ['<c-[>'],
            \ }
" }}}
" " fisadev/vim-ctrlp-cmdpalette {{{
nnoremap <Leader>p :CtrlPCmdPalette<CR>
" " }}}
" scrooloose/nerdtree {{{
nmap <C-e> :NERDTreeToggle<CR>
autocmd vimrc BufEnter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" }}}
" lambdalisue/gina.vim {{{
noremap <silent> <Leader>gis :<C-u>Gina status<CR>
noremap <silent> <Leader>gic :<C-u>Gina commit<CR>
" " }}}
" glidenote/memolist.vim {{{
let g:memolist_path = '$HOME/Dropbox/memolist'
let g:memolist_memo_suffix = 'md'
" }}}
" ryanoasis/vim-devicons {{{
" vim-devicons
let g:webdevicons_conceal_nerdtree_brackets = 1
let g:WebDevIconsNerdTreeAfterGlyphPadding = '  '
let g:WebDevIconsUnicodeDecorateFolderNodes = 1
let g:WebDevIconsNerdTreeGitPluginForceVAlign = 1
let g:WebDevIconsUnicodeDecorateFolderNodes = 1
" file-icons
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols = {}
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['cs'] = ''
let g:WebDevIconsUnicodeDecorateFileNodesExtensionSymbols['swift'] = ''
" }}}
" terryma/vim-multiple-cursors {{{
let g:multi_cursor_use_default_mapping=1
" }}}
" thinca/vim-quickrun {{{
nnoremap <Leader>q :<C-u>QuickRun<CR>
let g:quickrun_config = get(g:, 'quickrun_config', {})
let g:quickrun_config['_'] = {
            \ 'runner' : 'vimproc',
            \ 'runner/vimproc/updatetime' : 1,
            \ 'outputter' : 'multi:buffer:quickfix',
            \ 'outputter/buffer/close_on_empty' : 1,
            \ 'outputter/buffer/split' : 'botright',
            \ 'outputter/quickfix/into' : 1,
            \ 'hook/echo/enable' : 1,
            \ 'hook/echo/output_success' : 'SUCCESS  ',
            \ 'hook/echo/output_failure' : 'FAILURE  ',
            \ 'hook/inu/enable' : 1,
            \ 'hook/inu/wait' : 1
            \}
let g:quickrun_config.cs = { 'type' : 'xbuild' }
let g:quickrun_config.xbuild = {
            \ 'command' : 'xbuild',
            \ 'exec' : '%c %o',
            \ 'cmdopt' : '/nologo /verbosity:quiet /property:WarningLevel=1', 
            \ 'quickfix/error': '%f\\(%l\\,%c\\)%m', 
            \ 'outputter' : 'quickfix'
            \ }
" }}}
" osyo-manga/vim-watchdogs {{{
let g:watchdogs_check_BufWritePost_enable = 1

" C#  {{{
if executable('mcs')
    let g:quickrun_config['cs/watchdogs_checker'] = {
                \ 'type' : 'watchdogs_checker/mcs'}
    let g:quickrun_config['watchdogs_checker/mcs'] = {
                \ 'command' : 'mcs',
                \ 'exec' : '%c %o %s:p',
                \ 'cmdopt' : '--parse',
                \ 'quickfix/error': '%f\\(%l\\,%c\\):\ error\ CS%n:\ %m'
                \ }
endif
"}}}
" Shell script {{{
if executable('shellcheck')
    let g:quickrun_config['sh/watchdogs_checker'] = {
                \ 'type': 'watchdogs_checker/shellcheck'}
    let g:quickrun_config['watchdogs_checker/shellcheck'] = {
                \ 'command': 'shellcheck',
                \ 'exec': '%c %o %s:p'}
endif

call watchdogs#setup(g:quickrun_config)
" }}}
" }}}
" majutsushi/tagbar {{{
nnoremap <Leader>t :<C-u>TagbarToggle<CR>
" }}}
" Valloric/YouCompleteMe {{{
nnoremap <LocalLeader>r <C-u>:YcmCompleter ReloadSolution<CR>
nnoremap <LocalLeader>t <C-u>:YcmCompleter GetType<CR>

let g:UltiSnipsExpandTrigger='<c-k>'
let g:UltiSnipsJumpForwardTrigger='<c-k>'
let g:UltiSnipsJumpBackwardTrigger='<c-z>'
let g:UltiSnipsEditSplit='vertical'

let g:ycm_min_num_of_chars_for_completion = 3
let g:ycm_min_num_identifier_candidate_chars = 3
let g:ycm_key_invoke_completion = '<C-o>'
let g:ycm_show_diagnostics_ui = 0
let g:ycm_confirm_extra_conf = 0
let g:ycm_key_detailed_diagnostics = ''
let g:ycm_global_ycm_extra_conf = '~/src/github.com/hananana/dotfile/src/global_ycm_extra_conf.py'
let g:ycm_extra_conf_vim_data = ['&filetype', 'expand(expand("<sfile>:p:h"))']
let g:ycm_semantic_triggers = get( g:,'ycm_semantic_triggers', {} )
let g:ycm_semantic_triggers.vim = ['$', '&', 're![\w&$<-][\w:#<>-]*']
let g:ycm_semantic_triggers.objc = [
            \ 're!\@"\.*"\s',
            \ 're!\@\w+\.*\w*\s',
            \ 're!\@\(\w+\.*\w*\)\s',
            \ 're!\@\(\s*',
            \ 're!\@\[.*\]\s',
            \ 're!\@\[\s*',
            \ 're!\@\{.*\}\s',
            \ 're!\@\{\s*',
            \ 're!\@\’.*\’\s',
            \ '#ifdef ',
            \ 're!:\s*',
            \ 're!=\s*',
            \ 're!,\s*', ]
let g:ycm_semantic_triggers.objcpp = [
            \ '->','::',
            \ 're!\@"\.*"\s',
            \ 're!\@\w+\.*\w*\s',
            \ 're!\@\(\w+\.*\w*\)\s',
            \ 're!\@\(\s*',
            \ 're!\@\[.*\]\s',
            \ 're!\@\[\s*',
            \ 're!\@\{.*\}\s',
            \ 're!\@\{\s*',
            \ 're!\@\’.*\’\s',
            \ '#ifdef ',
            \ 're!:\s*',
            \ 're!=\s*',
            \ 're!,\s*', ]
let g:ycm_semantic_triggers.cpp = [
            \ '->','::',
            \ 're!\@"\.*"\s',
            \ 're!\@\w+\.*\w*\s',
            \ 're!\@\(\w+\.*\w*\)\s',
            \ 're!\@\(\s*',
            \ 're!\@\[.*\]\s',
            \ 're!\@\[\s*',
            \ 're!\@\{.*\}\s',
            \ 're!\@\{\s*',
            \ 're!\@\’.*\’\s',
            \ '#ifdef ',
            \ 're!:\s*',
            \ 're!=\s*',
            \ 're!,\s*', ]
let g:ycm_filetype_blacklist = {
            \ 'ruby' : 1
            \ }
" }}}
" artur-shaik/vim-javacomplete2' {{{
autocmd vimrc FileType java setlocal omnifunc=javacomplete#Complete
" }}}
" elzr/vim-json {{{
let g:vim_json_syntax_conceal = 0
" }}}
" iamcco/markdown-preview.vim' {{{
let g:mkdp_path_to_chrome = "/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome"
" }}}
" chrisbra/csv.vim' {{{
let g:csv_delim=','
" }}}
"}}}
" prg {{{
if executable('rg')
    set grepprg=rg\ --vimgrep\ --no-heading\ --smart-case
    set grepformat=%f:%l:%c:%m,%f:%l:%m
endif
" }}}
" functions {{{

command! ReloadVimrc :source $HOME/.vimrc
command! ShowPath :echo expand("%:p")
command! GenerateCtags :!ctags -R

" MarkDownPreview {{{
if !has('mac')
    command! MarkDownPreview call MarkDownPreview()
    function! MarkDownPreview()
        let l:path = strpart(substitute(expand('%:p'), getcwd(), '', 'g'), 1)
        execute('!/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome.exe ' . l:path)
    endfunction
endif
" }}}
" Denite {{{
"function! DeniteReplace(context)
"      let l:qflist = []
"      for l:target in a:context['targets']
"        if !has_key(l:target, 'action__path') | continue | endif
"        if !has_key(l:target, 'action__line') | continue | endif
"        if !has_key(l:target, 'action__text') | continue | endif
"
"        call add(l:qflist, {
"              \ 'filename': l:target['action__path'],
"              \ 'lnum': l:target['action__line'],
"              \ 'text': l:target['action__text']
"              \ })
"      endfor
"      call setqflist(l:qflist)
"      call qfreplace#start('')
"    endfunction
"call denite#custom#action('file', 'qfreplace', 'DeniteReplace')
"
"function! s:memoGrepDenite()
"    let l:option = '-path=' . expand('$HOME/Dropbox/memolist')
"    exe 'Denite' 'grep' l:option '-highlight-mode-insert=Search'
"endfunction
"command! MemoGrepDenite call s:memoGrepDenite()<CR>

" }}}
" uncrustify {{{
" see http://stackoverflow.com/questions/12374200/using-uncrustify-with-vim/15513829#15513829

autocmd vimrc FileType cs nnoremap <Leader>f :call UncrustifyAuto()<CR>

" 例: 保存時に自動フォーマット
" autocmd functions BufWritePre <buffer> :call UncrustifyAuto()

" uncrustifyの設定ファイル
let g:uncrustify_cfg_file_path = expand('$DOTDIR/src/uncrustifyconfig')

" uncrustifyでフォーマットする言語
let g:uncrustify_lang = ''
" autocmd FileType c let g:uncrustify_lang = 'c'
" autocmd FileType cpp let g:uncrustify_lang = 'cpp'
" autocmd FileType java let g:uncrustify_lang = 'java'
" autocmd FileType objc let g:uncrustify_lang = 'oc'
autocmd vimrc FileType cs let g:uncrustify_lang = 'cs'

" Restore cursor position, window position, and last search after running a
" command.
function! Preserve(command)
    " Save the last search.
    let l:search = @/
    " Save the current cursor position.
    let l:cursor_position = getpos('.')
    " Save the current window position.
    normal! H
    let l:window_position = getpos('.')
    call setpos('.', l:cursor_position)
    " Execute the command.
    execute a:command
    " Restore the last search.
    let @/ = l:search
    " Restore the previous window position.
    call setpos('.', l:window_position)
    normal! zt
    " Restore the previous cursor position.
    call setpos('.', l:cursor_position)
endfunction

" Don't forget to add Uncrustify executable to $PATH (on Unix) or
" %PATH% (on Windows) for this command to work.
function! Uncrustify(language)
    call Preserve(':silent %!uncrustify'.' -q '.' -l '.a:language.' -c '.
                \shellescape(fnamemodify(g:uncrustify_cfg_file_path, ':p')))
endfunction

function! UncrustifyAuto()
    if g:uncrustify_lang !=# ''
        call Uncrustify(g:uncrustify_lang)
    endif
endfunction

" }}}
" RUN IDE {{{
" --------------------------------
" vimからIDE RUN
" --------------------------------
" nnoremap <silent> <Leader>p :call RunIDE()<CR><CR>
" function RunIDE()
"     if (&ft=='cs')
"         :!osascript ~/.dotfiles/AppleScript/runUnity.scpt
"     else
"         :!osascript ~/.dotfiles/AppleScript/runXcode.scpt
"     endif
" endfunction
" }}}
" Modify Solution File{{{
function! ModifySolutionFile()
    :%s/C:/\/mnt\/c/g
    :%s/D:/\/mnt\/d/g
endfunction
" }}}

" }}}

" NOT ACTIVE old plugin setting
" Shougo/denite.nvim {{{
"     call denite#custom#source('file_rec', 'matchers', ['matcher_regexp'])
"     call denite#custom#map('insert', '<C-n>', '<denite:move_to_next_line>', 'noremap')
"     call denite#custom#map('insert', '<C-p>', '<denite:move_to_previous_line>', 'noremap')
"
"     call denite#custom#var('file_rec', 'command', ['rg', '--files'])
"     call denite#custom#var('grep', 'command', ['rg'])
"
"     nmap <silent> <Leader><Leader> :<C-u>Denite file_rec -highlight-mode-insert=Search<CR>
"     nmap <silent> <Leader>b :<C-u>Denite buffer -highlight-mode-insert=Search<CR>
"     nmap <silent> <Leader>y :<C-u>Denite neoyank -highlight-mode-insert=Search<CR>
"     nmap <silent> <Leader>a :<C-u>Denite -resume -highlight-mode-insert=Search<CR>
"     nmap <silent> <Leader>gg :<C-u>Denite grep -highlight-mode-insert=Search<CR>
"     nmap <silent> <Leader>gc :<C-u>DeniteCursorWord -highlight-mode-insert=Search grep<CR>
"     nmap <silent> <Leader>o :<C-u>Denite outline -highlight-mode-insert=Search<CR>
"     nmap <silent> <Leader>n :<C-u>Denite -resume -select=+1 -immediately -highlight-mode-insert=Search<CR>
"     nmap <silent> <Leader>p :<C-u>Denite -resume -select=-1 -immediately -highlight-mode-insert=Search<CR>
"     nmap <Leader>tt :<C-u>Denite -highlight-mode-insert=Search gtags_def:
"     nmap <silent> <Leader>tc :<C-u>DeniteCursorWord -highlight-mode-insert=Search gtags_context<CR>
" }}}
set secure