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

Puppet Support #6412

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

gautamprikshit1
Copy link

Fixes #6073
@jficz will you please test this?

Comment on lines +1 to +49
(function) @function
(variable) @variable
[
(identifier)
] @identifier

[
"class"
"define"
"plan"
"node"
"type"
] @keyword

[
"contain"
"include"
"inherits"
"require"
] @include

[
"case"
"else"
"elsif"
"if"
"unless"
] @conditional

(string) @string
(regex) @regex
(integer) @number
(float) @float
(regex) @string.regex
(comment) @comment
[(true) (false)] @boolean

(unprotected_string) @text

[
(chaining_arrow)
(operator)
] @operator


(interpolation
"${" @punctuation.special
"}" @punctuation.special) @none

Copy link
Member

Choose a reason for hiding this comment

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

Comment on lines +2374 to +2379
scope = "source.puppet"
injection-regex = "puppet"
file-types = ["puppet"]
roots = []
indent = { tab_width = 2, unit = " " }
comment-token = "#"
Copy link
Contributor

@erasin erasin Mar 25, 2023

Choose a reason for hiding this comment

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

file-types = ["pp"]
indent = { tab-width = 2, unit = " " }

there has tip: https://github.com/neovim-puppet/tree-sitter-puppet/tree/main/test/highlight

@jficz The file type here will conflict with pascal, can be overridden by custom languages.toml reconfiguration.

Copy link

@jficz jficz Mar 26, 2023

Choose a reason for hiding this comment

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

I would actually argue that it is Pascal (or, specifically, FreePascal's need to be different) which is in conflict with Puppet here. Historically and practically, .pas is the recognized Pascal extension. .pp is just a vendor-specific variant which doesn't really have a rational reason to exist in the first place and therefore it should be the other way around, that is. .pp for (Free)Pascal files should be overridden by custom language.toml if needed.

Some high-profile Pascal IDEs and variants don't even recognize .pp as Pascal files as far as I know while for Puppet, .pp is universally recognized.

@erasin
Copy link
Contributor

erasin commented Mar 25, 2023

I sort out the hightlights, check https://github.com/neovim-puppet/tree-sitter-puppet/tree/main/test/corpus, there are still some highlights that need to be implemented.

hightlights.scm

(function) @function
(function_declaration 
  (identifier) @function)
(parameter
  (variable) @variable.parameter)
(resource_title) @label
(resource_declaration (identifier) @type.constructor)
(resource_call (identifier) @type.constructor )
(include (identifier) @type.constructor )
(require (identifier) @type.constructor )
(contain (identifier) @type.constructor )
(resource_defaults (resource_type) @type.constructor)
(argument_list (argument (argument_name) @variable.other.member))

; reference ---
; (reference (identifier))
; (reference_identifier)


(variable) @variable
[
  (identifier)
] @identifier

[
  "function"
] @keyword.function

[
 "class"
 "define"
 "plan"
 "node"
 "type"
] @keyword.storage.type

[
  "contain"
  "include"
  "inherits"
  "require"
] @keyword.control.import

[
 "case"
 "else"
 "elsif"
 "if"
 "unless"
] @keyword.control.conditional

(heredoc) @string
(string) @string
(regex) @string.regexp
(integer) @constant.numeric.integer
(float) @constant.numeric.float
(comment) @comment
[(true) (false)] @constant.boolean

(unprotected_string) @text

[
 (chaining_arrow)
 (operator)
] @operator


(interpolation
  "${" @punctuation.special
  "}" @punctuation.special) @none

[
 "("
 ")"
 "["
 "]"
 "{"
 "}"
 ]@punctuation.bracket

[
 ","
 ":"
 "::"
] @punctuation.delimiter

[(type) (type_identifier)] @type

(escape_sequence) @constant.character.escape

Append indents.scm

[
(function_declaration) 
(resource_declaration)
(resource_defaults)
(if)
]@indent

[
  "case"
  "}"
]@outdent

@ardrigh
Copy link

ardrigh commented May 6, 2023

It would be great to see some Puppet .pp support added, as being detected as Pascal files breaks commenting (inserts // instead of #) and requires more care with formatting.

@jficz
Copy link

jficz commented May 25, 2023

so I tried this config using a custom patch against helix release 23.03 which contains the changes to language.toml as are present in the PR (with fixed tab-width typo), the highlights.scm as posted by @erasin and an update to pascal files removing the .pp suffix from it but I'm probably doing something wrong because I don't see any highlights at all. Is there a way to debug this and, preferably, to make changes without having to recompile the whole thing?

looks like the puppet grammar doesn't build, there is no puppet.so in runtime/grammars

@jficz
Copy link

jficz commented May 26, 2023

never mind, hx --grammar fetch, build and now it works well!

Need to tune the theme because I don't like the color scheme but the highlighter seems to work.

There are a few small issues though:

$vars, properties and "${interpolations}" are not highlighted, a certain strings break string highlights:

puppet

looks like that it is the dash (-) character that breaks the string highlight

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.

Puppet language support
5 participants