Re: [vim/vim] Make popup behave like a normal window (#5639)

2020-12-24 Fir de Conversatie ma...@prabir.me
@Bram wondering if there has been any more thoughts on focusable popup 
windows? Wouldn't a focusable flag and support for win_gotoid(windid) be 
enough?

On Tuesday, October 6, 2020 at 11:29:13 AM UTC-7 ma...@prabir.me wrote:

> Here are the different phases I think we need to have based on my priority.
>
> 1. Focus (useful for fuzzy finders as well as peeking into 
> docs/diagnostics error that are long or big)
> a. "focusable" flag
> b. win_gotoid(winid) to move focus to popup
>
> 2. All insert mode for popup (useful for fuzzy finders)
>
> 3. Cycle with Ctrl+W P
>
> If we have #1 we don't need to worry about #3 or how to get out of popup 
> though having a unified approach would make it consistent across different 
> plugins.
>
> I'm currently primarily interested in #1 and #2 only.
>
>
> On Tuesday, October 6, 2020 at 8:09:30 AM UTC-7 Bram Moolenaar wrote:
>
>>
>> Christian wrote:
>>
>> > On Mo, 05 Okt 2020, Blay263 wrote:
>> > > On Monday, October 5, 2020 at 10:28:08 AM UTC-4 Bram Moolenaar wrote:
>> > >> I have been thinking of this, but it raises many questions:
>> > >> 
>> > >> - How to focus a popup? I imagine in most cases you want to switch
>> > >> between the current window and the popup, back and forth. This
>> > >> matters especially if you already have a dozen split windows, you
>> > >> don't want to cycle through all of them to reach the popup, and
>> > >> you don't want to cycle through all windows to end up in the one
>> > >> you were coming from.
>> > 
>> > Can't we amend CTRL-W_P to this? E.g. if there exists a popup window, 
>> go 
>> > to that one, else if there exists a preview window go to that one else 
>> > error. I would imagine, that the preview window is not of that much use 
>> > now with popup windows. 
>>
>> Yeah, that could work. To remain backwards compatible CTRL-W P would
>> cycle through any preview and focusable popup windows. After the last
>> one back to the current window. Also, we can make Esc in Normal mode go
>> back to the current window, as it functions as a "get out of here" key.
>>
>> I was thinking of a "focusable" flag for popups. That would require
>> another command to go to non-focusable popup windows (if you really want
>> to). Another way could be to have some kind of priority. Or let it
>> depend on the buffer type. Anyway, still lot of choices to get right.
>>
>> -- 
>> Just remember...if the world didn't suck, we'd all fall off.
>>
>> /// Bram Moolenaar -- br...@moolenaar.net -- http://www.Moolenaar.net \\\
>> /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
>> \\\ an exciting new programming language -- http://www.Zimbu.org ///
>> \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
>>
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/0da9347f-66d1-44ea-a833-af1b8bda8928n%40googlegroups.com.


Re: [vim/vim] Make popup behave like a normal window (#5639)

2020-10-06 Fir de Conversatie ma...@prabir.me
Here are the different phases I think we need to have based on my priority.

1. Focus (useful for fuzzy finders as well as peeking into docs/diagnostics 
error that are long or big)
a. "focusable" flag
b. win_gotoid(winid) to move focus to popup

2. All insert mode for popup (useful for fuzzy finders)

3. Cycle with Ctrl+W P

If we have #1 we don't need to worry about #3 or how to get out of popup 
though having a unified approach would make it consistent across different 
plugins.

I'm currently primarily interested in #1 and #2 only.


On Tuesday, October 6, 2020 at 8:09:30 AM UTC-7 Bram Moolenaar wrote:

>
> Christian wrote:
>
> > On Mo, 05 Okt 2020, Blay263 wrote:
> > > On Monday, October 5, 2020 at 10:28:08 AM UTC-4 Bram Moolenaar wrote:
> > >> I have been thinking of this, but it raises many questions:
> > >> 
> > >> - How to focus a popup? I imagine in most cases you want to switch
> > >> between the current window and the popup, back and forth. This
> > >> matters especially if you already have a dozen split windows, you
> > >> don't want to cycle through all of them to reach the popup, and
> > >> you don't want to cycle through all windows to end up in the one
> > >> you were coming from.
> > 
> > Can't we amend CTRL-W_P to this? E.g. if there exists a popup window, go 
> > to that one, else if there exists a preview window go to that one else 
> > error. I would imagine, that the preview window is not of that much use 
> > now with popup windows. 
>
> Yeah, that could work. To remain backwards compatible CTRL-W P would
> cycle through any preview and focusable popup windows. After the last
> one back to the current window. Also, we can make Esc in Normal mode go
> back to the current window, as it functions as a "get out of here" key.
>
> I was thinking of a "focusable" flag for popups. That would require
> another command to go to non-focusable popup windows (if you really want
> to). Another way could be to have some kind of priority. Or let it
> depend on the buffer type. Anyway, still lot of choices to get right.
>
> -- 
> Just remember...if the world didn't suck, we'd all fall off.
>
> /// Bram Moolenaar -- br...@moolenaar.net -- http://www.Moolenaar.net \\\
> /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
> \\\ an exciting new programming language -- http://www.Zimbu.org ///
> \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/2ef28adb-dc8a-4279-9d39-bd06cb0eb402n%40googlegroups.com.


Re: [vim/vim] Add the matchfuzzy() function (#6932)

2020-10-05 Fir de Conversatie ma...@prabir.me
If you are porting might be good to look into comparing and porting other 
libraries. Would be also good to trying in real big projects such as 
chromium.

https://github.com/wincent/command-t  - C (actual search algorithm is in C)
https://github.com/jhawthorn/fzy  - C
https://github.com/lotabout/skim  - Rust  (
https://github.com/lotabout/fuzzy-matcher)
https://github.com/JazzCore/ctrlp-cmatcher/blob/master/autoload/fuzzycomt.c  
- C
https://github.com/garybernhardt/selecta 

Most of these are multi threaded so they are extremely fast.

If really want multithreading could write to file and then have another 
thread look at it. I briefly mentioned this at 
https://github.com/mattn/gof/issues/18


 

On Monday, October 5, 2020 at 1:41:02 PM UTC-7 vim-dev ML wrote:

> Hi,
>
> On Sun, Oct 4, 2020 at 7:10 PM lacygoill  wrote:
>
> > If you have any comments about the function arguments and the return
> > values, please let me know. We cannot change this after some time.
> >
> > I haven't had the time to read all the comments, but I'm using
> > matchfuzzypos(), and I had difficulties using its output for what I
> > wanted. I'm trying to implement a generic fuzzy search plugin. For now, I
> > just wrote a command to fuzzy search through Vim's help tags.I get the 
> help
> > tags via a grep(1)
> > <
> https://github.com/lacygoill/vim-fuzzy/blob/ef8173581e2dfc7ee2b7a04d87815a07927630e9/autoload/fuzzy.vim#L239-L245
> >
> > command, which is formatted by a perl(1)
> > <
> https://github.com/lacygoill/vim-fuzzy/blob/ef8173581e2dfc7ee2b7a04d87815a07927630e9/autoload/fuzzy.vim#L228
> >
> > (or awk(1)) command. Both are started asynchronously via a job. I use
> > perl so that an output line of grep(1) such as this one:
> >
> > /home/user/.fzf/doc/tags:fzf-toc fzf.txt /*fzf-toc*
> >
> > Is transformed into:
> >
> > fzf-toc fzf.txt
> >
> > Between the name of the tag and the name of the file where the tag is,
> > there is some whitespace including a tab. I rely on this tab to ignore 
> the
> > name of the file when fuzzy searching through the tags. I only want to 
> see
> > the names of the files to get some extra info.
> >
> > Here is how I do it
> > <
> https://github.com/lacygoill/vim-fuzzy/blob/ef8173581e2dfc7ee2b7a04d87815a07927630e9/autoload/fuzzy.vim#L394-L434
> >
> > :
> >
> > var str = substitute(filter_text, '\s*', '', 'g')
> > var pos: list>
> > var matchfuzzypos: list> = matchfuzzypos(TAGLIST, str)
> > [taglist_filtered, pos] = matchfuzzypos
> > map(taglist_filtered, {i, v -> [v] + pos[i]})
> > filter(taglist_filtered, {_, v -> v[-1] < match(v[0], "\t")})
> > pos = copy(taglist_filtered)->map({_, v -> v[1:]})
> > map(taglist_filtered, {_, v -> v[0]})
> >
> > I would like to simplify this code by passing the output of
> > matchfuzzypos() directly to filter() so that it removes the entries where
> > a match is located after the tab. But I can't do it, because if filter()
> > removes one tag name from taglist_filtered, the next time pos[i] is
> > evaluated, it will no longer apply to the right item. IOW, I need to 
> filter
> > both lists returned by matchfuzzypos() simultaneously. The only way I
> > found to do that is to temporarily merge the lists into a single one. It
> > works but I think it would be easier and more efficient if 
> matchfuzzypos()
> > returned a single list. Maybe a list of dictionaries:
> >
> > :echo matchfuzzypos(['clay', 'lacy'], 'la')
> > [{'match': 'lacy', 'pos': [0, 1]}, {'match': 'clay', 'pos': [1, 2]}]
> >
> >
> The previous implementation of matchfuzzypos() returned the match position
> along with
> the matched text. But Prabir commented that it will make it easier for
> plugins if all the
> matched stings are returned in a single List. It is a trade-off between
> these two
> approaches. I am not sure which one will be more useful for the plugins:
>
> 1. Returning a list with all the matched strings and another list with the
> matching
> positions (current implementation).
> 2. Return a single list where each item contains both the matched string
> and the
> matching position.
>
> Or a list of lists:
> >
> > :echo matchfuzzypos(['clay', 'lacy'], 'la')
> > [['lacy', 0, 1], ['clay', 1, 2]]
> >
> > This way, we wouldn't need to temporarily merge the lists, then split 
> them
> > back later. I'm a bit concerned by the impact it can have on performance,
> > especially when the operation is repeated frequently (e.g. every keypress
> > when a popup menu is visible), and the source of strings is big.
> > --
> >
> > There is something else which I think would be useful but it's more a
> > feature request. If you use fzf(1) to search through help tags via
> > :Helptags
> > <
> https://github.com/junegunn/fzf.vim/blob/0fe8e198a3a501b54dbc4f9587526c097599f95a/plugin/fzf.vim#L66
> >,
> > you should notice that we can use spaces between tokens. And when you do,
> > fzf(1) does 2 interesting things:
> >
> > - it ignores whitespace
> > - it looks for the tokens in no part

Re: [vim/vim] Make popup behave like a normal window (#5639)

2020-10-05 Fir de Conversatie ma...@prabir.me
>From a plugin author there are only two features I would need i.e. allow to 
pass an option for popup for focusable: true/false when creating popup and 
capability to focus on the popup or move focus to another buffer/win. 
Neovim has a win_gotoid() to focus to popup which avoids creating a new api 
since it treats popup as just any other window with buffer. Based on the 
api we might need a third once that says which one currently focused.

As for the experience it is like any other buffer or window. You can only 
be currently focused in a buffer or popup and not multiple. Use / for 
search, jkhl for movements and so on.

Here is how vim-lsp works when trying to show popup for hovering under a 
symbol that gives doc.
nmap  K (lsp-hover)  

lsp-hover is same as preview window concept in vim but instead of using 
preview window it uses popup if it exists.
We have a flag to allow autofocus for lsp-hover. if it is true we autofocus 
to popup window and if false the focus remains in the buffer. By default we 
have set it to false so it doesn't focus in the popup. The popup closes 
when cursor moves since it is not on focus. We then have a concept of 
double tap which means if the user again presses K when the popup is open 
it focus inside the popup. Inside the popup they can use all the features 
of normal buffer and cursor movement doesn't close the popup.

For fuzzy finder style popup it also becomes important. I have tried 
multiple approaches ie. using custom prompt similar to ctrlp, denite style 
where the prompt is a buffer. I'm leaning to denite style pattern but that 
means it won't work in popup. vim-clap already seems to be hitting this 
issue.
(Not related to popup but is there an event similar to InsertCharPre but 
that works in normal code so we can look at v:char and see what character 
is pressed? This would solve the issue of using prompt to work in multibyte 
chars and avoid this 
https://github.com/prabirshrestha/quickpick.vim/blob/68465f4654f83d4a711afe1059a104f9c16f4ac7/autoload/quickpick.vim#L48-L57.
 
getchar() isn't an option since it is blocking. This would solve the prompt 
issue but not popup issue)


On Monday, October 5, 2020 at 9:30:15 AM UTC-7 Blay263 wrote:

> I think the use cases have been detailed above and are limited. Neovim 
> provides a proof of concept. Not having the popup focusable is blocking 
> specific functionality that is already available in Neovim.
>
> On Monday, October 5, 2020 at 10:28:08 AM UTC-4 Bram Moolenaar wrote:
>
>>
>> > +1 I would also like the popup to be focusable so that it can be used 
>> like 
>> > a normal window/buffer. Neovim doesn't have this issue.
>> > 
>> > Here is another use case for me. This is vim-lsp 
>> >  using hover to show 
>> > information about the word under the cursor. Most rust projects have 
>> big 
>> > docs including great examples and I would like to move around and copy 
>> text 
>> > from popup, search inside the popup and use all my vim knowledge there. 
>> > 
>> > Right now the solution for me is to open the website or use neovim.
>>
>> I have been thinking of this, but it raises many questions:
>>
>> - How to focus a popup? I imagine in most cases you want to switch
>> between the current window and the popup, back and forth. This
>> matters especially if you already have a dozen split windows, you
>> don't want to cycle through all of them to reach the popup, and you
>> don't want to cycle through all windows to end up in the one you were
>> coming from.
>>
>> - If there is more than one focusable popup, how to reach each of them?
>> Perhaps some are connected to a specific window (e.g. for completion
>> or anchored to text), or some are unrelated to a specific window (e.g.
>> help).
>>
>> - What if the focused popup window closes? What if it closes while you
>> are typing (since they might be under control of some async plugin)?
>>
>> - How to avoid this turns into an avalanche of more feature requests?
>> Aka creeping featurism.
>>
>> -- 
>> He who laughs last, thinks slowest.
>>
>> /// Bram Moolenaar -- br...@moolenaar.net -- http://www.Moolenaar.net \\\
>> /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
>> \\\ an exciting new programming language -- http://www.Zimbu.org ///
>> \\\ help me help AIDS victims -- http://ICCF-Holland.org ///
>>
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/da38b161-ae38-4d4a-acf9-825e54451ba0n%40googlegroups.com.


Re: Vim9: rethinking conditions and boolean expressions

2020-10-04 Fir de Conversatie ma...@prabir.me
In javascript you can use !! operator to always convert it to boolean.

var name = ''
var nameExists = !!(name || 'Prabir')

On Saturday, October 3, 2020 at 12:25:21 PM UTC-7 Andy Wokula wrote:

> Am 03.10.2020 um 17:44 schrieb Bram Moolenaar:
> > Therefore, I'm going to make && and || have a boolean result again.
> > I think that is the easiest to understand, and what most languages do.
>
> +100
>
> -- 
> Andy
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/d82bdde2-4327-4907-a866-d57faf95ed2dn%40googlegroups.com.