This repository has been archived on 2020-04-04. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
Vim-Vixen/src/background/controllers/completions.js
2018-07-21 16:15:07 +09:00

43 lines
1.2 KiB
JavaScript

import CompletionsInteractor from '../usecases/completions';
import Completions from '../domains/completions';
export default class ContentMessageController {
constructor() {
this.completionsInteractor = new CompletionsInteractor();
}
getCompletions(line) {
let trimmed = line.trimStart();
let words = trimmed.split(/ +/);
let name = words[0];
if (words.length === 1) {
return this.completionsInteractor.queryConsoleCommand(name);
}
let keywords = trimmed.slice(name.length).trimStart();
switch (words[0]) {
case 'o':
case 'open':
case 't':
case 'tabopen':
case 'w':
case 'winopen':
return this.completionsInteractor.queryOpen(name, keywords);
case 'b':
case 'buffer':
return this.completionsInteractor.queryBuffer(name, keywords);
case 'bd':
case 'bdel':
case 'bdelete':
case 'bdeletes':
return this.completionsInteractor.queryBdelete(name, keywords);
case 'bd!':
case 'bdel!':
case 'bdelete!':
case 'bdeletes!':
return this.completionsInteractor.queryBdeleteForce(name, keywords);
case 'set':
return this.completionsInteractor.querySet(name, keywords);
}
return Promise.resolve(Completions.empty());
}
}