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

Ability to exclude paths from lsp_goto_diagnostic #2112

Open
ssoher opened this issue Nov 2, 2022 · 16 comments
Open

Ability to exclude paths from lsp_goto_diagnostic #2112

ssoher opened this issue Nov 2, 2022 · 16 comments

Comments

@ssoher
Copy link

ssoher commented Nov 2, 2022

When I invoke lsp_goto_diagnostic I want to see diagnostics of my own code only, but currently it also shows all the diagnostics from external libraries within the project.

It seems folder_exclude_patterns in the sublime-project doesn't effect this feature either.

I want to be able to exclude a bunch of paths from diagnostics checking and listing.

@jwortmann
Copy link
Member

I made a PR #2113 to ignore diagnostics for files within folder_exclude_patterns.

There is no general functionality to configure other files or folders where diagnostics should be ignored, but I know that some language servers have a custom setting for that (e.g. Julia server).

@rchl
Copy link
Member

rchl commented Dec 14, 2022

Does supporting folder_exclude_patterns covers your use case @ssoher.
I don't feel like we'd want to add more options for controlling this so if you are good with just using folder_exclude_patterns then we could close this feature request.

@ssoher
Copy link
Author

ssoher commented Dec 14, 2022

@rchl I'm afraid it does not. Ideally I should still be able to see the references, go to definitions, see auto completions, etc. etc. of all the external libraries. If I exclude the folders at project level I'll lose all that ability afaik. It's just that I don't care about the diagnostics in external code. I would love if there was a general setting to at least filter out parts of a project from diagnostics listing (if not checking as well).

Would it be easier or make more sense to implement on the specific server (omnisharp), should I close this and create a new issue there?

@rchl
Copy link
Member

rchl commented Dec 14, 2022

Maybe I'm wrong but I don't think folder_exclude_patterns would suppress any of the functionality you've mentioned. It should still be possible for LSP to open ignored files if "goto definitinon" references it, for example.

But having an option in the server for ignoring diagnostics in non-user code sounds good to me. Maybe (hopefully) the server has more knowledge to be able to tell whether something is "user code" or not. Though I imagine it could be tricky, depending on the language.

@ssoher
Copy link
Author

ssoher commented Dec 15, 2022

Maybe I'm wrong but I don't think folder_exclude_patterns would suppress any of the functionality you've mentioned. It should still be possible for LSP to open ignored files if "goto definitinon" references it, for example.

I wanted to confirm this, cloned the LSP repo into the packages folder and installed dependencies, restarted ST. LSP works alright but I still get the diagnostics from an excluded folder. Below is my sublime-project file.

{
    "folders":
    [
        {
            "path": ".",
            "folder_exclude_patterns": [".svn", "Library", "Logs", "obj", "Temp"],
            "file_include_patterns": ["*.cs", "*.md", "*.sublime-project", "*.sublime-workspace", "*.txt", "*.shader", "*.bat", "*.csproj", "*.sln"]
        }
    ],
}

The listed folders are excluded from the side bar and the GoTo actions so the folder_exlude_patterns work correctly. But when I invoke lsp_goto_diagnostic still all the diagnostics from an example path Library\PackageCache\com.unity.textmeshpro\... is shown. What am I doing wrong? (using LSP with LSP-omnisharp btw)

@rchl
Copy link
Member

rchl commented Dec 15, 2022

Works for me. Can you provide output of LSP: Troubleshoot server when that ignored file is opened?

@ssoher
Copy link
Author

ssoher commented Dec 15, 2022

# Troubleshooting: OmniSharp
## Version
 - LSP: 1.20.0
 - Sublime Text: 4143
## Server Test Run
 - exit code: 0
 - output
## Server Configuration
 - command
```json
[
  "C:\\Users\\sarper\\AppData\\Local\\Sublime Text\\Package Storage\\LSP-OmniSharp\\OmniSharp.exe", 
  "--languageserver"
]
  • shell command
"C:\Users\sarper\AppData\Local\Sublime Text\Package Storage\LSP-OmniSharp\OmniSharp.exe" --languageserver
  • selector
source.cs | source.cake
  • priority_selector
source.cs | source.cake
  • init_options
{}
  • settings
{
  "csharp": {
    "format": {
      "enable": true
    }, 
    "maxProjectFileCountForDiagnosticAnalysis": 1000, 
    "referencesCodeLens": {
      "enabled": true, 
      "filteredSymbols": []
    }, 
    "semanticHighlighting": {
      "enabled": true
    }, 
    "suppressHiddenDiagnostics": true, 
    "testsCodeLens": {
      "enabled": true
    }
  }, 
  "omnisharp": {
    "defaultLaunchSolution": null, 
    "enableAsyncCompletion": false, 
    "enableDecompilationSupport": false, 
    "enableEditorConfigSupport": true, 
    "enableImportCompletion": false, 
    "enableMsBuildLoadProjectsOnDemand": false, 
    "enableRoslynAnalyzers": false, 
    "loggingLevel": "information", 
    "maxFindSymbolsItems": 1000, 
    "maxProjectResults": 250, 
    "minFindSymbolsFilterLength": 0, 
    "organizeImportsOnFormat": false, 
    "useEditorFormattingSettings": true
  }, 
  "razor": {
    "format": {
      "enable": true
    }
  }
}
  • env
{
  "FrameworkPathOverride": "${storage_path}/LSP-OmniSharp/.msbuild/Current"
}

Active view

  • File name
E:\project\breakout\Library\PackageCache\[email protected]\Scripts\Editor\TMPro_FontAssetCreatorWindow.cs
  • Settings
{
  "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc", 
  "lsp_active": true, 
  "syntax": "Packages/C#/C#.sublime-syntax"
}
  • base scope
source.cs

Project / Workspace

  • folders
[
  "E:\\project\\breakout"
]
  • is project: True
  • project data:
{
  "folders": [
    {
      "file_include_patterns": [
        "*.cs", 
        "*.md", 
        "*.sublime-project", 
        "*.sublime-workspace", 
        "*.txt", 
        "*.shader", 
        "*.bat", 
        "*.csproj", 
        "*.sln"
      ], 
      "folder_exclude_patterns": [
        ".svn", 
        "Library", 
        "Logs", 
        "obj", 
        "Temp"
      ], 
      "path": "."
    }
  ]
}

LSP configuration

{
  "diagnostics_highlight_style": {
    "error": "", 
    "hint": "", 
    "info": "", 
    "warning": ""
  }, 
  "diagnostics_panel_include_severity_level": 2, 
  "document_highlight_style": "underline", 
  "show_code_actions": "", 
  "show_code_actions_in_hover": false, 
  "show_diagnostics_panel_on_save": 0, 
  "show_diagnostics_severity_level": 0, 
  "show_multiline_diagnostics_highlights": false, 
  "show_references_in_quick_panel": true
}

System PATH

  • d:\app\ImageMagick
  • C:\Program Files (x86)\Common Files\Oracle\Java\javapath
  • C:\Windows\system32
  • C:\Windows
  • C:\Windows\System32\Wbem
  • C:\Windows\System32\WindowsPowerShell\v1.0\
  • C:\Windows\System32\OpenSSH\
  • C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common
  • E:\app\nodejs\
  • e:\app\TDM-GCC-64\bin
  • E:\app\TortoiseSVN\bin
  • e:\app\Git\cmd
  • C:\Program Files\dotnet\
  • E:\app\Python\Python311\Scripts\
  • E:\app\Python\Python311\
  • C:\Users\sarper\AppData\Local\Programs\Python\Launcher\
  • C:\Users\sarper\AppData\Local\Microsoft\WindowsApps
  • e:\app\dev_tools_in_path
  • C:\Users\sarper.dotnet\tools
  • C:\Users\sarper\AppData\Roaming\npm
  • C:\Program Files\Mono\bin
  • E:\app\Unity\2021.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platform-tools\
  • E:\app\Git\usr\bin
  • E:\app\Unity\2021.3.8f1\Editor\Data\PlaybackEngines\AndroidPlayer\OpenJDK\jre\bin
  • C:\Users\sarper\AppData\Local\GitHubDesktop\bin

@rchl
Copy link
Member

rchl commented Dec 15, 2022

Thanks.
There was an issue with handling relative project paths in project file.
Fixing in #2142

@ssoher
Copy link
Author

ssoher commented Dec 15, 2022

Thank you, I've applied the changes in the commit #2142 but I'm still getting the same diagnostics listed. Did I change the correct source file at "C:\Users\sarper\AppData\Roaming\Sublime Text\Packages\LSP\plugin\core\windows.py"?

@rchl
Copy link
Member

rchl commented Dec 15, 2022

Yes, that should be the correct file. But you could try just checking out the PR branch since it's in the same repo.

I've also added some debug prints to that branch so you can try with that and post the results you get in the ST console.

@ssoher
Copy link
Author

ssoher commented Dec 15, 2022

This is what I get when I open the should-be-ignored file.

URI file:///e:/project/breakout/Library/PackageCache/com.unity.textmeshpro%403.0.6/Scripts/Editor/TMPro_FontAssetCreatorWindow.cs
PATTERNS ['**/.svn/**', '**/.git/**', '**/.hg/**', '**/CVS/**', '**/.Trash/**', '**/.Trash-*/**', '**/E:\\project\\breakout/.svn/**', '**/E:\\project\\breakout/**/.svn/**', '**/E:\\project\\breakout/Library/**', '**/E:\\project\\breakout/**/Library/**', '**/E:\\project\\breakout/Logs/**', '**/E:\\project\\breakout/**/Logs/**', '**/E:\\project\\breakout/obj/**', '**/E:\\project\\breakout/**/obj/**', '**/E:\\project\\breakout/Temp/**', '**/E:\\project\\breakout/**/Temp/**']

@ssoher
Copy link
Author

ssoher commented Dec 15, 2022

And this is the actual path in the os filesystem
"E:\project\breakout\Library\PackageCache\[email protected]\Scripts\Editor\TMPro_FontAssetCreatorWindow.cs"

@rchl
Copy link
Member

rchl commented Dec 15, 2022

Right. Then this needs more work to get it right on Windows.

@rchl
Copy link
Member

rchl commented Dec 15, 2022

I think the latest commit might work.

EDIT: Or maybe not. There might still be an extra leading / in the pattern that would mess things up...
Please post the result if you can though.

@ssoher
Copy link
Author

ssoher commented Dec 15, 2022

Sure, here is the log. Diagnostics still show up though.

PATH E:\project\breakout\Library\PackageCache\[email protected]\Scripts\Runtime\TMP_FontAsset.cs
PATTERNS ['**/.svn/**', '**/.git/**', '**/.hg/**', '**/CVS/**', '**/.Trash/**', '**/.Trash-*/**', '**/E:\\project\\breakout/.svn/**', '**/E:\\project\\breakout/**/.svn/**', '**/E:\\project\\breakout/Library/**', '**/E:\\project\\breakout/**/Library/**', '**/E:\\project\\breakout/Logs/**', '**/E:\\project\\breakout/**/Logs/**', '**/E:\\project\\breakout/obj/**', '**/E:\\project\\breakout/**/obj/**', '**/E:\\project\\breakout/Temp/**', '**/E:\\project\\breakout/**/Temp/**']

@rchl
Copy link
Member

rchl commented Dec 15, 2022

Thanks. So yes, needs more work to normalize paths to use forward slashes and handle situations with initial **/ part in the pattern that would also make it fail to match.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants