Skip to content

Commit

Permalink
fix(dirman): don't create index.norg files in the default workspace…
Browse files Browse the repository at this point in the history
… when running `:Neorg index`
  • Loading branch information
vhyrro committed Apr 10, 2023
1 parent d38a229 commit c60747f
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion lua/neorg/modules/core/norg/dirman/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ module.public = {
end,
--- Takes in a path (can include directories) and creates a .norg file from that path
---@param path string a path to place the .norg file in
---@param workspace string workspace name
---@param workspace? string workspace name
---@param opts? table additional options
--- - opts.no_open (bool) if true, will not open the file in neovim after creating it
--- - opts.force (bool) if true, will overwrite existing file content
Expand Down Expand Up @@ -486,6 +486,14 @@ module.on_event = function(event)
-- If somebody has executed the :Neorg index command then
if event.type == "core.neorgcmd.events.dirman.index" then
local current_ws = module.public.get_current_workspace()

if current_ws[1] == "default" then
neorg.utils.notify(
"No workspace is set! Use `:Neorg workspace <name>` to set the current workspace. Aborting..."
)
return
end

local index_path = table.concat({ current_ws[2], "/", module.config.public.index })

if vim.fn.filereadable(index_path) == 0 then
Expand Down

0 comments on commit c60747f

Please sign in to comment.