Opening floating window a specific cursor position

Hey everyone,

I am trying to make a quick floating window with the contents of a specific buffer, but I need to open that preview window in a specific line. I’ve already tried using getcurpos and setpos after and also the good old :normal! LINEG calls.

The current code is using lua, and it’s something like:

-- ... opts is create above this snippet

  buf = api.nvim_create_buf(false, true)
  win = api.nvim_open_win(buf, true, opts)
  api.nvim_buf_set_option(buf, "bufhidden", "wipe")
  api.nvim_win_set_option(win, "winblend", 0)

  -- need to open the window in the specific line here

Any hints?

Try using the '" register. I don’t know if this works for floating windows, but I have an autocommand in my init.vim that writes likes this:

au BufReadPost * '"