forked from khulnasoft-lab/init.lua
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest.lua
More file actions
29 lines (23 loc) · 1.02 KB
/
test.lua
File metadata and controls
29 lines (23 loc) · 1.02 KB
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
28
29
-- Create a scratch buffer and a floating window in Neovim using the Lua API
local api = vim.api
-- Create a scratch buffer (not listed, scratch)
local scratch_buf = api.nvim_create_buf(false, true)
assert(scratch_buf ~= 0, "Failed to create buffer")
-- Set buffer options (optional)
api.nvim_buf_set_option(scratch_buf, 'bufhidden', 'wipe')
api.nvim_buf_set_option(scratch_buf, 'filetype', 'neopilot-scratch')
-- Define window options for a floating window
local win_opts = {
relative = 'editor', -- Use 'editor' for global position, or 'win' for relative to window
row = 3,
col = 3,
width = 30,
height = 8,
style = 'minimal', -- Optional: Removes window decorations
border = 'rounded', -- Optional: Adds a border
}
-- Open the floating window
local scratch_win = api.nvim_open_win(scratch_buf, true, win_opts)
assert(scratch_win ~= 0, "Failed to open floating window")
-- (Optional) Set some lines in the buffer
api.nvim_buf_set_lines(scratch_buf, 0, -1, false, { "Hello from NeoPilot!", "This is a floating window." })