Skip to content

Commit

Permalink
feat: mason actions
Browse files Browse the repository at this point in the history
  • Loading branch information
TwIStOy committed Nov 21, 2023
1 parent 13b3cf4 commit bc869d5
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/conf/plugins/lsp/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import { plugin as mason } from "./mason";
import { plugin as aerial } from "./aerial";
import { plugin as typescriptToolsNvim } from "./typescript-tools-nvim";

export const plugins = [mason, aerial, typescriptToolsNvim];
export const plugins = [mason, aerial, typescriptToolsNvim] as const;
49 changes: 47 additions & 2 deletions src/conf/plugins/lsp/mason.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { AllMaybeMasonPackage } from "@conf/external_tools";
import { Plugin, PluginOpts } from "@core/model";
import {
ActionGroupBuilder,
Plugin,
PluginOpts,
andActions,
} from "@core/model";
import { inputArgsAndExec } from "@core/vim";

const spec: PluginOpts = {
shortUrl: "williamboman/mason.nvim",
Expand All @@ -22,6 +28,45 @@ const spec: PluginOpts = {
},
};

function generateActions() {
return ActionGroupBuilder.start()
.category("Mason")
.from("mason.nvim")
.addOpts({
id: "mason.open-window",
title: "Open mason window",
callback: "Mason",
})
.addOpts({
id: "mason.install",
title: "Install a tool",
callback: inputArgsAndExec("MasonInstall"),
})
.addOpts({
id: "mason.update",
title: "Update a tool",
callback: "MasonUpdate",
description: "Update a tool",
})
.addOpts({
id: "mason.uninstall",
title: "Uninstall a tool",
callback: inputArgsAndExec("MasonUninstall"),
description: "Uninstall a tool",
})
.addOpts({
id: "mason.uninstall-all",
title: "Uninstall all tools",
callback: "MasonUninstallAll",
})
.addOpts({
id: "mason.show-log",
title: "Show mason log",
callback: "MasonLog",
})
.build();
}

async function config(_: any, opts: AnyNotNil) {
luaRequire("mason").setup(opts);

Expand Down Expand Up @@ -99,4 +144,4 @@ async function config(_: any, opts: AnyNotNil) {
}
}

export const plugin = new Plugin(spec);
export const plugin = new Plugin(andActions(spec, generateActions));

0 comments on commit bc869d5

Please sign in to comment.