adding functionalities on the buffer
This commit is contained in:
@@ -1,53 +1,5 @@
|
||||
-- ideaDrop.nvim/init.lua
|
||||
local config = require("ideaDrop.config")
|
||||
local sidebar = require("ideaDrop.sidebar")
|
||||
local list = require("ideaDrop.list")
|
||||
local M = {}
|
||||
-- Main entry point for the ideaDrop plugin
|
||||
|
||||
---@class IdeaDrop
|
||||
---@field setup fun(user_opts: IdeaDropConfig): nil
|
||||
|
||||
---@class IdeaDropConfig
|
||||
---@field idea_dir string Directory where idea files will be stored
|
||||
|
||||
---Setup function for ideaDrop.nvim
|
||||
---@param user_opts IdeaDropConfig|nil User configuration options
|
||||
---@return nil
|
||||
function M.setup(user_opts)
|
||||
config.setup(user_opts)
|
||||
|
||||
vim.api.nvim_create_user_command("Idea", function(opts)
|
||||
local arg = opts.args
|
||||
local idea_dir = config.options.idea_dir
|
||||
|
||||
if arg == "listAll" then
|
||||
list.list_all()
|
||||
elseif arg ~= "" then
|
||||
-- Ensure directory exists (even for nested folders)
|
||||
local filename = arg:match("%.md$") and arg or (arg .. ".md")
|
||||
local full_path = idea_dir .. "/" .. filename
|
||||
|
||||
-- Create parent folders if needed
|
||||
local folder = vim.fn.fnamemodify(full_path, ":h")
|
||||
if vim.fn.isdirectory(folder) == 0 then
|
||||
vim.fn.mkdir(folder, "p")
|
||||
end
|
||||
|
||||
sidebar.open(full_path, filename)
|
||||
else
|
||||
-- Default to today's idea file
|
||||
local path = string.format("%s/%s.md", idea_dir, os.date("%Y-%m-%d"))
|
||||
sidebar.open(path)
|
||||
end
|
||||
end, {
|
||||
nargs = "?",
|
||||
complete = function()
|
||||
return { "listAll" }
|
||||
end,
|
||||
desc = "Open today's idea, a named idea, or list all",
|
||||
})
|
||||
|
||||
vim.notify("ideaDrop loaded!", vim.log.levels.INFO)
|
||||
end
|
||||
|
||||
return M
|
||||
-- Require the core module which contains the main setup function
|
||||
return require("ideaDrop.core.init")
|
||||
Reference in New Issue
Block a user