blob: 2174015e16d5a58814d1fec7a7f4624319d6e3ac (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
import { tool } from "@opencode-ai/plugin"
export default tool({
description: "Read the current live Neovim buffer. Use this instead of read when you need the current unsaved contents of the user's active buffer.",
args: {},
async execute() {
const nvim = process.env.NVIM
if (!nvim) {
throw new Error("$NVIM is not set; live_read must be run from a Neovim-spawned OpenCode process")
}
const expr = `join(getline(1, "$"), "\n")`
console.error(`[hobs.nvim] live_read tool called =${expr} =${nvim}`)
// const result = await Bun.$`echo "hello, there"`.text()
const result =
await Bun.$`nvim --headless --server ${nvim} --remote-expr ${expr}`.text()
console.error(`live tool returned ${result}`)
console.error(`done`)
return result
},
})
|