coc-extensions / coc-powershell

PowerShellEditorService integration for coc.vim

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

coc-powershell unresponsive

lc9er opened this issue · comments

System Details

  • Vim or NeoVim?: NeoVim
  • Version of Vim (run vim --version) or NeoVim (run nvim --version): 0.4.3
  • Version of coc-powershell (in Vim or NeoVim: :CocList extensions coc-powershell): 0.1.2
  • Operating System: Windows 10 - 1909
  • PowerShell version (in PowerShell: $PSVersionTable): 7.0.3

Issue Description

I am experiencing a problem with...

I run 'nvim some.ps1', the file opens, Neovim recognizes it as a Powershell file (according to statusline, but nothing else happens. There's no syntax highlighting, no linting, no completion, no terminal. If I manually start the extension, the integrated terminal appears, but the other features are still missing.

Expected Behaviour

-- Description of what should be happening --

I should open a ps1 file. the integrated terminal should open. I should see syntax highlighting, code completion, and linting.

Actual Behaviour

-- Description of what actually happens --

Nothing happens. It doesn't seem like the extension is functioning at all. Other extensions are functioning - the extensions for Rust and Python are functioning. I've also duplicated the same problem in vim 8.2, as well as with Neovim 0.4.4/pwsh 7.0.1/coc-powershell 0.1.2 on Ubuntu 18.04 WSL.

Have you tried using vim-polyglot mentioned in the recommended plug-ins?

https://github.com/coc-extensions/coc-powershell#recommended-plugins

Does that change anything for you (besides the obvious 'it now has highlighting')?

I've done some more testing. After activating the extension manually (:CocList / extensions / coc-powershell), the Integrated console opens and, eventually PSScriptAnalyzer becomes reponsive.

In addition, if I manually specify the filetype (:CocList / filetype / ps1), then all of the expected functionality for Powershell files is enabled. It seems like coc is not recognizing or triggering the extension when I open a ps1 file from the command line or from within nvim. It seems I have to do this everytime I reopen nvim.

@lc9er when you open the ps1 for the first time, what is the filetype?:

:set filetype

I think you're onto something. When I open a ps1 and run :set filetype, it shows filetype=powershell.

When I set the filetype using CoC, :set filetype then shows filetype=ps1.

So I think that explains why this happening, but I'm unsure as to how to fix this (or how this has happened at all - I've done plugin updates, but haven't changed my config).

We usually recommend vim polyglot because it sets the ft to ps1:
https://github.com/PProvost/vim-ps1/blob/master/ftdetect/ps1.vim

You may need to remove your packages 1 by 1 to figure it out. I'm curious which package is to blame.

When I remove polyglot, then open ps1 file, run :set filetype, it just shows filetype= ...

I tracked down how Coc.nvim discovers filetypes. In C:\Users<uid>\AppData\Local\coc\extensions\node_modules\coc-lists\lib\filetypes.js, you see this line

 let filetypes = await nvim.eval(`sort(map(split(globpath(&rtp, 'syntax/*.vim'), '\n'),'fnamemodify(v:val, ":t:r")'))`);

So it looks like it just rifles through the plugins directory and pulls the name off the .vim files. I re-installed polyglot and tried copying ps1.vim to powershell.vim, seeing if that would works as an ugly hack.

Highlighting worked, thanks to polyglot, but it still did not trigger the coc-powershell extension.

Somewhere, the powershell=ps1 mapping seems to have been lost. I can't figure out if that's a Coc or coc-powershell issue.

Oh interesting... this might be a matter of simply adding to our package.json:

"activationEvents": [
"onLanguage:ps1"
],

adding an onLanguage:powershell and onLanguage:pwsh for good measure.

Do you think you could test that out for me?

Is filetype guaranteed to be lower case? As another just in case, should we add PowerShell and Powershell?

Oh interesting... this might be a matter of simply adding to our package.json:

"activationEvents": [
"onLanguage:ps1"
],

adding an onLanguage:powershell and onLanguage:pwsh for good measure.

Do you think you could test that out for me?

This gets it closer to working! It activates the coc-powershell extension, so that the integrated terminal opens, completion, and PSScriptanalyzer integration are all working.

No syntax highlighting from polyglot, though. Note that I removed the powershell.vim copy of ps1.vim that I created in polyglot's syntax directory. :set filetype still shows filetype=powershell.

I'm not sure if at this point, it's an issue with vim-polyglot or not.

Ok so we need to update our activationEvents for sure. That's easy. @corbob that's a good point on casing. I'm not sure.

Now polyglot problem... hmm I really don't know tbh. What you could do is...

  1. uninstall coc-powershell or CoC entirely
  2. keep polyglot installed

That would prove that whatever is setting filetype to powershell is not coc-powershell.

Found it! I searched through the old vim-polyglot issues and found this, which mentions PProvost/vim-ps1. I installed the plugin, opened a ps1 file and nvim showed the filetype as ps1, instead of powershell.

I reinstalled Coc.nvim and now everything is working as expected.

That was ages ago though... weird you saw it only now.

When I first discovered coc-powershell, I had that plugin installed. I believe it was listed in the README, but removed it a long time ago. As in many months ago. I use nvim + coc-powershell everyday, and update my plugins frequently, so yeah - I'm just as confused as to why it became an issue now.

But does this mean that vim-ps1 should be included as a requirement? I'd hate for someone else to install the plugin and think it's not working.

But does this mean that vim-ps1 should be included as a requirement? I'd hate for someone else to install the plugin and think it's not working.

well we just need to do what I mentioned above to fix coc-powershell:

#106 (comment)

btw, do you want to submit a PR for that since it worked for you?

Happy to help if you need it :) just let me know here.

Closing this now that it's fixed :)