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

mini.statusline: Create lsp string in a separate method #687

Closed
2 tasks done
abeldekat opened this issue Feb 10, 2024 · 6 comments
Closed
2 tasks done

mini.statusline: Create lsp string in a separate method #687

abeldekat opened this issue Feb 10, 2024 · 6 comments
Labels
feature-request Request for a feature to existing module mini.statusline

Comments

@abeldekat
Copy link

abeldekat commented Feb 10, 2024

Contributing guidelines

Module(s)

mini.statusline

Description

Hello @echasnovski,

Using this plugin I could dispose of many lualine theme overrides. It was a joy to work with!

I added diagnostic colors as described here.
In order to do this, I also had to include code for the lsp(method MiniStatusline.section_diagnostics).

Currently, section diagnostics does not show when there is no lsp attached. Is that correct? The user could miss diagnostics when having a linter instead of an lsp.

Would you accept a PR where the lsp string is created in a separate method?
An outline:

H.default_content_active = function()
...
  local lsp   = MiniStatusline.section_lsp({ trunc_width = 75 }) --> new
  local diagnostics   = MiniStatusline.section_diagnostics({ trunc_width = 75 })
...
  return MiniStatusline.combine_groups({
...
    { hl = 'MiniStatuslineDevinfo',  strings = { git, lsp, diagnostics } },
...
  })
end

Best regards!

@abeldekat abeldekat added the feature-request Request for a feature to existing module label Feb 10, 2024
@echasnovski
Copy link
Owner

Thanks for the suggestion!

Currently, section diagnostics does not show when there is no lsp attached. Is that correct? The user could miss diagnostics when having a linter instead of an lsp.

Oh, you are completely right! This somehow slipped past me when I implemented this.

Right now, I don't particularly see much use in having separate LSP section (which would show server info, I presume?). Let me think about the possibly best way to resolve this.

@abeldekat
Copy link
Author

There is not much use in having a separate LSP section I think.

It would mean however that I don't have to copy the lsp code from mini.statusline into my own config. I quite like the default implementation.
The code handling the lsp string ( either LSP or an icon ) would not be changed, just moved.

I do think that there is a backward compatibility problem for users with a custom content.active method, using strings = { git, diagnostics }

mlwarner pushed a commit to mlwarner/mini.nvim that referenced this issue Apr 12, 2024
The diagnostic section was hidden behind a language server check, which
hides linter results.

Resolve echasnovski#687
@abeldekat
Copy link
Author

Hello @echasnovski,

I don't mind if this issue were to be closed. The current situation is fine, and I customized some more parts.

Best regards!

@echasnovski
Copy link
Owner

Let this be open for now. I do plan a 'mini.statusline' update some time soon-ish and this will be one thing to keep in mind.

echasnovski added a commit that referenced this issue May 22, 2024
Details:
- Depend only on if there are actually present diagnostic entries.
  This allows showing in not normal buffers and if there is no LSP
  server attached.
  Do not show ' -' if there is no diagnostics, as this will be
  **always** shown, which is not ergonomic.
- Use "Diag" fallback icon instead of "LSP".

Resolve #687
@echasnovski
Copy link
Owner

I have finally reached the first part of 'mini.statusline' refactor. The section_diagnostics() now depends exclusively on what data is returned by vim.diagnostic.get(). See changelog entry for more details.

It also means that the icon is not shown if there is no diagnostic entries in the buffer. Previously it served as an indicator that LSP server was attached to the buffer. Now there is a section_lsp() in default active content that serves this exact purpose.

@abeldekat
Copy link
Author

Thanks @echasnovski!

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.statusline
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants