Skip to content

Some diagnostic not showing in Neovim #2229

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

Open
5 of 6 tasks
sharpchen opened this issue Apr 4, 2025 · 2 comments
Open
5 of 6 tasks

Some diagnostic not showing in Neovim #2229

sharpchen opened this issue Apr 4, 2025 · 2 comments
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!

Comments

@sharpchen
Copy link

sharpchen commented Apr 4, 2025

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with PowerShell Editor Services itself and does not reproduce in a standalone PowerShell instance, and is not an issue with my editor.
  • I have verified that I am using the latest version of PowerShell Editor Services.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Some diagnostic show in vscode with powershell extension but not in neovim.(warning, errors are fine)
Is there a default config I've missed for PSScriptAnalyzer or something else?

neovim(no diagnostic for trailing spaces) vscode
Image Image

PowerShell Version

Name                           Value
----                           -----
PSVersion                      7.5.0
PSEdition                      Core
GitCommitId                    7.5.0
OS                             Arch Linux
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Editor Version

NVIM v0.11.0
Build type: Release
LuaJIT 2.1.1741730670
Run "nvim -V1 -v" for more info

Configured by nvim-lspconfig

local lsp = require('utils.lsp')
require('lspconfig').powershell_es.setup({
  bundle_path = lsp.path.pwsh_es,
  settings = {
    powershell = {
      codeFormatting = {
        Preset = 'OTBS',
        autoCorrectAliases = true,
        useConstantStrings = true,
        useCorrectCasing = true,
        whitespaceAroundOperator = true,
        whitespaceAfterSeparator = true,
        whitespaceBeforeOpenBrace = true,
        addWhitespaceAroundPipe = true,
      },
    },
  },
})

LspInfo:

- powershell_es (id: 1)
  - Version: 7.5.0 SHA: 99dab561892364d82d4965068f7f8b175e768b1b+99dab561892364d82d4965068f7f8b175e768b1b
  - Root directory: ~/.config/home-manager
  - Command: { "pwsh", "-NoLogo", "-NoProfile", "-Command", "& '/nix/store/w3d7s47qf8mfg04hmnpgd7h6l7l85zfc-powershell-editor-services-4.3.0/lib/powershell-editor-services/PowerShellEditorServices/Start-EditorServices.ps1' -BundledModulesPath '/nix/store/w3d7s47qf8mfg04hmnpgd7h6l7l85zfc-powershell-editor-services-4.3.0/lib/powershell-editor-services' -LogPath '/home/sharpchen/.cache/nvim/powershell_es.log' -SessionDetailsPath '/home/sharpchen/.cache/nvim/powershell_es.session.json' -FeatureFlags @() -AdditionalModules @() -HostName nvim -HostProfileId 0 -HostVersion 1.0.0 -Stdio -LogLevel Normal" }
  - Settings: {
      powershell = {
        codeFormatting = {
          Preset = "OTBS",
          addWhitespaceAroundPipe = true,
          autoCorrectAliases = true,
          useConstantStrings = true,
          useCorrectCasing = true,
          whitespaceAfterSeparator = true,
          whitespaceAroundOperator = true,
          whitespaceBeforeOpenBrace = true
        }
      }
    }

PowerShell Editor Services Version

idk how to attach it in neovim

Steps to Reproduce

# any snippet with trailing spaces
ni foo.txt                 

Visuals

No response

Logs

[START][2025-04-04 22:18:33] LSP logging initiated
[WARN][2025-04-04 22:18:33] ...lsp/handlers.lua:564	"Microsoft.PowerShell.EditorServices.Logging.HostLoggerAdapter: The log level 'Normal' is deprecated and will be removed in a future release. Please update your settings or command line options to use one of the following options: 'Trace', 'Debug', 'Information', 'Warning', 'Error', 'Critical'. | "
@sharpchen sharpchen added Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed! labels Apr 4, 2025
@andyleejordan
Copy link
Member

I don't believe that rule is included by default. I was only able to get that warning to show by manually setting my PSScriptAnalyzerSettings.psd1 file to include @{ IncludeRules = @('PSAvoidTrailingWhitespace') }. Try that?

If you need to change the path to the PSScriptAnalyzerSettings.psd1 settings file for the project/workspace, the setting is powershell.scriptAnalysis.settingsPath and you'd have to pass that it in through your client's configuration.

@sharpchen
Copy link
Author

Oh indeed, it's not a server problem. I think powershell extension does have some default rules enabled, PSAvoidTrailingWhitespace is just one of them(at least it is on my machine). Where can I find full list of these pre-included rules? Is it possible to set these rules as default even when PSScriptAnalyzerSettings.psd1 is absent in project root?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Issue-Bug A bug to squash. Needs: Triage Maintainer attention needed!
Projects
None yet
Development

No branches or pull requests

2 participants