LS job fails on windows vim if &shell is powershell

Open Beginner friendly
#276 1 comment 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
72/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
node.js, powershell, vim

Research direction

Start in autoload/copilot/client.vim, specifically copilot#client#New(), and inspect how the command is prepared when Vim runs on Windows with &shell set to PowerShell or pwsh. Reproduce the language-server launch in that environment and verify it also continues to work with the existing shell configuration; done means the server starts successfully without breaking other platforms.

Written by the indexing model from the issue text.

Description

The language server runs in node.js and is launched using:

 > npx @github/copilot-language-server@^1.408.0 --stdio

the problem is that the plugin (see copilot.vim/autoload/copilot/client.vim function copilot#client#New())
uses:

    job_start(['npx', '@github/copilot-language-server@^1.408.0', '--stdio'], ...)

which fails (is a win32 CreateProcess(...) issue) and should instead use:

    job_start('npx "@github/copilot-language-server@^1.408.0" --stdio', ...)

The following patch works for me:

    diff --git a/autoload/copilot/client.vim b/autoload/copilot/client.vim
    index c3ec862..c052bc8 100644
    --- a/autoload/copilot/client.vim
    +++ b/autoload/copilot/client.vim
    @@ -736,7 +736,7 @@ function! copilot#client#New() abort
         let instance.workspaceFolders[folder.uri] = v:true
       endfor
       call copilot#logger#Debug('Spawning ' . join(command, ' '))
    -  let is_win_shell = has('win32') && &shellcmdflag !~# '^-'
    +  let is_win_shell = has('win32') && ( &shell =~? 'powershell\|pwsh' || &shellcmdflag !~# '^-')
       if is_win_shell && command[0] !~# '[\/]'
         let exepath = exepath(command[0])
         if exepath !~? '\.exe$\|^$'
Dominant language
Vim Script
Stars
11.7k
Forks
812
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from github/copilot.vim

All issues in github/copilot.vim

Similar issues

More Operating Systems issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.