Code Monkey home page Code Monkey logo

Comments (6)

gelguy avatar gelguy commented on May 29, 2024 1

I've updated the behavior in #25.

The plugin will fallback to Vim's inbuilt wildmenu if an error is encountered when doing a custom completion for a user command.

from wilder.nvim.

gelguy avatar gelguy commented on May 29, 2024

Thanks for the bug report!

I've investigated and the root cause is there is a missing filter step for custom command completions. I wrongly assumed it was similar to customlist which did not require filtering.

I don't have access to my development environment so I won't be able to fix this immediately. For a workaround, you can try adding this config:

function! FilterCocList(ctx, res) abort
  let l:parsed = wilder#cmdline#parse(a:ctx.input)
  if l:parsed.cmd !=# 'CocList'  " other commands can be added here
    return a:res
  endif
  let l:arg = l:parsed.cmdline[l:parsed.pos :]
  return extend(a:res, {
        \ 'value': filter(a:res.value, {i, x -> match(x, l:arg) != -1}),
        \ 'data': extend(get(a:res, 'data', {}), {'query': l:arg})
        \ })

call wilder#set_option('pipeline', wilder#branch(
        \ wilder#python_search_pipeline(),
        \ wilder#cmdline_pipeline() + [funcref('FilterCocList')]
        \ )
endfunction

from wilder.nvim.

yutkat avatar yutkat commented on May 29, 2024

Thank you for your replay.

It worked in your config!! I appreciate it very much.

  function! FilterCocList(ctx, res) abort
    let l:parsed = wilder#cmdline#parse(a:ctx.input)
    if l:parsed.cmd ==# 'CocList'
      let l:arg = l:parsed.cmdline[l:parsed.pos :]
      return extend(a:res, {
            \ 'value': filter(a:res.value, {i, x -> match(x, l:arg) != -1}),
            \ 'data': extend(get(a:res, 'data', {}), {'query': l:arg})
            \ })
    endif
    return a:res
  endfunction

  call wilder#set_option('pipeline', wilder#branch(
        \ wilder#python_search_pipeline(),
        \ wilder#cmdline_pipeline() + [funcref('FilterCocList')]
        \ ))

from wilder.nvim.

yutkat avatar yutkat commented on May 29, 2024

But I found a new issue.

CocCommand does not work. Because it uses a script local function for completion.
https://github.com/neoclide/coc.nvim/blob/bdd9a9e1401fe6fdd57a9bd078e3651ecf1e0202/plugin/coc.vim#L415

This is the error message.
pipeline: Vim(let):E700: Unknown function: s:CommandList

Is there a solution?

from wilder.nvim.

gelguy avatar gelguy commented on May 29, 2024

There's a quick workaround for this by redefining the command:

function! CommandList(...) abort
  let list = coc#rpc#request('commandList', a:000)
  return join(list, "\n")
endfunction

command! -nargs=* -complete=custom,CommandList -range CocCommand :call coc#rpc#notify('runCommand', [<f-args>])

from wilder.nvim.

yutkat avatar yutkat commented on May 29, 2024

So that's the only way to override it. This is a pain with a lot of commands.

But thank you. I will continue to use this plugin.

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.