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

Breakpoint symbol is not using sign column background color by default #1137

Open
shmerl opened this issue Jan 14, 2024 · 2 comments
Open

Breakpoint symbol is not using sign column background color by default #1137

shmerl opened this issue Jan 14, 2024 · 2 comments

Comments

@shmerl
Copy link

shmerl commented Jan 14, 2024

Steps to Reproduce

My color scheme defines one color for Normal and a different color for SignColumn.

When simply placing a breakpoint, it uses background color of the editor pane (Normal) rather than sign column (SignColumn) color.

See example below (note background around symbol B):

dap_nvim_colors

Expected Result

It would make sense for the breakpoint and other nvim-dap signs to use the background of SignColumn by default.

Actual Result

Color used for breakpoint signs matches Normal color of the scheme.

I can work around it by setting the matching color for SignColumn through configuration for DapBreakpoint, DapStopped and etc. but it's not ideal and would break every time the color schema is changed.

@shmerl
Copy link
Author

shmerl commented Feb 6, 2024

I can try fixing it, but would appreciate if you can please give any pointers where in the code the color is being set (or not set).

Thanks!

@shmerl
Copy link
Author

shmerl commented Feb 6, 2024

If anyone needs also, for the current code, here is a workaround that reads current color for SignColumn and reuses it. This has to be applied before color scheme is loaded for the first time (or you can reload the color scheme if plugin is lazy loaded for example and this snippet is only executed at some later point):

vim.api.nvim_create_autocmd("ColorScheme", {
  pattern = "*",
  desc = "Prevent colorscheme clearing self-defined DAP marker colors",
  callback = function()
      -- Reuse current SignColumn background (except for DapStoppedLine)
      local sign_column_hl = vim.api.nvim_get_hl(0, { name = 'SignColumn' })
      -- if bg or ctermbg aren't found, use bg = 'bg' (which means current Normal) and ctermbg = 'Black'
      -- convert to 6 digit hex value starting with #
      local sign_column_bg = (sign_column_hl.bg ~= nil) and ('#%06x'):format(sign_column_hl.bg) or 'bg'
      local sign_column_ctermbg = (sign_column_hl.ctermbg ~= nil) and sign_column_hl.ctermbg or 'Black'

      vim.api.nvim_set_hl(0, 'DapStopped', { fg = '#00ff00', bg = sign_column_bg, ctermbg = sign_column_ctermbg })
      vim.api.nvim_set_hl(0, 'DapStoppedLine', { bg = '#2e4d3d', ctermbg = 'Green' })
      vim.api.nvim_set_hl(0, 'DapBreakpoint', { fg = '#c23127', bg = sign_column_bg, ctermbg = sign_column_ctermbg })
      vim.api.nvim_set_hl(0, 'DapBreakpointRejected', { fg = '#888ca6', bg = sign_column_bg, ctermbg = sign_column_ctermbg })
      vim.api.nvim_set_hl(0, 'DapLogPoint', { fg = '#61afef', bg = sign_column_bg, ctermbg = sign_column_ctermbg })
  end
})

-- reload current color scheme to pick up colors override if it was set up in a lazy plugin definition fashion
vim.cmd.colorscheme(vim.g.colors_name)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant