Add environment objects and methods #242
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello @byeze, sorry for the late answer. You can use completion-provider to achieve that |
Beta Was this translation helpful? Give feedback.
-
Hi guys, have you found a solution to suggest properties based on the object? I followed @suren-atoyan example but I don't understand how to make different suggestions based on the object. For example, if I write This below is my code, but it has the following 2 problems:
monaco.languages.registerCompletionItemProvider("javascript", {
provideCompletionItems: (model, position) => {
var word = model.getWordUntilPosition(position);
var range = {
startLineNumber: position.lineNumber,
endLineNumber: position.lineNumber,
startColumn: word.startColumn,
endColumn: word.endColumn
};
// Docs: https://microsoft.github.io/monaco-editor/api/interfaces/monaco.languages.CompletionItem.html
return {
suggestions: [
{
label: 'mysql',
kind: monaco.languages.CompletionItemKind.Variable,// Module,
documentation: "Anacleto library for working with MySQL.",
commitCharacters: ["."],
detail: "Anacleto MySQL library",
insertText: 'mysql',
range: range,
},
{
label: 'query({})',
filterText: 'mysql.query({})',
kind: monaco.languages.CompletionItemKind.Function,
insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet,
documentation: "mysql.query: mysql.query <any>(query: string | timeout: int | values: array | nestTables: boolean)",
detail: 'mysql.query({query..})',
insertText: 'mysql.query({query:${1:string}, timeout:${2:millis}, values:${3:array}, nestTables:${4:boolean}})',
range: range,
}
]
};
}
});
} |
Beta Was this translation helpful? Give feedback.
Hi guys, have you found a solution to suggest properties based on the object?
I followed @suren-atoyan example but I don't understand how to make different suggestions based on the object.
For example, if I write
console
the monaco suggestslog
,info
etc...i want that that if the user writesmysql
monaco suggests my custom methods.This below is my code, but it has the following 2 problems:
suggests
query
even though I haven't writtenmysql
when I select
mysql
from the suggestions then monaco doesn't suggestquery
(unless I press cmd + space)