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

coc-powershell unresponsive #106

Closed
lc9er opened this issue Aug 21, 2020 · 18 comments
Closed

coc-powershell unresponsive #106

lc9er opened this issue Aug 21, 2020 · 18 comments

Comments

@lc9er
Copy link
Contributor

lc9er commented Aug 21, 2020

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.

@TylerLeonhardt
Copy link
Collaborator

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')?

@lc9er
Copy link
Contributor Author

lc9er commented Aug 21, 2020 via email

@lc9er
Copy link
Contributor Author

lc9er commented Aug 21, 2020

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.

@TylerLeonhardt
Copy link
Collaborator

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

:set filetype

@lc9er
Copy link
Contributor Author

lc9er commented Aug 24, 2020

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).

@TylerLeonhardt
Copy link
Collaborator

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.

@lc9er
Copy link
Contributor Author

lc9er commented Aug 24, 2020

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.

@TylerLeonhardt
Copy link
Collaborator

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?

@corbob
Copy link
Member

corbob commented Aug 24, 2020

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

@lc9er
Copy link
Contributor Author

lc9er commented Aug 24, 2020

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.

@TylerLeonhardt
Copy link
Collaborator

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.

@lc9er
Copy link
Contributor Author

lc9er commented Aug 24, 2020

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.

@TylerLeonhardt
Copy link
Collaborator

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

@lc9er
Copy link
Contributor Author

lc9er commented Aug 25, 2020

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.

@TylerLeonhardt
Copy link
Collaborator

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?

@lc9er
Copy link
Contributor Author

lc9er commented Aug 29, 2020 via email

@TylerLeonhardt
Copy link
Collaborator

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

TylerLeonhardt pushed a commit that referenced this issue Aug 31, 2020
#108)

* Fixes issue #106 - coc-powershell fails to open automatically for ps1 filetypes.

* Update package.json

Co-authored-by: corbob <[email protected]>

Co-authored-by: Brian McGraw <[email protected]>
Co-authored-by: corbob <[email protected]>
@TylerLeonhardt
Copy link
Collaborator

Closing this now that it's fixed :)

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

No branches or pull requests

3 participants