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

Introduce Dockerfile mode #2888

Closed
wants to merge 11 commits into from
Closed

Conversation

@parisk
Copy link
Contributor

@parisk parisk commented Oct 23, 2014

This pull request introduces syntax highlighting for Dockerfiles by utilizing the simple mode add-on.

Features

  • Instruction highlighting
  • Line comment highlighting
  • Inline comment highlighting
next: "remainder"
}
],
remainder: [

This comment has been minimized.

@marijnh

marijnh Oct 27, 2014
Member

This state looks like it mostly works, but does so by accident. Is the rest of the line after a command always the continuation of the command? What if a line comment starts immediately after a command word? You can include a rule without regex (always matches) that has next: "start" to also go back to start when nothing else matches, but then you might as well make your directive rule immediately consume the text after it (using groups and an array of token styles).

Can directives span multiple lines?

This comment has been minimized.

@parisk

parisk Oct 31, 2014
Author Contributor

What if a line comment starts immediately after a command word?

This is not valid syntax at the moment. All Dockerfile instructions should be followed by at least one argument, so no line comment can occur right after a Dockerfile instruction.

Can directives span multiple lines?

Yes. Directives can span multiple lines and I mistakenly did not take this into account. Right now I am working on it.

var instructions = ["from", "maintainer", "run", "cmd", "expose", "env",
"add", "copy", "entrypoint", "volume", "user",
"workdir", "onbuild"],
instructionsRegex = instructions.join('|');

This comment has been minimized.

@marijnh

marijnh Oct 27, 2014
Member

You probably want to add "(" and ")\b" here so that addiction and such (words that start with a directive keyword) don't match.

parisk added 3 commits Oct 31, 2014
Also make a little bit more strict the instruction pattern
- Add fail safe return to start into all states
- Properly match multi-line arguments
- Highlight instruction only if followed by white space character or end of line
@parisk
Copy link
Contributor Author

@parisk parisk commented Nov 9, 2014

Did anyone had the time to check out the my last 3 commits? I think it would be great if the Pull Request got included into 4.8.

(@marijnh)

marijnh added a commit that referenced this pull request Nov 11, 2014
Issue #2888
@marijnh
Copy link
Member

@marijnh marijnh commented Nov 11, 2014

Thanks! Merged as 0930f2b, and followed up by efbd453.

I don't get email when you push to a pull request branch -- so always follow up with a comment.

@marijnh marijnh closed this Nov 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.