Skip to content

Commit

Permalink
fix: should setup highlights on WinNew,BufNew (#1944)
Browse files Browse the repository at this point in the history
- Always try stopping treesitter highlight for all buffers

Possibly not focusing on window after creating it, e.g. when using the peek window
  • Loading branch information
xiyaowong committed May 6, 2024
1 parent 8c1f5a0 commit 178483c
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions runtime/lua/vscode-neovim/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,19 @@ end

local function setup_treesitter_highlighting()
-- We don't need any treesitter highlights
vim.treesitter.stop()
for _, buf in ipairs(api.nvim_list_bufs()) do
vim.treesitter.stop(buf)
end
end

local function setup()
local group = api.nvim_create_augroup("VSCodeNeovimHighlight", { clear = true })
api.nvim_create_autocmd({ "BufWinEnter", "BufEnter", "WinEnter", "WinScrolled" }, {
api.nvim_create_autocmd({ "WinNew", "WinEnter", "BufNew", "BufEnter", "BufWinEnter" }, {
group = group,
callback = setup_win_hl_ns,
callback = function()
setup_win_hl_ns()
setup_treesitter_highlighting()
end,
})
api.nvim_create_autocmd({ "ColorScheme", "Syntax", "FileType" }, {
group = group,
Expand All @@ -167,10 +172,6 @@ local function setup()
end
end,
})
api.nvim_create_autocmd({ "BufWinEnter", "BufEnter" }, {
group = group,
callback = setup_treesitter_highlighting,
})
api.nvim_create_autocmd({ "VimEnter", "UIEnter" }, {
group = group,
callback = function()
Expand Down

0 comments on commit 178483c

Please sign in to comment.