Skip to content

Commit

Permalink
feat(command): add ruff.debugInformation command (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaegassy authored Jun 15, 2024
1 parent 4f33b0d commit d33f285
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
24 changes: 24 additions & 0 deletions src/commands/debugInformation.ts
Original file line number Diff line number Diff line change
@@ -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<boolean>('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();
}),
);
}
2 changes: 2 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -51,6 +52,7 @@ export async function activate(context: ExtensionContext): Promise<void> {
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);
Expand Down

0 comments on commit d33f285

Please sign in to comment.