Skip to content

Commit

Permalink
feat: typescript-tool actions
Browse files Browse the repository at this point in the history
  • Loading branch information
TwIStOy committed Nov 21, 2023
1 parent bc869d5 commit bf79f56
Showing 1 changed file with 57 additions and 39 deletions.
96 changes: 57 additions & 39 deletions src/conf/plugins/lsp/typescript-tools-nvim.ts
Original file line number Diff line number Diff line change
@@ -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",
Expand All @@ -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));

0 comments on commit bf79f56

Please sign in to comment.