From 04d23058be40bc6fa60adc399501af44ff0e75ed Mon Sep 17 00:00:00 2001 From: Nao Ueda Date: Thu, 10 Dec 2020 12:31:08 +0900 Subject: Don't use globpath to check if plugin exists. --- _config/101-lightline.vim | 4 +--- _config/102-ack.vim | 4 +--- _config/103-nerdtree.vim | 4 +--- _config/104-open-browser.vim | 4 +--- _config/105-fzf.vim | 4 +--- _config/106-easymotion.vim | 4 +--- _config/107-fern.vim | 4 +--- _config/108-fugitive-gitea.vim | 4 +--- _config/109-detectindent.vim | 4 +--- _config/110-ctrlp.vim | 12 +----------- _config/110_1-ctlp-matchfuzzy.vim | 4 ++++ _config/200-lsp.vim | 4 +--- _config/201-ale.vim | 4 +--- _config/202-async.vim | 4 +--- _config/203-gitgutter.vim | 4 +--- _config/204-fugitive.vim | 4 +--- _config/206-gina.vim | 4 +--- _config/301-markdown.vim | 4 +--- _config/302-lit-element.vim | 4 +--- _config/400-memolist.vim | 7 ++++--- vimrc | 12 +++++++----- 21 files changed, 33 insertions(+), 70 deletions(-) create mode 100644 _config/110_1-ctlp-matchfuzzy.vim diff --git a/_config/101-lightline.vim b/_config/101-lightline.vim index 9df4d30..75c9790 100644 --- a/_config/101-lightline.vim +++ b/_config/101-lightline.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/lightline.vim')) - finish -endif +UsePlugin 'lightline.vim' let g:lightline = { \ 'colorscheme': 'nord', diff --git a/_config/102-ack.vim b/_config/102-ack.vim index a2689c9..1aaadc9 100644 --- a/_config/102-ack.vim +++ b/_config/102-ack.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/ack.vim')) - finish -endif +UsePlugin 'ack.vim' " ack.vim " let g:ackprg = 'rg --vimgrep --no-heading --hidden --no-ignore-vcs' diff --git a/_config/103-nerdtree.vim b/_config/103-nerdtree.vim index ec52b48..54dea4a 100644 --- a/_config/103-nerdtree.vim +++ b/_config/103-nerdtree.vim @@ -1,5 +1,3 @@ -if empty(globpath(&rtp, 'autoload/nerdtree.vim')) - finish -endif +UsePlugin 'nerdtree' nmap d :NERDTreeToggle diff --git a/_config/104-open-browser.vim b/_config/104-open-browser.vim index 830ac93..21fd77c 100644 --- a/_config/104-open-browser.vim +++ b/_config/104-open-browser.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/openbrowser.vim')) - finish -endif +UsePlugin 'open-browser.vim' let g:netrw_nogx = 1 " disable netrw's gx mapping. nmap gx (openbrowser-smart-search) diff --git a/_config/105-fzf.vim b/_config/105-fzf.vim index e2b58c3..8215fc8 100644 --- a/_config/105-fzf.vim +++ b/_config/105-fzf.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/fzf/vim.vim')) - finish -endif +UsePlugin 'fzf.vim' " fzf " let $FZF_DEFAULT_COMMAND = 'rg --files --follow --hidden --no-ignore-vcs -g "!{.git,node_modules}/*" 2>/dev/null' diff --git a/_config/106-easymotion.vim b/_config/106-easymotion.vim index d309384..e56b1c2 100644 --- a/_config/106-easymotion.vim +++ b/_config/106-easymotion.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/EasyMotion.vim')) - finish -endif +UsePlugin 'vim-easymotion' let g:EasyMotion_do_mapping = 0 " Disable default mappings let g:EasyMotion_smartcase = 1 diff --git a/_config/107-fern.vim b/_config/107-fern.vim index 9b37045..5a18583 100644 --- a/_config/107-fern.vim +++ b/_config/107-fern.vim @@ -1,5 +1,3 @@ -if empty(globpath(&rtp, 'autoload/fern.vim')) - finish -endif +UsePlugin 'fern.vim' nmap d :Fern . -drawer diff --git a/_config/108-fugitive-gitea.vim b/_config/108-fugitive-gitea.vim index 6796c33..d753723 100644 --- a/_config/108-fugitive-gitea.vim +++ b/_config/108-fugitive-gitea.vim @@ -1,5 +1,3 @@ -if empty(globpath(&rtp, 'plugin/fugitive-gitea.vim')) - finish -endif +UsePlugin 'fugitive-gitea' let g:fugitive_gitea_domains = ['https://git.janiasu.com'] diff --git a/_config/109-detectindent.vim b/_config/109-detectindent.vim index 0feaccf..950b938 100644 --- a/_config/109-detectindent.vim +++ b/_config/109-detectindent.vim @@ -1,5 +1,3 @@ -if empty(globpath(&rtp, 'detectindent.vim')) - finish -endif +UsePlugin 'detectindent' let b:detectindent_preferred_indent = 4 diff --git a/_config/110-ctrlp.vim b/_config/110-ctrlp.vim index c6e53f7..9c3ebc7 100644 --- a/_config/110-ctrlp.vim +++ b/_config/110-ctrlp.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/ctrlp.vim')) - finish -endif +UsePlugin 'ctrlp.vim' let g:ctrlp_custom_ignore = { \ 'dir': '\v[\/]node_modules$', @@ -10,11 +8,3 @@ let g:ctrlp_switch_buffer = 0 " for multi-byte char let g:ctrlp_key_loop = 1 - -if !empty(globpath(&rtp, 'autoload/ctrlp_matchfuzzy.vim')) - let g:ctrlp_match_func = {'match': 'ctrlp_matchfuzzy#matcher'} -endif - -if !empty(globpath(&rtp, 'autoload/memolist.vim')) - nmap mf :exe "CtrlP" g:memolist_path -endif diff --git a/_config/110_1-ctlp-matchfuzzy.vim b/_config/110_1-ctlp-matchfuzzy.vim new file mode 100644 index 0000000..9fdab8e --- /dev/null +++ b/_config/110_1-ctlp-matchfuzzy.vim @@ -0,0 +1,4 @@ +UsePlugin 'ctrlp.vim' +UsePlugin 'ctrlp-matchfuzzy' + +let g:ctrlp_match_func = {'match': 'ctrlp_matchfuzzy#matcher'} diff --git a/_config/200-lsp.vim b/_config/200-lsp.vim index a06dcd8..e156029 100644 --- a/_config/200-lsp.vim +++ b/_config/200-lsp.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/lsp.vim')) - finish -endif +UsePlugin 'vim-lsp' let g:lsp_diagnostics_enabled = 1 let g:lsp_diagnostics_float_cursor = 1 diff --git a/_config/201-ale.vim b/_config/201-ale.vim index 2d491f6..31836e2 100644 --- a/_config/201-ale.vim +++ b/_config/201-ale.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/ale.vim')) - finish -endif +UsePlugin 'ale' let g:ale_sign_warning = '▲' let g:ale_sign_error = '✗' diff --git a/_config/202-async.vim b/_config/202-async.vim index aaf2741..4501183 100644 --- a/_config/202-async.vim +++ b/_config/202-async.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/async/job.vim')) - finish -endif +UsePlugin 'async.vim' let g:asyncomplete_remove_duplicates = 1 let g:asyncomplete_smart_completion = 1 diff --git a/_config/203-gitgutter.vim b/_config/203-gitgutter.vim index 5288a33..f4d294e 100644 --- a/_config/203-gitgutter.vim +++ b/_config/203-gitgutter.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/gitgutter.vim')) - finish -endif +UsePlugin 'vim-gitgutter' set updatetime=200 let g:gitgutter_sign_added = '│' diff --git a/_config/204-fugitive.vim b/_config/204-fugitive.vim index 4099a6b..bf807b4 100644 --- a/_config/204-fugitive.vim +++ b/_config/204-fugitive.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/fugitive.vim')) - finish -endif +UsePlugin 'vim-fugitive' " DiffRev command " https://github.com/tpope/vim-fugitive/issues/132#issuecomment-290644034 diff --git a/_config/206-gina.vim b/_config/206-gina.vim index 6d74df2..63f24bc 100644 --- a/_config/206-gina.vim +++ b/_config/206-gina.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/gina.vim')) - finish -endif +UsePlugin 'gina.vim' call extend(g:gina#command#browse#translation_patterns, { \ 'sfd.git.backlog.jp': [ diff --git a/_config/301-markdown.vim b/_config/301-markdown.vim index 9d2d8cf..6b1821f 100644 --- a/_config/301-markdown.vim +++ b/_config/301-markdown.vim @@ -1,5 +1,3 @@ -if empty(globpath(&rtp, 'ftplugin/markdown.vim')) - finish -endif +UsePlugin 'vim-markdown' let g:vim_markdown_folding_disabled = 1 diff --git a/_config/302-lit-element.vim b/_config/302-lit-element.vim index fe46349..ba86bac 100644 --- a/_config/302-lit-element.vim +++ b/_config/302-lit-element.vim @@ -1,5 +1,3 @@ -if empty(globpath(&rtp, 'autoload/htl_syntax.vim')) - finish -endif +UsePlugin 'vim-html-template-literals' let g:htl_css_templates = 1 diff --git a/_config/400-memolist.vim b/_config/400-memolist.vim index ebe2753..f54b3b9 100644 --- a/_config/400-memolist.vim +++ b/_config/400-memolist.vim @@ -1,6 +1,4 @@ -if empty(globpath(&rtp, 'autoload/memolist.vim')) - finish -endif +UsePlugin 'memolist.vim' let g:memolist_path = $HOME . '/.config/memo/_posts' @@ -11,3 +9,6 @@ let g:memolist_memo_suffix = "md" let g:memolist_memo_date = "%Y-%m-%d %H:%M" let g:memolist_qfixgrep = 0 let g:memolist_template_dir_path = $HOME . '/.config/memo/template' + +UsePlugin 'ctrlp.vim' +nmap mf :exe "CtrlP" g:memolist_path diff --git a/vimrc b/vimrc index ed3b3e1..ea630ac 100644 --- a/vimrc +++ b/vimrc @@ -172,8 +172,10 @@ colorscheme nord " " 各種設定の読み込み -let s:_ = '' -for s:_ in sort(split(globpath(&rtp, '_config/*.vim'))) - exec 'so' s:_ -endfor -unlet s:_ +let s:plugs = get(s:, 'plugs', get(g:, 'plugs', {})) +function! FindPlugin(name) abort + return has_key(s:plugs, a:name) ? isdirectory(s:plugs[a:name].dir) : 0 +endfunction +command! -nargs=1 UsePlugin if !FindPlugin() | finish | endif + +runtime! _config/*.vim -- cgit v1.2.3-54-g00ecf