Open pykong opened 1 year ago
I think I was able to implement this:
The only requirement is, that the file has to be open in one tab. But that's still a lot more convenient than no auto complete at all. I know and use a similar feature when writing SQL (opening the DB definition in one tab, having autocomplete for tables and columns for all other tabs!)
I have never written any typescript before, but if you think that's okay, I'm happy to send this as a PR @notZaki.
diff --git a/src/providers/completion.ts b/src/providers/completion.ts
index 56d1375..54e8e01 100644
--- a/src/providers/completion.ts
+++ b/src/providers/completion.ts
@@ -46,9 +46,15 @@ export class Completer implements vscode.CompletionItemProvider {
// This was used to terminate unecessary autompletion early, but might be causing suggestions to not appear for some users
// const invoker = document.lineAt(position.line).text[position.character-1];
// if (invoker !== '@') {return;}
+ const markdownDocuments = vscode.workspace.textDocuments.filter(
+ (document) => ['markdown', 'rmd', 'pweave_md'].includes(document.languageId)
+ );
const line = document.lineAt(position.line).text.substring(0, position.character).trim().split(" ");
const trigger = line[line.length-1];
- const suggestions = this.completion(trigger).concat(this.completionCrossref(trigger, document));
+ let suggestions: vscode.CompletionItem[] = [];
+ markdownDocuments.forEach(doc => {
+ suggestions.push(...this.completion(trigger).concat(this.completionCrossref(trigger, doc)))
+ })
this.extension.log(`Showing ${suggestions.length} suggestions`);
if (suggestions.length > 0) {
const configuration = vscode.workspace.getConfiguration('PandocCiter');
@pykong, just apply this patch and build it yourself for now if you still need it
I am using pandoc-include to break an otherwise big monolithic file into one root file including a set of smaller files.
This breaks however the autocompletion of cross-ref assets such as figures and listings. (Citeproc citations still wotk throughout all files though, if
PandocCiter.RootFile
is set.)I wished PandocCiter would account for such circumstance and still resolve cross-refs across file boundaries.
EDIT To be clearer: All references (for tables, figures, listings, sections, etc. ...) as defined via cross-ref syntax in any markdown file should be resolved by PandocCiter in any other markdown file within the same project directory.
@notZaki thanks for this extremely helpful plugin!