I have a Lua file (part of an nvim-cmp config) with a snippet that looks like this:
local mapping = {
["<C-n>"] = {
i = complete_and_select_next,
c = function()
if not expand_special_cmd_items() then
complete_and_select_next()
end
end,
},
["<C-p>"] = {
i = complete_and_select_prev,
c = function()
if not expand_special_cmd_items() then
complete_and_select_prev()
end
end,
},
["<C-y>"] = {
i = require "cmp.config.mapping".confirm({ select = false }),
c = require "cmp.config.mapping".confirm({ select = false }),
},
["<C-e>"] = {
i = require "cmp.config.mapping".abort(),
c = require "cmp.config.mapping".abort(),
},
["<C-z>"] = {
-- Normally <C-z> in command mode triggers wildmenu, so this is analogous.
c = complete_and_select_next,
},
-- We don't enable up/down for command line b/c they are used to navigate history.
["<Up>"] = {
i = select_prev_or_fall_back,
},
["<Down>"] = {
i = select_next_or_fall_back,
},
["<Enter>"] = {
i = function(fallback)
cmp.close()
fallback()
end,
},
}
mapping["<Tab>"] = mapping["<C-n>"]
mapping["<S-Tab>"] = mapping["<C-p>"]
These are technically continuous assign statements, but the first one is so large that aligning it with the latter two doesn't really make sense. I think in general the readability benefit of aligning the assignments probably only applies to sequences of single-line assignments.
I have a Lua file (part of an nvim-cmp config) with a snippet that looks like this:
These are technically continuous assign statements, but the first one is so large that aligning it with the latter two doesn't really make sense. I think in general the readability benefit of aligning the assignments probably only applies to sequences of single-line assignments.