{"id":15103291,"url":"https://github.com/smoeding/puppet-ts-mode","last_synced_at":"2026-01-18T01:36:16.322Z","repository":{"id":226045400,"uuid":"767583555","full_name":"smoeding/puppet-ts-mode","owner":"smoeding","description":"Emacs major mode with tree-sitter support for Puppet manifests","archived":false,"fork":false,"pushed_at":"2025-02-23T13:48:07.000Z","size":478,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-23T14:33:19.221Z","etag":null,"topics":["emacs","emacs-mode","puppet","tree-sitter"],"latest_commit_sha":null,"homepage":"","language":"Emacs Lisp","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smoeding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-03-05T14:57:57.000Z","updated_at":"2025-02-23T13:48:11.000Z","dependencies_parsed_at":"2024-03-05T16:31:00.814Z","dependency_job_id":"5f598509-5ff8-47d4-b955-02dd2c6676ec","html_url":"https://github.com/smoeding/puppet-ts-mode","commit_stats":{"total_commits":176,"total_committers":1,"mean_commits":176.0,"dds":0.0,"last_synced_commit":"5fd3724995721edb9fba12f4586b43a660bcc407"},"previous_names":["smoeding/puppet-ts-mode"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoeding%2Fpuppet-ts-mode","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoeding%2Fpuppet-ts-mode/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoeding%2Fpuppet-ts-mode/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smoeding%2Fpuppet-ts-mode/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smoeding","download_url":"https://codeload.github.com/smoeding/puppet-ts-mode/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247332546,"owners_count":20921853,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["emacs","emacs-mode","puppet","tree-sitter"],"created_at":"2024-09-25T19:23:13.271Z","updated_at":"2026-01-18T01:36:16.283Z","avatar_url":"https://github.com/smoeding.png","language":"Emacs Lisp","readme":"# Emacs major mode for Puppet using Tree-sitter\n\n[![MELPA](https://melpa.org/packages/puppet-ts-mode-badge.svg)](https://melpa.org/#/puppet-ts-mode)\n[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)\n[![Build Status](https://github.com/smoeding/puppet-ts-mode/actions/workflows/CI.yaml/badge.svg)](https://github.com/smoeding/puppet-ts-mode/actions/workflows/CI.yaml)\n\nThis is a major mode for [GNU Emacs](https://www.gnu.org/software/emacs/) 29.1 or later which adds support for the [Puppet](https://www.puppet.com) domain-specific language. It uses a Tree-sitter parser for Puppet to be able to parse the code and provide fontification, indentation, navigation and more.\n\nIt is a rewrite of the original [Puppet mode for Emacs](https://github.com/voxpupuli/puppet-mode).\n\n## Features\n\nThe mode provides the following features and enhancements to make writing Puppet manifests easier.\n\n### Syntax highlighting\n\nSyntax highlighting for the following elements is fully implemented:\n\n- comments\n- strings (including interpolated variables and escape sequences)\n- numbers\n- variables\n- constants (`true`, `false`, `default`, `undef`)\n- keywords (`if`, `unless`, `case`, `and`, `or`, `in`, ...)\n- resource types and metaparameters (`ensure`, `require`, `notify`, ...)\n- definitions (classes, defined types, type aliases, functions, nodes, plans)\n- built-in functions\n- custom functions\n- operators\n- syntax errors\n\n### Indentation and alignment\n\nThe alignment of resource attributes, function parameter lists and hashes is fully implemented. If point is within such a block, the function `puppet-ts-align-block` (bound to \u003ckbd\u003eC-c C-a\u003c/kbd\u003e by default) will align the attributes and parameters with respect to the `=\u003e` symbols.\n\n**Example:** Consider the following badly written file resource:\n\n``` puppet\nfile { '/var/www':\n  ensure    =\u003e directory,\n  owner =\u003e     'root',\n  group   =\u003e'www-data',\n  mode=\u003e'0755',\n}\n```\n\nType \u003ckbd\u003eC-c C-a\u003c/kbd\u003e when point is somewhere in this resource to neatly align all the attributes and fat arrows. The result will be like this:\n\n``` puppet\nfile { '/var/www':\n  ensure =\u003e directory,\n  owner  =\u003e 'root',\n  group  =\u003e 'www-data',\n  mode   =\u003e '0755',\n}\n```\n\n### Completion\n\nContext-aware completion is implemented using the `completion-at-point` function (normally bound to \u003ckbd\u003eC-M-i\u003c/kbd\u003e).\n\nThe function completes variable names using the local variable from the current manifest if the symbol before point looks like a variable that is, it starts with a `$` . Additional variables like the global `$facts` variable can be customized in `puppet-ts-completion-variables`.\n\nCompletion of variable names also works for interpolated variables in a string.\n\nThe function also completes resource parameters if point is within the resource declaration where a parameter is expected. Completion candidates are all the parameters that are valid for the current resource. That includes all metaparameters.\n\n### Navigation\n\nThe keybindings \u003ckbd\u003eC-M-a\u003c/kbd\u003e and \u003ckbd\u003eC-M-e\u003c/kbd\u003e jump to preceding or following resource declaration respectively. This seems to be more useful than jumping to the beginning or end of a definition since a Puppet manifest normally only has a single definition.\n\n### Imenu\n\nNavigation to the resource types and variable assignments used in a manifest is implemented using Imenu.\n\n### Cross-reference navigation\n\nNavigation from a referenced class, defined type, data type or function to the file where this corresponding type is defined (aka `xref`) is fully implemented.\n\n**Example:** Let's say you are editing the following `acme` class:\n\n``` puppet\n# a class managing everything\nclass acme (\n  Stdlib::Absolutepath $www_root,\n  Boolean              $enable,\n) inherits acme::params {\n\n  include nginx\n\n  nginx::resource::server { 'test2.local':\n    ensure   =\u003e stdlib::ensure($enable),\n    www_root =\u003e $www_root,\n    require  =\u003e Class['postgresql::server'],\n  }\n}\n```\n\nThe following navigation options are available:\n\n1. Point is on the `Stdlib::Absolutepath` data type: `M-.` opens the data type definition\n1. Point is on the `acme::params` subclass: `M-.` opens the class definition\n1. Point is on the `nginx` class: `M-.` opens the class definition\n1. Point is on the `nginx::resource::server` defined type: `M-.` opens the type definition\n1. Point is on the `stdlib::ensure` function: `M-.` opens the function definition\n1. Point is on the `postgresql::server` string: `M-.` opens the class definition\n\nNavigation to foreign classes only needs a list of directories to search (see the customization option `puppet-ts-module-path`). After jumping to a definition you can return back using `M-,`. These keybindings are defined by the `xref` package.\n\n### Skeletons for many standard Puppet statements and resource declarations\n\nIf you are not using `yasnipet` or another template package, you can use the implemented skeletons to insert often used types and keywords.\n\n**Example:** Typing \u003ckbd\u003eC-c C-t p\u003c/kbd\u003e will insert the following snippet leaving point just before the colon:\n\n``` puppet\npackage { :\n  ensure =\u003e present,\n}\n```\n\n#### Skeletons for types\n\nKey                  | Skeleton\n---------------------|---------------\n\u003ckbd\u003eC-c C-t a\u003c/kbd\u003e | type `anchor`\n\u003ckbd\u003eC-c C-t c\u003c/kbd\u003e | type `class`\n\u003ckbd\u003eC-c C-t e\u003c/kbd\u003e | type `exec`\n\u003ckbd\u003eC-c C-t f\u003c/kbd\u003e | type `file`\n\u003ckbd\u003eC-c C-t g\u003c/kbd\u003e | type `group`\n\u003ckbd\u003eC-c C-t h\u003c/kbd\u003e | type `host`\n\u003ckbd\u003eC-c C-t n\u003c/kbd\u003e | type `notify`\n\u003ckbd\u003eC-c C-t p\u003c/kbd\u003e | type `package`\n\u003ckbd\u003eC-c C-t s\u003c/kbd\u003e | type `service`\n\u003ckbd\u003eC-c C-t u\u003c/kbd\u003e | type `user`\n\n#### Skeletons for keywords\n\nKey                  | Skeleton\n---------------------|-------------------\n\u003ckbd\u003eC-c C-k c\u003c/kbd\u003e | keyword `class`\n\u003ckbd\u003eC-c C-k d\u003c/kbd\u003e | keyword `define`\n\u003ckbd\u003eC-c C-k n\u003c/kbd\u003e | keyword `node`\n\n## Installation\n\nEmacs 29.1 or above with Tree-sitter support is required.\n\nAlso the appropriate [parser](https://github.com/smoeding/tree-sitter-puppet) for the Puppet language needs to be installed. Note that there are different parsers available and only the referenced parser will work with this code.\n\nThe following Elisp code should be used to install the Puppet language parser.  This requires some tools -- notably a compiler toolchain -- to be available on your machine.\n\n```elisp\n(require 'puppet-ts-mode)\n(puppet-ts-mode-install-grammar)\n```\n\nUsing the function provided by the package ensures that a version of the parser matching the package will be installed. These commands should also be used to update the parser to the correct version when the package is updated.\n\n## License\n\nPuppet Tree-sitter Mode is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\n\nPuppet Tree-sitter Mode is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoeding%2Fpuppet-ts-mode","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmoeding%2Fpuppet-ts-mode","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmoeding%2Fpuppet-ts-mode/lists"}