mirror of
https://github.com/pojokcodeid/nvim-lazy.git
synced 2025-07-10 17:34:27 +02:00
enc: add gemini chat
This commit is contained in:
parent
5206ccb56e
commit
37aa6dd7a7
3 changed files with 61 additions and 4 deletions
|
@ -23,18 +23,18 @@
|
|||
"dracula.nvim": { "branch": "main", "commit": "96c9d19ce81b26053055ad6f688277d655b3f7d2" },
|
||||
"dressing.nvim": { "branch": "master", "commit": "2d7c2db2507fa3c4956142ee607431ddb2828639" },
|
||||
"friendly-snippets": { "branch": "main", "commit": "572f5660cf05f8cd8834e096d7b4c921ba18e175" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "6e3ee68bc9f65b21a21582a3d80e270c7e4f2992" },
|
||||
"gitsigns.nvim": { "branch": "main", "commit": "362fe61f9f19e9bceff178792780df5cce118a7d" },
|
||||
"indent-blankline.nvim": { "branch": "master", "commit": "005b56001b2cb30bfa61b7986bc50657816ba4ba" },
|
||||
"lazy.nvim": { "branch": "main", "commit": "6c3bda4aca61a13a9c63f1c1d1b16b9d3be90d7a" },
|
||||
"lualine.nvim": { "branch": "master", "commit": "a94fc68960665e54408fe37dcf573193c4ce82c9" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "73e0143385d8a2185944b42ed44d728b94ee19a3" },
|
||||
"mason-lspconfig.nvim": { "branch": "main", "commit": "c2465eb07db648026eee81005a659abe26e6d077" },
|
||||
"mason-nvim-dap.nvim": { "branch": "main", "commit": "4c2cdc69d69fe00c15ae8648f7e954d99e5de3ea" },
|
||||
"mason.nvim": { "branch": "main", "commit": "8024d64e1330b86044fed4c8494ef3dcd483a67c" },
|
||||
"menu": { "branch": "main", "commit": "7a0a4a2896b715c066cfbe320bdc048091874cc6" },
|
||||
"mini.indentscope": { "branch": "main", "commit": "5fdc3edf7bb1b6365980c2c47dac2f19ec93c97b" },
|
||||
"minty": { "branch": "main", "commit": "aafc9e8e0afe6bf57580858a2849578d8d8db9e0" },
|
||||
"multiple-cursors.nvim": { "branch": "main", "commit": "1ac15d047a4b265cc2389957bcc56ee561b29e02" },
|
||||
"neotest": { "branch": "master", "commit": "1d4b3bd89afa8bfa12fffd2bb1ccd26ac3c92ce5" },
|
||||
"neotest": { "branch": "master", "commit": "201edab09fc1657f24da203451a6f501539db460" },
|
||||
"neotest-golang": { "branch": "main", "commit": "9521843942423fcac9991c596ff19c1f4f500650" },
|
||||
"neotest-jest": { "branch": "main", "commit": "797515e113ac8e19c6855046d7f746d9c0c39c15" },
|
||||
"neotest-plenary": { "branch": "master", "commit": "3523adcf9ffaad1911960c5813b0136c1b63a2ec" },
|
||||
|
@ -52,7 +52,7 @@
|
|||
"nvim-dap-virtual-text": { "branch": "master", "commit": "fbdb48c2ed45f4a8293d0d483f7730d24467ccb6" },
|
||||
"nvim-dap-vscode-js": { "branch": "main", "commit": "03bd29672d7fab5e515fc8469b7d07cc5994bbf6" },
|
||||
"nvim-lint": { "branch": "master", "commit": "3c5e34c24834a67b1cb37600ab7663eefd2b0390" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "d8f03bfd5b54b10352276a0ed1f2ffe9c2e0676f" },
|
||||
"nvim-lspconfig": { "branch": "master", "commit": "1b6d7c3abf962cc392bcaf0dd7b92bdb9a1a5684" },
|
||||
"nvim-material-icon": { "branch": "main", "commit": "c25a4e56be2f846dfdf8f30b980adc17f219d019" },
|
||||
"nvim-navic": { "branch": "master", "commit": "f887d794a0f4594882814d7780980a949200a238" },
|
||||
"nvim-nio": { "branch": "master", "commit": "21f5324bfac14e22ba26553caf69ec76ae8a7662" },
|
||||
|
|
53
lua/gemini/init.lua
Normal file
53
lua/gemini/init.lua
Normal file
|
@ -0,0 +1,53 @@
|
|||
local M = {}
|
||||
M.last_popup_win = nil
|
||||
M.last_popup_buf = nil
|
||||
|
||||
function M.ask_gemini()
|
||||
-- Ambil path file buffer aktif
|
||||
--[[ local buf_path = vim.api.nvim_buf_get_name(0)
|
||||
if buf_path ~= "" then
|
||||
local dir = vim.fn.fnamemodify(buf_path, ":h")
|
||||
vim.api.nvim_set_current_dir(dir)
|
||||
end ]]
|
||||
|
||||
vim.ui.input({ prompt = "Prompt ke Gemini: " }, function(prompt)
|
||||
if not prompt or prompt == "" then
|
||||
vim.notify("Prompt kosong", vim.log.levels.WARN)
|
||||
return
|
||||
end
|
||||
|
||||
M.show_popup("Loading...")
|
||||
|
||||
vim.schedule(function()
|
||||
local output = vim.fn.system('gemini --prompt "' .. prompt .. '"')
|
||||
M.show_popup(output)
|
||||
end)
|
||||
end)
|
||||
end
|
||||
|
||||
function M.show_popup(output)
|
||||
if M.last_popup_win and vim.api.nvim_win_is_valid(M.last_popup_win) then
|
||||
vim.api.nvim_win_close(M.last_popup_win, true)
|
||||
end
|
||||
if M.last_popup_buf and vim.api.nvim_buf_is_valid(M.last_popup_buf) then
|
||||
vim.api.nvim_buf_delete(M.last_popup_buf, { force = true })
|
||||
end
|
||||
|
||||
local buf = vim.api.nvim_create_buf(false, true)
|
||||
vim.api.nvim_buf_set_lines(buf, 0, -1, false, vim.split(output or "", "\n"))
|
||||
local width = math.floor(vim.o.columns * 0.6)
|
||||
local height = math.floor(vim.o.lines * 0.8)
|
||||
local win = vim.api.nvim_open_win(buf, true, {
|
||||
relative = "editor",
|
||||
width = width,
|
||||
height = height,
|
||||
row = math.floor((vim.o.lines - height) / 2),
|
||||
col = math.floor((vim.o.columns - width) / 2),
|
||||
style = "minimal",
|
||||
border = "rounded",
|
||||
})
|
||||
M.last_popup_win = win
|
||||
M.last_popup_buf = buf
|
||||
end
|
||||
|
||||
return M
|
|
@ -3,3 +3,7 @@ require("pcode.user.default")
|
|||
require("pcode.config.lazy_lib")
|
||||
require("pcode.user.colorscheme")
|
||||
require("pcode.core.neovide")
|
||||
|
||||
vim.keymap.set({ "n", "v", "x" }, "<C-i>", function()
|
||||
require("gemini").ask_gemini()
|
||||
end, { noremap = true, silent = true, desc = "Prompt Gemini CLI" })
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue