Skip to content

feat(config): get default diagnostic icons from :sign config#461

Closed
Iron-E wants to merge 5 commits into
masterfrom
feat/diagnostics-get-defined-signs
Closed

feat(config): get default diagnostic icons from :sign config#461
Iron-E wants to merge 5 commits into
masterfrom
feat/diagnostics-get-defined-signs

Conversation

@Iron-E

@Iron-E Iron-E commented Apr 14, 2023

Copy link
Copy Markdown
Collaborator

Diff looks absurd because it's based on #451.

Uses sign_getdefined to generate the default icon, rather than hard-coding it.

Iron-E added 5 commits April 14, 2023 13:50
If you do:

```lua
require'barbar'.setup {
  icons = {
    diagnostics = {
      [vim.diagnostic.ERROR] = {enabled = true},
      [vim.diagnostic.HINT] = {enabled = true},
    },
  },
}
```

…it will not work. This is because a function in `Buffer` was using
`ipairs`, which stops upon reaching the first `nil` numerical index in a
`table`. However, upon fixing this, I discovered another bug: `icons`
was not being fully merged.

We had a snippet of code to "deep extend" `icons.diagnostics`, but since
we were only using `vim.tbl_deep_extend` on the other `icons` options,
they did not inherit the diagnostics. I extracted this snippet to a
function and called it on all `icons.modified`, `icons.current`, etc.
We reference distinct sides of the barbar often enough that it probably
deserves its own alias.
We already had a `current_buffer_index` variable in
`get_bufferline_containers`, so we can use that instead of storing all
the activities of each buffer in their containers and looping over the
buffers in each container looking for the current buffer,

Apologies for the style changes; I was debugging something else,
and had a really hard time reading this particular section. While
reading through to understand the changes I discovered this performance
improvement.
@Iron-E Iron-E added the request New feature or request label Apr 14, 2023
@Iron-E Iron-E self-assigned this Apr 14, 2023
@Iron-E Iron-E closed this Apr 29, 2023
@Iron-E Iron-E deleted the feat/diagnostics-get-defined-signs branch April 29, 2023 03:27
@Iron-E

Iron-E commented Apr 29, 2023

Copy link
Copy Markdown
Collaborator Author

Probably not a good idea. Not everyone configures these.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

request New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant