Skip to content
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

LSP formatting without calling the topiary binary #1526

Merged
merged 6 commits into from
Aug 11, 2023

Conversation

vkleen
Copy link
Member

@vkleen vkleen commented Aug 11, 2023

With this change formatting in the LSP uses topiary as a library instead of calling an external binary, just like the implementation of nickel format. The result is formatting capability in the LSP without any external dependencies enabled by default.

@github-actions github-actions bot temporarily deployed to pull request August 11, 2023 15:56 Inactive
(this is covered in the setup instructions).
[topiary](https://github.com/tweag/topiary). NLS exposes a formatting capability
when compiled with the `format` Cargo feature, which is enabled by default. No
configuration or external dependencies are necessary.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉

pub mod goto;
pub mod hover;
pub mod symbols;

#[cfg(feature = "format")]
pub mod formatting;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need a feature flag? I thought those were mainly for keeping the core cheaply embeddable, but it's fine if nls is big...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jneem has a point. While you could argue that more features just means more configurability, this does has cost in sprinkling #[cfg(feature = "format")] (and #[cfg(..)] is a quite rigid mechanism). I'm fine either way but it's a good question to ask if NLS without formatting is something that could be useful.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't really have a great argument for the feature flag. Let's just do without and see if someone complains; adding it back in shouldn't be too hard if that happens.

Copy link
Member

@yannham yannham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Testing this is also surprisingly straightforward. In general, at least until now, I feel like we have hit a sweet spot in our testing infrastructure: quite simple (TOML-based meta-comments) but still extensible and powerful enough.

lsp/nls/README.md Outdated Show resolved Hide resolved
pub mod goto;
pub mod hover;
pub mod symbols;

#[cfg(feature = "format")]
pub mod formatting;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jneem has a point. While you could argue that more features just means more configurability, this does has cost in sprinkling #[cfg(feature = "format")] (and #[cfg(..)] is a quite rigid mechanism). I'm fine either way but it's a good question to ask if NLS without formatting is something that could be useful.

@github-actions github-actions bot temporarily deployed to pull request August 11, 2023 16:50 Inactive
@github-actions github-actions bot temporarily deployed to pull request August 11, 2023 17:04 Inactive
@vkleen vkleen added this pull request to the merge queue Aug 11, 2023
Merged via the queue into master with commit bb410b8 Aug 11, 2023
5 checks passed
@vkleen vkleen deleted the feat/lsp-integrated-format branch August 11, 2023 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants