Skip to content

Commit 0488dd7

Browse files
authored
Update test.lua
Improve floating window setup: better variable names, options, and comments Signed-off-by: NeoPilot <221231603+neopilotai@users.noreply.github.com>
1 parent 66347b8 commit 0488dd7

1 file changed

Lines changed: 26 additions & 3 deletions

File tree

test.lua

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,29 @@
1+
-- Create a scratch buffer and a floating window in Neovim using the Lua API
2+
13
local api = vim.api
2-
local buf = api.nvim_create_buf(false, true)
3-
local win = vim.api.nvim_open_win(buf, true,
4-
{relative='win', row=3, col=3, width=12, height=3})
54

5+
-- Create a scratch buffer (not listed, scratch)
6+
local scratch_buf = api.nvim_create_buf(false, true)
7+
assert(scratch_buf ~= 0, "Failed to create buffer")
8+
9+
-- Set buffer options (optional)
10+
api.nvim_buf_set_option(scratch_buf, 'bufhidden', 'wipe')
11+
api.nvim_buf_set_option(scratch_buf, 'filetype', 'neopilot-scratch')
12+
13+
-- Define window options for a floating window
14+
local win_opts = {
15+
relative = 'editor', -- Use 'editor' for global position, or 'win' for relative to window
16+
row = 3,
17+
col = 3,
18+
width = 30,
19+
height = 8,
20+
style = 'minimal', -- Optional: Removes window decorations
21+
border = 'rounded', -- Optional: Adds a border
22+
}
23+
24+
-- Open the floating window
25+
local scratch_win = api.nvim_open_win(scratch_buf, true, win_opts)
26+
assert(scratch_win ~= 0, "Failed to open floating window")
627

28+
-- (Optional) Set some lines in the buffer
29+
api.nvim_buf_set_lines(scratch_buf, 0, -1, false, { "Hello from NeoPilot!", "This is a floating window." })

0 commit comments

Comments
 (0)