echasnovski / mini.nvim

Library of 40+ independent Lua modules improving overall Neovim (version 0.8 and higher) experience with minimal effort
MIT License
5.4k stars 191 forks source link

mini.align: add default modifier for pipe (|) #1368

Open aktau opened 5 days ago

aktau commented 5 days ago

Contributing guidelines

Module(s)

mini.align

Description

There's already some pre-existing modifiers for common splits, like =. For example:

https://github.com/echasnovski/mini.nvim/blob/c8922aef8207137e66c80acdb9523668599ba62a/lua/mini/align.lua#L595-L601

I think the pipe is another common one. I use it a lot for markdown-like tables (also in plain text). I've got the following:

      -- Add special modifier for pipes, often used for (markdown) tables.
      -- mini.align already has builtins for ["="], [","] and [" "].
      modifiers = {
        ["|"] = function(steps, opts)
          opts.split_pattern = "|"
          table.insert(steps.pre_justify, mini.align.gen_step.trim("both", "keep"))
          opts.merge_delimiter = ' '
        end,
      },

One could consider adding it to the default set.

echasnovski commented 5 days ago

Thanks for the suggestion!

It does make sense to have this built-in. However, I vaguely remember considering it and opted out for some reason. I'll revisit later.