Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(command): add ruff.debugInformation command #25

Merged
merged 1 commit into from
Jun 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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