2

What I have referenced in my .zshrc file:

nvim --headless -c 'LspInstall tsserver | qall'

This doesn't work. The qall is regarded as an argument of LspInstall while I didn't mean to. The LspInstall will take some time to download the language servers, thus it seems like that I need some pseudo-command like:

await LspInstall tsserver then qall

Any idea?

3
  • 1
    You can use multiple -c flags. Does nvim --headless -c 'LspInstall tsserver' -c 'qall' work?
    – B Layer
    Oct 5 at 9:37
  • @BLayer: You're awesome :) It works! Sorry for my easy question.
    – job_start
    Oct 5 at 9:51
  • :) No worries. .
    – B Layer
    Oct 5 at 9:52
3

I guess the LspInstall user command is configured to take multiple parameters. No matter, you can use multiple -c flags, each with their own command(s).

Specifically...

You can use up to 10 "+" or "-c" arguments in a Vim command. They are executed in the order given. A "-S" argument counts as a "-c" argument as well.

(Source: :h -c)

So try...

nvim --headless -c 'LspInstall tsserver' -c 'qall'
2
  • 1
    I'm happy-happy now~
    – job_start
    Oct 5 at 9:54
  • It is more likely the command wasn’t declared with -bar, in which case the bar wont work. Wrapping in execute will, or multiple commands, as you pointed out. (-nargs= whatever has nothing to do with bar-handling, in other words.)
    – D. Ben Knoble
    Oct 5 at 12:10
3

An alternative solution that works if you're running the commands inside a Vim instance (you're not, but the existing answer is already the best solution for your exact circumstances) is to use :execute to more specifically delimit the arguments to the LspInstall command.

Instead of:

:LspInstall tsserver | qall

You can use:

:execute "LspInstall tsserver" | qall
1
  • As I said under the other answer, I suspect LspInstall is missing -bar
    – D. Ben Knoble
    Oct 5 at 16:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.