nvim-trevJ.lua
nvim-trevJ.lua copied to clipboard
SplitJoin.vim-like toggle functionality
Is it possible to split a node under the cursor if pressed once and join if pressed again?
Not at the moment but sounds like a nice feature
This is a bit of a hack, but I got this to work:
M.join_at_cursor = function()
local filetype = vim.bo.filetype
if settings.containers[filetype] == nil then
warn("filetype %s is not configured", filetype)
return
end
local node = get_container_at_cursor(filetype)
if node then
local srow, _, erow, _ = node:range()
vim.cmd(string.format([[%d,%djoin]], srow + 1, erow + 1))
else
warn "no container at cursor"
end
end