Code Monkey home page Code Monkey logo

Comments (18)

gelguy avatar gelguy commented on May 31, 2024 1

To clarify, wilder doesn't hijack or remap / (unless you use a mapping for wilder#start_from_normal_mode()). It uses CmdlineEnter to detect that the / or : cmdline has been entered.

What is happening here is that vim-visual-multi remaps / and when multi mode is entered, the statusline is changed to show additional info for multi mode. wilder is drawing over the statusline, which is causing the conflict here.

For triggering wilder on a keybinding, you can use

" remove the wilder#enable_cmdline_enter() call
cmap <expr> <F1> wilder#main#start()

wilder will then start only after <F1> is pressed.

This can be followed up with another mapping

nmap g/ /<F1>

which would avoid conflicting with the / mapping of vim-visual-multi.

from wilder.nvim.

IndianBoy42 avatar IndianBoy42 commented on May 31, 2024

Ah, I think I understand now. thank you, I will try your suggestions

from wilder.nvim.

gelguy avatar gelguy commented on May 31, 2024

vim-visual-multi exposes enough information to recreate the statusline so an alternative would be to add that information to wilder#wildmenu_renderer().

Very rough example to demonstrate:

  let s:Wildmenu_renderer = wilder#wildmenu_renderer(({
        \ 'left': [{-> s:vm()}, wilder#previous_arrow()],
        \ 'right': [wilder#next_arrow()],
        \ }))

  function! s:foo()
    if !exists('b:visual_multi')
      return ''
    endif
    let v = b:VM_Selection.Vars
    let vm = VMInfos()
    let color  = '%#VM_Extend#'

    try
      if v.insert
        if vm.Insert.replace
          let [ mode, color ] = [ 'V-R', '%#VM_Mono#' ]
        else
          let [ mode, color ] = [ 'V-I', '%#VM_Cursor#' ]
        endif
      else
        let mode = { 'n': 'V-M', 'v': 'V', 'V': 'V-L', "\<C-v>": 'V-B' }[mode()]
      endif
    catch
      let mode = 'V-M'
    endtry
    let mode = exists('v.statusline_mode') ? v.statusline_mode : mode
    let patterns = string(vm.patterns)[:(winwidth(0)-30)]

    return printf(' %s %s %s %s ', mode, vm.ratio, patterns, vm.status)
  endfunction

For reference: https://github.com/mg979/vim-visual-multi/blob/f994695813ebaecc9e37c7ea216c65d9cd659767/autoload/vm/themes.vim#L100-L126

from wilder.nvim.

IndianBoy42 avatar IndianBoy42 commented on May 31, 2024

I'm not sure but I don't think the problem is just the statusline getting covered up, because it also functionally doesn't work.

It reverts back to just searching the document, without doing the vim-visual-multi things.

from wilder.nvim.

gelguy avatar gelguy commented on May 31, 2024

Can you paste your config here?

from wilder.nvim.

IndianBoy42 avatar IndianBoy42 commented on May 31, 2024

My whole config is actually here on github: https://github.com/indianBoy42/lunarvim

the wilder config is in lua/lv-wilder/init.lua

from wilder.nvim.

gelguy avatar gelguy commented on May 31, 2024

Could you also list steps to reproduce?

from wilder.nvim.

IndianBoy42 avatar IndianBoy42 commented on May 31, 2024

BTW: disabling wilder#enable_cmdline_enter() and enabling wilder separately seems to work, which is what is on the latest commit in the repo

from wilder.nvim.

IndianBoy42 avatar IndianBoy42 commented on May 31, 2024

To reproduce the problem

  1. uncomment out wilder#enable_cmdline_enter() firstly
  2. Visually select some region of test
  3. enter / to enter vim-visual-multi "Visual Regex"
  4. the vim-visual-multi statusline would flicker briefly and the regex search will act like a vanilla vim search
  5. if wilder#enable_cmdline_enter() is disabled then after step 3, you would be able to type some search and when you hit enter, the found regions will be added as selections in vim-visual-multi

from wilder.nvim.

gelguy avatar gelguy commented on May 31, 2024

I'm not able to reproduce this - am I missing a keymapping (I'm using the default g:VM_leader \\)?

  1. Visually selecting a region and entering / doesn't enter VM-REGEX mode, it's Vim's default Visual mode
  2. Visually selecting a region and entering \\/ enters VM-REGEX mode
  3. VM-REGEX mode is the same as searching with /, after entering your search with <CR>:
    a. If there's one or more matches, it goes back to V-M mode with the matches added to selections
    b. If there's no match across the whole buffer, a Pattern not found error is thrown, and it goes back to VM-REGEX mode
    c. If there's no match within the lines of the visual selection, but a match in the buffer, there's no error thrown and it goes back to normal mode (likely a bug?)
    d. Note that matches also have to start after the cursor
    e. Matches are searched within the lines where the visual selection starts and stops, so it's possible to have a match outside the visual selection if it's on the same line
  4. If wilder is active, there's no difference in the behavior, other than the statusline being drawn over

Can I confirm my observations are correct?

from wilder.nvim.

IndianBoy42 avatar IndianBoy42 commented on May 31, 2024

For point one I have remapped "/" in visual mode to do VM-REGEX, sorry for not mentioning that (relevant config)

point 2 is correct for the default mapping

point 3 is how it should work

point 4 is where we diverge for some reason, after searching it doesn't go to V-M mode, it goes to normal mode for me, which it shouldnt do. This only happens if wilder is active, either from cmdline_enter or from wilder#main#start()

also I have noticed that the search highlighting is a bit weird with wilder active, the highlight disappears as I type, although it shows up permanently after I hit <CR>. I don't know if this is expected/related

from wilder.nvim.

gelguy avatar gelguy commented on May 31, 2024

Regarding the highlights, see #30.

Can you check if Step 3c is being reached? The match has to start after the cursor and be within the lines of the visual selection.

e.g.

|f|oobar

If f is the visual selection, foo is not considered a match and it would go back to normal mode. This occurs with or without wilder. I'm using a minimal config with vim-visual-multi as the only plugin.

" set to wherever vim-plug was installed
set runtimepath^=~/.vim/

call plug#begin('~/.vim/plugins')
Plug 'mg979/vim-visual-multi'
call plug#end()

let g:VM_maps = {}
let g:VM_maps["Visual Regex"] = "/"

from wilder.nvim.

IndianBoy42 avatar IndianBoy42 commented on May 31, 2024

No 3c isn't being reached, I am searching for something that definitely has a match in the visual selection region

I just tried to implement the fix from #30, I changed to use wildmenu_renderer instead of popupmenu_renderer and now VM-REGEX works. Switching back makes it stop working again

The popupmenu renderer uses a buffer right? to change the contents does vim technically switch out of the file buffer? This would rip us out of any visual-multi mode (V-M or VM-REGEX)

from wilder.nvim.

IndianBoy42 avatar IndianBoy42 commented on May 31, 2024

I have encountered this problem of BufLeave/BufExit autocmds being run due to popup windows like that (compe autocompletion windows for example). It is annoying but I suppose it means that popupmenu_renderer is just incompatible

from wilder.nvim.

gelguy avatar gelguy commented on May 31, 2024

I think some other plugin in combination with wilder and vim-visual-multi is causing this issue.

I don't have a better workaround than the one in #63 (comment).

from wilder.nvim.

IndianBoy42 avatar IndianBoy42 commented on May 31, 2024

Did you try wilder+vim-visual-multi using popupmenu_renderer or with wildmenu_renderer? Can you confirm whether they work together with popupmenu for you?

from wilder.nvim.

gelguy avatar gelguy commented on May 31, 2024

Both work fine for me, other than the statusline being covered.

from wilder.nvim.

gelguy avatar gelguy commented on May 31, 2024

I'm closing this issue since the original question is solved by #63 (comment).

If you wish to, we can continue the investigation with vim-visual-multi in another issue if you open one.

from wilder.nvim.

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.