Giter Club home page Giter Club logo

wilder.nvim's Introduction

wilder.nvim

A more adventurous wildmenu

wilder.nvim adds new features and capabilities to wildmenu.

  • Automatically provides suggestions as you type
    • : cmdline support - autocomplete commands, expressions, filenames, etc.
    • / search support - get search suggestions from the current buffer
  • High level of customisation
    • build your own custom pipeline to suit your needs
    • customisable look and appearance

wilder

Getting started

Requirements

  • Vim 8.1+ or Neovim 0.3+
  • To use the optional Python features, Neovim or Vim with yarp is needed

Install

With Shougo/dein.nvim

call dein#add('gelguy/wilder.nvim')

" To use Python remote plugin features in Vim, can be skipped
if !has('nvim')
  call dein#add('roxma/nvim-yarp')
  call dein#add('roxma/vim-hug-neovim-rpc')
endif

With junegunn/vim-plug

if has('nvim')
  function! UpdateRemotePlugins(...)
    " Needed to refresh runtime files
    let &rtp=&rtp
    UpdateRemotePlugins
  endfunction

  Plug 'gelguy/wilder.nvim', { 'do': function('UpdateRemotePlugins') }
else
  Plug 'gelguy/wilder.nvim'

  " To use Python remote plugin features in Vim, can be skipped
  Plug 'roxma/nvim-yarp'
  Plug 'roxma/vim-hug-neovim-rpc'
endif

With wbthomason/packer.nvim

use {
  'gelguy/wilder.nvim',
  config = function()
    -- config goes here
  end,
}

Minimal config

Start with the following minimal configuration in your init.vim or .vimrc:

" Key bindings can be changed, see below
call wilder#setup({'modes': [':', '/', '?']})

Be aware that call wilder#setup should be after call plug#end() if you use vim-plug.

When in : cmdline mode, wildmenu suggestions will be automatically provided. When searching using /, suggestions from the current buffer will be provided. Substring matching is used by default.

Use <Tab> to cycle through the list forwards, and <S-Tab> to move backwards.

The keybinds can be changed:

" Default keys
call wilder#setup({
      \ 'modes': [':', '/', '?'],
      \ 'next_key': '<Tab>',
      \ 'previous_key': '<S-Tab>',
      \ 'accept_key': '<Down>',
      \ 'reject_key': '<Up>',
      \ })

Ideally next_key should be set to be the same as &wildchar. Otherwise there might be a conflict when wildmenu is active at the same time as wilder.

To change the behavior so wilder does not activate automatically, set the enable_cmdline_enter option in wilder#setup() to 0.

call wilder#setup({
      \ 'modes': [':', '/', '?'],
      \ 'enable_cmdline_enter': 0,
      \ })

Pressing <Tab> (or whichever key next_key is set to) will activate wilder.

Lua config (Experimental)

For Neovim 0.5+, configuration in Lua is also supported. Note that this is experimental.

local wilder = require('wilder')
wilder.setup({modes = {':', '/', '?'}})

For every wilder#foo() method, the wilder Lua module exposes a wilder.foo() method in Lua. All function arguments are the same and only needs to be translated to the Lua equivalent.

Note: this is achieved by using a Vim Script to Lua wrapper shim which introduces some overhead. The core logic is still written in Vim Script so a Lua configuration is in general not more performant than a Vim Script configuration.

Customising the pipeline

Search

Use wilder#set_option('pipeline', <pipeline>) to customise the pipeline. The pipeline is a list of functions (referred to as pipes) which are executed in order, passing the result of the previous function to the next one.

For example, in Neovim or Vim with yarp, to use fuzzy matching instead of substring matching:

Vim Script
" For Neovim or Vim with yarp
" For wild#cmdline_pipeline():
"   'language'   : set to 'python' to use python
"   'fuzzy'      : 0 - turns off fuzzy matching
"                : 1 - turns on fuzzy matching
"                : 2 - partial fuzzy matching (match does not have to begin with the same first letter)
" For wild#python_search_pipeline():
"   'pattern'    : can be set to wilder#python_fuzzy_delimiter_pattern() for stricter fuzzy matching
"   'sorter'     : omit to get results in the order they appear in the buffer
"   'engine'     : can be set to 're2' for performance, requires pyre2 to be installed
"                : see :h wilder#python_search() for more details
call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({
      \       'language': 'python',
      \       'fuzzy': 1,
      \     }),
      \     wilder#python_search_pipeline({
      \       'pattern': wilder#python_fuzzy_pattern(),
      \       'sorter': wilder#python_difflib_sorter(),
      \       'engine': 're',
      \     }),
      \   ),
      \ ])
Lua
wilder.set_option('pipeline', {
  wilder.branch(
    wilder.cmdline_pipeline({
      -- sets the language to use, 'vim' and 'python' are supported
      language = 'python',
      -- 0 turns off fuzzy matching
      -- 1 turns on fuzzy matching
      -- 2 partial fuzzy matching (match does not have to begin with the same first letter)
      fuzzy = 1,
    }),
    wilder.python_search_pipeline({
      -- can be set to wilder#python_fuzzy_delimiter_pattern() for stricter fuzzy matching
      pattern = wilder.python_fuzzy_pattern(),
      -- omit to get results in the order they appear in the buffer
      sorter = wilder.python_difflib_sorter(),
      -- can be set to 're2' for performance, requires pyre2 to be installed
      -- see :h wilder#python_search() for more details
      engine = 're',
    })
  ),
})

wilder#branch() is a higher-order pipe which is able to provide control flow given its own lists of pipelines. Note: For Lua, wilder.branch() takes a variadic list of arguments and so cannot have a trailing comma.

See the docs at :h wilder-pipeline for a more details.

File finder pipeline (Neovim or Vim with yarp)

File finder

When getting file completions, fuzzily search and match through all files under the project directory. Has to be placed above wilder#cmdline_pipeline().

Vim Script
" 'file_command' : for ripgrep : ['rg', '--files']
"                : for fd      : ['fd', '-tf']
" 'dir_command'  : for fd      : ['fd', '-td']
" 'filters'      : use ['cpsm_filter'] for performance, requires cpsm vim plugin
"                  found at https://github.com/nixprime/cpsm
call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#python_file_finder_pipeline({
      \       'file_command': ['find', '.', '-type', 'f', '-printf', '%P\n'],
      \       'dir_command': ['find', '.', '-type', 'd', '-printf', '%P\n'],
      \       'filters': ['fuzzy_filter', 'difflib_sorter'],
      \     }),
      \     wilder#cmdline_pipeline(),
      \     wilder#python_search_pipeline(),
      \   ),
      \ ])
Lua
wilder.set_option('pipeline', {
  wilder.branch(
    wilder.python_file_finder_pipeline({
      -- to use ripgrep : {'rg', '--files'}
      -- to use fd      : {'fd', '-tf'}
      file_command = {'find', '.', '-type', 'f', '-printf', '%P\n'}, 
      -- to use fd      : {'fd', '-td'}
      dir_command = {'find', '.', '-type', 'd', '-printf', '%P\n'},
      -- use {'cpsm_filter'} for performance, requires cpsm vim plugin
      -- found at https://github.com/nixprime/cpsm
      filters = {'fuzzy_filter', 'difflib_sorter'},
    }),
    wilder.cmdline_pipeline(),
    wilder.python_search_pipeline()
  ),
})

To optimise for performance, the file_command, dir_command and filters options can be customised. See :h wilder#python_file_finder_pipeline() for more details.

Customising the renderer

Use wilder#set_option('renderer', <renderer>) to change how wilder draws the results. By default, wilder tries its best to look like the default wildmenu.

Wildmenu renderer

Wildmenu

wilder#wildmenu_renderer() draws the candidates above the cmdline. For Neovim 0.4+, a floating window is used. For Vim 8.1+ with popup support, a popup window is used. Otherwise the statusline is used. Note: When using the statusline, the wildmenu will only show on the statusline of the current window.

Vim Script
" 'highlighter' : applies highlighting to the candidates
call wilder#set_option('renderer', wilder#wildmenu_renderer({
      \ 'highlighter': wilder#basic_highlighter(),
      \ }))
Lua
wilder.set_option('renderer', wilder.wildmenu_renderer({
  -- highlighter applies highlighting to the candidates
  highlighter = wilder.basic_highlighter(),
}))
Minimal theme

An alternative theme which shows a spinner and the current number of items:

Wildmenu Minimal

Vim Script
call wilder#set_option('renderer', wilder#wildmenu_renderer({
      \ 'highlighter': wilder#basic_highlighter(),
      \ 'separator': ' · ',
      \ 'left': [' ', wilder#wildmenu_spinner(), ' '],
      \ 'right': [' ', wilder#wildmenu_index()],
      \ }))
Lua
wilder.set_option('renderer', wilder.wildmenu_renderer({
  highlighter = wilder.basic_highlighter(),
  separator = ' · ',
  left = {' ', wilder.wildmenu_spinner(), ' '},
  right = {' ', wilder.wildmenu_index()},
}))
Airline/Lightline theme

For Airline and Lightline users, wilder#wildmenu_airline_theme() and wilder#wildmenu_lightline_theme() can be used.

Wildmenu Airline

Vim Script
" Use wilder#wildmenu_lightline_theme() if using Lightline
" 'highlights' : can be overriden, see :h wilder#wildmenu_renderer()
call wilder#set_option('renderer', wilder#wildmenu_renderer(
      \ wilder#wildmenu_airline_theme({
      \   'highlights': {},
      \   'highlighter': wilder#basic_highlighter(),
      \   'separator': ' · ',
      \ })))
Lua
wilder.set_option('renderer', wilder.wildmenu_renderer(
  -- use wilder.wildmenu_lightline_theme() if using Lightline
  wilder.wildmenu_airline_theme({
    -- highlights can be overriden, see :h wilder#wildmenu_renderer()
    highlights = {default = 'StatusLine'},
    highlighter = wilder.basic_highlighter(),
    separator = ' · ',
  })
))

Popupmenu renderer

Popupmenu

For Neovim 0.4+ or Vim 8.1+ with popup support, wilder#popupmenu_renderer() can be used to draw the results on a popupmenu, similar to wildoptions+=pum. The implementation for Vim is still experimental.

Vim Script
" 'highlighter' : applies highlighting to the candidates
call wilder#set_option('renderer', wilder#popupmenu_renderer({
      \ 'highlighter': wilder#basic_highlighter(),
      \ }))
Lua
wilder.set_option('renderer', wilder.popupmenu_renderer({
  -- highlighter applies highlighting to the candidates
  highlighter = wilder.basic_highlighter(),
}))

Use wilder#renderer_mux() to choose which renderer to use for different cmdline modes. This is helpful since the popupmenu might overlap the current window when searching with /.

Vim Script
call wilder#set_option('renderer', wilder#renderer_mux({
      \ ':': wilder#popupmenu_renderer(),
      \ '/': wilder#wildmenu_renderer(),
      \ }))
Lua
wilder.set_option('renderer', wilder.renderer_mux({
  [':'] = wilder.popupmenu_renderer({
    highlighter = wilder.basic_highlighter(),
  }),
  ['/'] = wilder.wildmenu_renderer({
    highlighter = wilder.basic_highlighter(),
  }),
}))

Popupmenu pumblend

For Neovim, the pumblend option can be set to change the transparency of the popupmenu. By default, the value of the &pumblend option is used. To disable transparency, set the value to 0.

Vim Script
call wilder#set_option('renderer', wilder#popupmenu_renderer({
      \ 'pumblend': 20,
      \ }))
Lua
wilder.set_option('renderer', wilder.popupmenu_renderer({
  pumblend = 20,
}))
Popupmenu borders

Popupmenu Border

Use wilder#popupmenu_border_theme() to add a border around the popup menu.

Vim Script
" 'border'            : 'single', 'double', 'rounded' or 'solid'
"                     : can also be a list of 8 characters,
"                     : see :h wilder#popupmenu_border_theme() for more details
" 'highlights.border' : highlight to use for the border`
call wilder#set_option('renderer', wilder#popupmenu_renderer(wilder#popupmenu_border_theme({
      \ 'highlights': {
      \   'border': 'Normal',
      \ },
      \ 'border': 'rounded',
      \ })))
Lua
wilder.set_option('renderer', wilder.popupmenu_renderer(
  wilder.popupmenu_border_theme({
    highlights = {
      border = 'Normal', -- highlight to use for the border
    },
    -- 'single', 'double', 'rounded' or 'solid'
    -- can also be a list of 8 characters, see :h wilder#popupmenu_border_theme() for more details
    border = 'rounded',
  })
))
Fill up entire width like Emacs helm

Helm

Set the min_width option to 100%.

Vim Script
" wilder#popupmenu_border_theme() is optional.
" 'min_height' : sets the minimum height of the popupmenu
"              : can also be a number
" 'max_height' : set to the same as 'min_height' to set the popupmenu to a fixed height
" 'reverse'    : if 1, shows the candidates from bottom to top
call wilder#set_option('renderer', wilder#popupmenu_renderer(wilder#popupmenu_border_theme({
      \ 'highlighter': wilder#basic_highlighter(),
      \ 'min_width': '100%',
      \ 'min_height': '50%',
      \ 'reverse': 0,
      \ })))
Lua
wilder.set_option('renderer', wilder.popupmenu_renderer(
  wilder.popupmenu_border_theme({
    highlighter = wilder.basic_highlighter(),
    min_width = '100%', -- minimum height of the popupmenu, can also be a number
    min_height = '50%', -- to set a fixed height, set max_height to the same value
    reverse = 0,        -- if 1, shows the candidates from bottom to top
  })
))
Devicons for popupmenu

Popupmenu Devicons

Supports ryanoasis/vim-devicons, kyazdani42/nvim-web-devicons and lambdalisue/nerdfont.vim by default. To use other plugins, the get_icon option can be changed. See :h wilder#popupmenu_devicons for more details.

Vim Script
call wilder#set_option('renderer', wilder#popupmenu_renderer({
      \ 'highlighter': wilder#basic_highlighter(),
      \ 'left': [
      \   ' ', wilder#popupmenu_devicons(),
      \ ],
      \ 'right': [
      \   ' ', wilder#popupmenu_scrollbar(),
      \ ],
      \ }))
Lua
wilder.set_option('renderer', wilder.popupmenu_renderer({
  highlighter = wilder.basic_highlighter(),
  left = {' ', wilder.popupmenu_devicons()},
  right = {' ', wilder.popupmenu_scrollbar()},
}))

Command Palette (Experimental)

Palette

wilder#popupmenu_palette_theme() can be used to draw the popupmenu in the middle of the screen, similar to a command palette.

Vim Script
" 'border'            : 'single', 'double', 'rounded' or 'solid'
"                     : can also be a list of 8 characters,
"                     : see :h wilder#popupmenu_palette_theme() for more details
" 'max_height'        : max height of the palette
" 'min_height'        : set to the same as 'max_height' for a fixed height window
" 'prompt_position'   : 'top' or 'bottom' to set the location of the prompt
" 'reverse'           : set to 1 to reverse the order of the list
"                     : use in combination with 'prompt_position'
call wilder#set_option('renderer', wilder#popupmenu_renderer(wilder#popupmenu_palette_theme({
      \ 'border': 'rounded',
      \ 'max_height': '75%',
      \ 'min_height': 0,
      \ 'prompt_position': 'top',
      \ 'reverse': 0,
      \ })))
Lua
wilder.set_option('renderer', wilder.popupmenu_renderer(
  wilder.popupmenu_palette_theme({
    -- 'single', 'double', 'rounded' or 'solid'
    -- can also be a list of 8 characters, see :h wilder#popupmenu_palette_theme() for more details
    border = 'rounded',
    max_height = '75%',      -- max height of the palette
    min_height = 0,          -- set to the same as 'max_height' for a fixed height window
    prompt_position = 'top', -- 'top' or 'bottom' to set the location of the prompt
    reverse = 0,             -- set to 1 to reverse the order of the list, use in combination with 'prompt_position'
  })
))

Better highlighting

Popupmenu Fuzzy

The highlighter option for both wilder#wildmenu_renderer() and wilder#popupmenu_renderer() can be changed for better fuzzy highlighting.

The highlights.accent option sets the highlight group to use for the matched characters. wilder#make_hl() is a helper method which creates a new highlight group based on the attributes of an existing one.

Basic configuration for both Vim and Neovim:

Vim Script
" Create the WilderAccent highlight by overriding the guifg attribute of Pmenu
" and return the name of the highlight
let l:hl = wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}]),

call wilder#set_option('renderer', wilder#popupmenu_renderer({
      \ 'highlighter': wilder#basic_highlighter(),
      \ 'highlights': {
      \   'accent': l:hl,
      \ },
      \ }))

" Can also be passed to the 'highlights' option
call wilder#set_option('renderer', wilder#popupmenu_renderer({
      \ 'highlighter': wilder#basic_highlighter(),
      \ 'highlights': {
      \   'accent': wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}]),
      \ },
      \ }))

For Neovim or Vim with yarp:

Vim Script
" For python_cpsm_highlighter : requires cpsm vim plugin found at
"                               https://github.com/nixprime/cpsm
call wilder#set_option('renderer', wilder#popupmenu_renderer({
      \ 'highlighter': [
      \   wilder#pcre2_highlighter(),
      \   wilder#python_cpsm_highlighter(),
      \ ],
      \ 'highlights': {
      \   'accent': wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}]),
      \ },
      \ }))

For Neovim:

Vim Script
" For lua_pcre2_highlighter : requires `luarocks install pcre2`
" For lua_fzy_highlighter   : requires fzy-lua-native vim plugin found
"                             at https://github.com/romgrk/fzy-lua-native
call wilder#set_option('renderer', wilder#popupmenu_renderer({
      \ 'highlighter': [
      \   wilder#lua_pcre2_highlighter(),
      \   wilder#lua_fzy_highlighter(),
      \ ],
      \ 'highlights': {
      \   'accent': wilder#make_hl('WilderAccent', 'Pmenu', [{}, {}, {'foreground': '#f4468f'}]),
      \ },
      \ }))
Lua
wilder.set_option('renderer', wilder.popupmenu_renderer({
  highlighter = {
    wilder.lua_pcre2_highlighter(), -- requires `luarocks install pcre2`
    wilder.lua_fzy_highlighter(),   -- requires fzy-lua-native vim plugin found
                                    -- at https://github.com/romgrk/fzy-lua-native
  },
  highlights = {
    accent = wilder.make_hl('WilderAccent', 'Pmenu', {{a = 1}, {a = 1}, {foreground = '#f4468f'}}),
  },
}))

Gradient highlighting

Gradient

wilder#highlighter_with_gradient() wraps other highlighters and applies a gradient highlight.

Vim Script
let s:scale = ['#f4468f', '#fd4a85', '#ff507a', '#ff566f', '#ff5e63',
      \ '#ff6658', '#ff704e', '#ff7a45', '#ff843d', '#ff9036',
      \ '#f89b31', '#efa72f', '#e6b32e', '#dcbe30', '#d2c934',
      \ '#c8d43a', '#bfde43', '#b6e84e', '#aff05b']
let s:gradient = map(s:scale, {i, fg -> wilder#make_hl(
      \ 'WilderGradient' . i, 'Pmenu', [{}, {}, {'foreground': fg}]
      \ )})

" Pass the highlighters as the argument to wilder#highlighter_with_gradient()
" 'highlights.gradient'          : must be set.
" 'highlights.selected_gradient' : can be set to apply gradient highlighting for the selected candidate.
call wilder#set_option('renderer', wilder#popupmenu_renderer({
      \ 'highlights': {
      \   'gradient': s:gradient,
      \ },
      \ 'highlighter': wilder#highlighter_with_gradient([
      \    ... highlighters ...
      \ ]),
      \ }))
Lua
local gradient = {
  '#f4468f', '#fd4a85', '#ff507a', '#ff566f', '#ff5e63',
  '#ff6658', '#ff704e', '#ff7a45', '#ff843d', '#ff9036',
  '#f89b31', '#efa72f', '#e6b32e', '#dcbe30', '#d2c934',
  '#c8d43a', '#bfde43', '#b6e84e', '#aff05b'
}

for i, fg in ipairs(gradient) do
  gradient[i] = wilder.make_hl('WilderGradient' .. i, 'Pmenu', {{a = 1}, {a = 1}, {foreground = fg}})
end

wilder.set_option('renderer', wilder.popupmenu_renderer({
  highlights = {
    gradient = gradient, -- must be set
    -- selected_gradient key can be set to apply gradient highlighting for the selected candidate.
  },
  highlighter = wilder.highlighter_with_gradient({
    wilder.basic_highlighter(), -- or wilder.lua_fzy_highlighter(),
  }),
}))

A nice set of color scales can be found at d3-scale-chromatic. Use the dropdown to select discrete(<x>) for a smaller list of colors. Click on a scale to copy it as a string.

Note: Gradient highlighting slows down performance by a lot.

Example configs

Basic config (for both Vim and Neovim)

Vim Script
call wilder#setup({'modes': [':', '/', '?']})

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline(),
      \     wilder#search_pipeline(),
      \   ),
      \ ])

call wilder#set_option('renderer', wilder#wildmenu_renderer({
      \ 'highlighter': wilder#basic_highlighter(),
      \ }))
Lua
local wilder = require('wilder')
wilder.setup({modes = {':', '/', '?'}})

wilder.set_option('pipeline', {
  wilder.branch(
    wilder.cmdline_pipeline(),
    wilder.search_pipeline()
  ),
})

wilder.set_option('renderer', wilder.wildmenu_renderer({
  highlighter = wilder.basic_highlighter(),
}))

Fuzzy config (for Neovim or Vim with yarp)

Vim Script
call wilder#setup({'modes': [':', '/', '?']})

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({
      \       'fuzzy': 1,
      \       'set_pcre2_pattern': 1,
      \     }),
      \     wilder#python_search_pipeline({
      \       'pattern': 'fuzzy',
      \     }),
      \   ),
      \ ])

let s:highlighters = [
        \ wilder#pcre2_highlighter(),
        \ wilder#basic_highlighter(),
        \ ]

call wilder#set_option('renderer', wilder#renderer_mux({
      \ ':': wilder#popupmenu_renderer({
      \   'highlighter': s:highlighters,
      \ }),
      \ '/': wilder#wildmenu_renderer({
      \   'highlighter': s:highlighters,
      \ }),
      \ }))
Lua
local wilder = require('wilder')
wilder.setup({modes = {':', '/', '?'}})

wilder.set_option('pipeline', {
  wilder.branch(
    wilder.cmdline_pipeline({
      fuzzy = 1,
      set_pcre2_pattern = 1,
    }),
    wilder.python_search_pipeline({
      pattern = 'fuzzy',
    })
  ),
})

local highlighters = {
  wilder.pcre2_highlighter(),
  wilder.basic_highlighter(),
}

wilder.set_option('renderer', wilder.renderer_mux({
  [':'] = wilder.popupmenu_renderer({
    highlighter = highlighters,
  }),
  ['/'] = wilder.wildmenu_renderer({
    highlighter = highlighters,
  }),
}))

Neovim Lua only config

Lua
local wilder = require('wilder')
wilder.setup({modes = {':', '/', '?'}})
-- Disable Python remote plugin
wilder.set_option('use_python_remote_plugin', 0)

wilder.set_option('pipeline', {
  wilder.branch(
    wilder.cmdline_pipeline({
      fuzzy = 1,
      fuzzy_filter = wilder.lua_fzy_filter(),
    }),
    wilder.vim_search_pipeline()
  )
})

wilder.set_option('renderer', wilder.renderer_mux({
  [':'] = wilder.popupmenu_renderer({
    highlighter = wilder.lua_fzy_highlighter(),
    left = {
      ' ',
      wilder.popupmenu_devicons()
    },
    right = {
      ' ',
      wilder.popupmenu_scrollbar()
    },
  }),
  ['/'] = wilder.wildmenu_renderer({
    highlighter = wilder.lua_fzy_highlighter(),
  }),
}))

Advanced config (for Neovim only or Vim with yarp)

This is a good approximatiton of the configuration used in the GIF from the beginning of the README. The colorscheme used if tokyonight.

Vim Script
call wilder#setup({'modes': [':', '/', '?']})

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#python_file_finder_pipeline({
      \       'file_command': {_, arg -> stridx(arg, '.') != -1 ? ['fd', '-tf', '-H'] : ['fd', '-tf']},
      \       'dir_command': ['fd', '-td'],
      \       'filters': ['cpsm_filter'],
      \     }),
      \     wilder#substitute_pipeline({
      \       'pipeline': wilder#python_search_pipeline({
      \         'skip_cmdtype_check': 1,
      \         'pattern': wilder#python_fuzzy_pattern({
      \           'start_at_boundary': 0,
      \         }),
      \       }),
      \     }),
      \     wilder#cmdline_pipeline({
      \       'fuzzy': 2,
      \       'fuzzy_filter': has('nvim') ? wilder#lua_fzy_filter() : wilder#vim_fuzzy_filter(),
      \     }),
      \     [
      \       wilder#check({_, x -> empty(x)}),
      \       wilder#history(),
      \     ],
      \     wilder#python_search_pipeline({
      \       'pattern': wilder#python_fuzzy_pattern({
      \         'start_at_boundary': 0,
      \       }),
      \     }),
      \   ),
      \ ])

let s:highlighters = [
      \ wilder#pcre2_highlighter(),
      \ has('nvim') ? wilder#lua_fzy_highlighter() : wilder#cpsm_highlighter(),
      \ ]

let s:popupmenu_renderer = wilder#popupmenu_renderer(wilder#popupmenu_border_theme({
      \ 'border': 'rounded',
      \ 'empty_message': wilder#popupmenu_empty_message_with_spinner(),
      \ 'highlighter': s:highlighters,
      \ 'left': [
      \   ' ',
      \   wilder#popupmenu_devicons(),
      \   wilder#popupmenu_buffer_flags({
      \     'flags': ' a + ',
      \     'icons': {'+': '', 'a': '', 'h': ''},
      \   }),
      \ ],
      \ 'right': [
      \   ' ',
      \   wilder#popupmenu_scrollbar(),
      \ ],
      \ }))

let s:wildmenu_renderer = wilder#wildmenu_renderer({
      \ 'highlighter': s:highlighters,
      \ 'separator': ' · ',
      \ 'left': [' ', wilder#wildmenu_spinner(), ' '],
      \ 'right': [' ', wilder#wildmenu_index()],
      \ })

call wilder#set_option('renderer', wilder#renderer_mux({
      \ ':': s:popupmenu_renderer,
      \ '/': s:wildmenu_renderer,
      \ 'substitute': s:wildmenu_renderer,
      \ }))
Lua
local wilder = require('wilder')
wilder.setup({modes = {':', '/', '?'}})

wilder.set_option('pipeline', {
  wilder.branch(
    wilder.python_file_finder_pipeline({
      file_command = function(ctx, arg)
        if string.find(arg, '.') ~= nil then
          return {'fdfind', '-tf', '-H'}
        else
          return {'fdfind', '-tf'}
        end
      end,
      dir_command = {'fd', '-td'},
      filters = {'cpsm_filter'},
    }),
    wilder.substitute_pipeline({
      pipeline = wilder.python_search_pipeline({
        skip_cmdtype_check = 1,
        pattern = wilder.python_fuzzy_pattern({
          start_at_boundary = 0,
        }),
      }),
    }),
    wilder.cmdline_pipeline({
      fuzzy = 2,
      fuzzy_filter = wilder.lua_fzy_filter(),
    }),
    {
      wilder.check(function(ctx, x) return x == '' end),
      wilder.history(),
    },
    wilder.python_search_pipeline({
      pattern = wilder.python_fuzzy_pattern({
        start_at_boundary = 0,
      }),
    })
  ),
})

local highlighters = {
  wilder.pcre2_highlighter(),
  wilder.lua_fzy_highlighter(),
}

local popupmenu_renderer = wilder.popupmenu_renderer(
  wilder.popupmenu_border_theme({
    border = 'rounded',
    empty_message = wilder.popupmenu_empty_message_with_spinner(),
    highlighter = highlighters,
    left = {
      ' ',
      wilder.popupmenu_devicons(),
      wilder.popupmenu_buffer_flags({
        flags = ' a + ',
        icons = {['+'] = '', a = '', h = ''},
      }),
    },
    right = {
      ' ',
      wilder.popupmenu_scrollbar(),
    },
  })
)

local wildmenu_renderer = wilder.wildmenu_renderer({
  highlighter = highlighters,
  separator = ' · ',
  left = {' ', wilder.wildmenu_spinner(), ' '},
  right = {' ', wilder.wildmenu_index()},
})

wilder.set_option('renderer', wilder.renderer_mux({
  [':'] = popupmenu_renderer,
  ['/'] = wildmenu_renderer,
  substitute = wildmenu_renderer,
}))

Tips

Reducing input latency

Input latency when typing in the cmdline is due to wilder rendering synchronously. Rendering time increases for each wilder#wildmenu_renderer() item, wilder#popupmenu_renderer() column, or by having a slow highlighter.

Use minimal configuration

The fastest configuration for wilder is to use the non-fuzzy pipelines and the default renderers. For Vim, the Python cmdline pipeline might be slow due to the overhead of the remote plugin.

For searching, the Python pipeline is faster as it is non-blocking and Python's regex is faster than Vim's.

" Neovim or Vim with yarp
call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({'language': has('nvim') ? 'python' : 'vim'}),
      \     wilder#python_search_pipeline(),
      \   ),
      \ ])

" The wildmenu renderer is faster than the popupmenu renderer.
" By default no highlighting is applied.

" call wilder#set_option('renderer', wilder#popupmenu_renderer())
call wilder#set_option('renderer', wilder#wildmenu_renderer())

If this configuration is still not fast enough, the available options are to implement a faster renderer e.g. using Lua or to improve the current rendering code.

If highlighting is important, use the Lua highlighters for best performance. For Vim, avoid using the python highlighers (e.g. wilder#python_cpsm_highlighter()) due to the overhead introduced by the remote plugin.

Avoid wilder#wildmenu_spinner() and wilder#popupmenu_spinner() as they cause frequent re-renders.

Use debounce

Use wilder#debounce() or the debounce option in pipelines to avoid rendering too often. The debounce option is currently supported by wilder#search_pipeline(), wilder#cmdline_pipeline() and wilder#python_file_finder_pipeline(). The debounce interval is in milliseconds.

There is a tradeoff in increased latency for the final result due to the debounce versus the increased input latency per character typed due to the rendering of intermediate results.

" Debounce the whole pipeline
call wilder#set_option('pipeline', [
      \ wilder#debounce(10),
      \ wilder#branch(
      \   ...
      \ ),
      \ ])

" Or debounce individual pipelines
call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({
      \       'debounce': 10,
      \     }),
      \     wilder#search_pipeline({
      \       'debounce': 10,
      \     }),
      \   ),
      \ ])

Faster Startup time

Set up an autocmd to defer initialisation to the first CmdlineEnter:

" ++once supported in Nvim 0.4+ and Vim 8.1+
autocmd CmdlineEnter * ++once call s:wilder_init() | call wilder#main#start()

function! s:wilder_init() abort
  call wilder#setup(...)
  call wilder#set_option(..., ...)

  call wilder#set_option('pipeline', ...)
  call wilder#set_option('renderer', ...)
endfunction

Vim-specific optimisations

Using the Python remote plugin is slow, which may cause latency when getting cmdline completions.

wilder#vim_fuzzy_filter() should be performant enough as long as the number of candidates is not too large.

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({
      \       'language': 'vim',
      \       'fuzzy': 1,
      \       'fuzzy_filter': wilder#vim_fuzzy_filter(),
      \     }),
      \     ...
      \   ),
      \ ])

Avoid using the Python highlighters e.g. wilder#cpsm_highlighter() or wilder#pcre2_highlighter().

Troubleshooting

Disabling in the case of errors

Use q: to open the cmdline-window and enter the following command

call wilder#disable()

Alternatively, define a mapping in your init.vim or .vimrc

nnoremap <Leader>w :call wilder#toggle()<CR>

Cannot scroll through /-search history with <Up> or <Down>

A workaround was added for #30. This workaround breaks the / history when using the wilder#wildmenu_renderer().

The workaround can be disabled by setting:

call wilder#set_option('renderer', wilder#wildmenu_renderer({
      \ 'apply_incsearch_fix': 0,
      \ }))

dein.vim lazy loading remote plugins

If you have g:dein#lazy_rplugins set to true, the remote plugin will not load until the plugin is sourced.

call dein#add('gelguy/wilder.nvim', {
      \ 'lazy': 1,
      \ 'on_event' : 'CmdlineEnter',
      \ })

Acknowledgements

Many thanks to the following codebases for providing ideas and reference:

Shougo/denite.nvim

junegunn/fzf.vim

vim-airline/vim-airline

itchyny/lightline.vim

nixprime/cpsm

raghur/fruzzy

Yggdroot/LeaderF

nvim-telescope/telescope.nvim

ryanoasis/vim-devicons

Xuyuanp/scrollbar.nvim

liuchengxu/vim-clap

and many more!

wilder.nvim's People

Contributors

gcballesteros avatar gelguy avatar jityao avatar notpeelz avatar otakutyrant avatar ratheesh avatar rockyzhang24 avatar tsuyoshicho avatar z0rc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

wilder.nvim's Issues

Wilder changes behaviour of <Up> when searching

Vim's default behaviour of <Up> in / breaks with wilder.

This is what :help c_<Up> reads:

							c_<Up> c_Up
<Up>	recall older command-line from history, whose beginning
		matches the current command-line (see below).

To reproduce:

  1. Use the following minimal .vimrc:
call plug#begin('~/.config/nvim/packages/')
Plug 'gelguy/wilder.nvim'
call plug#end()

call wilder#enable_cmdline_enter()
  1. Do / and then press <Up> a couple of times.
  2. Some other text that is not part of your latest searches show up.
  3. Compare to doing this with an empty .vimrc, which does what :help c_<Up> describes

Expected behaviour when pressing <Up>:

Your latest searches show up in the command-line.

<Up> does seem to work with : (command-line mode), but does not work with ? (backwards search).

Neovim incsearch highlighting tracking issue

incsearch highlighting disappears or is sometimes wrong

  • [All versions] Occurs when using wilder#popupmenu_renderer() when searching
  • [Neovim 0.5] Occurs for both wilder#popupmenu_renderer() and wilder#wildmenu_renderer() when searching and the current window view changes (e.g. moves due to incsearch)

See neovim/neovim#14064
See neovim/neovim#12495 (outdated)

A workaround is to use wilder#wildmenu_renderer({'mode': 'statusline'}) for searching.

Update: the statusline workaround doesn't work for Neovim 0.6 nightly.

How to disable foldcolumn for floating window

Hey,
first I like to thank you for this amazing plugin! 🙏

I just did the setup and I'm super happy. Unfortunately there is this tiny cosmetic issue of a gap on the left side:

screenshot_1606000663

I suppose that it is the foldcolumn that is visible there. I'm using a recent NeoVim version, so the renderer should open a floating window. Do you have a specific filetype for the displayed buffer which would allow to disable the option there?

This is my configuration. So there should be actually no gap and in your screenshots I can't see such neither.

call wilder#set_option('modes', ['/', '?', ':'])
call wilder#set_option('renderer', wilder#float_renderer({
      \   'separator': '',
      \   'separator_hl': 'Grey',
      \   'hl': 'GreenBold',
      \   'left': [
      \     {
      \       'value': [
      \         wilder#condition(
      \           { -> getcmdtype() ==# ':' },
      \           ' COMMAND ',
      \           ' SEARCH '
      \         ),
      \         '',
      \       ],
      \       'hl': 'RedBackground',
      \     },
      \     ' ',
      \   ],
      \   'right': [
      \     ' ',
      \     wilder#index({ 'hl': 'YellowBold' }),
      \   ],
      \ }))

Case Insensitive / and ?

Is it possible to have suggestions displayed case insensitively? Specifically when using / and ? for searching.

Neovim floating window visual artifacts

wilder#wildmenu_renderer() with mode: float and wilder#popupmenu_renderer() will sometimes leave behind visual artifacts which cannot be cleared with redraw.

The visual artifacts can be cleared by causing the grid chars to be redrawn e.g. by scrolling.

Most commonly occurs when the cmdline width exceeds cmdheight so the floats have to be drawn over the cmdline.

Fuzzy finder only matches from the first letter onward.

When typing a pattern, the fuzzy finder only matches words that begin with the first letter of the pattern.

In this example, the pattern "term" matches with the word ctermfg, but the fuzzy finder will not show it, since it will only show matches that begin with the letter "t":
Screenshot from 2021-08-12 14-12-16

I can also confirm that ctermfg is indexed by wilder, since typing "cter" shows it:
Screenshot from 2021-08-12 14-19-28

It'd be nice if we had the option to enable a broader matching style for the fuzzy finder, which included words that do not begin with first letter of the pattern.

Using external fuzzy finder

In the present code, is there a provision to pass the completion through external tools like fzf?
If not, is there a plan to do this?
Currently, full fuzzy completion is not working for me.

Vim(call):E697: List lacks of ending character ']' using example config.

Here is my config, I'm using Neovim 0.5 with Packer.

  {
    "gelguy/wilder.nvim",
    requires = "nixprime/cpsm",
    config = function()
      vim.cmd([[
call wilder#enable_cmdline_enter()
set wildcharm=<Tab>
cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>"
cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>"
call wilder#set_option('modes', ['/', '?', ':'])

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#python_file_finder_pipeline({
      \       'file_command': {_, arg -> stridx(arg, '.') != -1 ? ['fd', '-tf', '-H'] : ['fd', '-tf']},
      \       'dir_command': ['fdfind', '-td'],
      \       'filters': ['cpsm_filter'],
      \       'cache_timestamp': {-> 1},
      \     }),
      \     wilder#cmdline_pipeline({
      \       'fuzzy': 1,
      \       'fuzzy_filter': wilder#python_cpsm_filter(),
      \       'set_pcre2_pattern': 0,
      \     }),
      \     wilder#python_search_pipeline({
      \       'pattern': wilder#python_fuzzy_pattern({
      \         'start_at_boundary': 0,
      \       }),
      \     }),
      \   ),
      \ ])

let g:highlighters = [
      \ wilder#pcre2_highlighter(),
      \ wilder#lua_fzy_highlighter(),
      \ ]

call wilder#set_option('renderer', wilder#renderer_mux({
      \ ':': wilder#popupmenu_renderer({
      \   'highlighter': g:highlighters,
      \   'left': [
      \     wilder#popupmenu_devicons(),
      \   ],
      \   'right': [
      \     ' ',
      \     wilder#popupmenu_scrollbar(),
      \   ],
      \ }),
      \ '/': wilder#wildmenu_renderer({
      \   'highlighter': g:highlighters,
      \ }),
      \ }))
      ]])
    end,
  }

Option to reverse wilder#history

Thank you for releasing this great plugin!

Current wilder shows history on popup menu in reverse order compared to the default popup history.

It would be great if we could change the order by an option.

CPSM Error

After compiling and installing CPSM I get the following error as soon as I :e

pipeline: Vim(let):Error invoking '/Users/garfield/.config/nvim/plugged/wilder.nvim/rplugin/
python3/wilder:function:_wilder_python_get_file_completion' on channel 5:^@Invalid channel: 5

My wilder config is as follows:

 "Wilder
call wilder#enable_cmdline_enter()
set wildcharm=<Tab>
cmap <expr> <c-n> wilder#in_context() ? wilder#next() : "\<c-n>"
cmap <expr> <c-p> wilder#in_context() ? wilder#previous() : "\<c-p>"
cmap <expr> <C-D> wilder#can_accept_completion() ? wilder#accept_completion() : "\<C-D>"
call wilder#set_option('modes', [':'])

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({
      \       'fuzzy': 1,
      \       'fuzzy_filter': wilder#python_cpsm_filter(),
      \       'set_pcre2_pattern': 0,
      \     }),
      \     wilder#python_search_pipeline({
      \       'pattern': wilder#python_fuzzy_pattern({
      \         'start_at_boundary': 0,
      \       }),
      \     }),
      \   ),
      \ ])




let s:highlighters = [
        \ wilder#pcre2_highlighter(),
        \ wilder#basic_highlighter(),
        \ ]

call wilder#set_option('renderer', wilder#renderer_mux({
      \ ':': wilder#popupmenu_renderer({
      \   'highlighter': s:highlighters,
      \   'left': [
      \     wilder#popupmenu_devicons(),
      \   ],
      \   'right': [
      \     ' ',
      \     wilder#popupmenu_scrollbar(),
      \   ],
      \ }),
      \ '/': wilder#wildmenu_renderer({
      \   'highlighter': s:highlighters,
      \ }),
      \ }))

OS: macOS Catalina

NVIM v0.6.0-dev+c31bc6ea7
Build type: Release
LuaJIT 2.1.0-beta3

vim8 native package manager support

Hello 👋
Can this awesome plugin be installed with vim8's native package manager? If it can then what is the installation process?
Thank you)

[Question] I want to set pumblend to floatwin

I would like to set pumblend on the completion window to make it transparent.
I think the image in the README sets the transparency, but I couldn't figure out how to do it after reading the doc.
How can I set it to make the completion window transparent?

Neovim Python Error when entering command mode

NVIM v0.4.2
Vi IMproved 8.1
python Version: 3.7.4
pynvim Version: 0.3.2

After starting up neovim and entering any of the supported command lines eg ':' '?' or '/' I get the following error. After the error goes away the auto suggestion works great. When using regular vim the issue does not persist so I assume its part of the neovim python integration. The error seems to becoming from autoload/wilder/main.vim on line 66. When I comment out the line the error doesn't appear. I have only added the minimal settings from the help file.

Error detected while processing function
3[1]
23_start[8]
E117: unknown function: _wilder_init

Keep up the great work on this awesome plugin!

Wrong candidate order (the result of sorting is not satisfactory)

This is a great plugin! I have found that the completion candidate order is not what I expect.

My config for wilder.nvim

call wilder#enable_cmdline_enter()
set wildcharm=<Tab>
cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>"
cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>"

" only / and ? are enabled by default
call wilder#set_option('modes', ['/', '?', ':'])

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({
      \       'language': 'python',
      \       'fuzzy': 1,
      \     }),
      \     wilder#python_search_pipeline({
      \       'pattern': wilder#python_fuzzy_pattern(),
      \       'sorter': wilder#python_fuzzywuzzy_sorter(),
      \       'engine': 're',
      \     }),
      \   ),
      \ ])

call wilder#set_option('renderer', wilder#wildmenu_renderer({
      \ 'highlighter': wilder#basic_highlighter(),
      \ 'separator': '  ',
      \ 'right': [' ', wilder#wildmenu_index()],
      \ }))

When I type :h vim.paste(), I would expect that vim.paste() is ranked first in the completion item. However, it is rankded the last in the list of completion items (see image below)

image

echo not visible when wilder enabled

:echo 1 does not display when wilder is enabled. I'm using NVIM v0.6.0-dev+62d67de59 with the following wilder config:

call wilder#enable_cmdline_enter()
set wildcharm=<tab>
cmap <expr> <c-n> wilder#in_context() ? wilder#next() : "\<c-n>"
cmap <expr> <c-p> wilder#in_context() ? wilder#previous() : "\<c-p>"
call wilder#set_option('modes', ['/', '?', ':'])

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     [
      \       wilder#check({_, x -> empty(x)}),
      \       wilder#history(),
      \       wilder#result({
      \         'draw': [{_, x -> '' . x}],
      \       }),
      \     ],
      \     wilder#python_file_finder_pipeline({
      \       'file_command': {_, arg -> stridx(arg, '.') != -1 ? ['fd', '-tf', '-H'] : ['fd', '-tf']},
      \       'dir_command': ['fd', '-td'],
      \       'filters': ['fuzzy_filter', 'difflib_sorter'],
      \       'cache_timestamp': {-> 1},
      \     }),
      \     wilder#cmdline_pipeline({
      \       'fuzzy': 1,
      \       'set_pcre2_pattern': 0,
      \     }),
      \     [
      \       {_, x -> x[:1] ==# '\v' ? x[2:] : x},
      \     ] + wilder#python_search_pipeline({
      \       'pattern': wilder#python_fuzzy_pattern({
      \         'start_at_boundary': 0,
      \       }),
      \     }),
      \   ),
      \ ])

let s:highlighters = [
      \ wilder#pcre2_highlighter(),
      \ wilder#lua_fzy_highlighter(),
      \ ]
call wilder#set_option('renderer', wilder#renderer_mux({
      \ ':': wilder#popupmenu_renderer({
      \   'highlighter': s:highlighters,
      \   'left': [
      \     wilder#popupmenu_devicons(),
      \   ],
      \   'right': [
      \     ' ',
      \     wilder#popupmenu_scrollbar(),
      \   ],
      \ }),
      \ '/': wilder#wildmenu_renderer({
      \   'highlighter': s:highlighters,
      \ }),
      \ }))

Issue with cpsm

Hi, sorry that I'm asking an issue about cpsm here, but I looked at their repo and seems to be pretty dormant for quite a while and your plugin is the only reason I found out about them in the first place 😉

The "recommended" advanced Neovim configuration mentions that we need cpsm. Just adding it to vimplug doesn't seem to be enough because I see this error in neovim:

python_cpsm_filt: No module named 'cpsm_py'

I think we need to run their ./install.sh, but when I run it, I see the following errors:

PY3 not specified; inferring Python version from /usr/bin/vim
Python 3 selected
-- The C compiler identification is GNU 11.1.0
-- The CXX compiler identification is GNU 11.1.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Error at /usr/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find Boost (missing: Boost_INCLUDE_DIR program_options)
Call Stack (most recent call first):
  /usr/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.21/Modules/FindBoost.cmake:2345 (find_package_handle_standard_args)
  CMakeLists.txt:21 (find_package)

Can you help me please?

Function call depth is higher than 'maxfuncdepth'

Was there a recent update to the plugin? Today I noticed that all of a sudden I am getting the error:

Error detected while processing function wilder#separator[1]..wilder#separator[1]..wilder#separator[1]..wilder#separator[1]..wilder#separat
or[1]..wilder#separator[1]..wilder#separator[1]..wilder#separator[1]..wilder#separator[1]..wilder#separator[1]..wilder#separator[1]..wilder
#separator[1]..wilder#separator[1]..wilder#separator[1]
...
...
E132: Function call depth is higher than 'maxfuncdepth'

at (neo)vim start-up. After dismissing the error the functionalities of the plugin do not really work.

Setup

nvim -v
NVIM v0.5.0-dev+1083-g1aec5ba85
Build type: Release
LuaJIT 2.1.0-beta3

macOs Big Sur 
11.2.2

Feature Request: wilder menu in centered floating window

First off, this is fantastic and so good it should be built in. Thanks a ton, you're a legend.

especially on large high res screens, looking down to the command bar having to move my head is a bit annoying - what I'd love is a telescope-esque UI that floats in the middle of the screen. Potentially even actually using telescope.
This would also give you a lot of extra space to do cool things like e.g. preview the file if someone is typing :e <myfile.py>, previewing the man page if someone is doing ! curl etc.

I know this is probably a lot of work but nonetheless think cool idea.

Thanks a ton!

Wilder popup menu does not close after pressing <C-f>

By default <C-f> opens the command-line window. However, wilder leaves its popup menu open when pressing <C-f>, which blocks the command-line-window.

To reproduce:

  1. Use the following minimal .vimrc:
call plug#begin('~/.config/nvim/packages/')
Plug 'gelguy/wilder.nvim'
call plug#end()

call wilder#setup({'modes': [':', '/', '?']})
call wilder#set_option('renderer', wilder#popupmenu_renderer({
      \ 'highlighter': wilder#basic_highlighter(),
      \ }))
  1. Do : and then press <C-f>.

CocList subcommand completion does not work

wilder.nvim is the best plugin I've come across this year.

However, the CocList completion doesn't seem to be working well.

Peek 2020-08-18 11-32

I think you should be able to complete it, or you should be able to set it to ignore some commands.


vim version: nvim v0.5.0-627-g94b7ff730
coc.nvim version: 0.0.78-bdd9a9e140

  call wilder#enable_cmdline_enter()
  set wildcharm=<Tab>
  cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>"
  cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>"
  nnoremap <expr> <SubLeader>w wilder#toggle()

  " only / and ? is enabled by default
  call wilder#set_option('modes', ['/', '?', ':'])
  let s:hl = 'LightlineMiddle_active'
  let s:mode_hl = 'LightlineLeft_active_0'
  let s:index_hl = 'LightlineRight_active_0'

  call wilder#set_option('renderer', wilder#wildmenu_renderer({
        \ 'highlights': {
        \   'default': s:hl,
        \ },
        \ 'apply_highlights': wilder#query_common_subsequence_spans(),
        \ 'separator': '  ',
        \ 'left': [{'value': [
        \    wilder#condition(
        \      {-> getcmdtype() ==# ':'},
        \      ' COMMAND ',
        \      ' SEARCH ',
        \    ),
        \    wilder#condition(
        \      {ctx, x -> has_key(ctx, 'error')},
        \      '!',
        \      wilder#spinner({
        \        'frames': '-\|/',
        \        'done': '',
        \      }),
        \    ), ' ',
        \ ], 'hl': s:mode_hl,},
        \ wilder#separator('', s:mode_hl, s:hl, 'left'), ' ',
        \ ],
        \ 'right': [
        \    ' ', wilder#separator('', s:index_hl, s:hl, 'right'),
        \    wilder#index({'hl': s:index_hl}),
        \ ],
        \ }))

incorrect documentation for wilder#cmdline_pipeline

The documentation for sorter argument of wilder#cmdline_pipeline:

        For Neovim, |wilder#python_sort_difflib()| and
        |wilder#python_sort_fuzzywuzzy()| can be used here.

If we use wilder#python_sort_fuzzywuzzy(), we get an error, because it is deprecated in favor of wilder#python_fuzzywuzzy_sort(). However, wilder#python_fuzzywuzzy_sort() can not be used here either. We should use wilder#python_fuzzywuzzy_sorter() instead.

All of this is confusing for a new user like me.

Add option to select first item in but not insert it

I would love it if Wilder automatically selected the first item in the suggestion list but without inserting its text into the command-line. And calling wilder#accept_completion() would insert the text in the selected suggestion. This is in my experience how most tools that auto-complete what you're typing work.

What I'm trying to describe is kinda like what set completeopt+=noinsert does for Vim's completion menu.

Is this configurable now or would it be possible to implement as a feature?

No module named 'pwd' on Windows

On Windows I have the fallowing error when traying to complete:

E117: Unknown function: _wilder_init

NeoVim's checkhealth returns:

## Remote Plugins
  - WARNING: "wilder.nvim" is not registered.
  - WARNING: Out of date
    - ADVICE:
      - Run `:UpdateRemotePlugins`

After runing :UpdateRemotePlugins I get the error

ModuleNotFoundError: No module named 'pwd'

Using the fuzzy config from the example.

call wilder#enable_cmdline_enter()
set wildcharm=<Tab>
cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>"
cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>"
call wilder#set_option('modes', ['/', '?', ':'])

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({
      \       'fuzzy': 1,
      \     }),
      \     wilder#python_search_pipeline({
      \       'pattern': 'fuzzy',
      \     }),
      \   ),
      \ ])

let s:highlighters = [
        \ wilder#pcre2_highlighter(),
        \ wilder#basic_highlighter(),
        \ ]

call wilder#set_option('renderer', wilder#renderer_mux({
      \ ':': wilder#popupmenu_renderer({
      \   'highlighter': s:highlighters,
      \ }),
      \ '/': wilder#wildmenu_renderer({
      \   'highlighter': s:highlighters,
      \ }),
      \ }))

python version -> 3.9.6
nvim version -> 0.5.0

Works fine under WSL, but not native Windows.

Float renderer overwrites statusline in neovim

I am using neovim built with the latest commit(as on today c423ec65dcda1b5).
I observe that float renderer is overwriting status line and also displaying line number. A sample screenshot is shown below

wilder_float_renderer

Following is my renderer configuration:

call wilder#set_option('renderer', wilder#float_renderer({
\ 'separator':' • ',
\ 'separator_hl': s:sep_hl,
\ 'hl': s:status_hl,
\ 'left': [
\ {'value': [' WILDER', wilder#spinner()], 'hl': s:mode_hl},
\ wilder#separator('', s:mode_hl, s:status_hl, 'left'), ' ',
\ ],
\ 'right': [
\ ' ', wilder#separator('', s:index_hl, s:status_hl, 'right'),
\ wilder#index({'hl': s:index_hl}),
\ ],
\ }))

This setting works fine for wilder#statusline_renderer()
Can you please help me in configuring right settings?

autochdir not working

my vim configuration uses autochdir, but the current path is not changed when the wilder executes
: e /path/of/ file

Neovim hangs when using Python fuzzy filters

Neovim sometimes becomes unresponsive when passing a large number of candidates (>10000) to the Python fuzzy filters (e.g. wilder#python_fuzzy_filter() or wilder#python_cpsm_filter().

Workarounds

  • Triggering a resize will make Neovim responsive again
  • Use wilder#lua_fzy_filter() which is a performant (but non-async) filter

Make auto_select optional on accept_completion

Would it be possible to expose the auto_select being run on the call to run_pipeline in wilder#main#accept_completion as an option?

I personally find it (mildly) annoying that when I accept something from the list the first value from the next list gets autocompleted because that stops me from keeping typing. Instead I have to get rid of the autocompletion then type.

My current solution is to manually set it to 0 but having the option to disable would be nice.

Edit: I can attempt a pull request if you think the request is reasonable

Any plans to allow configuration from lua?

Right now all the configuration is done through vimscript calls and variables. Personally, I want to keep as much of my configuration as lua, but this plugin makes me keep around some large blocks of vim.cmd[[]]

Custom pipeline and problem with sorter

Great plugin!

I created a pipelines for oldfiles selection with :o and :os and :ov. Works nice, but I cannot figure out how to apply a sorter to it. Can you help me please?

all wilder#enable_cmdline_enter()
set wildcharm=<Tab>
cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>"
cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>"
call wilder#set_option('modes', ['/', '?', ':'])
 
call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#python_file_finder_pipeline({
      \       'file_command': ['find', '.', '-type', 'f', '-printf', '%P\n'],
      \       'dir_command': ['find', '.', '-type', 'd', '-printf', '%P\n'],
      \       'filters': ['python_fuzzy_filter'],
      \     }),        
      \     [ wilder#check({ctx, x -> x =~ "^o "}),
      \       {ctx, x -> {'value': wilder#vim_fuzzy_filt(ctx, {}, copy(eval('v:oldfiles')), x[2:]),
      \                   'replace': [{ctx, x, data -> 'e ' .x}]} }],
      \     [ wilder#check({ctx, x -> x =~ "^os "}),
      \       {ctx, x -> {'value': wilder#vim_fuzzy_filt(ctx, {}, copy(eval('v:oldfiles')), x[3:]), 
      \                   'replace': [{ctx, x, data -> 'split ' .x}]} }],
      \     [ wilder#check({ctx, x -> x =~ "^ov "}),
      \       {ctx, x -> {'value': wilder#vim_fuzzy_filt(ctx, {}, copy(eval('v:oldfiles')), x[3:]), 
      \                   'replace': [{ctx, x, data -> 'vsplit ' .x}]} }],
      \     wilder#cmdline_pipeline(),
      \     wilder#python_search_pipeline(),
      \   ),           
      \ ])             
                       
call wilder#set_option('renderer', wilder#renderer_mux({
      \ ':': wilder#popupmenu_renderer({'left': [wilder#popupmenu_devicons()], 'highlighter': wilder#basic_highlighter()}),
      \ '/': wilder#wildmenu_renderer({'highlighter': wilder#basic_highlighter()})
      \ }))            

Leading lines of input() prompt are cleared

I'm using neovim 0.5.0 with the following minimal rc:

set runtimepath^=~/.vim runtimepath+=~/.vim/after
let &packpath = &runtimepath

" vim-plug
call plug#begin()

Plug 'gelguy/wilder.nvim'

call plug#end()

" wilder.nvim
call wilder#enable_cmdline_enter()
call wilder#set_option('modes', ['/', '?', ':'])

function! Foo() abort
  let prompt = "hello\nworld: "
  call input(l:prompt)
endfunction
function! Bar() abort
  echo 'hello'
  echo 'world'
  call input('User input: ')
endfunction

" vim: set tabstop=4 softtabstop=0 expandtab shiftwidth=2 smarttab:

Now if I :call Foo(), I'd expect the following in cmdline:

hello
world: 

But instead it shows:

world:

Similarly if I :call Bar(), I expect

hello
world
User input: 

But instead it shows only

User input: 

If I comment out

call wilder#enable_cmdline_enter()
call wilder#set_option('modes', ['/', '?', ':'])

from vimrc above, the outputs are back to normal.

Highlight color for results separator

This is a great plugin and more improved compared to Cmd2.

Can you let me know how to customize highlighting for the separator between results? Example would be great.

self.state.buf may be invalid in s:add_highlight

The patch fixes the problem.

diff --git a/autoload/wilder/renderer/vim_api.vim b/autoload/wilder/renderer/vim_api.vim
index 3700b6b..561cac4 100644
--- a/autoload/wilder/renderer/vim_api.vim
+++ b/autoload/wilder/renderer/vim_api.vim
@@ -110,6 +110,10 @@ function! s:set_line(line, str) dict abort
 endfunction

 function! s:add_highlight(hl, line, col_start, col_end) dict abort
+  if self.state.buf < 0
+    return
+  endif
+
   let l:prop_type = 'WilderProp_' . a:hl

   if !has_key(self.state.prop_types, a:hl)

Conflicts with other plugins that use "/"

specifically vim-visual-multi has a feature that allows you to multi select all matches of a certain regex. However with wilder.nvim enabled for '/' the vim-visual-multi regex search gets replaced by the wilder regex search.

Is there anyway to get these plugins to work together? ideally I could use wilder completions in the vim-visual-multi, but another way could be to have the wilder search only trigger when called from a certain keybinding (ie have a separate function to start wilder search)

Renderering errors with ambiwidth=double

Setting ambiwidth=double might cause strdisplaywidth() calculations to be wrong if the terminal still renders the characters as single width.

If you have this issue, please post your environment (OS, terminal, Vim version, $TERM) and config below to help with debugging.

Vim regular expressions are not supported and cause 'bad escape' errors

For example, when I search for \chello, it prints out a warning python_search: bad escape \c at position 1.

Considering behaviours of Vim regexps are sometimes influenced by settings as well, e.g. ignorecase, smartcase, I'm wondering if it's possible to leave this part of job to Vim itself? Or it's time to find/create a Vim regexp library for Python?

Add hint for dein users in readme

Hey there,

really nice plugin. I just struggled for an eternity trying to figure out why it didn't work for me.

After a long time i realized that this line in my vimrc:
let g:dein#lazy_rplugins = v:true
means that i have to lazy load the plugin, which i didn't at first.
In fact before this plugin i had no idea what remote plugins are.

Maybe it would be a nice hint for dein users in the readme.

Obviously it's my own stupidity, but i can imagine few people are familiar with remote plugins, since it isn't commonly used by plugins. At least i haven't seen it a lot.

Thanks for the plugin, have a nice day.

how to configure pseudo-transparency (winblend / pumblend) ?

I have basic pop-up menu pseudo-transparency set in my init.vim file:

set termguicolors
set pumblend=50

This gives me psuedo-transparent popup windows with coc (not shown) and telescope (telescope config shown below using winblend):

lua << EOF
require('telescope').setup{
  defaults = {
    ...
    winblend = 20,
    ...
  }
}
EOF

How do I configure this pumblend/winblend feature for wilder? Can we include that in the docs? (If someone shows me how, then I could create a PR to include the instructions in the README).

wilder with shortmess-=F overrides messages

I've had wilder installed and set shortmess-=F as required by nvim-metals. This resulted in all the messages being overriden with information about current file. Eg when doing :map gd I would see:
"./init.vim" 13 lines --61%--
The expected No mapping found can be still seen in :messages

minimal init.vim repro (with plug.vim):

set shortmess-=F
call plug#begin()
Plug 'gelguy/wilder.nvim'
call plug#end()

call wilder#enable_cmdline_enter()

set wildcharm=<Tab>
cmap <expr> <Tab> wilder#in_context() ? wilder#next() : "\<Tab>"
cmap <expr> <S-Tab> wilder#in_context() ? wilder#previous() : "\<S-Tab>"

" only / and ? is enabled by default
call wilder#set_option('modes', ['/', '?', ':'])

popup menu rendered not working

As described here in the docs I am trying to default the rendered to popup menu: my configuration is the following

call wilder#set_option('renderer', wilder#popupmenu_renderer({
			\ 'highlights': wilder#basic_highlighter(),
			\ 'apply_highlights': wilder#query_common_subsequence_spans(),
			\ 'separator': ' · ',
			\ 'ellipsis': '...',
			\ 'left': [{'value': [
			\    wilder#condition(
			\      {-> getcmdtype() ==# ':'},
			\      ' COMMAND ',
			\      ' SEARCH ',
			\    ),
			\ ], 'hl': s:mode_hl,},
			\ wilder#separator('', s:mode_hl, s:hl, 'left'), ' ',
			\ ],
			\ 'right': [
			\    ' ', wilder#separator('', s:index_hl, s:hl, 'right'),
			\    wilder#index({'hl': s:index_hl}),
			\ ],
			\ }))

however, the popup is not showing up and neither are the suggestions on the statusline: is there any other option I have to set to have it working?

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.