dstein64 / nvim-scrollview

A Neovim plugin that displays interactive vertical scrollbars and signs.
MIT License
517 stars 9 forks source link

Use user-set diagnostic signs by default #94

Closed chrisgrieser closed 1 year ago

chrisgrieser commented 1 year ago

Currently, when the user has not configured signs for diagnostics, this plugin falls back to E, W, H, and I. https://github.com/dstein64/nvim-scrollview/blob/main/plugin/scrollview.vim#L108

However, I think it might make more sense to use any diagnostic icons the user may have already set via vim.fn.sign_define.

The user-set values can be retrieved by quering for these:

require("scrollview").setup {
    diagnostics_error_symbol = vim.fn.sign_getdefined("DiagnosticSignError")[1].text,
    diagnostics_warn_symbol = vim.fn.sign_getdefined("DiagnosticSignWarn")[1].text,
    diagnostics_info_symbol = vim.fn.sign_getdefined("DiagnosticSignInfo")[1].text,
    diagnostics_hint_symbol = vim.fn.sign_getdefined("DiagnosticSignHint")[1].text,
}

(I'd make a PR, but the respective file is in vimscript and not lua, in which I am not really knowledgable enough to not mess something up 🙈)

dstein64 commented 1 year ago

Good idea. Thanks!

As of 0d9223f813f606ab20ff3af78faa9b1e89f047f9, if there is user-defined sign text and/or sign text highlights for diagnostics, those will be used by default.

The text is trimmed since I noticed that the manually set text gets padded (e.g., 'E' gets padded with a trailing space to become 'E '). If padding is desired, the symbol will have to be set manually.