nvim-lua / lsp-status.nvim

Utility functions for getting diagnostic status and progress messages from LSP servers, for use in the Neovim statusline
MIT License
621 stars 41 forks source link

feat: Return diagnostic information only if count > 0 #47

Closed dhruvmanila closed 3 years ago

dhruvmanila commented 3 years ago

For the following functions, it would be better if the information is returned only if the total count is greater than 0, otherwise the statusline will always be filled with 0 count diagnostic information.

Another way, if this is not preferred to be the default behavior, an option can be provided in the config function.

wbthomason commented 3 years ago

Can you elaborate on what you mean by the statusline being filled with 0 values? At least with the default component, this does not happen for me, and I would in general expect people writing their own components to test for zero before including the relevant counter text.

dhruvmanila commented 3 years ago

Sure, sorry to be not clear, what I mean is with the help of this PR (https://github.com/nvim-lua/lsp-status.nvim/pull/39) there were four functions added for the four types of diagnostic information, namely the following:

Ignoring the spacing problem, we can see that even if there is no error, the function still returns the output: Screenshot 2021-04-02 at 10 23 38

I would in general expect people writing their own components to test for zero before including the relevant counter text.

I did create my own components but as the plugin provides an interface to get the same information, its a bit simpler. So, what I am recommending is to update the function such that the default behavior is to return only if the count is > 0.

wbthomason commented 3 years ago

Ah, I see. So, you would essentially propose changing https://github.com/nvim-lua/lsp-status.nvim/blob/60a3ad9dc2f43e0e512c242411541846a86eb7de/lua/lsp-status/statusline.lua#L17 to only return a string if the count is > 0, otherwise return nil?

dhruvmanila commented 3 years ago

Yes, that's what I am proposing :)