Skip to content

Commit

Permalink
feat: add llm.documentFilter setting (#84)
Browse files Browse the repository at this point in the history
* feat: add `llm.documentFilter` setting

* feat: bump to `0.1.2`
  • Loading branch information
McPatate authored Oct 5, 2023
1 parent 9b0d6f8 commit 213d151
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ const json = await res.json() as { generated_text: string };

Note that the example above is a simplified version to explain what is happening under the hood.

### Suggestion behavior

You can tune the way the suggestions behave:
- `llm.enableAutoSuggest` lets you choose to enable or disable "suggest-as-you-type" suggestions.
- `llm.documentFilter` lets you enable suggestions only on specific files that match the pattern matching syntax you will provide. The object must be of type [`DocumentFilter | DocumentFilter[]`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#documentFilter):
- to match on all types of buffers: `llm.documentFilter: { pattern: "**" }`
- to match on all files in `my_project/`: `llm.documentFilter: { pattern: "/path/to/my_project/**" }`
- to match on all python and rust files: `llm.documentFilter: { pattern: "**/*.{py,rs}" }`

### Keybindings

**llm-vscode** sets two keybindings:
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "huggingface-vscode",
"displayName": "llm-vscode",
"description": "LLM powered development for VS Code",
"version": "0.1.1",
"version": "0.1.2",
"publisher": "HuggingFace",
"icon": "small_logo.png",
"engines": {
Expand Down Expand Up @@ -174,6 +174,16 @@
],
"default": null,
"description": "Tokenizer configuration for the model, check out the documentation for more details"
},
"llm.documentFilter": {
"type": [
"object",
"array"
],
"default": {
"pattern": "**"
},
"description": "Filter documents to enable suggestions for"
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as vscode from 'vscode';
import {
DocumentFilter,
LanguageClient,
LanguageClientOptions,
ServerOptions,
Expand Down Expand Up @@ -170,7 +171,8 @@ export function activate(context: vscode.ExtensionContext) {
},

};
vscode.languages.registerInlineCompletionItemProvider({ pattern: '**' }, provider);
const documentFilter = config.get("documentFilter") as DocumentFilter | DocumentFilter[];
vscode.languages.registerInlineCompletionItemProvider(documentFilter, provider);
}

export function deactivate() {
Expand Down

0 comments on commit 213d151

Please sign in to comment.