diff --git a/book/src/generated/lang-support.md b/book/src/generated/lang-support.md index dd6195e1..5c2cb0f1 100644 --- a/book/src/generated/lang-support.md +++ b/book/src/generated/lang-support.md @@ -305,6 +305,7 @@ | wgsl | ✓ | ✓ | ✓ | ✓ | ✓ | `wgsl-analyzer` | | wikitext | ✓ | | | | | `wikitext-lsp` | | wit | ✓ | | ✓ | | | | +| woodpecker-ci | ✓ | ✓ | ✓ | ✓ | ✓ | `yaml-language-server` | | wren | ✓ | ✓ | ✓ | | | | | xit | ✓ | | | | | | | xml | ✓ | ✓ | ✓ | | ✓ | | diff --git a/languages.toml b/languages.toml index b91347b6..b979db49 100644 --- a/languages.toml +++ b/languages.toml @@ -5108,3 +5108,20 @@ language-servers = [ "ripple-lsp" ] [[grammar]] name = "ripple" source = { git = "https://github.com/Ripple-TS/ripple", rev = "49762f0a63de0d1845fcd2e6632639c095995336", subpath = "packages/tree-sitter" } + +[[language]] +name = "woodpecker-ci" +scope = "source.woodpecker-ci" +injection-regex = "^woodpecker-ci$" +# https://woodpecker-ci.org/docs/usage/workflows +file-types = [ + { glob = ".woodpecker.yaml" }, + { glob = ".woodpecker/*.yaml" }, + { glob = ".woodpecker/*.yml" }, +] +grammar = "yaml" +indent = { tab-width = 2, unit = " " } +language-servers = ["yaml-language-server"] +comment-token = "#" +formatter = { command = "yamlfmt", args = ['-'] } +auto-format = true diff --git a/runtime/queries/woodpecker-ci/highlights.scm b/runtime/queries/woodpecker-ci/highlights.scm new file mode 100644 index 00000000..6af434f9 --- /dev/null +++ b/runtime/queries/woodpecker-ci/highlights.scm @@ -0,0 +1,48 @@ +; yaml highlights from runtime/queries/yaml/highlights.scm +(boolean_scalar) @constant.builtin.boolean +(null_scalar) @constant.builtin +(double_quote_scalar) @string +(single_quote_scalar) @string +(block_scalar) @string +(string_scalar) @string +(escape_sequence) @constant.character.escape +(integer_scalar) @constant.numeric.integer +(float_scalar) @constant.numeric.float +(comment) @comment +(anchor_name) @type +(alias_name) @type +(tag) @type +(yaml_directive) @keyword + +(block_mapping_pair + key: (flow_node [(double_quote_scalar) (single_quote_scalar)] @variable.other.member)) +(block_mapping_pair + key: (flow_node (plain_scalar (string_scalar) @variable.other.member))) + +(flow_mapping + (_ key: (flow_node [(double_quote_scalar) (single_quote_scalar)] @variable.other.member))) +(flow_mapping + (_ key: (flow_node (plain_scalar (string_scalar) @variable.other.member)))) + +[ +"," +"-" +":" +">" +"?" +"|" +] @punctuation.delimiter + +[ +"[" +"]" +"{" +"}" +] @punctuation.bracket + +["*" "&" "---" "..."] @punctuation.special + +; Highlight the toplevel keys differently as keywords +; https://woodpecker-ci.org/docs/usage/workflow-syntax +(block_mapping_pair + key: (flow_node (plain_scalar (string_scalar) @keyword (#any-of? @keyword "steps" "workspace" "labels" "matrix" "services" "variables" "clone" "skip_clone" "depends_on" "runs_on"))) ) diff --git a/runtime/queries/woodpecker-ci/indents.scm b/runtime/queries/woodpecker-ci/indents.scm new file mode 100644 index 00000000..4ba254e8 --- /dev/null +++ b/runtime/queries/woodpecker-ci/indents.scm @@ -0,0 +1 @@ +; inherits: yaml diff --git a/runtime/queries/woodpecker-ci/injections.scm b/runtime/queries/woodpecker-ci/injections.scm new file mode 100644 index 00000000..a393f20e --- /dev/null +++ b/runtime/queries/woodpecker-ci/injections.scm @@ -0,0 +1,49 @@ +((comment) @injection.content + (#set! injection.language "comment")) + +; https://woodpecker-ci.org/docs/usage/workflow-syntax#commands +; e.g. +; ``` +; steps: +; - name: backend +; image: golang +; commands: +; - go build +; - go test +; ``` +(block_mapping_pair + key: (flow_node) @_key (#eq? @_key "commands") + value: (block_node + (block_sequence + (block_sequence_item + (flow_node + (plain_scalar + (string_scalar) @injection.content)) + (#set! injection.language "bash"))))) + +(block_mapping_pair + key: (flow_node) @_key (#any-of? @_key "commands") + value: (block_node + (block_sequence + (block_sequence_item + (block_node + (block_scalar) @injection.content + (#set! injection.language "bash")))))) + +; https://woodpecker-ci.org/docs/usage/workflow-syntax#entrypoint +; e.g. +; ``` +; job1: +; services: +; entrypoint: ["/usr/local/bin/docker-entrypoint.sh", "-c", 'max_connections=100'] +; ``` +(block_mapping_pair + key: (flow_node) @_key (#any-of? @_key "entrypoint") + value: (flow_node + (flow_sequence + (flow_node + [ + (double_quote_scalar) + (single_quote_scalar) + ] @injection.content))) + (#set! injection.language "bash")) diff --git a/runtime/queries/woodpecker-ci/rainbows.scm b/runtime/queries/woodpecker-ci/rainbows.scm new file mode 100644 index 00000000..4ba254e8 --- /dev/null +++ b/runtime/queries/woodpecker-ci/rainbows.scm @@ -0,0 +1 @@ +; inherits: yaml diff --git a/runtime/queries/woodpecker-ci/tags.scm b/runtime/queries/woodpecker-ci/tags.scm new file mode 100644 index 00000000..80532798 --- /dev/null +++ b/runtime/queries/woodpecker-ci/tags.scm @@ -0,0 +1,17 @@ +; select steps +; e.g. +; ``` +; steps: +; - name: build-image +; image: docker +; commands: +; - docker build --rm -t local/project-image . +; volumes: +; - /var/run/docker.sock:/var/run/docker.sock +; ``` +(block_mapping_pair + key: (_) @_key (#eq? @_key "steps") + value: (block_node + (block_sequence + (block_sequence_item + (block_node) @definition.struct)))) diff --git a/runtime/queries/woodpecker-ci/textobjects.scm b/runtime/queries/woodpecker-ci/textobjects.scm new file mode 100644 index 00000000..4ba254e8 --- /dev/null +++ b/runtime/queries/woodpecker-ci/textobjects.scm @@ -0,0 +1 @@ +; inherits: yaml