Fixed issues
This commit is contained in:
parent
dad689ded2
commit
c366268b5c
@ -1,4 +1,4 @@
|
|||||||
-- plugin/gemini/api.lua
|
-- lua/gemini/api.lua
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
-- plugin/gemini/init.lua
|
-- lua/gemini/init.lua
|
||||||
print(vim.o.runtimepath)
|
|
||||||
require("gemini.api")
|
local api = require("gemini.api")
|
||||||
|
local M = {}
|
||||||
|
|
||||||
local function gemini_query(prompt)
|
local function gemini_query(prompt)
|
||||||
local response = api.get_response(prompt)
|
local response = api.get_response(prompt)
|
||||||
@ -23,36 +24,32 @@ local function gemini_query(prompt)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
vim.api.nvim_create_user_command("Gemini", function(opts)
|
-- Make gemini_query available in M so it can be used by the setup function
|
||||||
local prompt = opts.args
|
M.gemini_query = gemini_query
|
||||||
if prompt == "" then
|
|
||||||
vim.notify("Please provide a prompt for Gemini.", vim.log.levels.WARN)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
gemini_query(prompt)
|
|
||||||
end, {
|
|
||||||
desc = "Query Google AI",
|
|
||||||
nargs = "+", -- Require at least one argument
|
|
||||||
complete = "shellcmd", -- Optional: Enable completion
|
|
||||||
})
|
|
||||||
|
|
||||||
-- Keymapping example (optional)
|
function M.setup()
|
||||||
vim.keymap.set("n", "<leader>g", function()
|
-- Create the user command
|
||||||
vim.ui.input({ prompt = "Gemini Query: " }, function(input)
|
vim.api.nvim_create_user_command("Gemini", function(opts)
|
||||||
if input then
|
local prompt = opts.args
|
||||||
gemini_query(input)
|
if prompt == "" then
|
||||||
|
vim.notify("Please provide a prompt for Gemini.", vim.log.levels.WARN)
|
||||||
|
return
|
||||||
end
|
end
|
||||||
end)
|
M.gemini_query(prompt) -- Use M.gemini_query instead of gemini_query
|
||||||
end, { desc = "Query Google AI (via Input)" })
|
end, {
|
||||||
|
desc = "Query Google AI",
|
||||||
|
nargs = "+",
|
||||||
|
complete = "shellcmd",
|
||||||
|
})
|
||||||
|
|
||||||
-- Add a setup function (even if it's empty)
|
-- Set up keymapping
|
||||||
local function setup()
|
vim.keymap.set("n", "<leader>g", function()
|
||||||
print("gemini.setup() called") -- For debugging
|
vim.ui.input({ prompt = "Gemini Query: " }, function(input)
|
||||||
require("gemini.api")
|
if input then
|
||||||
print("api module loaded:", api) -- For debugging
|
M.gemini_query(input) -- Use M.gemini_query instead of gemini_query
|
||||||
-- Optional: Add any initialization logic here
|
end
|
||||||
|
end)
|
||||||
|
end, { desc = "Query Google AI (via Input)" })
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return M
|
||||||
setup = setup,
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user