first commit

This commit is contained in:
2026-04-17 17:32:58 +02:00
commit fc8a13bd96
8 changed files with 680 additions and 0 deletions

66
lua/jasper/init.lua Normal file
View File

@@ -0,0 +1,66 @@
--- jasper/init.lua
--- Public setup() entry point for the jasper.nvim plugin.
local M = {}
local config = require("jasper.config")
local timer = require("jasper.timer")
--- Setup the plugin.
---
--- Call this from your Neovim config, e.g.:
---
--- require("jasper").setup()
---
--- or with options:
---
--- require("jasper").setup({
--- -- Default inactivity timeout in minutes (overrides .jasper_config.json value)
--- inactivity_timeout = 10,
--- })
---
--- @param opts table|nil global plugin options
function M.setup(opts)
opts = opts or {}
local group = vim.api.nvim_create_augroup("Jasper", { clear = true })
vim.api.nvim_create_autocmd("VimEnter", {
group = group,
callback = function()
-- Read the project config
local project_cfg = config.load()
if not project_cfg then
-- No .jasper_config.json found: silently do nothing
return
end
if not project_cfg.attivita_id then
vim.notify(
"[Jasper] .jasper_config.json found but 'attivita_id' is missing",
vim.log.levels.WARN
)
return
end
-- Merge: project file values < global setup() opts (global opts take priority)
local effective_opts = {
attivita_id = project_cfg.attivita_id,
inactivity_timeout = opts.inactivity_timeout
or project_cfg.inactivity_timeout
or 10,
}
timer.setup(effective_opts)
end,
})
vim.api.nvim_create_autocmd("VimLeave", {
group = group,
callback = function()
timer.teardown()
end,
})
end
return M