Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,34 @@ name: Tests

on:
pull_request:
branches: [ main ]
push:
branches: [ main ]
branches: [main]

jobs:
test:
name: Run Test Suite
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Lua
uses: leafo/gh-actions-lua@v10
with:
luaVersion: "5.1"

- name: Run tests
run: |
echo "🧪 Running notes.nvim test suite..."
lua tests/run_tests.lua

- name: Test results
if: success()
run: |
echo "✅ All tests passed! Ready to merge."

- name: Test failures
if: failure()
run: |
echo "❌ Tests failed. Please fix before merging."
exit 1
exit 1
47 changes: 39 additions & 8 deletions lua/notes/init.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
-- Main module for notes.nvim plugin

local config = require("notes.config")
local daily = require("notes.daily")
local utils = require("notes.utils")
local completion = require("notes.completion")
local M = {}

-- Lazy-load modules to avoid Windows timing issues
local function get_modules()
local config = require("notes.config")
local daily = require("notes.daily")
local utils = require("notes.utils")
local completion = require("notes.completion")

-- Ensure config module is properly loaded
if not config or not config.setup then
error("notes.nvim: config module failed to load properly")
end

return config, daily, utils, completion
end

-- Setup function called by users
function M.setup(user_config)
local config, daily, utils, completion = get_modules()

-- Setup configuration
config.setup(user_config)
local opts = config.options
Expand All @@ -21,6 +34,8 @@ end

-- Setup autocommands
function M.setup_autocommands(opts)
local config, daily, utils, completion = get_modules()

local augroup = vim.api.nvim_create_augroup("NotesNvimAutoUpdate", { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
group = augroup,
Expand All @@ -34,6 +49,8 @@ end

-- Setup user commands
function M.setup_commands(opts)
local config, daily, utils, completion = get_modules()

vim.api.nvim_create_user_command("DailyNote", function(cmd_opts)
if cmd_opts.args and cmd_opts.args ~= "" then
daily.dynamic_daily_note(cmd_opts.args, opts)
Expand All @@ -55,21 +72,35 @@ function M.setup_commands(opts)
end, { desc = "Create a new quick note" })
end

-- Helper function to ensure setup has been called
local function ensure_setup()
local config, daily, utils, completion = get_modules()

if not config.options.pkm_dir then
error("notes.nvim not configured. Call require('notes').setup({ pkm_dir = '/path/to/your/notes' }) first")
end
return config.options
end

-- Export individual functions for advanced users
M.daily_note = function()
return daily.daily_note(config.options)
local config, daily, utils, completion = get_modules()
return daily.daily_note(ensure_setup())
end

M.tomorrow_note = function()
return daily.tomorrow_note(config.options)
local config, daily, utils, completion = get_modules()
return daily.tomorrow_note(ensure_setup())
end

M.quick_note = function()
return daily.quick_note(config.options)
local config, daily, utils, completion = get_modules()
return daily.quick_note(ensure_setup())
end

M.dynamic_daily_note = function(input)
return daily.dynamic_daily_note(input, config.options)
local config, daily, utils, completion = get_modules()
return daily.dynamic_daily_note(input, ensure_setup())
end

return M
Loading