Skip to content

Commit

Permalink
feat(list): support change default action by configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
chemzqm committed May 18, 2021
1 parent f38f31d commit 971c5f8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
15 changes: 12 additions & 3 deletions doc/coc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2847,20 +2847,29 @@ list.
For configuration of a specified list, use section that starts with:
`list.source.{name}`, where `{name}` is the name of list.

Configure default options:~
Change default action:~

If you want to use `tabe` as default action of symbols list, you can use:
>
// change default action of symbols
"list.source.symbols.defaultAction": "tabe"
<
in your coc-settings.json

Change default options:~

Use `list.source.{name}.defaultOptions` setting like: >
// make symbols list use normal mode and interactive by default
"list.source.symbols.defaultOptions": ["--interactive", "--number-select"],
<
Note: some list like symbols only work in interactive mode, you must
include `--interactive` to `defaultOptions`.
include `--interactive` in `defaultOptions`.

Note: default options will not be used when there're options passed
with |:CocList| command.

Config default arguments:~
Change default arguments:~

Use `list.source.{name}.defaultArgs` setting like: >
Expand Down
10 changes: 10 additions & 0 deletions src/list/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,16 @@ export class ListManager implements Disposable {
window.showMessage(`list "${name}" recreated.`)
}
this.listMap.set(name, list)
let config = workspace.getConfiguration(`list.source.${name}`)
let defaultAction = config.get<string>('defaultAction')
if (defaultAction && list.actions.find(o => o.name == defaultAction)) {
list.defaultAction = defaultAction
}
extensions.addSchemeProperty(`list.source.${name}.defaultAction`, {
type: 'string',
default: null,
description: `Default default action of "${name}" list.`
})
extensions.addSchemeProperty(`list.source.${name}.defaultOptions`, {
type: 'array',
default: list.interactive ? ['--interactive'] : [],
Expand Down

0 comments on commit 971c5f8

Please sign in to comment.