diff --git a/src/conf/plugins/lsp/typescript-tools-nvim.ts b/src/conf/plugins/lsp/typescript-tools-nvim.ts index a5bf2e5b..d984cb21 100644 --- a/src/conf/plugins/lsp/typescript-tools-nvim.ts +++ b/src/conf/plugins/lsp/typescript-tools-nvim.ts @@ -1,4 +1,58 @@ -import { Plugin, PluginOpts, buildSimpleCommand } from "@core/model"; +import { + ActionGroupBuilder, + Plugin, + PluginOpts, + andActions, + buildSimpleCommand, +} from "@core/model"; + +function generateActions() { + return ActionGroupBuilder.start() + .category("TSTools") + .from("typescript-tools.nvim") + .addOpts({ + id: "typescript-tools.organize-imports", + title: "Sorts and removes unused imports", + callback: "TSToolsOrganizeImports", + }) + .addOpts({ + id: "typescript-tools.sort-imports", + title: "Sorts imports", + callback: "TSToolsSortImports", + }) + .addOpts({ + id: "typescript-tools.remove-unused-imports", + title: "Removes unused imports", + callback: "TSToolsRemoveUnusedImports", + }) + .addOpts({ + id: "typescript-tools.remove-unused", + title: "Removes all unused statements", + callback: "TSToolsRemoveUnused", + }) + .addOpts({ + id: "typescript-tools.add-missing-imports", + title: + "Adds imports for all statements that lack one and can be imported", + callback: "TSToolsAddMissingImports", + }) + .addOpts({ + id: "typescript-tools.fix-all", + title: "Fixes all fixable erros in the current file", + callback: "TSToolsFixAll", + }) + .addOpts({ + id: "typescript-tools.go-to-source-definition", + title: "Go to the source definition", + callback: "TSToolsGoToSourceDefinition", + }) + .addOpts({ + id: "typescript-tools.rename-file", + title: "Rename file and apply changes to connected files", + callback: "TSToolsRenameFile", + }) + .build(); +} export const spec: PluginOpts = { shortUrl: "pmizio/typescript-tools.nvim", @@ -16,43 +70,7 @@ export const spec: PluginOpts = { "TSToolsRenameFile", ], }, - allowInVscode: false, - extends: { - commands: { - category: "TSTools", - commands: [ - buildSimpleCommand( - "Sorts and removes unused imports", - "TSToolsOrganizeImports" - ), - buildSimpleCommand("Sorts imports", "TSToolsSortImports"), - buildSimpleCommand( - "Removes unused imports", - "TSToolsRemoveUnusedImports" - ), - buildSimpleCommand( - "Removes all unused statements", - "TSToolsRemoveUnused" - ), - buildSimpleCommand( - "Adds imports for all statements that lack one and can be imported", - "TSToolsAddMissingImports" - ), - buildSimpleCommand( - "Fixes all fixable erros in the current file", - "TSToolsFixAll" - ), - buildSimpleCommand( - "Go to the source definition", - "TSToolsGoToSourceDefinition" - ), - buildSimpleCommand( - "Rename file and apply changes to connected files", - "TSToolsRenameFile" - ), - ], - }, - }, + allowInVscode: false, }; -export const plugin = new Plugin(spec); +export const plugin = new Plugin(andActions(spec, generateActions));