zed icon indicating copy to clipboard operation
zed copied to clipboard

Add syntax highlighting and LSP for Dockerfiles

Open everettraven opened this issue 1 year ago • 9 comments

Looks like it could resolve #5311 ? I haven't messed with any docker-compose stuff but seeing as that is YAML based and there is already YAML support this should address the Dockerfile syntax highlighting and LSP support.

I'm also a Rust newbie so if there is anything that looks off please do let me know!

A screenshot showing syntax highlighting when running via cargo run: Screenshot 2024-01-27 at 8 28 25 PM

Release Notes:

  • Added syntax highlighting and LSP for Dockerfiles

everettraven avatar Jan 28 '24 01:01 everettraven

We require contributors to sign our Contributor License Agreement, and we don't have @everettraven on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

cla-bot[bot] avatar Jan 28 '24 01:01 cla-bot[bot]

@cla-bot check

everettraven avatar Jan 28 '24 01:01 everettraven

The cla-bot has been summoned, and re-checked this pull request!

cla-bot[bot] avatar Jan 28 '24 01:01 cla-bot[bot]

Awesome, but I noticed that the syntax after PREFIX(run. etc) doesn't seem to be highlighted, I'm very impressed by the vscode plug-in, can you help me take a look: https://marketplace.visualstudio.com/items?itemName=jeff-hykin.better-dockerfile-syntax image

d1y avatar Jan 28 '24 02:01 d1y

This looks close to be done, so it would be great to add a new docs entry to the https://github.com/zed-industries/zed/tree/main/docs/src/languages list before merging.

SomeoneToIgnore avatar Jan 29 '24 11:01 SomeoneToIgnore

Awesome, but I noticed that the syntax after PREFIX(run. etc) doesn't seem to be highlighted, I'm very impressed by the vscode plug-in, can you help me take a look: https://marketplace.visualstudio.com/items?itemName=jeff-hykin.better-dockerfile-syntax image

@d1y I updated the tree-sitter highlighting to get as close to this as I could. The new highlighting looks like this: Screenshot 2024-01-29 at 9 32 04 AM

There is variable expansion highlighting where possible but there are some limitations as the tree-sitter-dockerfile crate doesn't currently have support for expansion in certain instructions (one is the RUN instruction) and no shell command syntax highlighting (it was either the whole shell command is highlighted or none, although this limitation could be due to me being more novice in messing with this tooling). That being said, I think this PR is "good enough" as is regarding the syntax highlighting and it could be incrementally improved in the future.

everettraven avatar Jan 29 '24 14:01 everettraven

This looks close to be done, so it would be great to add a new docs entry to the https://github.com/zed-industries/zed/tree/main/docs/src/languages list before merging.

@SomeoneToIgnore Thanks for pointing that out! Rebased and added!

everettraven avatar Jan 29 '24 14:01 everettraven

@maxdeviant @SomeoneToIgnore Anything else needed to get this merged?

everettraven avatar Feb 01 '24 01:02 everettraven

This needs a rebase, but otherwise I see no blocking issues, the comments are welcome to be fixed in follow-up PRs.

SomeoneToIgnore avatar Feb 01 '24 12:02 SomeoneToIgnore

Do you have any further questions about this PR? Can we merge? I really need this

d1y avatar Feb 18 '24 01:02 d1y

Can we merge?

Would be nice, but GH does not allow this for the PRs with conflicts. Neither can I push into the branch, so one small step has to be done by somebody.

https://github.com/zed-industries/zed/pull/6905#issuecomment-1921258868

image

SomeoneToIgnore avatar Feb 18 '24 05:02 SomeoneToIgnore

https://github.com/zed-industries/zed/pull/7977 made that happen thanks to @d1y , hence closing this stale one.

SomeoneToIgnore avatar Feb 18 '24 18:02 SomeoneToIgnore

@d1y Thanks for taking this over! I had some stuff come up and wasn't able to circle back around to address the comments/conflicts :(. Awesome to see this work get in!

everettraven avatar Feb 19 '24 14:02 everettraven