-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fc4e31b
commit fe2ba3b
Showing
4 changed files
with
69 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,40 @@ | ||
namespace rstudio.intellisense { | ||
|
||
export function create_intellisense(model: monaco.editor.ITextModel, position: monaco.Position): any { | ||
var suggestions = [ | ||
{ label: 'hello', kind: monaco.languages.CompletionItemKind.Text, documentation: 'A greeting word' }, | ||
{ label: 'world', kind: monaco.languages.CompletionItemKind.Text, documentation: 'The planet we live on' } | ||
]; | ||
let word = model.getWordUntilPosition(position); | ||
let range = { | ||
startLineNumber: position.lineNumber, | ||
endLineNumber: position.lineNumber, | ||
startColumn: word.startColumn, | ||
endColumn: word.endColumn | ||
}; | ||
|
||
return { suggestions: suggestions }; | ||
return { | ||
suggestions: createDependencyProposals(range, word) | ||
}; | ||
} | ||
|
||
export const r_keywords = [ | ||
'c', 'require', 'library', 'if', 'for', 'list', 'str', 'print', 'return', 'function', 'let', 'const', 'imports', 'from' | ||
]; | ||
|
||
function createDependencyProposals(range, curWord) { | ||
// snippets的定义同上 | ||
// keys(泛指一切待补全的预定义词汇)的定义: | ||
let keys = []; | ||
let snippets = []; | ||
|
||
for (const item of r_keywords) { | ||
keys.push({ | ||
label: item, | ||
kind: monaco.languages.CompletionItemKind.Keyword, | ||
documentation: "", | ||
insertText: item, | ||
range: range | ||
}); | ||
} | ||
|
||
return snippets.concat(keys); | ||
} | ||
} | ||
|