Skip to content

Commit

Permalink
Unlink border highlight groups so that they can be detected by Neovim.
Browse files Browse the repository at this point in the history
  • Loading branch information
fredizzimo committed Dec 3, 2023
1 parent 8c82434 commit 505baee
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
22 changes: 22 additions & 0 deletions lua/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,25 @@ vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
rpcnotify("neovide.quit", vim.v.exiting)
end
})

local function unlink_highlight(name)
local highlight = vim.api.nvim_get_hl(0, {name=name, link=false})
vim.api.nvim_set_hl(0, name, highlight)
end

-- Neovim only reports the final highlight group in the ext_hlstate information
-- So we need to unlink all the groups when the color scheme is changed
-- This is quite hacky, so let the user disable it.
vim.api.nvim_create_autocmd({ "ColorScheme" }, {
pattern = "*",
nested = false,
callback = function()
if vim.g.neovide_unlink_border_highlights then
unlink_highlight("FloatTitle")
unlink_highlight("FloatFooter")
unlink_highlight("FloatBorder")
unlink_highlight("WinBar")
unlink_highlight("WinBarNC")
end
end
})
2 changes: 2 additions & 0 deletions src/window/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ pub struct WindowSettings {
pub theme: String,
pub input_macos_alt_is_meta: bool,
pub input_ime: bool,
pub unlink_border_highlights: bool,

#[option = "mousemoveevent"]
pub mouse_move_event: bool,
Expand Down Expand Up @@ -59,6 +60,7 @@ impl Default for WindowSettings {
mouse_move_event: false,
observed_lines: None,
observed_columns: None,
unlink_border_highlights: true,
}
}
}
25 changes: 24 additions & 1 deletion website/docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Lua:
vim.g.neovide_underline_stroke_scale = 1.0
```

**Unrelease yet.**
**Unreleased yet.**

Setting `g:neovide_underline_stroke_scale` to a floating point will increase or decrease the stroke
width of the underlines (including undercurl, underdash, etc.). If the scaled stroke width is less
Expand Down Expand Up @@ -346,6 +346,29 @@ Set the [`background`](https://neovim.io/doc/user/options.html#'background') opt
starts. Possible values: _light_, _dark_, _auto_. On systems that support it, _auto_ will mirror the
system theme, and will update `background` when the system theme changes.

#### Fix border and winbar scrolling glitches

VimScript:

```vim
let g:neovide_unlink_border_highlights = v:true
```

Lua:

```lua
vim.g.neovide_unlink_border_highlights = true
```

**Unreleased yet.**

Neovide uses some highlight groups for detecting the border of the windows, when scrolling. This
detection is not perfect due to some limitations of Neovim, it only returns the final highlight
groups for linked highlights. This option unlinks those highlight groups after the color scheme is
loaded to make Neovide detect them properly.

If this causes other problems, you can set this option to false.

### Functionality

#### Refresh Rate
Expand Down

0 comments on commit 505baee

Please sign in to comment.