Skip to content

Commit

Permalink
WIP - Source clojuredocs from clojure-lsp
Browse files Browse the repository at this point in the history
Adding a command for testing how to get clojuredocs.
(Which can't be done yet, see:
clojure-lsp/clojure-lsp#598)
Addressing #689
  • Loading branch information
PEZ committed Oct 24, 2021
1 parent 11edd5f commit 4251238
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1516,6 +1516,11 @@
"title": "Clojure-lsp Server Info",
"category": "Calva Diagnostics"
},
{
"category": "Calva",
"command": "calva.clojuredocs",
"title": "Clojuredocs"
},
{
"category": "Calva",
"command": "calva.toggleBetweenImplAndTest",
Expand Down
22 changes: 22 additions & 0 deletions src/lsp/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,23 @@ async function serverInfoCommandHandler(): Promise<void> {
}
}

async function clojuredocsCommandHandler(): Promise<void> {
const client = getStateValue(LSP_CLIENT_KEY);
if (client) {
const clojuredocs = await getClojuredocs(client);
const calvaSaysChannel = state.outputChannel();
calvaSaysChannel.appendLine(`Clojuredocs:`);
const clojuredocsPretty = JSON.stringify(clojuredocs, null, 2);
calvaSaysChannel.appendLine(clojuredocsPretty);
calvaSaysChannel.show(true);
} else {
vscode.window.showInformationMessage('There is no clojure-lsp server running.');
}
}

async function activate(context: vscode.ExtensionContext): Promise<void> {
vscode.commands.registerCommand('calva.diagnostics.clojureLspServerInfo', serverInfoCommandHandler);
vscode.commands.registerCommand('calva.clojuredocs', clojuredocsCommandHandler);
const extensionPath = context.extensionPath;
const currentVersion = readVersionFile(extensionPath);
const userConfiguredClojureLspPath = config.getConfig().clojureLspPath;
Expand Down Expand Up @@ -368,6 +383,13 @@ async function getServerInfo(lspClient: LanguageClient): Promise<any> {
return lspClient.sendRequest('clojure/serverInfo/raw');
}

async function getClojuredocs(lspClient: LanguageClient): Promise<any> {
return lspClient.sendRequest('clojure/clojuredocs/raw', {
symName: 'pprint',
symNs: 'clojure.core'
});
}

export default {
activate,
deactivate,
Expand Down

0 comments on commit 4251238

Please sign in to comment.