Complete set commands
This commit is contained in:
parent
a28f6f916d
commit
1e39fed618
2 changed files with 44 additions and 1 deletions
|
@ -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([]);
|
||||
};
|
||||
|
|
|
@ -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 };
|
||||
|
|
Reference in a new issue