Comments (8)
It's also conceivable that the "format on save" option could be enabled in a per-project
This is not only conceivable, but already possible:
Lines 14 to 16 in 8696a5d
For this you need to use the Sublime Text project feature, i.e. save a *.sublime-project
file (Project / Save Project As... from the menu) and edit the "settings"
section in that project file.
A "smart" option for this setting might be a bit tricky to implement (but not impossible); it would first need to signalize that to the LSP-* helper plugin if applicable, which would then need to implement the logic to read from pyproject.toml
whether the project is configured for ruff formatting, and pass the result back to LSP.
from lsp.
It's also conceivable that the "format on save" option could be enabled in a per-project
This is not only conceivable, but already possible:
Indeed, I've tested and I'm able to disable "format on save" in projects where I don't want it or enable it in projects where I do. I don't believe this solution is the right one, though, because it requires additional per-project configuration that's specific to my development workflow (using Sublime Text) and configuration (LSP plus lsp-ruff plus "format on save" enabled by default). As an example, I'm guessing the Python project wouldn't want me adding a cpython.sublime-settings
to the project just to disable the behavior. And I'd like to avoid adding it to the 100+ projects I maintain where I want the setting enabled. I'm not complaining; just sharing my experience.
from lsp.
Can't this be a server setting like "ruff.smartAutoFormat" and let lsp-ruff (the server) figure it out?
from lsp.
For this you need to use the Sublime Text project feature, i.e. save a
*.sublime-project
file (Project / Save Project As... from the menu) and edit the"settings"
section in that project file.
I've found it's not sufficient to create such a project file. It does work for that current session, but if one exits SublimeText and then re-opens it on that folder (e.g. subl .
), the project file is not opened and the setting has no effect. One has to additionally change their workflow to open the project file when working on that project (i.e. subl *.sublime-project
). That's rather inconvenient and clunky to have to rewire my brain for each affected project.
from lsp.
ctrl+shift+p is the default shortcut that opens a project selector that shows the list of projects that were saved. This is how you are really supposed to interact with the projects.
from lsp.
Today I encountered another case where having a .sublime-project is unhelpful. I was editing a specific file (e.g. subl ~/.local/bin/hg
) and I was making some changes to it, but ruff's formatting was actually corrupting the intended syntax (replacing '''
with """
where '''
is needed). Again I needed a way to temporarily disable the save-on-format. Is there a way to configure a hot key or action that would disable format-on-save for the current session?
from lsp.
ctrl+shift+p is the default shortcut that opens a project selector that shows the list of projects that were saved. This is how you are really supposed to interact with the projects.
This didn't work for me, but I think on Mac, the hotkey is Ctrl+Cmd+p. I do get a project switcher there. This approach still doesn't suit the workflow very well as it requires having an open session and replacing the current session with a different one... and even I'm already working on that project and I realize the settings aren't loaded, using the quick project switcher causes the current tabs to be closed. It's the wrong workaround for the problem I'm facing.
from lsp.
Is there a way to configure a hot key or action that would disable format-on-save for the current session?
Currently there is no dynamic toggle for that setting, but you could create a custom command to toggle it globally (and add a key binding for it):
import sublime
import sublime_plugin
class ToggleLspSettingCommand(sublime_plugin.ApplicationCommand):
def run(self, setting_name='lsp_format_on_paste'):
lsp_settings = sublime.load_settings('LSP.sublime-settings')
value = lsp_settings.get(setting_name)
if not isinstance(value, bool):
raise ValueError(setting_name + 'is not boolean')
lsp_settings.set(setting_name, not value)
sublime.save_settings('LSP.sublime-settings')
If/when #2448 gets merged, it should work without the server(s) being restarted.
from lsp.
Related Issues (20)
- [Runtime Error] ModuleNotFoundError: No module named 'wcmatch' HOT 1
- Investigate why didSave notification is not sent if view closed immediately after saving
- Two alternative hover definitions provided: one on mouseover, the other upon keyboard shortcut HOT 6
- Not Working After 3.8 Upgrade HOT 3
- Discuss removal of some APIs HOT 3
- Allow LSP packages to customize format_completion HOT 1
- Support list of commands, provided by language servers HOT 5
- Syntax highlighting in popups, returned by 3rd party language server, not work HOT 10
- Package is not installable HOT 5
- MissingUriError: View has no URI HOT 1
- `websocket_server` installs a root logger
- Cannot install LSP on clean installation HOT 15
- Updated to LSP 2.1.0 leads to FileNotFoundError and no LSP HOT 6
- `lsp_code_actions_on_save` do not work intermittently HOT 8
- KeyError on file-watcher HOT 2
- Replace `Enum` object with it's scalar value in the LSP log panel? HOT 1
- Text selection in popups HOT 2
- Unable to open URI
- Provide `Transport` as parameter when invoking `plugin.on_post_start` HOT 8
- Allow `AbstractPlugin` to handle `window/logMessage` notification HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lsp.