Closed svartkanin closed 1 month ago
This (not adding trailing comma) is the default behavior. Customizing it for specific languages is left to users. The dedicated customization approach is via hooks with built-in gen_hooks
table containing several most common cases. Handling of trailing comma included.
This is use case can be resolved by creating '~/.config/nvim/after/ftplugin/go.lua' with the following content:
if _G.MiniSplitjoin ~= nil then
local gen_hook = MiniSplitjoin.gen_hook
local parens = { brackets = { '%b()' } }
-- Add trailing comma when splitting inside parenthesis
local add_comma_parens = gen_hook.add_trailing_separator(parens)
-- Delete trailing comma when joining inside parenthesis
local del_comma_parens = gen_hook.del_trailing_separator(parens)
vim.b.minisplitjoin_config = {
split = { hooks_post = { add_comma_parens } },
join = { hooks_post = { del_comma_parens } },
}
end
Aahh perfect thanks for the quick reply
Contributing guidelines
Module(s)
mini.splitjoin
Description
In Golang when a split of arguments is donw it will correctly put each argument on a new line, e.g.
But Golang requires the last argument to be suffixed with a
,
to compile, so the correct split should result inNeovim version
NVIM v0.10.0
Steps to reproduce
mkdir test && cd test && go mod init test.com
touch main.go
func test(a int, b int, c int) { println("test") }
func main() { test(1, 2, 3) }
func test( a int, b int, c int, ) {
func test( a int, b int, c int ) {