Closed pirey closed 4 years ago
Issue-Label Bot is automatically applying the label feature_request
to this issue, with a confidence of 0.76. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!
Links: app homepage, dashboard and code for this bot.
You can use let opened = CocAction('runCommand', 'explorer.getNodeInfo', 'closest') is v:null
, more information see this https://github.com/weirongxu/coc-explorer/wiki/Vim-API
i got this error on initial load neovim
the error only happen on initial load. the code works after that.
it seems that my code is running before runComman is ready, i'm not really sure.
is there a way to check if runCommand
is ready?
what do you think?
i'm calling this function in lightline component, which i suppose is called everytime lightline is updated.
here's an excerpt.
let g:lightline = {
" ...
\ 'tabline': {
\ 'left': [['explorer_pad', 'buffers']]
\ }
\ 'component_function': {
\ 'explorer_pad': 'LightlineCocExplorerLeftpad',
" ...
\ },
" ...
\}
function! LightlineCocExplorerLeftpad() abort
if &co < 86
return ''
endif
if CocAction('runCommand', 'explorer.getNodeInfo', 'closest') isnot# v:null
return printf('%-29s', '') . '⎟'
endif
return ''
endfunction
:help CocNvimInit
Ok. so there is no direct means to check if coc has already started.
for anyone looking at similar issue later, what i do is to set custom variable to indicate coc has initialized.
function! s:on_coc_init()
let g:coc_ready = 1
endfunction
autocmd User CocNvimInit call s:on_coc_init()
then i can use it in lightline function
if get(g:, 'coc_ready', 0)
if CocAction('runCommand', 'explorer.getNodeInfo', 'closest') isnot# v:null
return printf('%-29s', '') . '⎟'
endif
endif
thanks @weirongxu
It is not working when having multiple windows by explorer.getNodeInfo
.
I use the code below.
let l:winnrs = filter(range(1, winnr('$')), 'getwinvar(v:val, "&ft") == "coc-explorer"')
let l:opened = len(l:winnrs) > 0
if l:opened
......
else
......
endif
is there a way to know if there is current coc-explorer window buffer opened?
right now i'm using this method:
but it rather hacky.
i'm just wondering if it has already this feature built-in to coc-explorer