Skip to content

Commit

Permalink
Add "Reload Import Registries" command
Browse files Browse the repository at this point in the history
  • Loading branch information
sgwilym committed Jun 19, 2024
1 parent 4641516 commit 0eb21b6
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions deno.novaextension/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## NEXT

- Add a new "Reload Import Registries" command.
- Manually restart the server when the config file changes.
- The "Cache dependencies" command was broken by the underlying command having been removed from the LSP. It has now been updated to the new command.
- Removed the workspace "Enabled paths" and "Disabled paths" setting. If you were to add some enabled paths and remove all of them, Nova would leave an empty array, which would make the Deno LSP decide not to be enabled for anything. If you need to conditionally disable which files are analysed by the LSP, use the deno.json `exclude` option to do so.
Expand Down
7 changes: 7 additions & 0 deletions deno.novaextension/extension.json
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,13 @@
"syntaxes": ["typescript", "tsx", "javascript", "jsx"]
}
},
{
"title": "Reload Import Registries",
"command": "co.gwil.deno.commands.reloadImportRegistries",
"filters": {
"syntaxes": ["typescript", "tsx", "javascript", "jsx"]
}
},
{
"title": "Restart Deno LSP server",
"command": "co.gwil.deno.commands.restartServer"
Expand Down
4 changes: 2 additions & 2 deletions src/client_disposable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import registerFormatDocument from "./commands/format_document.ts";
import registerCache from "./commands/cache.ts";
import registerReloadImportRegistries from "./commands/reload_import_registries.ts";
import registerRenameSymbol from "./commands/rename_symbol.ts";
import registerPaletteFindSymbol from "./commands/palette_find_symbol.ts";
import registerSymbolSidebarFindSymbol from "./commands/sidebar_find_symbol.ts";
Expand All @@ -9,7 +10,6 @@ import { getOverridableBoolean, wrapCommand } from "nova-utils";
const FORMAT_ON_SAVE_CONFIG_KEY = "co.gwil.deno.config.formatOnSave";
const TRUSTED_HOSTS_CONFIG_KEY = "co.gwil.deno.config.trustedImportHosts";
const UNTRUSTED_HOSTS_CONFIG_KEY = "co.gwil.deno.config.untrustedImportHosts";
const ENABLED_PATHS_CONFIG_KEY = "deno.enablePaths";

// Deno expects a map of hosts for its autosuggestion feature, where each key is a URL and its value a bool representing whether it is trusted or not. Nova does not have a Configurable like this, so we'll have to assemble one out of two arrays.

Expand Down Expand Up @@ -113,7 +113,6 @@ export async function makeClientDisposable(
},
{
syntaxes,
debug: true,
initializationOptions: {
enable: true,

Expand Down Expand Up @@ -150,6 +149,7 @@ export async function makeClientDisposable(
try {
clientDisposable.add(registerFormatDocument(client));
clientDisposable.add(registerCache(client));
clientDisposable.add(registerReloadImportRegistries(client));
clientDisposable.add(registerRenameSymbol(client));

// palette Find Symbol command
Expand Down
2 changes: 1 addition & 1 deletion src/commands/cache.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isWorkspace, wrapCommand } from "nova-utils";

export default function cache(client: LanguageClient) {
export default function registerCache(client: LanguageClient) {
return nova.commands.register(
"co.gwil.deno.commands.cache",
wrapCommand(cache),
Expand Down
14 changes: 14 additions & 0 deletions src/commands/reload_import_registries.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { wrapCommand } from "nova-utils";

export default function registerReloadImportRegistries(client: LanguageClient) {
return nova.commands.register(
"co.gwil.deno.commands.reloadImportRegistries",
wrapCommand(reloadImportRegistries),
);

async function reloadImportRegistries() {
await client.sendRequest("workspace/executeCommand", {
command: "deno.reloadImportRegistries",
});
}
}

0 comments on commit 0eb21b6

Please sign in to comment.