Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better display of yarn run completions #76

Closed
jods4 opened this issue Dec 19, 2016 · 1 comment
Closed

Better display of yarn run completions #76

jods4 opened this issue Dec 19, 2016 · 1 comment

Comments

@jods4
Copy link

jods4 commented Dec 19, 2016

Following #74, I tested formatted completions: /.bin executables are displayed plain, package.json scripts are prefixed with a *.
yarn run
The result is better than nothing, although color would be 10x better 😭

To achieve this, I modified the scripts function as follows:

local function scripts_display_filter(scripts)
    return function(matches)
        for i, m in ipairs(matches) do
            local prefix = scripts[m] ~= nil and '* ' or '  '
            matches[i] = prefix..m
        end
        return matches
    end
end

-- Reads package.json in current directory and extracts all "script" commands defined
local function scripts(token)
    -- Read package.json first
    local package_json = io.open('package.json')
    -- If there is no such file, then close handle and return
    if package_json == nil then return {} end

    -- Read the whole file contents
    local package_contents = package_json:read("*a")
    package_json:close()

    local scripts = w(JSON:decode(package_contents).scripts)
    clink.match_display_filter = scripts_display_filter(scripts)
    return scripts:keys()
end
@vladimir-kotikov
Copy link
Owner

Looks nice ;) Though i personally prefer an option without space between * and a suggestion. @jods4, could you send a PR with this?

chrisant996 added a commit that referenced this issue Aug 19, 2022
This colors the yarn run matches.

In old Clink versions, it has no effect.
chrisant996 added a commit that referenced this issue Aug 20, 2022
* WIP [common] Adds basic wrapper for tables

* WIP [common] Fixes tables wrapper to assign metatable correctly

* WIP [common] Rework matchers using new table wrapper

* Fix #103; show also remote branches in git merge.

* Fix #117; .init.lua isn't loaded under some circumstances.

The "." at the beginning of the ".init.lua" file name marks it as a hidden file
in Linux and some sync programs.  That can cause sync programs to not copy the
file.  Renaming to "!init.lua" resolves that problem, while still ensuring the
script is loaded before any of the other completion scripts.

* Fixing #117 requires a change in Cmder.

So, for best compatibility, clink-completions will have both .init.lua and
!init.lua files.

* Explicitly add the completions directory.

This enables newer Clink versions to load and use completions scripts on demand,
even in Cmder (which manually loads clink-completions scripts, so Clink doesn't
know about their script directory).

* Fix #16; add curl completions.

* Fix #145; add sudo argmatcher.

Requires Clink v1.3.40 to work fully properly.

* Rename to path_module so builtin path APIs are available.

* Fix base git flags bleeding thru to commands.

`git ls-files` doesn't have a linked argmatcher, so the `git` flags were
bleeding into it.  And etc for other commands.

* Smarter completions for git add and git checkout.

It's very unusual to add or checkout unchanged files.

So `git add` uses `git status -uall` to generate file matches.
And `git checkout` uses `git status -uno` to generate file matches.

* Fix `hide=true` for linked argmatchers.

* Fix #131; add winget completions.

* Simplify help_parser unsupported short circuit.

Return nothing, rather than returning an empty table.
This makes it easier for a caller to recognize it's not supported.

* matchers.ext_files improvements.

- It uses new APIs when available.
- It accepts a list of wildcards and adds them all at once, which makes
adding directories much more efficient (only one time).

* Add comments for some matchers module exports.

* Add some common argmatchers.

* Add robocopy argmatcher.

* Some explicit version checks, just in case.

* Add premake5 argmatcher.

* Add msbuild argmatcher.

* Add argmatchers for GNU grep and sed.

* Better capitalization function in robocopy argmatcher.

* Add adb/fastboot/scrcopy argmatchers.

* Fix typo in winget complete position.

* Fix #76; better display of yarn run completions.

This colors the yarn run matches.

In old Clink versions, it has no effect.

* Fix `yarn` completions.

While improving `yarn run` completions, `yarn` completions lost the
`run` matches.

Also, apply color to yarn local module matches, to differentiate them
from yarn commands.

* Clean luacheck warnings.

* Fix typo in yarn run completions.

* Fix some back-compat issues for v0.4.9.

* Tell luacheck about another Clink API.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants