-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
141 additions
and
79 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
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,21 @@ | ||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. | ||
|
||
import { InitializeResult } from "vscode-languageclient"; | ||
|
||
export class DenoServerInfo { | ||
readonly #fullVersion: string; | ||
|
||
constructor(serverInfo: InitializeResult["serverInfo"]) { | ||
this.#fullVersion = serverInfo?.version ?? ""; | ||
} | ||
|
||
/** Gets the version with configuration and architecture. Ex: x.x.x (release, x86_64-etc) */ | ||
get versionWithBuildInfo() { | ||
return this.#fullVersion; | ||
} | ||
|
||
/** Gets the version. Ex. x.x.x */ | ||
get version() { | ||
return this.#fullVersion.split(" ")[0]; | ||
} | ||
} |
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,59 @@ | ||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. | ||
|
||
import type { ConfigurationScope } from "vscode"; | ||
|
||
// types shared with typescript-deno-plugin | ||
|
||
/** When `vscode.WorkspaceSettings` get serialized, they keys of the | ||
* configuration are available. This interface should mirror the configuration | ||
* contributions made by the extension. | ||
*/ | ||
export interface Settings { | ||
/** Specify an explicit path to the `deno` cache instead of using DENO_DIR | ||
* or the OS default. */ | ||
cache: string | null; | ||
/** Settings related to code lens. */ | ||
codeLens: { | ||
implementations: boolean; | ||
references: boolean; | ||
referencesAllFunctions: boolean; | ||
test: boolean; | ||
testArgs: string[]; | ||
} | null; | ||
/** A path to a `tsconfig.json` that should be applied. */ | ||
config: string | null; | ||
/** Is the extension enabled or not. */ | ||
enable: boolean; | ||
/** A path to an import map that should be applied. */ | ||
importMap: string | null; | ||
/** A flag that enables additional internal debug information to be printed | ||
* to the _Deno Language Server_ output. */ | ||
internalDebug: boolean; | ||
/** Determine if the extension should be providing linting diagnostics. */ | ||
lint: boolean; | ||
/** Specify an explicit path to the `deno` binary. */ | ||
path: string | null; | ||
suggest: { | ||
autoImports: boolean; | ||
completeFunctionCalls: boolean; | ||
names: boolean; | ||
paths: boolean; | ||
imports: { | ||
autoDiscover: boolean; | ||
hosts: Record<string, boolean>; | ||
} | null; | ||
} | null; | ||
/** Determine if the extension should be type checking against the unstable | ||
* APIs. */ | ||
unstable: boolean; | ||
} | ||
|
||
export interface PluginSettings { | ||
workspace: Settings; | ||
documents: Record<string, DocumentSettings>; | ||
} | ||
|
||
export interface DocumentSettings { | ||
scope: ConfigurationScope; | ||
settings: Partial<Settings>; | ||
} |
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,38 @@ | ||
// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. | ||
|
||
import { DenoExtensionContext } from "./types"; | ||
|
||
import * as vscode from "vscode"; | ||
|
||
export class DenoStatusBar { | ||
readonly #inner: vscode.StatusBarItem; | ||
|
||
constructor() { | ||
this.#inner = vscode.window.createStatusBarItem( | ||
vscode.StatusBarAlignment.Right, | ||
0, | ||
); | ||
} | ||
|
||
dispose() { | ||
this.#inner.dispose(); | ||
} | ||
|
||
refresh(extensionContext: DenoExtensionContext) { | ||
if (extensionContext.serverInfo) { | ||
this.#inner.text = `Deno ${extensionContext.serverInfo.version}`; | ||
this.#inner.tooltip = extensionContext.serverInfo.versionWithBuildInfo; | ||
} | ||
|
||
// show only when "enable" is true and language server started | ||
if ( | ||
extensionContext.workspaceSettings.enable && | ||
extensionContext.client && | ||
extensionContext.serverInfo | ||
) { | ||
this.#inner.show(); | ||
} else { | ||
this.#inner.hide(); | ||
} | ||
} | ||
} |
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
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