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

html: Add support for autoclosing of tags #11761

Merged
merged 22 commits into from
May 20, 2024
Merged

Conversation

osiewicz
Copy link
Contributor

@osiewicz osiewicz commented May 13, 2024

Fixes #5267
TODO:

  • Publish our fork of vscode-langservers-extracted on GH and wire that through as a language server of choice for HTML extension.
  • Figure out how to prevent edits made by remote participants from moving the cursor of a host.

Release Notes:

  • Added support for autoclosing of HTML tags in local projects.

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label May 13, 2024
@osiewicz osiewicz changed the title HTML: Add support for HTML: Add support for autoclosing of tags May 13, 2024
@maxdeviant maxdeviant changed the title HTML: Add support for autoclosing of tags html: Add support for autoclosing of tags May 13, 2024
@@ -2,7 +2,7 @@ use std::{env, fs};
use zed_extension_api::{self as zed, Result};

const SERVER_PATH: &str =
"node_modules/vscode-langservers-extracted/bin/vscode-html-language-server";
"/Users/hiro/Projects/vscode-langservers-extracted/bin/vscode-html-language-server";

Choose a reason for hiding this comment

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

Hardcoded path here still? (Sorry if you were already aware of it.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No worries; yeah, this PR is still WIP

@osiewicz osiewicz marked this pull request as draft May 14, 2024 22:00
@BZBaXraM
Copy link

Add it!

@osiewicz osiewicz marked this pull request as ready for review May 20, 2024 13:28
@osiewicz
Copy link
Contributor Author

For the record, this is not gonna work for remote participants of a pairing session, though we should be able to make it so with a new RPC call.

@osiewicz osiewicz merged commit 0b8c168 into main May 20, 2024
8 checks passed
@osiewicz osiewicz deleted the workspace-edit-snippet-support branch May 20, 2024 15:00
@osiewicz
Copy link
Contributor Author

osiewicz commented May 20, 2024

Relevant repositories:

All of this should work outside of Zed. Note that I'm not a npm guru (far from it), so the way deps are wired through to make installing work via github might be a bit of an eyesore.
Tag autoclosing is gated behind a client capability on server side so the new implementation of LS is compatible with older Zed clients. I tested installation process manually on my machine; @bennetbo also paired with me to test it on his end as well.
I'm gonna release a new version of HTML extension. Snippet edits will kick in starting with next Preview on Wednesday.

osiewicz added a commit to zed-industries/extensions that referenced this pull request May 20, 2024
@JosephTLyons JosephTLyons mentioned this pull request May 20, 2024
1 task
@ThatOneCalculator
Copy link
Contributor

Does this also apply to Vue files?

@RemcoSmitsDev
Copy link
Contributor

RemcoSmitsDev commented May 20, 2024

Does this also apply to Vue files?

The Vue extension should add this to its config:

opt_into_language_servers = ["vscode-html-language-server", ...

@mariansimecek
Copy link

Hi, it seems there is a problem with autocompleting tags when it shouldn't. This is a TypeScript file:

Screenshot from 2024-05-21 10-14-19

@osiewicz
Copy link
Contributor Author

Thanks for reporting this @mariansimecek , I'll follow up shortly with a fix.

@mariansimecek
Copy link

@osiewicz I found another problem, now inside tsx file. It autocompletes tag when writing lambda function.
Screenshot from 2024-05-21 10-50-48
Screenshot from 2024-05-21 10-50-52

@osiewicz
Copy link
Contributor Author

Yeah, I think we should just roll back completions in TS/JS files for the time being. Bummer.

@osiewicz osiewicz mentioned this pull request May 21, 2024
osiewicz added a commit that referenced this pull request May 21, 2024
Add config for tag autoclosing: add following to lsp section of your
settings:
    "vscode-html-language-server": {
      "settings": {
        "html": { "tagAutoclosing": true }
      }
    }

It also accepts `css`, `js/ts` and `javascript` as options.

Disable HTML language server in JS/TS/TSX files for now. I decided to
disable it for now as it caused excessive edits in these types of files
(as reported by @mariansimecek in
#11761 (comment));
it looks like HTML language server tries to track language ranges (e.g.
whether a particular span is TS/HTML fragment etc) just like we do.
However in plain JS/TSX files it seems like it treats the whole file as
one big chunk of HTML, which is.. not right, to say the least.

No release note, as HTML extension goodies are not on Preview yet.

Release Notes:

- N/A
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla-signed The user has signed the Contributor License Agreement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JSX/HTML tag auto-close feature
6 participants