Files
ideadrop.nvim/lua/ideaDrop/core/config.lua
Carlos Gutierrez c706e8ee4f fix: improve graph path handling and error messages
- Handle nil idea_dir in config (don't override default with nil)
- Expand environment variables and ~ in paths during setup
- Add get_idea_dir() helper function for consistent path access
- Remove trailing slashes from paths
- Add fallback to non-recursive glob if recursive finds no files
- Show actual path being used in error messages for debugging
- Better error messages when directory doesn't exist or has no .md files
2026-01-10 23:06:46 -05:00

56 lines
1.6 KiB
Lua

-- ideaDrop/config.lua
---@class Config
---@field options IdeaDropOptions
---@field setup fun(user_opts: IdeaDropOptions|nil): nil
---@class GraphOptions
---@field animate boolean Whether to animate layout (default: false)
---@field show_orphans boolean Whether to show orphan nodes (default: true)
---@field show_labels boolean Whether to show node labels by default (default: true)
---@field node_colors table<string, string>|nil Custom colors for folders/tags
---@class IdeaDropOptions
---@field idea_dir string Directory where idea files will be stored
---@field graph GraphOptions|nil Graph visualization options
local M = {}
---Default configuration options
M.options = {
idea_dir = vim.fn.stdpath("data") .. "/ideaDrop", -- default path
graph = {
animate = false, -- Set to true for animated layout
show_orphans = true, -- Show nodes with no connections
show_labels = true, -- Show node labels by default
node_colors = nil, -- Custom node colors by folder/tag
},
}
---Setup function to merge user options with defaults
---@param user_opts IdeaDropOptions|nil User configuration options
---@return nil
function M.setup(user_opts)
user_opts = user_opts or {}
-- Handle nil idea_dir (don't override default with nil)
if user_opts.idea_dir == nil then
user_opts.idea_dir = M.options.idea_dir
end
-- Expand environment variables and ~ in idea_dir
if user_opts.idea_dir then
user_opts.idea_dir = vim.fn.expand(user_opts.idea_dir)
end
M.options = vim.tbl_deep_extend("force", M.options, user_opts)
end
---Gets the idea directory path (expanded)
---@return string
function M.get_idea_dir()
return vim.fn.expand(M.options.idea_dir or "")
end
return M