Skip to content

Commit

Permalink
feat: add enableAutoSuggest setting (#81)
Browse files Browse the repository at this point in the history
* docs: add section about keybindings

* docs: mention `llm-intellij`

* feat: bump version to `0.1.1`
  • Loading branch information
McPatate authored Oct 3, 2023
1 parent 70ecf8a commit 0629a47
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
We also have extensions for:
* [neovim](https://github.com/huggingface/llm.nvim)
* [jupyter](https://github.com/bigcode-project/jupytercoder)
* [intellij](https://github.com/huggingface/llm-intellij)

Previously **huggingface-vscode**.

Expand Down Expand Up @@ -89,6 +90,12 @@ 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.

### Keybindings

**llm-vscode** sets two keybindings:
* you can trigger suggestions with `Cmd+shift+l` by default, which corresponds to the `editor.action.inlineSuggest.trigger` command
* [code attribution](#code-attribution) is set to `Cmd+shift+a` by default, which corresponds to the `llm.attribution` command

### [**llm-ls**](https://github.com/huggingface/llm-ls)

By default, **llm-ls** is bundled with the extension. When developing locally or if you built your own binary because your platform is not supported, you can set the `llm.lsp.binaryPath` setting to the path of the binary.
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.

7 changes: 6 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.0",
"version": "0.1.1",
"publisher": "HuggingFace",
"icon": "small_logo.png",
"engines": {
Expand Down Expand Up @@ -72,6 +72,11 @@
{
"title": "Llm",
"properties": {
"llm.enableAutoSuggest": {
"type": "boolean",
"default": true,
"description": "Enable automatic suggestions"
},
"llm.configTemplate": {
"type": "string",
"enum": [
Expand Down
9 changes: 5 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export function activate(context: vscode.ExtensionContext) {
if (command.startsWith("~/")) {
command = homedir() + command.slice("~".length);
}
console.log(`command: ${command}`);
const serverOptions: ServerOptions = {
run: {
command, transport: TransportKind.stdio, options: {
Expand Down Expand Up @@ -113,13 +112,15 @@ export function activate(context: vscode.ExtensionContext) {
ctx.subscriptions.push(attribution);
const provider: vscode.InlineCompletionItemProvider = {
async provideInlineCompletionItems(document, position, context, token) {
console.log(context);
const config = vscode.workspace.getConfiguration("llm");
const autoSuggest = config.get("enableAutoSuggest") as boolean;
if (context.triggerKind === vscode.InlineCompletionTriggerKind.Automatic && !autoSuggest) {
return;
}
if (position.line <= 0) {
console.log("line <= 0");
return;
}

const config = vscode.workspace.getConfiguration("llm");
let params = {
position,
textDocument: client.code2ProtocolConverter.asTextDocumentIdentifier(document),
Expand Down

0 comments on commit 0629a47

Please sign in to comment.