echasnovski / mini.nvim

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

Add format function for LSP progress #1275

Open KaspervdHeijden opened 1 week ago

KaspervdHeijden commented 1 week ago

Contributing guidelines

Module(s)

mini.notify

Description

Currently the LSP progress message format is hardcoded. See https://github.com/echasnovski/mini.nvim/blob/df1559e2ed7ece458e0a97a8bb9556d465d1c775/lua/mini/notify.lua#L678

It would be nice to make this more dynamic, via a format function.

KaspervdHeijden commented 1 week ago

Please see https://github.com/echasnovski/mini.nvim/pull/1276

echasnovski commented 1 week ago

Thanks for the suggestion!

I think the proper way is to add some kind of source field to notification specification. One small issue is that add() was not really designed to be extensible (mostly by design to limit complexity). I'd take some time to think if adding source as fourth argument is worth it.

KaspervdHeijden commented 1 week ago

Fair enough. My current workaround is quite hacky:

                notify.setup({
                    content = {
                        format = function (str)
                            local parts = vim.split(str.msg, ': ')

                            if #parts == 2 then
                                return parts[2]
                            end

                            return string.format('\n  %s  \n', str.msg)
                        end,
                    },
                    window = {
                        winblend = 0,
                        config   = function ()
                            local pad = vim.o.cmdheight + (vim.o.laststatus > 0 and 1 or 0)

                            return {
                                row    = vim.o.lines - pad - 1,
                                col    = vim.o.columns,
                                border = 'none',
                                anchor = 'SE',
                            }
                        end,
                    }
                })
            })

https://gitlab.com/kaspervdheijden/kickstart/-/blob/master/lua/plugins-enabled/mini-nvim.lua?ref_type=heads#L78

echasnovski commented 1 week ago

Fair enough. My current workaround is quite hacky:

I don't find the code particularly hacky, on the contrary even - quite concise and to the point. The fact that it is applied to any notification and not only to the ones coming from LSP progress - yeah, maybe.