Skip to content

Commit aef8349

Browse files
committed
refactor(config): To make more possible on initial startup with no plugins
1 parent 277b68d commit aef8349

File tree

2 files changed

+45
-29
lines changed

2 files changed

+45
-29
lines changed

autoload/settings.vim

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ function! settings#LoadSettings() abort
8181

8282

8383
function! s:find_root()
84-
for vcs in ['.venv', 'Pipfile', 'Procfile', 'Gemfile', '.git', '.svn', '.hg']
84+
for vcs in ['.venv', 'Pipfile', 'Procfile', 'pyproject.toml', 'Gemfile', '.git', '.svn', '.hg']
8585
let dir = finddir(vcs.'/..', ';')
8686
if !empty(dir)
8787
execute 'FZF' dir
@@ -91,16 +91,30 @@ function! settings#LoadSettings() abort
9191
FZF
9292
endfunction
9393

94-
" command! FZFR call s:find_root()
95-
96-
command! -bang FZFR
97-
\ call fzf#run(fzf#wrap('my-stuff', {'dir': FindRootDirectory()}, <bang>0))
98-
99-
94+
function! OnLoadFZF()
95+
if !exists(':FZF') || !exists(':FZFAg')
96+
echo 'bail'
97+
return
98+
endif
10099

101-
nmap <space> :<C-u>FZFR<CR>
102-
"nmap <space> :<C-u>FZF<CR>
100+
" fzf#wrap is resilient: It's Truthy even after plugged wipes depending on
101+
" the dir. Also check for fzf#complete to make sure it's possible to
102+
" actually see if fzf exists.
103+
if exists('*fzf#wrap') && exists('*fzf#complete')
104+
command! -bang FZFR
105+
\ call fzf#run(fzf#wrap('my-stuff', {'dir': FindRootDirectory()}, <bang>0))
106+
nmap <space> :<C-u>FZFR<CR>
107+
endif
108+
if exists(':FZFAg')
109+
nnoremap <silent> <C-F> :<C-u>FZFAg<cr>
110+
endif
111+
if exists(':FZFAgRoot')
112+
nnoremap <silent> <C-f> :<C-u>FZFAgRoot<cr>
113+
endif
114+
" Old one: nmap <space> :<C-u>FZF<CR>
115+
endfunction
103116

117+
call plugin_loader#PlugOnLoad('fzf.vim', 'call OnLoadFZF()')
104118

105119
""""
106120
" Tags in buffer
@@ -152,9 +166,6 @@ function! settings#LoadSettings() abort
152166
endfunction
153167

154168
command! BTags call s:btags()
155-
156-
157-
nmap <space> :<C-u>FZFR<CR>
158169
nmap <C-o> :<C-u>BTags<CR>
159170
160171

@@ -211,8 +222,7 @@ function! settings#LoadSettings() abort
211222
\ 'down': '50%'
212223
\ })
213224

214-
nnoremap <silent> <C-F> :<C-u>FZFAg<cr>
215-
nnoremap <silent> <C-f> :<C-u>FZFAgRoot<cr>
225+
216226

217227
if executable('rg')
218228
command! -bang -nargs=* Rg
@@ -241,14 +251,3 @@ endfunction
241251
set laststatus=2
242252
set cmdheight=2 " Used to show docs when popup not available
243253
" endif
244-
245-
if &rtp =~ 'wilder'
246-
" ++once supported in Nvim 0.4+ and Vim 8.1+
247-
" Also need to switch
248-
autocmd CmdlineEnter * ++once call s:wilder_init() | call g:wilder#main#start()
249-
250-
function! s:wilder_init() abort
251-
call wilder#setup({'modes': [':', '/', '?']})
252-
call wilder#set_option('use_python_remote_plugin', 0)
253-
endfunction
254-
endif

plugins.vim

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,9 @@ else
9191
endif
9292

9393
function! OnLoadCoc()
94-
if ! &rtp =~ 'coc.nvim'
94+
" if ! &rtp =~ 'coc.nvim'
95+
if !exists('*CocActionAsync') || !exists('*CocAction')
96+
echo "coc.nvim not initialized, aborting loading"
9597
return
9698
endif
9799

@@ -107,9 +109,8 @@ function! OnLoadCoc()
107109
\ <SID>check_back_space() ? "\<Tab>" :
108110
\ coc#refresh()
109111
inoremap <expr><S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
110-
111112
inoremap <silent><expr> <CR> coc#pum#visible() ? coc#_select_confirm()
112-
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
113+
\: "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
113114
114115
" Remap keys for gotos
115116
nmap <F12> <Plug>(coc-definition)
@@ -152,7 +153,8 @@ autocmd FileType javascript,typescript,typescript.tsx let b:coc_root_patterns =
152153

153154
" Plug 'neoclide/coc.nvim', {'branch': 'release'}
154155
Plug 'neoclide/coc.nvim', {'branch': 'master', 'do': 'yarn install --frozen-lockfile'}
155-
call OnLoadCoc()
156+
call plugin_loader#PlugOnLoad('coc.nvim', 'call OnLoadCoc()')
157+
156158

157159
" For coc-settings.json jsonc
158160
autocmd FileType json syntax match Comment +\/\/.\+$+
@@ -240,3 +242,18 @@ else
240242
Plug 'roxma/nvim-yarp'
241243
Plug 'roxma/vim-hug-neovim-rpc'
242244
endif
245+
246+
function! OnLoadWilder()
247+
if &rtp =~ 'wilder.nvim'
248+
" ++once supported in Nvim 0.4+ and Vim 8.1+
249+
" Also need to switch
250+
autocmd CmdlineEnter * ++once call s:wilder_init() | call g:wilder#main#start()
251+
252+
function! s:wilder_init() abort
253+
call wilder#setup({'modes': [':', '/', '?']})
254+
call wilder#set_option('use_python_remote_plugin', 0)
255+
endfunction
256+
endif
257+
endfunction
258+
259+
call plugin_loader#PlugOnLoad('wilder.nvim', 'call OnLoadWilder()')

0 commit comments

Comments
 (0)