CKolkey / ts-node-action

Neovim Plugin for running functions on nodes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature Request] Integrating cycle_case action with LSP's textDocument/rename

aretrosen opened this issue · comments

I would like to integrate the cycle_case action with LSP rename, so that I can change case of all occurrences of a function or say variable at once. Is it possible to bind a code action with another function? Also, is it possible to apply only one type of code action to a node, say maybe I want to bind a key only for the "Cycle Case" code action?

Sure, I think something like this would work :)

local  function cycle_case_via_lsp()
  local action = require("ts-node-action.actions").cycle_case()[1][1]
  local node   = require("nvim-treesitter.ts_utils").get_node_at_cursor()
  vim.lsp.buf.rename(action(node))
end

vim.keymap.set({ "n" }, "K", cycle_case_via_lsp, { desc = "Apply cycle_case node action via LSP Rename" })

This works! Thank you.