added completionModifier
allows a highlight rule modify keyword completions
This commit is contained in:
parent
cf0c81a25f
commit
27284cd29f
2 changed files with 13 additions and 1 deletions
|
|
@ -368,14 +368,18 @@ var Mode = function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.getCompletions = function(state, session, pos, prefix) {
|
this.getCompletions = function(state, session, pos, prefix) {
|
||||||
|
var self = this;
|
||||||
var keywords = this.$keywordList || this.$createKeywordList();
|
var keywords = this.$keywordList || this.$createKeywordList();
|
||||||
return keywords.map(function(word) {
|
return keywords.map(function(word) {
|
||||||
return {
|
var r = {
|
||||||
name: word,
|
name: word,
|
||||||
value: word,
|
value: word,
|
||||||
score: 0,
|
score: 0,
|
||||||
meta: "keyword"
|
meta: "keyword"
|
||||||
};
|
};
|
||||||
|
return self.$highlightRules.completionModifier ? self.$highlightRules.completionModifier.call(self, r) : r;
|
||||||
|
}).filter(function(value) {
|
||||||
|
return value !== undefined;
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -228,6 +228,14 @@ var TextHighlightRules = function() {
|
||||||
return this.$keywords;
|
return this.$keywords;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function that can be set by HighlightRules to modify a keyword completion.
|
||||||
|
* The function receives {name<string>, value<string>, score<number>, meta<string>}
|
||||||
|
* and should return the same type or undefined to skip adding the result to
|
||||||
|
* the completion list.
|
||||||
|
*/
|
||||||
|
this.completionModifier = null;
|
||||||
|
|
||||||
}).call(TextHighlightRules.prototype);
|
}).call(TextHighlightRules.prototype);
|
||||||
|
|
||||||
exports.TextHighlightRules = TextHighlightRules;
|
exports.TextHighlightRules = TextHighlightRules;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue