feat: Merge V2 WebSocket telemetry push into existing gemini-integration.lua

This commit is contained in:
Riz Ashraf committed 2026-09-12 23:15:04 +01:00
1 parent 4d69f5e771
commit 86fab8abb1
2 files changed
+18 -34

No files matched your search

+18 -6
View File
@@ -1,15 +1,13 @@
-- gemini-integration.lua
-- Registers the active Neovim instance for the Antigravity MCP Server
vim.api.nvim_create_autocmd({"VimEnter", "FocusGained"}, {
callback = function()
vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter"}, {
callback = function(ev)
-- Only register if Neovim has an active UI attached (ignore headless/embedded instances)
if #vim.api.nvim_list_uis() > 0 then
local server_name = vim.v.servername
if server_name then
local home = os.getenv("HOME")
if not home then
home = os.getenv("USERPROFILE")
end
-- 1. Legacy Disk Write (Fallback)
local home = os.getenv("HOME") or os.getenv("USERPROFILE")
if home then
os.execute("mkdir -p " .. home .. "/.gemini")
local path = home .. "/.gemini/active_nvim.txt"
@@ -19,6 +17,20 @@ vim.api.nvim_create_autocmd({"VimEnter", "FocusGained"}, {
f:close()
end
end
-- 2. V2 Telemetry Push (WebSockets & Cross-OS Sync via Rust Server)
local file = vim.api.nvim_buf_get_name(0)
local cursor = vim.api.nvim_win_get_cursor(0)
local row, col = cursor[1], cursor[2]
local payload = string.format(
'{"session_id": "%s", "event": "%s", "file": "%s", "line": %d, "col": %d}',
server_name:gsub("\\", "\\\\"), ev.event, file:gsub("\\", "\\\\"), row, col
)
vim.fn.jobstart({
"curl", "-s", "-X", "POST", "http://127.0.0.1:3000/nvim/telemetry",
"-H", "Content-Type: application/json",
"-d", payload
}, { detach = true })
end
end
end,