local ui = require("javelin.ui") local data = require("javelin.data") local Javelin = {} ---@class JavelinConfig local defaults = { use_git_root = true, -- Passthrough options to Snacks.win menu = { width = 0.6, height = 8, title_pos = "center", border = "rounded", keys = { [""] = "goto", q = "close", [""] = "close", }, }, } function Javelin.open() return ui.open() end ---@param index number function Javelin.select(index) return ui.select(index) end function Javelin.add() return data.add_current() end local function create_user_command() local commands = { open = Javelin.open, add = Javelin.add, } vim.api.nvim_create_user_command("Javelin", function(args) local cmd = vim.trim(args.args or "") if cmd == "" then commands.open() elseif commands[cmd] then commands[cmd]() end end, { desc = "Javelin", nargs = "?", complete = function(_, line) if line:match("^%s*Javelin %w+ ") then return {} end local prefix = line:match("^%s*Javelin (%w*)") or "" return vim.tbl_filter(function(key) return key:find(prefix) == 1 end, vim.tbl_keys(commands)) end, }) end ---@param opt? JavelinConfig function Javelin.setup(opt) ---@type JavelinConfig local options = vim.tbl_deep_extend("force", {}, defaults, opt or {}) create_user_command() ui.setup(options) data.setup(options) end return Javelin