Skip to content

Configure PSSA from Start-EditorServices #2001

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

Closed
csc027 opened this issue Feb 24, 2023 · 10 comments
Closed

Configure PSSA from Start-EditorServices #2001

csc027 opened this issue Feb 24, 2023 · 10 comments
Labels
Issue-Discussion Let's talk about it. Resolution-Answered Will close automatically.

Comments

@csc027
Copy link
Contributor

csc027 commented Feb 24, 2023

Summary

How do I configure the underlying PSScriptAnalyzer (PSSA) instance to use custom rules from the starting point Start-EditorServices for use in non-Visual Studio Code editors?

Description

I have a working PSES setup working for my Neovim setup, providing completion and linting for the default ruleset. However, I currently do not know how to configure custom PSSA rules for the PSSA instance bundled with PSES.

I know for VS Code, you could change the settings in your workspace, as documented here.

To be clear, I was able to get those rules working via implicit settings documented here. However, I have many different PowerShell repositories in my use case. It would be onerous to save a settings file each and every repository.

So, is it possible to configure the underlying PSSA instance's settings to explicitly use custom rules from either Start-EditorServices or from making specific changes to the environment that PSSA runs from?

@ghost ghost added the Needs: Triage Maintainer attention needed! label Feb 24, 2023
@andyleejordan
Copy link
Member

I think you would have to send those same settings that VS Code uses over LSP using whatever method your LSP client in Neovim provides to do so. In my experience this can be kind of tricky depending on the client, but here's the docs I found for Neovim's LSP client.

@andyleejordan
Copy link
Member

Ah ha, specifically you'll want to look at vim.lsp.start_client(), and pass it a map under the settings key in the start config.

@andyleejordan
Copy link
Member

Here is a completely random example of that I found on GitHub for you: https://github.com/ChristianChiarulli/nvim/blob/1631262e8df1de2ad0ecfd5f7dffd9c4476d7933/ftplugin/java.lua#L119

@andyleejordan andyleejordan added Issue-Question Resolution-Answered Will close automatically. and removed Needs: Triage Maintainer attention needed! labels Apr 10, 2023
@csc027
Copy link
Contributor Author

csc027 commented Apr 11, 2023

Thank you so much! I was tearing my hair out trying to figure out how to pass the values to the server. For some reason, I was so stuck thinking about how to configure it via the entry point, that it didn't event occur to me that I should pass the settings through the LSP protocol.

@csc027 csc027 closed this as completed Apr 11, 2023
@csc027
Copy link
Contributor Author

csc027 commented Apr 11, 2023

Also, how useful would it be to add this to the documentation somewhere, perhaps in docs/guide? I'm not sure what the roadmap is for PSES; so, I'm not sure how quickly the settings would change.

@andyleejordan
Copy link
Member

It would be a great addition. I have work planned for this month to make using PSES from Emacs/Vim etc. (as in other LSP clients that are not VS Code) much easier, and will include some tested documentation on configuration. Because yes, LSP can be so confusing. It's fantastic tech compared to where we were at a decade ago, but I remember the pain the first time I tried to get Emacs with an LSP client to send a setting to OmniSharp (a C# LSP server)...it's the only reason I remembered enough to know what to look for here!

@csc027
Copy link
Contributor Author

csc027 commented Apr 12, 2023

That sounds awesome! Would you take a PR for documentation after the changes are put in? I can't profess to know Emacs very well, but I think I could add the one for NeoVim.

@andyleejordan
Copy link
Member

Would love it, heck I'd welcome it now! I'll keep it updated after the fact too. The best Vim example I currently have is the end to end test: https://github.com/PowerShell/PowerShellEditorServices/blob/main/test/vim-test.vim

@csc027
Copy link
Contributor Author

csc027 commented Apr 13, 2023

Okay, cool. I'll put some time in once the weekend hits. It'll probably start as a draft.

@csc027
Copy link
Contributor Author

csc027 commented Apr 15, 2023

I added a draft PR #2016. I'll get some more changes in as I think of things that are missing. Feel free to comment on any style or content issues with it.


Edit: No longer a draft.

@andyleejordan andyleejordan added the Issue-Discussion Let's talk about it. label Nov 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Discussion Let's talk about it. Resolution-Answered Will close automatically.
Projects
None yet
Development

No branches or pull requests

2 participants