Skip to content

Commit

Permalink
bufread->bufreadpost, listen bufnewfile
Browse files Browse the repository at this point in the history
  • Loading branch information
champignoom committed May 24, 2023
1 parent d1e2f6a commit fe601e8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lua/neorg.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ function neorg.setup(config)
-- Then boot up the environment
neorg.org_file_entered(false)
else
-- Else listen for a BufRead event and fire up the Neorg environment
-- Else listen for a BufReadPost event and fire up the Neorg environment
vim.cmd([[
autocmd BufAdd *.norg ++once :lua require('neorg').org_file_entered(false)
command! -nargs=* NeorgStart delcommand NeorgStart | lua require('neorg').org_file_entered(true, <q-args>)
Expand Down
8 changes: 5 additions & 3 deletions lua/neorg/modules/core/autocommands/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ local module = neorg.modules.create("core.autocommands")
---@param name string #The name of the autocommand that was just triggered
---@param triggered_from_norg boolean #If true, that means we have received this event as part of a *.norg autocommand
function _neorg_module_autocommand_triggered(name, triggered_from_norg)
neorg.events.broadcast_event(neorg.events.create(module, name, { norg = triggered_from_norg }))
local event = neorg.events.create(module, name, { norg = triggered_from_norg })
assert(event)
neorg.events.broadcast_event(event)
end

-- A convenience wrapper around neorg.events.define_event
Expand Down Expand Up @@ -108,7 +110,7 @@ module.events.subscribed = {
bufmodifiedset = false,
bufnew = false,
bufnewfile = false,
bufread = false,
bufreadpost = false,
bufreadcmd = false,
bufreadpre = false,
bufunload = false,
Expand Down Expand Up @@ -226,7 +228,7 @@ module.events.defined = {
bufmodifiedset = module.autocmd_base("bufmodifiedset"),
bufnew = module.autocmd_base("bufnew"),
bufnewfile = module.autocmd_base("bufnewfile"),
bufread = module.autocmd_base("bufread"),
bufreadpost = module.autocmd_base("bufreadpost"),
bufreadcmd = module.autocmd_base("bufreadcmd"),
bufreadpre = module.autocmd_base("bufreadpre"),
bufunload = module.autocmd_base("bufunload"),
Expand Down
9 changes: 6 additions & 3 deletions lua/neorg/modules/core/concealer/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,8 @@ end

local event_handlers = {
["core.neorgcmd.events.core.concealer.toggle"] = handle_toggle_prettifier,
["core.autocommands.events.bufread"] = handle_init_event,
["core.autocommands.events.bufnewfile"] = handle_init_event,
["core.autocommands.events.bufreadpost"] = handle_init_event,
["core.autocommands.events.insertenter"] = handle_insertenter,
["core.autocommands.events.insertleave"] = handle_insertleave,
["core.autocommands.events.cursormoved"] = handle_cursor_moved,
Expand Down Expand Up @@ -925,7 +926,8 @@ module.load = function()
module.config.custom
)

module.required["core.autocommands"].enable_autocommand("BufRead")
module.required["core.autocommands"].enable_autocommand("BufNewFile")
module.required["core.autocommands"].enable_autocommand("BufReadPost")
module.required["core.autocommands"].enable_autocommand("InsertEnter")
module.required["core.autocommands"].enable_autocommand("InsertLeave")
module.required["core.autocommands"].enable_autocommand("CursorMoved")
Expand Down Expand Up @@ -1024,7 +1026,8 @@ end

module.events.subscribed = {
["core.autocommands"] = {
bufread = true,
bufnewfile = true,
bufreadpost = true,
insertenter = true,
insertleave = true,
vimleavepre = true,
Expand Down

0 comments on commit fe601e8

Please sign in to comment.