Skip to content

Commit

Permalink
...
Browse files Browse the repository at this point in the history
  • Loading branch information
TwIStOy committed Nov 21, 2023
1 parent 4f8ca54 commit d1fad84
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 43 deletions.
12 changes: 8 additions & 4 deletions src/conf/plugins/treesitter/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import {plugin as treesj} from "./treesj";
import {plugin as nvimTreesitterEndwise} from "./nvim-treesitter-endwise";
import {plugin as nvimTreesitterTextobject} from "./nvim-treesitter-textobject";
import { plugin as treesj } from "./treesj";
import { plugin as nvimTreesitterEndwise } from "./nvim-treesitter-endwise";
import { plugin as nvimTreesitterTextobject } from "./nvim-treesitter-textobject";

export const plugins = [treesj, nvimTreesitterEndwise, nvimTreesitterTextobject];
export const plugins = [
treesj,
nvimTreesitterEndwise,
nvimTreesitterTextobject,
] as const;
77 changes: 38 additions & 39 deletions src/conf/plugins/treesitter/nvim-treesitter-textobject.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { Plugin, PluginOpts } from "@core/model";
import {
ActionGroupBuilder,
Plugin,
PluginOpts,
andActions,
} from "@core/model";

const spec: PluginOpts = {
shortUrl: "nvim-treesitter/nvim-treesitter-textobjects",
Expand Down Expand Up @@ -52,43 +57,37 @@ const spec: PluginOpts = {
luaRequire("nvim-treesitter.configs").setup(opts);
},
},
allowInVscode: true,
extends: {
commands: {
category: "Textobject",
enabled: (buffer) => {
return buffer.tsHighlighter.length > 0;
},
commands: [
{
name: "Swap previous",
callback: () => {
luaRequire("nvim-treesitter.textobjects.swap").swap_previous(
"@parameter.inner"
);
},
rightClick: {
title: "Swap previous",
keys: [","],
index: 1,
},
},
{
name: "Swap next",
callback: () => {
luaRequire("nvim-treesitter.textobjects.swap").swap_next(
"@parameter.inner"
);
},
rightClick: {
title: "Swap next",
keys: ["."],
index: 2,
},
},
],
},
},
allowInVscode: true,
};

export const plugin = new Plugin(spec);
function generateActions() {
return ActionGroupBuilder.start()
.from("nvim-treesitter-textobjects")
.category("TSTextObjects")
.condition((buf) => {
return buf.tsHighlighter.length > 0;
})
.addOpts({
id: "treesitter-textobjects.swap-previous",
title: "Swap previous",
callback: () => {
luaRequire("nvim-treesitter.textobjects.swap").swap_previous(
"@parameter.inner"
);
},
keys: ",",
})
.addOpts({
id: "treesitter-textobjects.swap-next",
title: "Swap next",
callback: () => {
luaRequire("nvim-treesitter.textobjects.swap").swap_next(
"@parameter.inner"
);
},
keys: ".",
})
.build();
}

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

0 comments on commit d1fad84

Please sign in to comment.