'Do not format' setting does not work with LSP
See original GitHub issueI’m trying to exclude my flutter repo from being auto-formatted. I added patterns for the directory as well as a single file flutter-dev/packages/flutter_tools/lib/src/commands/downgrade.dart
. Yet, saving that file still formats it.
To Reproduce Steps to reproduce the behavior:
- Add paths to ‘Do not format’ setting
- Save modified file
downgrade.dart
inside ‘flutter-dev’ folder
Expected behavior
downgrade.dart
is not formatted
Versions (please complete the following information):
- VS Code version: 1.60.2
- Dart extension version: 3.26.0
- Dart/Flutter SDK version: 2.6.0-12.0.pre.27, Dart version 2.15.0
settings.json
{
"[dart]": {
"editor.formatOnSave": true,
"editor.rulers": [
80
],
"editor.selectionHighlight": false,
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "first",
"editor.tabCompletion": "onlySnippets",
"editor.wordBasedSuggestions": false
},
"dart.doNotFormat": [
"**/development/flutter/**",
"**/development/flutter-dev/**",
"**/flutter-dev/**",
"*/downgrade.dart"
],
"workbench.sideBar.location": "right",
"workbench.colorTheme": "Material Theme Darker",
"workbench.iconTheme": "eq-material-theme-icons-darker",
"dart.debugExternalPackageLibraries": false,
"dart.debugSdkLibraries": false,
"git.autofetch": true,
"dart.hotReloadProgress": "statusBar",
"files.autoSave": "onFocusChange",
"explorer.confirmDragAndDrop": false,
"workbench.tree.indent": 16,
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
[LSP] Why does formatting not work for certain lsp's? - Reddit
Certain lsp's don't seem to format files using vim.lsp.buf.formatting() . For example, i've installed the html lsp using LspInstall html .
Read more >LSP formatting doesn't always work - Neovim Discourse
Formatting requests are pretty simple, I can't imagine that we are doing anything wrong client side if you are running a single, “true”...
Read more >emacs-lsp/lsp-mode - Gitter
I'm getting the flycheck-add-next-checker: lsp is not a valid syntax checker everytime I (require 'lsp-ui) ... your fix indeed solves it but I'm...
Read more >VSCode OCaml Platform - Visual Studio Marketplace
Note: File formatting is performed on the OCaml-LSP side, so OCaml-LSP may be the culprit in a formatting problem. Make sure, however, that...
Read more >Core - LSP Mode - LSP support for Emacs
Hooks to run after diagnostics are received. ... Do not use this setting unless you are familiar with lsp-mode internals and you are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The
doNotFormat
setting is not currently supported when using the LSP integration (which is the new default). The way it was implemented was a little awkward and if it’s still being used we should probably find a better way of handling it than just mirroring what we had into LSP.In the meantime, if there are specific projects you don’t want to format, you can use the VS Code Workspace Settings to disable format-on-save for just those specific workspaces (for example in my Flutter framework checkout, I have
"editor.formatOnSave": false
in the workspace settings so it never formats on save). If you use Git in VS Code, then using only format modified text may also reduce the formatting to only the lines you’re changing.Okey, closing this as as-intended for now. If there’s demand for disabling format-on-save for specific files we can try to get this via VS Code. Thanks!