Code Monkey home page Code Monkey logo

Comments (2)

gelguy avatar gelguy commented on May 29, 2024 1

Thanks! I'll update this in a later version.

For a workaround, if you enable the fuzzy option for the cmdline_pipeline it will do fuzzy matching which also ignores casing.

e.g.

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

where :e rm will match README.md

from wilder.nvim.

gelguy avatar gelguy commented on May 29, 2024

I was tinkering about with this and reached the conclusion that this is better implemented as a separate filter.

function! s:wildignorecase_filter(ctx, xs, data)
  let l:expand = get(a:data, 'cmdline.expand')
  let l:ignorecase = &wildignorecase && (l:expand ==# 'dir' || l:expand ==# 'file')
  let l:q = get(a:data, 'cmdline.match_arg', '')
  return empty(l:q) ? a:xs :
      \ filter(a:xs, {_, x -> l:ignorecase ? x[0 : len(l:q) - 1] ==? l:q : x[0 : len(l:q) - 1] ==# l:q})
endfunction

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({
      \       'fuzzy': 1,
      \       'fuzzy_filter': {ctx, xs, q -> xs},
      \     }) + [wilder#result({
      \       'value': funcref('s:wildignorecase_filter'),
      \     })],
      \     wilder#python_search_pipeline(),
      \   ),
      \ ])

The fuzzy_filter returns all the candidates and s:wildignorecase_filter filters the candidates accordingly. To get correct highlighting, use the wilder#basic_highlighter() with the case_sensitive: 0 option.

Alternatively, you can use a filter that is case-insensitive for all queries.

call wilder#set_option('pipeline', [
      \   wilder#branch(
      \     wilder#cmdline_pipeline({
      \       'fuzzy': 1,
      \       'fuzzy_filter': {ctx, xs, q -> empty(q) ? xs : filter(_, x -> x[0 : len(q) -1] ==? q)},
      \     }),
      \     wilder#python_search_pipeline(),
      \   ),
      \ ])

I still recommend using fuzzy: 1 with the default filters as shown in the above comment.

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.