feat: Merge V2 WebSocket telemetry push into existing gemini-integration.lua
This commit is contained in:
1 parent
4d69f5e771
commit
86fab8abb1
2 files changed
+18
-34
No files matched your search
+18
-6
@@ -1,15 +1,13 @@
|
|||||||
-- gemini-integration.lua
|
-- gemini-integration.lua
|
||||||
-- Registers the active Neovim instance for the Antigravity MCP Server
|
-- Registers the active Neovim instance for the Antigravity MCP Server
|
||||||
vim.api.nvim_create_autocmd({"VimEnter", "FocusGained"}, {
|
vim.api.nvim_create_autocmd({"VimEnter", "FocusGained", "BufEnter"}, {
|
||||||
callback = function()
|
callback = function(ev)
|
||||||
-- Only register if Neovim has an active UI attached (ignore headless/embedded instances)
|
-- Only register if Neovim has an active UI attached (ignore headless/embedded instances)
|
||||||
if #vim.api.nvim_list_uis() > 0 then
|
if #vim.api.nvim_list_uis() > 0 then
|
||||||
local server_name = vim.v.servername
|
local server_name = vim.v.servername
|
||||||
if server_name then
|
if server_name then
|
||||||
local home = os.getenv("HOME")
|
-- 1. Legacy Disk Write (Fallback)
|
||||||
if not home then
|
local home = os.getenv("HOME") or os.getenv("USERPROFILE")
|
||||||
home = os.getenv("USERPROFILE")
|
|
||||||
end
|
|
||||||
if home then
|
if home then
|
||||||
os.execute("mkdir -p " .. home .. "/.gemini")
|
os.execute("mkdir -p " .. home .. "/.gemini")
|
||||||
local path = home .. "/.gemini/active_nvim.txt"
|
local path = home .. "/.gemini/active_nvim.txt"
|
||||||
@@ -19,6 +17,20 @@ vim.api.nvim_create_autocmd({"VimEnter", "FocusGained"}, {
|
|||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
end,
|
end,
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
local function send_telemetry(event)
|
|
||||||
local session_id = vim.v.servername
|
|
||||||
if not session_id or session_id == '' then return end
|
|
||||||
|
|
||||||
local file = vim.api.nvim_buf_get_name(0)
|
|
||||||
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
|
|
||||||
|
|
||||||
local payload = string.format(
|
|
||||||
'{"session_id": "%s", "event": "%s", "file": "%s", "line": %d, "col": %d}',
|
|
||||||
session_id:gsub("\\", "\\\\"), 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
|
|
||||||
|
|
||||||
local group = vim.api.nvim_create_augroup("GeminiTelemetry", { clear = true })
|
|
||||||
|
|
||||||
local events = { "FocusGained", "BufEnter", "VimEnter" }
|
|
||||||
for _, event in ipairs(events) do
|
|
||||||
vim.api.nvim_create_autocmd(event, {
|
|
||||||
group = group,
|
|
||||||
callback = function() send_telemetry(event) end
|
|
||||||
})
|
|
||||||
end
|
|
||||||
Reference in new issue
Block a user