Skip to content

Commit

Permalink
Merge pull request #18 from HexmosTech/origin/suggest-relevant-envs
Browse files Browse the repository at this point in the history
Enhancements to variable auto-completion. 

The MR implements both:

1. Fuzzy and fast env variable auto-completion
2. VSCode word completions

The results of the above two are combined into one auto-completion menu.
  • Loading branch information
shrsv authored Aug 20, 2023
2 parents 25e2085 + 2a6c7c7 commit 352d7e5
Show file tree
Hide file tree
Showing 8 changed files with 195 additions and 1,491 deletions.
5 changes: 3 additions & 2 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,16 @@ This MR [adds/removes/fixes/replaces] the [feature/bug/etc].
- [x] 🙅 no, because they aren't needed
- [ ] 🙋 no, because I need help

## Added to documentation?
## Added to documentation?

- [x] 📜 README.md
- [ ] 🙅 no documentation needed

## Prettify the repositary

`npm run format`

- [ ] 👍
- [ ] 👍
- [x] 🙅 no

## [optional] Are there any post-deployment tasks we need to perform?
Expand Down
32 changes: 32 additions & 0 deletions .github/workflows/publish-extension.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Publish VS Code Extension

on:
push:
branches:
- main # Change this to your default branch if it's not 'main'

jobs:
build-and-publish:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "14"

- name: Install Dependencies
run: npm install

- name: Package Extension
run: npx vsce package

- name: Publish Extension
# npx vsce publish takes either major or minor arg.
# passing minor would make a minor release
# passing major would make a major release
run: npx vsce publish major
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
72 changes: 36 additions & 36 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"devDependencies": {
"@types/glob": "^7.2.0",
"@types/mocha": "^9.1.0",
"@types/node": "14.x",
"@types/node": "16.x",
"@types/vscode": "^1.65.0",
"@typescript-eslint/eslint-plugin": "^5.12.1",
"@typescript-eslint/parser": "^5.12.1",
Expand Down
3 changes: 3 additions & 0 deletions src/executeCurrentFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ var path = require("path");
var json2html = require("json2html");
import splitLama2Output from "./parseOut";
import { getShowLama2Term } from "./utils";
import { MIN_VERSION_TO_CHECK } from "./extension";
import { getL2VersionAndUpdatePrompt } from "./checkL2Version";

class ExecuteCurrentFile {
LAMA2_TERM_NAME = "AutoLama2";
Expand Down Expand Up @@ -237,6 +239,7 @@ class ExecuteCurrentFile {
}

execFile() {
getL2VersionAndUpdatePrompt(MIN_VERSION_TO_CHECK);
let terminal = getShowLama2Term(this.LAMA2_TERM_NAME);
let { cmd, rflag, rfile } = this.getLama2Command();
this.outPath = rfile;
Expand Down
21 changes: 14 additions & 7 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ import {
getDotENVS,
replaceTextAfterEnvSelected,
suggestENVSFromDotEnv,
suggestENVs,
lama2RegisterCompletionItemProvider,
} from "./suggestEnvironmentVars";
import { genLama2Examples } from "./genLama2Examples";
import { execCurL2File } from "./executeCurrentFile";
import { prettifyL2File } from "./prettifyL2File";
import { getL2VersionAndUpdatePrompt } from "./checkL2Version";

const MIN_VERSION_TO_CHECK = "1.5.1";
export const MIN_VERSION_TO_CHECK = "1.5.6";

export function activate(context: vscode.ExtensionContext) {
console.log('>>> Congratulations, your extension "Lama2" is now active!');
Expand Down Expand Up @@ -51,20 +51,27 @@ export function activate(context: vscode.ExtensionContext) {
l2Version === undefined ||
semver.lt(l2Version, MIN_VERSION_TO_CHECK)
) {
// The L2 version, if less than v1.5.0, does not support the `l2 -e <filepath>` feature.
// Therefore, we use the extension to fetch variables from the l2.env file for suggestions.
getDotENVS();
suggestEnvVariables = suggestENVSFromDotEnv();
} else {
suggestEnvVariables = suggestENVs();
// L2 versions greater than or equal to v1.5.0 support the `l2 -e <filepath>` feature.
// Therefore, we fetch variables from both the l2.env and l2config.env files for suggestions using this command.
suggestEnvVariables = lama2RegisterCompletionItemProvider();
}

context.subscriptions.push(
suggestEnvVariables,
vscode.commands.registerCommand("envoptions", () => {
// This method is activated when the user selects a suggested env variable.
replaceTextAfterEnvSelected();
// The following part is unnecessary for L2 versions > 1.5.0
vscode.commands.registerCommand("envoptions", (selectedEnv: string) => {
// This method is triggered when a user selects a suggested environment variable.
replaceTextAfterEnvSelected(selectedEnv);
})
);
}

// this method is called when your extension is deactivated
export function deactivate() {}
export function deactivate() {
console.log("Deactivating the extension");
}
Loading

0 comments on commit 352d7e5

Please sign in to comment.