Skip to content

Question about rendering floating window #368

Discussion options

You must be logged in to vote

Set the filetype after opening the buffer in a window:

function! lib#debug#popup()
  let lines = ['# abc', '## 123', '---', 'hello world']
  let buf = nvim_create_buf(v:true, v:true)
  call nvim_buf_set_lines(buf, 0, -1, v:false, lines)

  let win = nvim_open_win(buf, v:false, {
      \ 'width': 20,
      \ 'height': 10,
      \ 'col': 0,
      \ 'row': 1,
      \ 'relative': 'cursor',
      \ })

  call setbufvar(buf, '&buftype', 'nofile')
  call setbufvar(buf, '&filetype', 'markdown')
endfunction

You can keep the buftype where it is, I just moved both of them for consistency.

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@solomonwzs
Comment options

@MeanderingProgrammer
Comment options

Answer selected by MeanderingProgrammer
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants