Created
July 16, 2025 13:30
-
-
Save wladston/35d55a318a8acfb9208b23ef0fa2bb83 to your computer and use it in GitHub Desktop.
Neovim, switch colorscheme preserving underline on links, highlights, and formatting
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- After changing colorscheme, Neovim wipes syntax highlights and conceal rules. | |
-- This re-runs filetype syntax and restores conceal settings if they were in use. | |
-- Prevents broken link formatting and visible markdown/tutor syntax. | |
vim.api.nvim_create_autocmd('ColorScheme', { | |
pattern = '*', | |
callback = function() | |
local win = vim.api.nvim_get_current_win() | |
local conceallevel = vim.wo[win].conceallevel | |
local concealcursor = vim.wo[win].concealcursor | |
local ft = vim.bo.filetype | |
if ft ~= '' then | |
vim.cmd('doautocmd Syntax ' .. ft) | |
end | |
if conceallevel > 0 then | |
vim.schedule(function() | |
vim.wo[win].conceallevel = conceallevel | |
vim.wo[win].concealcursor = concealcursor | |
end) | |
end | |
end, | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment