Vim API - weirongxu/coc-explorer GitHub Wiki
Vim API
Note: Vim may be blocked when using CocAction
in autocmd
https://github.com/neoclide/coc.nvim/wiki/F.A.Q#my-vim-is-blocked-sometimes
Base types
ExplorerFinder
Type:'closest' | number >= 0
Closest, or bufnr, or 0 for current buffer
Position
Type: 'current' | number | ['relative', number, string?]
'current'
: The current cursor linenumber
: The absolute line index['relative', number, string?]
: The relative line index- subparameter 2
number
: The relative line index - subparameter 3
string?
: Explorer source type
- subparameter 2
Action
Type: string | {'name': string, 'args': string[]}
CocAction(...)
Run action of coc with args, more information :h CocAction()
CocActionAsync(...)
Call CocAction without blocking vim. more information :h CocActionAsync()
API List
explorer.doAction
Arguments:
name | type | default | description |
---|---|---|---|
explorerFinder | ExplorerFinder | ||
actions | Action[] | ||
positions | Position[] | ['current'] | |
actionMode | 'n' | 'v' | 'n' | |
count | number | 1 |
Examples:
# Execute `expand` or `open` action at the current cursor position
:call CocActionAsync('runCommand', 'explorer.doAction', 0, ['expandable?', 'expand', 'open'])
# Execute `nodeNext` action at line 5
:call CocActionAsync('runCommand', 'explorer.doAction', 0, ['nodeNext'], [5])
# Execute action at line 0 of file source
:call CocActionAsync('runCommand', 'explorer.doAction', 'closest', ['reveal'], ['relative', 0, 'file'](/weirongxu/coc-explorer/wiki/'relative',-0,-'file'))
explorer.getNodeInfo
Arguments:
name | type | default | description |
---|---|---|---|
explorerFinder | ExplorerFinder | ||
position | Position | 'current' |
Examples:
:echo CocAction('runCommand', 'explorer.getNodeInfo', 0)
:echo CocAction('runCommand', 'explorer.getNodeInfo', 0, ['relative', 2, 'file'](/weirongxu/coc-explorer/wiki/'relative',-2,-'file'))
explorer.getIcon
Arguments:
name | type | default |
---|---|---|
filepath | string | |
isDirectory | boolean | false |
Return:
{
'name': string,
'code': string,
'color': string,
}
" or
v:null " when icon is not found
Examples:
:echo CocAction('runCommand', 'explorer.getIcon', 'path/to/main.c') " {"name":"c","code":"","color":"#519aba"}
:echo CocAction('runCommand', 'explorer.getIcon', 'path/to/package.json') " {"name":"json","code":"","color":"#cbcb41"}
:echo CocAction('runCommand', 'explorer.getIcon', 'path/to/node_modules', v:true) " {"name":"javascript","code":"","color":"#cbcb41"}