CKolkey / ts-node-action

Neovim Plugin for running functions on nodes.
359 stars 20 forks source link

Getting Started - Setting Keymaps for Builtin Actions #52

Closed CharlesARoy closed 1 year ago

CharlesARoy commented 1 year ago

Apologies for asking such a basic question, but I'm having a hard time getting keymaps to work for the builtin functions.

I can successfully create and use the keymap for node_action, as described under Usage, e.g.:

vim.keymap.set(
    { "n" },
    "K",
    require("ts-node-action").node_action,
    { desc = "Trigger Node Action" },
)

But when I try something similar for the builtin actions, they aren't working. For example, I tried a few variations of:

vim.keymap.set(
    { "n" },
    "C",
    require('ts-node-action.actions').cycle_quotes(),
    { desc = "Cycle Quotes" },
)

My setup function is currently empty, e.g. ts_node_action.setup({}). I assumed that for the builtins, I wouldn't need to specify the languages and node types, but maybe that's my issue?

Any help is appreciated!

CKolkey commented 1 year ago

You only need the one keymap for require("ts-node-action").node_action set - the built-in actions trigger based on the type of node your cursor is over. So, if you're on a string node, triggering that keymap should change the quotes.

If that doesn't work, lemme know what language you're using and we can try to sort it out.

CharlesARoy commented 1 year ago

Gotcha, that clears that up. Thanks!