Add support for Puppet#435
Conversation
|
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
|
I signed it! |
|
CLAs look good, thanks! |
| ], | ||
| [ | ||
| // Matching keywords | ||
| [PR['PR_KEYWORD'], /^(?:case|class|default|define|else|elsif|false|if|inherits|node|unless|undef|true)\b/, null], |
There was a problem hiding this comment.
There are additional keywords - here are all the current keywords.
KEYWORDS = {
'case' => [:CASE, 'case', 4],
'class' => [:CLASS, 'class', 5],
'default' => [:DEFAULT, 'default', 7],
'define' => [:DEFINE, 'define', 6],
'if' => [:IF, 'if', 2],
'elsif' => [:ELSIF, 'elsif', 5],
'else' => [:ELSE, 'else', 4],
'inherits' => [:INHERITS, 'inherits', 8],
'node' => [:NODE, 'node', 4],
'and' => [:AND, 'and', 3],
'or' => [:OR, 'or', 2],
'undef' => [:UNDEF, 'undef', 5],
'false' => [:BOOLEAN, false, 5],
'true' => [:BOOLEAN, true, 4],
'in' => [:IN, 'in', 2],
'unless' => [:UNLESS, 'unless', 6],
'function' => [:FUNCTION, 'function', 8],
'type' => [:TYPE, 'type', 4],
'attr' => [:ATTR, 'attr', 4],
'private' => [:PRIVATE, 'private', 7],
}
APP_MANAGEMENT_KEYWORDS = {
:with_appm => {
'application' => [:APPLICATION, 'application', 11],
'consumes' => [:CONSUMES, 'consumes', 8],
'produces' => [:PRODUCES, 'produces', 8],
'site' => [:SITE, 'site', 4]
},
|
I would much rather see a highlighter that is correct in what it highlights and leaves the rest plain than something that is more of a guess that will be wrong a lot of the time. Happy to collaborate and contribute but it needs to start from solid ground. Puppet is quite complex to lex correctly. The real lexer is here: https://github.com/puppetlabs/puppet/blob/master/lib/puppet/pops/parser/lexer2.rb |
|
Thanks @hlindberg for your feedback. I don't have the time to implement all these :( at lease not alone. True that Puppet is quite complex to lex on all cases but based on my experience most people don't use all the syntax options that are available (amen to that!) Likely, some of those will even be discontinued, so does it really worth the trouble? On a similar example, there are some puppet-linter plugins that report "broken code" on some edge cases (which are 100% syntactically correct). Still, that does not render the plugin useless simply because most people are not using those edge cases. What do you think is a good compromise solution? Extending the list of keywords and add support for C-style multiline comments should be trivial. Others might take a bit longer and still not cover all cases. |
|
@jorgemorgado People do use syntax highlighters to document and publish articles about the puppet language ;-). Some constructs are naturally more common than others, but you will see many of the new additions in puppet 4.x gradually being used more. I think it is far better if a highlighter is missing a highlight than if it highlights the wrong way. A good set to start with are the basic tokens (comments, strings (single and double quoted with interpolation), numbers, regexp, names (lower case bare words), types (upper case bare words), variables, and keywords). Then there is only the tricky heredoc left to deal with of the lexical constructs. At present there are no lexical constructs in puppet that are slated for deprecation. There are some under discussion but removal of those, should such decisions be made, are years away. Thus, in terms of changes to this PR, I think it is mostly a matter of removing the highlighting rules that will not work well. |
No description provided.