Closed PMassicotte closed 4 months ago
Congratulations! The functions work well. But I'm getting these warnings:
Missing <Plug> label in description table: 'RSourceCurrentFun'
Missing <Plug> label in description table: 'RDSourceCurrentFun'
You used different labels in the map_desc
table and while creating the maps: RSourceCurrentFun
x RSendCurrentFun
, and RDSourceCurrentFun
x RDSendCurrentFun
.
It seems that the cursor is moving to the next line after the function, not the next non-empty line. Also, maybe you could send all functions in a single 'source()` command, as below:
local lines = {}
for id, node in r_fun_query:iter_captures(root_node, bufnr, 0, -1) do
local name = r_fun_query.captures[id]
-- Kinda hacky, but it works. Check if the parent of the function is
-- the root node, if so, it's a top level function
local s, _, _, _ = node:parent():range()
if name == "rfun" and s == 0 then
local start_row, _, end_row, _ = node:range()
-- Only send the function if the user wants to capture the current
-- function
if
capture_all or (cursor_pos >= start_row + 1 and cursor_pos <= end_row + 1)
then
M.source_lines(lines, nil)
lines = vim.fn.extend(
lines,
vim.api.nvim_buf_get_lines(bufnr, start_row, end_row + 1, false)
)
if move_down == true then
vim.api.nvim_win_set_cursor(bufnr, { end_row + 1, 0 })
cursor.move_next_line()
end
end
end
end
if #lines then M.source_lines(lines) end
Tx for the feedback, I will make the change tomorrow morning!
Congratulations! The functions work well. But I'm getting these warnings:
Missing <Plug> label in description table: 'RSourceCurrentFun' Missing <Plug> label in description table: 'RDSourceCurrentFun'
You used different labels in the
map_desc
table and while creating the maps:RSourceCurrentFun
xRSendCurrentFun
, andRDSourceCurrentFun
xRDSendCurrentFun
.
Good catch!
Is it ready to merge, or do you still plan to work on it?
All good for now!
Thank you! This implements a missing feature!
This PR creates 3 news functions:
<localleader>fc
, (function current)<localleader>fd
, (function current and move down)<localleader>fa
, (function all)