-
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
closes #10 adapted code from #16 thanks to @JamieMagee
- Loading branch information
1 parent
718deed
commit ec3dee3
Showing
5 changed files
with
169 additions
and
11 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
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,53 @@ | ||
// from PR of https://github.com/nix-community/vscode-nix-ide/pull/16/ | ||
|
||
import { env, ExtensionContext, Uri, window, workspace } from "vscode"; | ||
import { | ||
Executable, | ||
LanguageClient, | ||
LanguageClientOptions, | ||
ServerOptions, | ||
} from "vscode-languageclient"; | ||
import { config, UriMessageItem } from "./configuration"; | ||
|
||
let client: LanguageClient; | ||
|
||
export async function activate(context: ExtensionContext): Promise<void> { | ||
if (config.serverPath === undefined || config.serverPath === "") { | ||
const selection = await window.showErrorMessage<UriMessageItem>( | ||
"Unable to find Nix language server", | ||
{ | ||
title: "Install language server", | ||
uri: Uri.parse("https://github.com/nix-community/rnix-lsp"), | ||
} | ||
); | ||
if (selection?.uri !== undefined) { | ||
await env.openExternal(selection?.uri); | ||
return; | ||
} | ||
} | ||
const serverExecutable: Executable = { | ||
command: config.serverPath, | ||
}; | ||
const serverOptions: ServerOptions = serverExecutable; | ||
|
||
const nixDocumentSelector: { scheme: string; language: string }[] = [ | ||
{ scheme: "file", language: "nix" }, | ||
{ scheme: "untitled", language: "nix" }, | ||
]; | ||
|
||
const clientOptions: LanguageClientOptions = { | ||
documentSelector: nixDocumentSelector, | ||
synchronize: { | ||
fileEvents: workspace.createFileSystemWatcher("**/*.nix"), | ||
}, | ||
outputChannel: window.createOutputChannel("Nix"), | ||
}; | ||
|
||
client = new LanguageClient("nix", "Nix", serverOptions, clientOptions); | ||
client.registerProposedFeatures(); | ||
context.subscriptions.push(client.start()); | ||
} | ||
|
||
export function deactivate(): Thenable<void> | undefined { | ||
return client ? client.stop() : undefined; | ||
} |
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,28 @@ | ||
import * as vscode from "vscode"; | ||
|
||
import { MessageItem, Uri } from "vscode"; | ||
|
||
export interface UriMessageItem extends MessageItem { | ||
uri: Uri; | ||
} | ||
|
||
export class Config { | ||
readonly rootSection = "nix"; | ||
|
||
private get cfg(): vscode.WorkspaceConfiguration { | ||
return vscode.workspace.getConfiguration(this.rootSection); | ||
} | ||
|
||
private get<T>(path: string): T { | ||
return this.cfg.get<T>(path)!; | ||
} | ||
|
||
get serverPath(): string { | ||
return this.get<string>("serverPath"); | ||
} | ||
|
||
get LSPEnabled(): boolean { | ||
return this.get<boolean>("enableLanguageServer"); | ||
} | ||
} | ||
export const config = new Config(); |
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 |
---|---|---|
|
@@ -2065,6 +2065,13 @@ loud-rejection@^1.0.0: | |
currently-unhandled "^0.4.1" | ||
signal-exit "^3.0.0" | ||
|
||
lru-cache@^6.0.0: | ||
version "6.0.0" | ||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" | ||
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== | ||
dependencies: | ||
yallist "^4.0.0" | ||
|
||
map-obj@^1.0.0, map-obj@^1.0.1: | ||
version "1.0.1" | ||
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-1.0.1.tgz#d933ceb9205d82bdcf4886f6742bdc2b4dea146d" | ||
|
@@ -2884,6 +2891,13 @@ semver@^6.0.0: | |
resolved "https://registry.yarnpkg.com/semver/-/semver-6.3.0.tgz#ee0a64c8af5e8ceea67687b133761e1becbd1d3d" | ||
integrity sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw== | ||
|
||
semver@^7.3.4: | ||
version "7.3.4" | ||
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.4.tgz#27aaa7d2e4ca76452f98d3add093a72c943edc97" | ||
integrity sha512-tCfb2WLjqFAtXn4KEdxIhalnRtoKFN7nAwj0B3ZXCbQloV2tq5eDbcTmT68JJD3nRJq24/XgxtQKFIpQdtvmVw== | ||
dependencies: | ||
lru-cache "^6.0.0" | ||
|
||
set-blocking@^2.0.0: | ||
version "2.0.0" | ||
resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" | ||
|
@@ -3371,6 +3385,33 @@ vsce@^1.83.0: | |
yauzl "^2.3.1" | ||
yazl "^2.2.2" | ||
|
||
[email protected]: | ||
version "6.0.0" | ||
resolved "https://registry.yarnpkg.com/vscode-jsonrpc/-/vscode-jsonrpc-6.0.0.tgz#108bdb09b4400705176b957ceca9e0880e9b6d4e" | ||
integrity sha512-wnJA4BnEjOSyFMvjZdpiOwhSq9uDoK8e/kpRJDTaMYzwlkrhG1fwDIZI94CLsLzlCK5cIbMMtFlJlfR57Lavmg== | ||
|
||
vscode-languageclient@^7.0.0: | ||
version "7.0.0" | ||
resolved "https://registry.yarnpkg.com/vscode-languageclient/-/vscode-languageclient-7.0.0.tgz#b505c22c21ffcf96e167799757fca07a6bad0fb2" | ||
integrity sha512-P9AXdAPlsCgslpP9pRxYPqkNYV7Xq8300/aZDpO35j1fJm/ncize8iGswzYlcvFw5DQUx4eVk+KvfXdL0rehNg== | ||
dependencies: | ||
minimatch "^3.0.4" | ||
semver "^7.3.4" | ||
vscode-languageserver-protocol "3.16.0" | ||
|
||
[email protected]: | ||
version "3.16.0" | ||
resolved "https://registry.yarnpkg.com/vscode-languageserver-protocol/-/vscode-languageserver-protocol-3.16.0.tgz#34135b61a9091db972188a07d337406a3cdbe821" | ||
integrity sha512-sdeUoAawceQdgIfTI+sdcwkiK2KU+2cbEYA0agzM2uqaUy2UpnnGHtWTHVEtS0ES4zHU0eMFRGN+oQgDxlD66A== | ||
dependencies: | ||
vscode-jsonrpc "6.0.0" | ||
vscode-languageserver-types "3.16.0" | ||
|
||
[email protected]: | ||
version "3.16.0" | ||
resolved "https://registry.yarnpkg.com/vscode-languageserver-types/-/vscode-languageserver-types-3.16.0.tgz#ecf393fc121ec6974b2da3efb3155644c514e247" | ||
integrity sha512-k8luDIWJWyenLc5ToFQQMaSrqCHiLwyKPHKPQZ5zz21vM+vIVUSvsRpcbiECH4WR88K2XZqc4ScRcZ7nk/jbeA== | ||
|
||
vscode-test@^0.4.1: | ||
version "0.4.3" | ||
resolved "https://registry.yarnpkg.com/vscode-test/-/vscode-test-0.4.3.tgz#461ebf25fc4bc93d77d982aed556658a2e2b90b8" | ||
|
@@ -3446,6 +3487,11 @@ y18n@^4.0.0: | |
resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" | ||
integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== | ||
|
||
yallist@^4.0.0: | ||
version "4.0.0" | ||
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" | ||
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== | ||
|
||
yaml@^1.10.0: | ||
version "1.10.0" | ||
resolved "https://registry.yarnpkg.com/yaml/-/yaml-1.10.0.tgz#3b593add944876077d4d683fee01081bd9fff31e" | ||
|