Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add format function for LSP progress #1275

Open
2 tasks done
KaspervdHeijden opened this issue Oct 13, 2024 · 4 comments
Open
2 tasks done

Add format function for LSP progress #1275

KaspervdHeijden opened this issue Oct 13, 2024 · 4 comments
Labels
feature-request Request for a feature to existing module mini.notify

Comments

@KaspervdHeijden
Copy link

Contributing guidelines

Module(s)

mini.notify

Description

Currently the LSP progress message format is hardcoded. See

local msg = string.format(

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

@KaspervdHeijden KaspervdHeijden added the feature-request Request for a feature to existing module label Oct 13, 2024
@KaspervdHeijden
Copy link
Author

Please see #1276

@echasnovski
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for a feature to existing module mini.notify
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants