-
Notifications
You must be signed in to change notification settings - Fork 5
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
Propagate air.toml settings to client #160
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems to work pretty well in practice. I mostly have a number of naming questions and an aversion to sending all of Settings
over to the client right now
crates/lsp/src/notifications.rs
Outdated
use crate::{main_loop::LspState, workspaces::WorkspaceSettings}; | ||
|
||
#[derive(serde::Serialize, serde::Deserialize)] | ||
struct SettingsNotifications { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
struct SettingsNotifications { | |
struct DidChangeFileSettings { |
I would love if we could use names that feel like "real" LSP notifications
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm... But we send this notification in did_open
as well, not necessarily when a toml changed.
How about air/syncFileSettings
? It seems like we do need a new prefix here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We agreed air/syncFileSettings
is great 👍
editors/code/src/settings.ts
Outdated
if (file.startsWith("file:///")) { | ||
file = url.fileURLToPath(file); | ||
} | ||
return path.normalize(file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe if indent_style === "space"
we also set tabSize
? That keeps them in sync, but still allows for user customizable tab size when indent_style = "tab"
Interestingly if you have a tabSize = 4
but indentSize = 2
and actually format with tabs, VS Code does show you a little vertical line at the 2 space marker, even though the tab has a visual size of 4 (i.e. it visually shows you the info for indentSize
)
![Screenshot 2025-01-15 at 1 02 55 PM](https://private-user-images.githubusercontent.com/19150088/403533587-04f34134-26b7-473a-9e28-e927e1921cc0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MDIxMzMsIm5iZiI6MTczOTQwMTgzMywicGF0aCI6Ii8xOTE1MDA4OC80MDM1MzM1ODctMDRmMzQxMzQtMjZiNy00NzNhLTllMjgtZTkyN2UxOTIxY2MwLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDIzMTAzM1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWM0NzgwOGY1Njg0NWEyZjZkNTZjMmQ0Y2RlYWViM2M2OTdiYWVmYTA3YmNlMjNjMzAzYmNkNDQ2OWIzYTdjMjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0._jg_LcawRHbNYDjWfJ31hLTkrsecVjPhy-4n0uMferQ)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wondered what's the right thing to do here. If we keep them in sync, we're working against an explicit VS Code feature, namely that you can set tabSize
to be different than indentSize
when insertSpaces
is true, so that you can use tabs to format tables. You could imagine tabSize
be set in a settings.json file. And the tables would be protected by air: ignore
comments.
We can just not support this. According to threads in the vscode repo it's mostly needed for old corporate codebases. I'd be surprised to see R users miss this feature.
And then we avoid the strange mismatch in the status bar that I agree is confusing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm happy to not support this edge case
74ef0bc
to
1262215
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check out #173 first and see if you agree. I've been keeping the serde derives minimal so far with these types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really loving everything in one file!
I don't disagree but I can't promise they won't creep back in over the course of a PR that changes direction in terms of serde requirements... I don't think such derivations on non-generated types bloat the binary that much? I agree that it's nice to avoid implying a type crosses an interop boundary though. |
Co-authored-by: Davis Vaughan <[email protected]>
Co-authored-by: Davis Vaughan <[email protected]>
de0d6d2
to
884f555
Compare
Closes #160.
Controlled by
air.settingsBackpropagation
. Uses the same approach as the editorconfig extension: when the active editor changes we apply the air.toml settings to the active editor.We send custom
tomlSettings
LSP notifications to the client:The client maintains a map of settings. Ideally we wouldn't have to do that but in practice we need to because invisible editors can't have their settings changed. So instead of changing the settings when the notification arrives, we change it when the active editor changes.
Unlike editorconfig, we change
indentSize
rather thantabSize
. This is for consistency with the principle thattabSize
is a user preference setting. Note that it seems some VS Code feature such as move line up are not affected byindentSize
and instead usetabSize
. There might be other bugs of this kind, which could explain why editorconfig decided to changetabSize
.