Code Monkey home page Code Monkey logo

Comments (6)

prabirshrestha avatar prabirshrestha commented on August 18, 2024 3

sent initial PR at #748

from vital.vim.

ujihisa avatar ujihisa commented on August 18, 2024

Let's definitely have them. And yes let's have both the lower layor one to bridge and the one to orchestrate/coordinate a set of popups.

from vital.vim.

prabirshrestha avatar prabirshrestha commented on August 18, 2024

This one seems interesting since it supports border which I believe neovim doesn't support by default. junegunn/fzf.vim#821 (comment) I have found popup without border very difficult to use since some colorschemes blend together and very difficult to know what the issue is.

I haven't played much with popup apis but would be good to hear thoughts from those who have experience around it.

from vital.vim.

lambdalisue avatar lambdalisue commented on August 18, 2024

Just note.

https://github.com/lambdalisue/loupe.vim/blob/master/autoload/loupe/viewer/nvim.vim#L24-L105

To provide borders in Neovim, we need to make the border by ourselves like above.

The feature request has closed in Neovim.
neovim/neovim#9718

from vital.vim.

prabirshrestha avatar prabirshrestha commented on August 18, 2024

Here is an api I can think of some would most likely have to be pushed as a higher level api.

let s:Popup = vital#vital#import('UI.Popup')

function! s:demo() abort
    let popup = s:Popup.new({
        \ 'max_width': 'auto',
        \ 'max_height': 'auto',
        \ 'min_height': 'auto',
        \ 'min_width': 'auto',
        \ 'height': 10,
        \ 'width': 10,
        \ 'border': 1,
        \ 'borderchars': '',
        \ 'contents': ['hello', 'world'],
        \ 'screenpos': [0, 0],
        \ 'directionalhint': 'bottomleft|bottomright|topleftedge|topcenter',
        \ 'focusable': 0,
        \ 'zindex': 0,
        \ 'drag': 0,
        \ 'scrollbar': 0,
        \ 'on_event': function('s:on_event'),
        \ })
    let winid = popup.get_winid()

    let [height, width] = popup.get_dimensions(id)
    call popup.set_dimensions(height, width)
    " or
    let height = popup.get_height()
    let width = popup.get_width()
    call popup.set_height(height)
    call popup.set_width(width)

    let isopen = popup.is_open()
    call popup.show(id)  " open popup
    call popup.hide(id)  " popup is hidden
    " or
    call popup.set_visibility(0)
    let isvisible = popup.get_visiblity()

    let contents = popup.get_contents()
    call popup.set_contents(contents)

    call popup.focus() " focus cursor

    call popup.close(id) " disposes and cleans up the popup
endfunction

function! s:on_event(id, event, data) abort
    let l:popup = s:Popup.get(a:id)

    let l:bufnr = a:data['bufnr']
    let l:popuid = a:id

    if a:event == 'open'
        " register autocmd for cursor move so can auto close the popup
    elseif a:event == 'close'
    elseif a:event == 'focus'
    elseif a:event == 'blur'
    elseif a:event == 'hidden'
    elseif a:event == 'scrolldown'
    elseif a:event == 'scrollup'
    endif
endfunction

Another option is for s:Popup.new() to return an id which is a number instead of string so when using different languages such as lua or rpc it is very easy to pass references around. This does mean one would have to use call s:Popup.close(id)
//cc @hrsh7th since he had submitted a similar PR to refactor this for vim-lsp.

from vital.vim.

prabirshrestha avatar prabirshrestha commented on August 18, 2024

Seems like the border in neovim uses two floating window most likely to not have impact on syntax highlighting. In order to make it consistent with vim and have z-index the same might have to use the same trick on vim.

from vital.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.