wookayin / semshi

🌈 Semantic Highlighting for Python in Neovim
79 stars 5 forks source link

Highlight priority? #9

Open crides opened 1 year ago

crides commented 1 year ago

maim-2023 04 09 16 39 56

In this screenshot, the pprint is highlighted with DianosticUnnecessary (linked to Comment), but semshiImported overwrote it. Is it possible to change the highlight priority so that DianosticUnnecessary is shown?

neovim 0.9.0, with pyright lsp

wookayin commented 1 year ago

Yes, the extmark (buf-local highlight) has different priority: semshi has priority 4096 and diagnostics has a fixed priority 150.

-- vim.api.nvim_buf_get_extmarks(0, -1, 0, -1, {details=true})

{ 1, 4, 0, {
      end_col = 13,
      end_right_gravity = false,
      end_row = 4,
      hl_eol = false,
      hl_group = "DiagnosticUnderlineWarn",
      ns_id = 61,
      priority = 150,
      right_gravity = true
    } }

{ 1, 4, 7, {
      end_col = 13,
      end_right_gravity = false,
      end_row = 4,
      hl_eol = false,
      hl_group = "semshiImported",
      ns_id = 321173,
      priority = 4096,
      right_gravity = true
    } }

From https://github.com/neovim/neovim/commit/791e400858ae8d32f974b40c4e1c0d54b66f610f:

So I think it makes sense semshi should use priority around 100. Since semshi uses nvim_buf_add_highlight (which does not support setting priority) instead of nvim_buf_set_extmark, we will need to migrate to the extmark API first.