Closed zbindenren closed 1 year ago
This is a very interesting idea!! This should definitely be possible to do. Although this might be a little tricky to implement, I can see there being lots of corners cases to be handled. Will definitely try it though
Added the move up and down actions. Although I implemented it only for nodes on different lines with no overlaps in lines. I am still pleased with how it works right now.
Had tried adding code to move the comments (above the node) as well with the node, but had trouble writting code to consistently identify comments lines. If any one has any ideas about this do let me know.
This was the best attempt I had made using Comment.nvim to detect if entire line above the node is comment or not
local utils = require("Comment.utils")
local config = require("Comment.config")
local function isComment()
local lcs, rcs = utils.parse_cstr(config:get(), {
ctype = utils.ctype.linewise,
-- ctype = utils.ctype.blockwise,
cmode = utils.cmode.uncomment,
cmotion = utils.cmotion.line,
range = {
srow = 0,
scol = 0,
erow = 0,
ecol = 1
}
})
local check_comment = utils.is_commented(lcs, rcs, config:get().padding)
-- This is comment
local row, _ = unpack(vim.api.nvim_win_get_cursor(0))
local lines = vim.api.nvim_buf_get_lines(0, row-1, row, false)
print(check_comment(lines[1]))
end
Added the move up and down actions. Although I implemented it only for nodes on different lines with no overlaps in lines. I am still pleased with how it works right now.
Feature is working for me, so I am closing issue.
THX.
I am not sure if this is possible, but it would be great for refactoring, to navigate a buffer with navbuddy and move functions, structs etc. up and down.