Skip to content

fix(cmd): "E488: Trailing characters" when invoking lazy trigger cmd with arguments#1

Merged
zuqini merged 1 commit intozuqini:mainfrom
Yuhf7:fix/e488-command-with-args
Dec 26, 2025
Merged

fix(cmd): "E488: Trailing characters" when invoking lazy trigger cmd with arguments#1
zuqini merged 1 commit intozuqini:mainfrom
Yuhf7:fix/e488-command-with-args

Conversation

@Yuhf7
Copy link
Copy Markdown
Contributor

@Yuhf7 Yuhf7 commented Dec 26, 2025

Problem

If a command is set to lazy-load a plugin, running it with arguments won't load the plugin because the wrapper command created by zpack does not accept arguments by default.

For instance, with the spec:

return {
    'ibhagwan/fzf-lua',
    cmd = 'FzfLua',
    config = function ()
        require('fzf-lua').setup { }
    end,
}

Running :FzfLua will load the plugin correctly, whereas :FzfLua files will error with E488: Trailing characters: files.

Solution

According to :h :command-nargs:

By default, a user defined command will take no arguments (and an error is reported if any are supplied). However, it is possible to specify that the command can take arguments, using the -nargs attribute.

Setting nargs = '*' in the opts field of the zpack command wrapper fixes the issue.

Problem: If a command is set to lazy-load a plugin, running it with arguments
won't load the plugin because the wrapper command created by zpack does not
accept arguments by default, resulting in `E488: Trailing characters` error.

Solution: set `nargs = '*'` so that the wrapper command can accept any
number of args and correcly pass them onto the real command once loaded.
@zuqini
Copy link
Copy Markdown
Owner

zuqini commented Dec 26, 2025

Thank you for your contribution, and I appreciate your added test!

@zuqini zuqini merged commit d510920 into zuqini:main Dec 26, 2025
1 check passed
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 this pull request may close these issues.

2 participants