Skip to content

Commit

Permalink
fix: issue with syntax highlighting after load
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc-stripe committed Sep 14, 2022
1 parent adf5b9d commit e3460f4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 13 additions & 0 deletions lua/resession/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,19 @@ M.load = function(name, opts)
local bufnr = vim.fn.bufadd(buf.name)
if buf.loaded then
vim.fn.bufload(bufnr)
vim.api.nvim_create_autocmd("BufWinEnter", {
desc = "After showing the buffer in the window, manually set the filetype to trigger syntax highlighting",
callback = function()
vim.api.nvim_buf_set_option(
bufnr,
"filetype",
vim.api.nvim_buf_get_option(bufnr, "filetype")
)
end,
buffer = bufnr,
once = true,
nested = true,
})
end
util.restore_buf_options(bufnr, buf.options)
end
Expand Down
3 changes: 1 addition & 2 deletions lua/resession/layout.lua
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ local function set_winlayout_data(layout, scale_factor, visit_data)
else
local bufnr = vim.fn.bufadd(win.bufname)
vim.api.nvim_win_set_buf(win.winid, bufnr)
-- After setting the buffer into the window, manually set the filetype to trigger syntax
-- highlighting
-- After setting the buffer into the window, manually set the filetype to trigger syntax highlighting
vim.api.nvim_buf_set_option(bufnr, "filetype", vim.api.nvim_buf_get_option(bufnr, "filetype"))
end
pcall(vim.api.nvim_win_set_cursor, win.winid, win.cursor)
Expand Down

0 comments on commit e3460f4

Please sign in to comment.