PowerShellEditorServices icon indicating copy to clipboard operation
PowerShellEditorServices copied to clipboard

LSP support for modules

Open mhegreberg opened this issue 4 years ago • 15 comments

I'd like to get LSP support for modules I use frequently, like MSOnline.

I copied the modules into my bundle_path, but that doesn't seem to import them into the session of powershell that PSES runs

for context, I'm using neovim LSP running in WSL debian, with these settings:

image image

mhegreberg avatar Aug 05 '21 18:08 mhegreberg

I'm sorry, what are you trying to do? The bundle_path is just for the bundled modules that are necessary for PSES to work. Other PowerShell modules should be installed and loaded like normal.

andyleejordan avatar Sep 09 '21 23:09 andyleejordan

I'm hoping to have lsp support for the modules I'm using, so I can have goto definitions, autocomplete, etc.

when I use a python, typescript, or c# LSP any imported modules/packages show up in those places.

are you saying that if I have the module loaded in the instance of powershell that PSES is running in, then those features should work?

mhegreberg avatar Sep 09 '21 23:09 mhegreberg

Yes, it should. Essentially the LSP server hosts a PowerShell session, and any modules installed and imported into that session (the integrated terminal) then become available for the server to answer gotos, completions, etc.

andyleejordan avatar Sep 10 '21 01:09 andyleejordan

In that case, I'm not entirely sure what's causing my issue. here are my module paths in powershell: image

and here is the MSOnline module in two of those paths (I made an extra copy while troubleshooting): image image

WSL is definitely talking to the windows version of powershell: image

the LSP works for some functions: image

but it is not able to pull anything from MSOnline: image

it also seems unable to pull anything from ActiveDirectory, which is also installed: image

Is there something I'm missing?

mhegreberg avatar Sep 10 '21 15:09 mhegreberg

Have you tried Import-Module MSOnline in the integrated console? Also before you do that, show us the output of Get-Module (my guess is that MSOnline does not show up, but should after the import).

andyleejordan avatar Sep 10 '21 16:09 andyleejordan

I haven't messed with the integrated terminal yet, though I suspect you're right. what do I need to do to hook into the repl? i'm not using coc-powershell, but the lsp engine built directly into neovim

mhegreberg avatar Sep 10 '21 17:09 mhegreberg

Ohhh. Ok, skip that, and just put Import-Module MSOnline in your script and try executing it with whatever NeoVim integration is available for executing code in the PowerShell session.

andyleejordan avatar Sep 10 '21 20:09 andyleejordan

I don't see a whole lot in their documentation...a really cheap hack would be to put that import statement in your profile because PSES should execute it. You might have to figure out how to send LSP configurations over from NeoVim. I used to do that with Emacs and it wasn't the easiest thing in the world 😣

andyleejordan avatar Sep 10 '21 21:09 andyleejordan

@mhegreberg Hey, did you figure this out? Did any of those suggestions help out?

andyleejordan avatar Sep 21 '21 20:09 andyleejordan

Hey, sorry, I missed this.

I tried importing the module within Start-EditorServices.ps1 image and it didn't make a difference. I'll mess with using my profile today and see if that works.

thanks!

mhegreberg avatar Sep 22 '21 18:09 mhegreberg

I made a profile.ps1 that only contains "Import-Module MSOnline" and it also doesn't seem to pull it in. I'm going to see if I can figure out the REPL feature.

mhegreberg avatar Sep 22 '21 18:09 mhegreberg

Just checking in, anything work yet?

andyleejordan avatar Sep 28 '21 20:09 andyleejordan

I have been unsuccessful so far, but I have some time set aside tomorrow I'm going to use to see if I can make vim communicate with the powershell REPL, or at least open it in another shell.

mhegreberg avatar Sep 30 '21 19:09 mhegreberg

In your original post you have this configuration:

image

Are you still using the "-NoProfile" switch? Because this does exactly what it says: It prevents loading any profiles.

Lofavreel avatar Oct 02 '21 12:10 Lofavreel

Once I added the import lines to my profile, i removed the -NoProfile flag, to no avail On Oct 2, 2021 05:00, Lofavreel @.***> wrote: In your original post you have this configuration:

Are you still using the "-NoProfile" switch? Because this does exactly what it says: It prevents loading any profiles.

—You are receiving this because you were mentioned.Reply to this email directly, view it on GitHub, or unsubscribe.Triage notifications on the go with GitHub Mobile for iOS or Android.

mhegreberg avatar Oct 02 '21 16:10 mhegreberg