-
Notifications
You must be signed in to change notification settings - Fork 45
Vim API
Raidou edited this page May 18, 2022
·
8 revisions
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
Type๏ผ'closest' | number >= 0
Closest, or bufnr, or 0 for current buffer
Type: 'current' | number | ['relative', number, string?]
-
'current'
: The current cursor line -
number
: 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
Type: string | {'name': string, 'args': string[]}
Run action of coc with args, more information :h CocAction()
Call CocAction without blocking vim. more information :h CocActionAsync()
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']])
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']])
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"}