Giter Site home page Giter Site logo

Comments (9)

Ordoviz avatar Ordoviz commented on September 28, 2024 1

Tested again. Now it's fixed!

from complgen.

adaszko avatar adaszko commented on September 28, 2024

Here's what works:

for path in ~/.config/complgen/*.usage; do
    stem=$(basename "$path" .usage)
    eval "
_complgen_jit_$stem () {
    local words cword
    _get_comp_words_by_ref -n = words cword
    local prefix="\${words[\$cword]}"
    local -a completions=(\$(complgen complete \"$HOME/.config/complgen/${stem}.usage\" bash --prefix="\$prefix" -- \${words[@]:1:\$cword-1}))
    for item in "\${completions[@]}"; do
        if [[ \$item = "\${prefix}"* ]]; then
            COMPREPLY+=("\$item")
        fi
    done
    __ltrim_colon_completions "\$prefix"
    return 0
}
"
    complete -o nospace -F _complgen_jit_$stem "$stem"
    unset stem
done

from complgen.

adaszko avatar adaszko commented on September 28, 2024

Thanks for reporting!

from complgen.

Ordoviz avatar Ordoviz commented on September 28, 2024

Still broken: mygrep --color=n<TAB> completes to mygrep --color=--color=never.

I have built using cargo build from latest commit and tested with bash --noprofile --norc -i; source /usr/share/bash-completion/bash_completion.

from complgen.

adaszko avatar adaszko commented on September 28, 2024

Take another look please, it should work better now: https://github.com/adaszko/complgen/blob/4927e628c54244114a7d9d691a125333f9eeaafc/README.md#bash-integration

from complgen.

Ordoviz avatar Ordoviz commented on September 28, 2024

We are getting there. These autocomplete correctly now:

mygrep <TAB>
mygrep --color=<TAB>
mygrep --color=a<TAB>
mygrep --color=al<TAB>

but mygrep --color completes to mygrep =

from complgen.

adaszko avatar adaszko commented on September 28, 2024

mygrep --color<TAB> works on my end:

image

To be clear, I'm talking about the JIT mode, with Bash and complgen at commit 4927e62. Perhaps you're at some older commit?

from complgen.

Ordoviz avatar Ordoviz commented on September 28, 2024

I was using this grammar:

mygrep --color "use markers to highlight the matching strings"=<WHEN>;
<WHEN> ::= always | never | auto;

Changing it to

mygrep --color=<WHEN>;
<WHEN> ::= always | never | auto;

fixes the bug.

from complgen.

adaszko avatar adaszko commented on September 28, 2024

Check again please. The issue was Bash weirdness to do with handling $COMP_WORDBREAKS characters in completions (= and : are among which). Special filtering needs to be performed then to get correct results. I did that for shell script output in the past but seem to have forgotten about it for the JIT mode.

from complgen.

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.