diff options
author | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-07-11 21:58:41 +0900 |
---|---|---|
committer | Shin'ya Ueoka <ueokande@i-beam.org> | 2018-07-11 21:58:41 +0900 |
commit | 1e39fed6183bf3b10f48eb52868bb5ab3fe3134f (patch) | |
tree | dd4c311d90e7212287b2ba2ce6a19eb6fcc38ab9 /src | |
parent | a28f6f916d77baf87e3c023abbd6494e009a8d12 (diff) |
Complete set commands
Diffstat (limited to 'src')
-rw-r--r-- | src/background/shared/completions/index.js | 37 | ||||
-rw-r--r-- | src/shared/settings/properties.js | 8 |
2 files changed, 44 insertions, 1 deletions
diff --git a/src/background/shared/completions/index.js b/src/background/shared/completions/index.js index 22713e7..d630f33 100644 --- a/src/background/shared/completions/index.js +++ b/src/background/shared/completions/index.js @@ -2,6 +2,7 @@ import commandDocs from 'shared/commands/docs'; import * as tabs from './tabs'; import * as histories from './histories'; import * as bookmarks from './bookmarks'; +import * as properties from 'shared/settings/properties'; const completeCommands = (typing) => { let keys = Object.keys(commandDocs); @@ -86,6 +87,40 @@ const getBufferCompletions = async(command, keywords, excludePinned) => { ]; }; +const getSetCompletions = (command, keywords) => { + let keys = Object.keys(properties.docs).filter( + name => name.startsWith(keywords) + ); + let items = keys.map((key) => { + if (properties.types[key] === 'boolean') { + return [ + { + caption: key, + content: command + ' ' + key, + url: 'Enable ' + properties.docs[key], + }, { + caption: 'no' + key, + content: command + ' no' + key, + url: 'Disable ' + properties.docs[key], + } + ]; + } + return [ + { + caption: key, + content: command + ' ' + key, + url: 'Set ' + properties.docs[key], + } + ]; + }).flat(); + return Promise.resolve([ + { + name: 'Properties', + items, + } + ]); +}; + const complete = (line, settings) => { let trimmed = line.trimStart(); let words = trimmed.split(/ +/); @@ -121,6 +156,8 @@ const complete = (line, settings) => { case 'bdelete': case 'bdeletes': return getBufferCompletions(name, keywords, true); + case 'set': + return getSetCompletions(name, keywords); } return Promise.resolve([]); }; diff --git a/src/shared/settings/properties.js b/src/shared/settings/properties.js index 4bda8d6..b392cbb 100644 --- a/src/shared/settings/properties.js +++ b/src/shared/settings/properties.js @@ -15,4 +15,10 @@ const defaults = { adjacenttab: true, }; -export { types, defaults }; +const docs = { + hintchars: 'Hint characters on follow mode', + smoothscroll: 'smooth scroll', + adjacenttab: 'open adjacent tabs', +}; + +export { types, defaults, docs }; |