Skip to content

Commit

Permalink
refactor(config): To make more possible on initial startup with no pl…
Browse files Browse the repository at this point in the history
…ugins
  • Loading branch information
tony committed Oct 22, 2022
1 parent 277b68d commit baca1cb
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 29 deletions.
49 changes: 24 additions & 25 deletions autoload/settings.vim
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ function! settings#LoadSettings() abort


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

" command! FZFR call s:find_root()

command! -bang FZFR
\ call fzf#run(fzf#wrap('my-stuff', {'dir': FindRootDirectory()}, <bang>0))


function! OnLoadFZF()
if !exists(':FZF') || !exists(':FZFAg')
echo 'bail'
return
endif

nmap <space> :<C-u>FZFR<CR>
"nmap <space> :<C-u>FZF<CR>
" fzf#wrap is resilient: It's Truthy even after plugged wipes depending on
" the dir. Also check for fzf#complete to make sure it's possible to
" actually see if fzf exists.
if exists('*fzf#wrap') && exists('*fzf#complete')
command! -bang FZFR
\ call fzf#run(fzf#wrap('my-stuff', {'dir': FindRootDirectory()}, <bang>0))
nmap <space> :<C-u>FZFR<CR>
endif
if exists(':FZFAg')
nnoremap <silent> <C-F> :<C-u>FZFAg<cr>
endif
if exists(':FZFAgRoot')
nnoremap <silent> <C-f> :<C-u>FZFAgRoot<cr>
endif
" Old one: nmap <space> :<C-u>FZF<CR>
endfunction

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

""""
" Tags in buffer
Expand Down Expand Up @@ -152,9 +166,6 @@ function! settings#LoadSettings() abort
endfunction

command! BTags call s:btags()


nmap <space> :<C-u>FZFR<CR>
nmap <C-o> :<C-u>BTags<CR>

Expand Down Expand Up @@ -211,8 +222,7 @@ function! settings#LoadSettings() abort
\ 'down': '50%'
\ })

nnoremap <silent> <C-F> :<C-u>FZFAg<cr>
nnoremap <silent> <C-f> :<C-u>FZFAgRoot<cr>


if executable('rg')
command! -bang -nargs=* Rg
Expand Down Expand Up @@ -241,14 +251,3 @@ endfunction
set laststatus=2
set cmdheight=2 " Used to show docs when popup not available
" endif

if &rtp =~ 'wilder'
" ++once supported in Nvim 0.4+ and Vim 8.1+
" Also need to switch
autocmd CmdlineEnter * ++once call s:wilder_init() | call g:wilder#main#start()

function! s:wilder_init() abort
call wilder#setup({'modes': [':', '/', '?']})
call wilder#set_option('use_python_remote_plugin', 0)
endfunction
endif
25 changes: 21 additions & 4 deletions plugins.vim
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ else
endif

function! OnLoadCoc()
if ! &rtp =~ 'coc.nvim'
" if ! &rtp =~ 'coc.nvim'
if !exists('*CocActionAsync') || !exists('*CocAction')
echo "coc.nvim not initialized, aborting loading"
return
endif

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

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


" For coc-settings.json jsonc
autocmd FileType json syntax match Comment +\/\/.\+$+
Expand Down Expand Up @@ -240,3 +242,18 @@ else
Plug 'roxma/nvim-yarp'
Plug 'roxma/vim-hug-neovim-rpc'
endif

function! OnLoadWilder()
if &rtp =~ 'wilder'
" ++once supported in Nvim 0.4+ and Vim 8.1+
" Also need to switch
autocmd CmdlineEnter * ++once call s:wilder_init() | call g:wilder#main#start()

function! s:wilder_init() abort
call wilder#setup({'modes': [':', '/', '?']})
call wilder#set_option('use_python_remote_plugin', 0)
endfunction
endif
endfunction

autocmd! User wilder.nvim call OnLoadWilder()

0 comments on commit baca1cb

Please sign in to comment.