sublimelsp / LSP-ruff

LSP helper for ruff - an extremely fast Python linter, written in Rust.
https://packagecontrol.io/packages/LSP-ruff
MIT License
35 stars 4 forks source link

2.0.0 seems to ignore "configuration" setting key #66

Closed munkybutt closed 3 months ago

munkybutt commented 3 months ago

Hey - with the latest update I have migrated across to the new settings but it seems like my "ruff.toml" file is ignored. I noticed my imports were no longer being sorted according to my isort rules and the behaviour remains the same if the "configuration" key is commented out or not. These are my settings:

{
    "initializationOptions": {
        "globalSettings": {
                        "configuration": "D:/p4/tools/dcc_tools/mg_tools/.projects/ruff.toml",
            "showNotification": "on",
            "organizeImports": true,
            "fixAll": true,
        },
    }
}

To confirm, the ruff.toml path does exist and it was working with the previous lsp-ruff version yesterday.

This is the contents of my ruff.toml

# Exclude a variety of commonly ignored directories.
exclude = [
    ".bzr",
    ".direnv",
    ".eggs",
    ".git",
    ".git-rewrite",
    ".hg",
    ".ipynb_checkpoints",
    ".mypy_cache",
    ".nox",
    ".pants.d",
    ".pyi",
    ".pyenv",
    ".pytest_cache",
    ".pytype",
    ".ruff_cache",
    ".svn",
    ".tox",
    ".venv",
    ".vscode",
    "__pypackages__",
    "_build",
    "buck-out",
    "build",
    "dist",
    "node_modules",
    "site-packages",
    "venv",
]

# Same as Black.
line-length = 100
indent-width = 4

# Assume Python 3.10
target-version = "py310"

[lint]
select = ["E", "F", "I"]
ignore = []

# Allow fix for all enabled rules (when `--fix`) is provided.
fixable = ["ALL"]
unfixable = []

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

[lint.isort]
combine-as-imports = false
force-single-line = true
lines-between-types = 1
no-sections = true
required-imports = ["from __future__ import annotations"]

[format]
# Like Black, use double quotes for strings.
quote-style = "double"

# Like Black, indent with spaces, rather than tabs.
indent-style = "space"

# Like Black, respect magic trailing commas.
skip-magic-trailing-comma = false

# Like Black, automatically detect the appropriate line ending.
line-ending = "auto"

# Enable auto-formatting of code examples in docstrings. Markdown,
# reStructuredText code/literal blocks and doctests are all supported.
#
# This is currently disabled by default, but it is planned for this
# to be opt-out in the future.
docstring-code-format = true

# Set the line length limit used when formatting code snippets in
# docstrings.
#
# This only has an effect when the `docstring-code-format` setting is
# enabled.
docstring-code-line-length = "dynamic"

Any help would be appreciated

munkybutt commented 3 months ago

I just noticed that when I open my lsp-ruff.sublime-settings file this is printed to the console: Unable to open /C/Users/Shea.Richardson/AppData/Roaming/Sublime Text/Packages/LSP-ruff/LSP-ruff.sublime-settings

LDAP commented 3 months ago

@jfcherng

jfcherng commented 3 months ago

I just noticed that when I open my lsp-ruff.sublime-settings file this is printed to the console: Unable to open /C/Users/Shea.Richardson/AppData/Roaming/Sublime Text/Packages/LSP-ruff/LSP-ruff.sublime-settings

did you try to restart ST?

munkybutt commented 3 months ago

yes - restart ruff from command panel, restart ST. I have yet to uninstall/re-install lsp-ruff. I shall try that

munkybutt commented 3 months ago

Still the same after a re-install :(

munkybutt commented 3 months ago

The settings must be found as this prints when I save them: reloading settings Packages/User/LSP-ruff.sublime-settings

rchl commented 3 months ago

Can you show the output of LSP: Troubleshoot server? It shows effective settings that are used.

rchl commented 3 months ago

But if you are getting a message like Unable to open /C/Users/Shea.Richardson/AppData/Roaming/Sublime Text/Packages/LSP-ruff/LSP-ruff.sublime-settings then it means that the initializationOptions that you provided in your initial message are not saved in the correct file. In which files did you set those?

munkybutt commented 3 months ago

Here is the output of LSP: Troublshoot server

Troubleshooting: LSP-ruff

Version

## Server Configuration
 - command
```json
[
  "$server_path",
  "server"
]

Active view

Project / Workspace

LSP configuration

{
  "diagnostics_additional_delay_auto_complete_ms": 0,
  "diagnostics_delay_ms": 0,
  "diagnostics_gutter_marker": "dot",
  "diagnostics_highlight_style": {
    "error": "squiggly",
    "hint": "underline",
    "info": "underline",
    "warning": "squiggly"
  },
  "diagnostics_panel_include_severity_level": 4,
  "document_highlight_style": "underline",
  "inhibit_snippet_completions": false,
  "inhibit_word_completions": true,
  "log_debug": false,
  "log_max_size": 8192,
  "log_server": [],
  "lsp_code_actions_on_save": {
    "source.organizeImports": true
  },
  "lsp_format_on_save": false,
  "on_save_task_timeout_ms": 2000,
  "popup_max_characters_height": 1250,
  "popup_max_characters_width": 100,
  "semantic_highlighting": false,
  "show_code_actions": "annotation",
  "show_code_actions_in_hover": true,
  "show_code_lens": "annotation",
  "show_diagnostics_count_in_view_status": false,
  "show_diagnostics_in_view_status": true,
  "show_diagnostics_panel_on_save": 0,
  "show_diagnostics_severity_level": 4,
  "show_multiline_diagnostics_highlights": true,
  "show_references_in_quick_panel": false,
  "show_symbol_action_links": true,
  "show_view_status": true
}

System PATH

munkybutt commented 3 months ago

And I save the settings to the file that is opened using the ST menu: image Which is: C:\Users\Shea.Richardson\AppData\Roaming\Sublime Text\Packages\User\LSP-ruff.sublime-settings When the settings window opens is when the error prints that the file that has just been opened cannot be found 😕

jfcherng commented 3 months ago

Do you likely have your own custom override in Package/

And I save the settings to the file that is opened using the ST menu: image Which is: C:\Users\Shea.Richardson\AppData\Roaming\Sublime Text\Packages\User\LSP-ruff.sublime-settings When the settings window opens is when the error prints that the file that has just been opened cannot be found 😕

So when you clike the menu item in your screenshot, the left pane is empty?

jfcherng commented 3 months ago

Huh wait, I see Unable to open /C/Users/jfcherng/AppData/Roaming/Sublime Text/Packages/LSP-ruff/LSP-ruff.sublime-settings in my console too.

jfcherng commented 3 months ago

Huh wait, I see Unable to open /C/Users/jfcherng/AppData/Roaming/Sublime Text/Packages/LSP-ruff/LSP-ruff.sublime-settings in my console too.

I think this is a ST bug. It happens for every plugin when open settings with side-by-side layout.

munkybutt commented 3 months ago

ah ok so red herring heh

munkybutt commented 3 months ago

Do you likely have your own custom override in Package/

And I save the settings to the file that is opened using the ST menu: image Which is: C:\Users\Shea.Richardson\AppData\Roaming\Sublime Text\Packages\User\LSP-ruff.sublime-settings When the settings window opens is when the error prints that the file that has just been opened cannot be found 😕

So when you clike the menu item in your screenshot, the left pane is empty?

No override in packages image

jfcherng commented 3 months ago

But that shouldn't matter. I am now trying to check how ruff server uses initializationOptions but I can't find any document about that.

munkybutt commented 3 months ago

initializationOptions worked prior to v2.0.0

jfcherng commented 3 months ago

what if you move everything in globalSettings into settings?

rchl commented 3 months ago

Based on neovim configuration examples in https://docs.astral.sh/ruff/editors/settings/#__tabbed_1_2 it should be:

{
    "initializationOptions": {
        "settings": {
            "configuration": "D:/p4/tools/dcc_tools/mg_tools/.projects/ruff.toml",
            "showNotification": "on",
            "organizeImports": true,
            "fixAll": true,
        },
    }
}
rchl commented 3 months ago

And options like showNotifications might not do anything for us. This is marked as VSCode specific.

jfcherng commented 3 months ago

I can't find any source about "globalSettings". If "settings" works, we can just move to it.

munkybutt commented 3 months ago

what if you move everything in globalSettings into settings?

this seems to have done the trick - tyty!