Skip to content

Commit

Permalink
Merge pull request #37 from AckslD/fix-r
Browse files Browse the repository at this point in the history
fix(): handle cases where brackets are not children of container
  • Loading branch information
AckslD committed Feb 19, 2024
2 parents 7f40154 + e856822 commit 96196f9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# nvim-trevJ.lua

:warning: *This plugin is in an early stage and docs is a bit sparse. Feel free to try it out though and let me know if you have any problems/suggestions.*

Nvim-plugin for doing the opposite of join-line (J) of arguments, powered by treesitter.
The intention of the plugin is the same as [`revJ`](https://github.com/AckslD/nvim-revJ.lua).
However `trevJ` uses treesitter to figure out the formatting and in general does everything much more efficient and better, while not polluting registers, last visual selection etc.
Expand Down
9 changes: 9 additions & 0 deletions lua/trevj.lua
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ local settings = {
parameter_list = make_default_opts(),
parameter_call_list = make_default_opts(),
},
r = {
arguments = make_no_final_sep_opts(),
},
}, make_javascript_typescript_containers()),
}

Expand Down Expand Up @@ -226,7 +229,13 @@ M.format_at_cursor = function()
new_lines[#new_lines] = new_lines[#new_lines] .. table.remove(lines, 1)
vim.list_extend(new_lines, lines)
elseif child:named() then
if #new_lines == 0 then
new_lines = { "" }
end
vim.list_extend(new_lines, indent_lines(lines, indent + shiftwidth))
if opts.final_end_line and i == #children then
vim.list_extend(new_lines, { "" })
end
else
if opts.final_end_line and i == #children then
vim.list_extend(new_lines, indent_lines(lines, indent))
Expand Down

0 comments on commit 96196f9

Please sign in to comment.