sublimelsp / LSP-css

CSS, SCSS, LESS support for Sublime's LSP plugin
MIT License
37 stars 0 forks source link

Settings ignored #43

Open psydvl opened 2 years ago

psydvl commented 2 years ago

I've just install LSP-css And there is fully ignorance of settings change Code keeps formatting Newline keeps creating

LSP-css.sublime-settings content ``` json { "settings": { "css.format.enable": false, "scss.format.enable": false, "less.format.enable": false, "css.format.newlineBetweenRules": false, "css.format.newlineBetweenSelectors": false, } } ```
Troubleshooting page # Troubleshooting: LSP-css ## Version - LSP: 1.18.0 - Sublime Text: 4126 ## Server Test Run - exit code: 0 - output ``` ``` ## Server Configuration - command ```json [ "${node_bin}", "${server_path}", "--stdio" ] ``` - shell command ```sh /usr/bin/node "/home/nixi/.cache/sublime-text/Package Storage/LSP-css/16.17.0/language-server/css-language-features/server/out/node/cssServerMain.js" --stdio ``` - selector ``` source.css | source.scss | source.less ``` - priority_selector ``` (source.css)|(source.scss)|(source.less) ``` - init_options ```json { "provideFormatter": true } ``` - settings ```json { "css": { "completion": { "completePropertyWithSemicolon": true, "triggerPropertyValueCompletion": true }, "customData": [], "format": { "braceStyle": "collapse", "enable": false, "maxPreserveNewLines": null, "newlineBetweenRules": false, "newlineBetweenSelectors": false, "preserveNewLines": true, "spaceAroundSelectorSeparator": false }, "hover": { "documentation": true, "references": true }, "lint": { "argumentsInColorFunction": "error", "boxModel": "ignore", "compatibleVendorPrefixes": "ignore", "duplicateProperties": "ignore", "emptyRules": "warning", "float": "ignore", "fontFaceProperties": "warning", "hexColorLength": "error", "idSelector": "ignore", "ieHack": "ignore", "importStatement": "ignore", "important": "ignore", "propertyIgnoredDueToDisplay": "warning", "universalSelector": "ignore", "unknownAtRules": "warning", "unknownProperties": "warning", "unknownVendorSpecificProperties": "ignore", "validProperties": [], "vendorPrefix": "warning", "zeroUnits": "ignore" }, "trace": { "server": "off" }, "validate": true }, "less": { "completion": { "completePropertyWithSemicolon": true, "triggerPropertyValueCompletion": true }, "format": { "braceStyle": "collapse", "enable": true, "maxPreserveNewLines": null, "newlineBetweenRules": true, "newlineBetweenSelectors": true, "preserveNewLines": true, "spaceAroundSelectorSeparator": false }, "hover": { "documentation": true, "references": true }, "lint": { "argumentsInColorFunction": "error", "boxModel": "ignore", "compatibleVendorPrefixes": "ignore", "duplicateProperties": "ignore", "emptyRules": "warning", "float": "ignore", "fontFaceProperties": "warning", "hexColorLength": "error", "idSelector": "ignore", "ieHack": "ignore", "importStatement": "ignore", "important": "ignore", "propertyIgnoredDueToDisplay": "warning", "universalSelector": "ignore", "unknownAtRules": "warning", "unknownProperties": "warning", "unknownVendorSpecificProperties": "ignore", "validProperties": [], "vendorPrefix": "warning", "zeroUnits": "ignore" }, "validate": true }, "scss": { "completion": { "completePropertyWithSemicolon": true, "triggerPropertyValueCompletion": true }, "format": { "braceStyle": "collapse", "enable": true, "maxPreserveNewLines": null, "newlineBetweenRules": true, "newlineBetweenSelectors": true, "preserveNewLines": true, "spaceAroundSelectorSeparator": false }, "hover": { "documentation": true, "references": true }, "lint": { "argumentsInColorFunction": "error", "boxModel": "ignore", "compatibleVendorPrefixes": "ignore", "duplicateProperties": "ignore", "emptyRules": "warning", "float": "ignore", "fontFaceProperties": "warning", "hexColorLength": "error", "idSelector": "ignore", "ieHack": "ignore", "importStatement": "ignore", "important": "ignore", "propertyIgnoredDueToDisplay": "warning", "universalSelector": "ignore", "unknownAtRules": "warning", "unknownProperties": "warning", "unknownVendorSpecificProperties": "ignore", "validProperties": [], "vendorPrefix": "warning", "zeroUnits": "ignore" }, "validate": true } } ``` - env ```json { "PATH": "/usr/bin:/usr/bin:" } ``` ## Active view - File name ``` /home/nixi/work/Projects/Playground/012/index.css ``` - Settings ```json { "auto_complete_selector": "meta.tag, source - comment - string.quoted.double.block - string.quoted.single.block - string.unquoted.heredoc", "lsp_active": true, "syntax": "Packages/CSS/CSS.sublime-syntax" } ``` - base scope ``` source.css ``` ## Project / Workspace - folders ```json [ "/home/nixi/work/Projects/Playground", "/home/nixi/work/Projects/Playground/00f", "/home/nixi/work/Projects/Playground/012" ] ``` - is project: True - project data: ```json { "folders": [ { "path": "/home/nixi/work/Projects/Playground" }, { "path": "/home/nixi/work/Projects/Playground/00f" }, { "path": "/home/nixi/work/Projects/Playground/012" } ], "settings": { "LSP": { "gopls": { "enabled": true } } } } ``` ## LSP configuration ```json { "clients": { "gopls": { "env": { "PATH": "/home/nixi/go/bin" } } }, "inhibit_snippet_completions": true, "inhibit_word_completions": true, "log_debug": true, "show_references_in_quick_panel": true } ``` ## System PATH - /home/nixi/go/bin - /home/nixi/miniconda3/condabin - /home/nixi/.nix-profile/bin - /nix/var/nix/profiles/default/bin - /home/nixi/.local/bin - /usr/local/bin - /usr/bin - /bin
jfcherng commented 2 years ago

I can confirm that with "css.format.enable": false,, the server still responses to lsp format selection/document.


Given https://github.com/microsoft/vscode/blob/d9fd208c2958d37b88834fbb674a3c6761360052/extensions/css-language-features/package.json#L311 and https://github.com/microsoft/vscode/issues/145763, the correct setting is indeed "css.format.enable". In that case, I don't think it's an issue of LSP-css.

jfcherng commented 2 years ago

As a workaround (?), you can set provideFormatter in initializationOptions to false.

rchl commented 2 years ago

[languageId].format.* seem to be handled on the extension side in VSCode and provideFormatter appears to be the option to use otherwise. Of course that doesn't help with respecting settings for the formatting options.

This would have to implemented in the package to work properly.

psydvl commented 2 years ago

provideFormatter disable all formatting at all, otherwise, [languageId].format.enable should allow enabling only some formatters. However, I've added this option only to check that it's not working at all

jfcherng commented 2 years ago

I have following "assumptions" in my mind so that I don't think there is a solution.

  1. This issue could be bothering only (?) if it's done auto when saving a file.
  2. lsp_format_on_save checks server capabilities like formatting': {'dynamicRegistration': True}, 'rangeFormatting': {'dynamicRegistration': True}, which is depending on provideFormatter.
  3. You cannot change provideFormatter, which is in initializationOptions, after the server has been initialized.
  4. There will be only exact one (shared) session in a ST window. That means the formatting capability is either enabled for all (css/less/sass) or for none in a ST window.

Disclaimer: I didn't check LSP's source codes. Correct me if I am wrong.

psydvl commented 2 years ago

@jfcherng

  1. This issue caused by ignorance of all at least formatting options: even if you manually format file, it will not be used

2-4 Let's use LSP as LSP extension itself, client extension as LSP server extension (in our case LSP-css), server as language server provideFormatter - option to LSP. It sets should LSP expect formatter logic from client extension or not
Otherwise, "settings" block (I'm not sure about this part) a. if set in client extension, sent by it (because it's extension .sublime-settings file) to LSP then applied to workspace LSP settings (Server configuration settings in attached Troubleshooting) b. if set in LSP "setting" or project "settings" just applied to workspace LSP settings Then those settings LSP are sent to server via language server protocol And can be changed without server restart https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#workspace_didChangeConfiguration (but probably LSP restart server if LSP-css .sublime-settings file is changed)

So, provideFormatter not depend on server at all, it only says to LSP, that we don't load anything formatter specific from extension Workspace "settings" associated settings can be changed without server restart And we can set formatting enable only for few files, providing something else (like linting or hover documentation) from others

However, issue caused by LSP not send info to server or doing this wrong way And while those options works in VS Code there are some problems in this extension

I apologize if this is written in too much of a rambling way

rchl commented 2 years ago

VSCode uses extension functionality to toggle formatting capabilities. This is not a standard LSP thing so it's not easily applicable to ST.

The server itself could toggle formatting capability dynamically but that particular one doesn't implement that.

So then there is also an option for ST LSP to toggle formatting on the client side (which coincidentally is in review at https://github.com/sublimelsp/LSP/pull/2033) and use that API from a plugin. But we're some way away from that still...

psydvl commented 2 years ago

But what about applying those settings after restart server manually, for example with restarting ST Or set options on launch unavailable too?

That mostly why I've start this issue: I want to set this options even if I need to restart ST

jfcherng commented 2 years ago

That's not an acceptable implementation imo. As for a personal workaround, you do whatever you want.

That makes no difference with that when you need formatting, set provideFormatter to true and restart the server. And when you don't need it, set it to false and restart the server. In that case, it's already working now.