-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from dcermak/vscode-client
Add a simple VSCode language client
- Loading branch information
Showing
9 changed files
with
1,758 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
--- | ||
name: build the vscode extension | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
|
||
jobs: | ||
build: | ||
|
||
runs-on: ubuntu-latest | ||
|
||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node-version: [18.x, 20.x] | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3.6.0 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
|
||
- name: Get npm cache directory | ||
id: npm-cache-dir | ||
shell: bash | ||
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | ||
|
||
- uses: actions/cache@v3 | ||
id: npm-cache | ||
with: | ||
path: ${{ steps.npm-cache-dir.outputs.dir }} | ||
key: node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: | | ||
-node- | ||
- run: npm install | ||
- run: npm run package | ||
|
||
- uses: actions/upload-artifact@v3 | ||
if: ${{ matrix.node-version == '18.x' }} | ||
with: | ||
name: rpm-spec-language-server.vsix | ||
path: rpm-spec-language-server-*.vsix |
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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/dist/ | ||
/node_modules/ | ||
/clients/vscode/out/ | ||
/rpm-spec-language-server-*.vsix |
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
.* | ||
*~ | ||
*.lock | ||
*.json | ||
*.xml | ||
*.vsix | ||
**/*.ts | ||
**/*.map | ||
**/*.py | ||
**/*.log | ||
dist/** | ||
clients/emacs/** | ||
htmlcov/** | ||
rpm_spec_language_server*/** | ||
tests/** | ||
pyproject.toml | ||
**/__pycache__/* | ||
.github/** | ||
.vscode/** | ||
.pytest_cache/** | ||
source/** | ||
build/** |
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
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import * as net from "net"; | ||
|
||
import { LanguageClient, ServerOptions } from "vscode-languageclient/node"; | ||
|
||
function startLangServerTCP(addr: number): LanguageClient { | ||
let clientSocket: net.Socket; | ||
|
||
const serverOptions: ServerOptions = () => { | ||
return new Promise((resolve) => { | ||
clientSocket = new net.Socket(); | ||
|
||
clientSocket.connect(addr, "127.0.0.1", () => { | ||
resolve({ | ||
reader: clientSocket, | ||
writer: clientSocket, | ||
}); | ||
}); | ||
|
||
clientSocket.on("close", () => { | ||
setTimeout(() => { | ||
clientSocket.connect(addr, "127.0.0.1"); | ||
}, 1000); | ||
}); | ||
}); | ||
}; | ||
|
||
return new LanguageClient(`tcp lang server (port ${addr})`, serverOptions, { | ||
documentSelector: [{ scheme: "file", language: "rpmspec" }], | ||
outputChannelName: "[rpmspec_lsp] RPMSpecFileLanguageServer", | ||
}); | ||
} | ||
|
||
let client: LanguageClient; | ||
|
||
export async function activate() { | ||
client = startLangServerTCP(2087); | ||
await client.start(); | ||
} | ||
|
||
export function deactivate(): Thenable<void> { | ||
return client ? client.stop() : Promise.resolve(); | ||
} |
Oops, something went wrong.