Skip to content

Commit

Permalink
fix(core.highlights): fix disappearing highlights when opening up nor…
Browse files Browse the repository at this point in the history
…g files
  • Loading branch information
vhyrro committed May 30, 2023
1 parent d1fb8c9 commit 9db5645
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lua/neorg/modules/core/highlights/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -539,17 +539,21 @@ module.public = {
--- Reads the highlights configuration table and applies all defined highlights
trigger_highlights = function()
if not require("nvim-treesitter.query").has_highlights("norg") then
if vim.bo.filetype == "norg" then
require("nvim-treesitter.highlight").attach(vim.api.nvim_get_current_buf(), "norg")
else
vim.api.nvim_create_autocmd("FileType", {
pattern = "norg",
once = true,
callback = function(data)
require("nvim-treesitter.highlight").attach(data.buf, "norg")
end,
})
do
local query = require("nvim-treesitter.query")
if not query.has_highlights("norg") then
query.invalidate_query_cache()
assert(
query.has_highlights(
"norg",
"nvim-treesitter has no available highlights for norg! Ensure treesitter is properly loaded in your config."
)
)
if vim.bo.filetype == "norg" then
require("nvim-treesitter.highlight").attach(vim.api.nvim_get_current_buf(), "norg")
end
end
end
Expand Down

0 comments on commit 9db5645

Please sign in to comment.