Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Support neovim float term #15

Description

@hsanson

This tip could be included in the documentation for those interested in using neovim float term instead of a split:

" Floating window with borders for NNN and FFF
" https://github.com/neovim/neovim/issues/9718#issuecomment-559573308
function! s:layout()
  let s:cwin = winnr()
  let height = &lines - (float2nr(&lines / 3))
  let width = float2nr(&columns - (&columns / 3))
  let row = (&lines / 2) - (height / 2)
  let column = (&columns / 2) - (width / 2)
  let opts = {
        \ 'relative': 'editor',
        \ 'row': row,
        \ 'col': column,
        \ 'width': width,
        \ 'height': height,
        \ 'style': 'minimal'
        \ }
  let top = '' . repeat('', width - 2) . ''
  let mid = '' . repeat(' ', width - 2) . ''
  let bot = '' . repeat('', width - 2) . ''
  let lines = [top] + repeat([mid], height - 2) + [bot]
  let s:buf = nvim_create_buf(v:false, v:true)
  call nvim_buf_set_lines(s:buf, 0, -1, v:true, lines)
  let s:win = nvim_open_win(s:buf, v:true, opts)
  set winhl=Normal:Floating
  let opts.row += 1
  let opts.height -= 2
  let opts.col += 2
  let opts.width -= 4
  call nvim_open_win(nvim_create_buf(v:false, v:true), v:true, opts)
  augroup NNNGroup
    autocmd!
    au BufWipeout <buffer> exe 'bw '.s:buf
    au BufWipeout <buffer> exe s:cwin . 'wincmd w'
  augroup END
endfunction
let g:fff#split = 'call ' . string(function('<SID>layout')) . '()'

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions