diff --git a/README.md b/README.md index d64c149..b07ebf2 100644 --- a/README.md +++ b/README.md @@ -145,6 +145,7 @@ Other settings have the same configuration as [ruff-vscode](https://github.com/a - `ruff.executeAutofix`: Fix all auto-fixable problems - `ruff.executeFormat`: Format document - `ruff.executeOrganizeImports`: Format imports +- `ruff.debugInformation`: Print debug information (native server only) - `ruff.showOutput`: Show ruff output channel - `ruff.restart`: Restart Server - `ruff.builtin.installServer`: Install ruff-lsp diff --git a/package.json b/package.json index 75b8bc1..4a4bd70 100644 --- a/package.json +++ b/package.json @@ -302,6 +302,11 @@ "command": "ruff.executeOrganizeImports", "title": "Format imports" }, + { + "title": "Print debug information (native server only)", + "category": "Ruff", + "command": "ruff.debugInformation" + }, { "command": "ruff.showOutput", "title": "Show ruff output channel" diff --git a/src/commands/debugInformation.ts b/src/commands/debugInformation.ts new file mode 100644 index 0000000..91efc53 --- /dev/null +++ b/src/commands/debugInformation.ts @@ -0,0 +1,24 @@ +import { commands, ExtensionContext, LanguageClient, window, workspace } from 'coc.nvim'; +import { ExecuteCommandRequestType } from '../requestTypes'; + +export async function register(context: ExtensionContext, client: LanguageClient) { + await client.onReady(); + + context.subscriptions.push( + commands.registerCommand('ruff.debugInformation', async () => { + if (!client || !workspace.getConfiguration('ruff').get('nativeServer')) { + return; + } + + const params = { + command: `ruff.printDebugInformation`, + }; + + await client.sendRequest(ExecuteCommandRequestType, params).then(undefined, async () => { + await window.showErrorMessage('Failed to print debug information.'); + }); + + client.outputChannel.show(); + }), + ); +} diff --git a/src/index.ts b/src/index.ts index 50781f0..0f28a03 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,6 +8,7 @@ import * as executeAutofixCommandFeature from './commands/executeAutofix'; import * as executeFormatCommandFeature from './commands/executeFormat'; import * as executeOrganizeImportsCommandFeature from './commands/executeOrganizeImports'; import * as restartCommandFeature from './commands/restart'; +import * as debugInformationCommandFeature from './commands/debugInformation'; import * as showOutputCommandFeature from './commands/showOutput'; import * as autoFixOnSaveFeature from './features/autoFixOnSave'; import * as showDocumentationCodeActionFeature from './features/showDocumentation'; @@ -51,6 +52,7 @@ export async function activate(context: ExtensionContext): Promise { executeAutofixCommandFeature.register(context, client); executeOrganizeImportsCommandFeature.register(context, client); executeFormatCommandFeature.register(context, client); + debugInformationCommandFeature.register(context, client); restartCommandFeature.register(context, client); autoFixOnSaveFeature.register(client); showDocumentationCodeActionFeature.register(context, client);