A major mode for editing Tengo script files in GNU Emacs.
Tengo is a small, dynamic, fast, secure scripting language for Go. This package provides syntax highlighting, indentation, and navigation support for Tengo source files (.tengo).
- Syntax Highlighting: Comprehensive highlighting for keywords, built-ins, constants, operators, strings, and comments.
- Context-Aware Indentation:
- Smart indentation for braces
{}, parentheses(), and brackets[]. - Robust Logic: Correctly ignores braces found inside strings or comments (e.g.,
x := "{"will not trigger indentation).
- Smart indentation for braces
- Navigation:
- Support for
beginning-of-defun(C-M-a) andend-of-defun(C-M-e). - Works with named functions (
func foo()) and variable-assigned anonymous functions (foo := func()).
- Support for
- Imenu Support: Indexing for top-level functions and variable declarations for quick navigation.
- Electric Support: Integration with
electric-indent-mode.
- Download
tengo-mode.elto a directory in yourload-path(e.g.,~/.emacs.d/lisp/). - Add the following to your Emacs configuration (
.emacsorinit.el):
(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'tengo-mode)If you have the file saved locally:
(use-package tengo-mode
:load-path "~/.emacs.d/lisp/"
:mode "\\.tengo\\'")(use-package tengo-mode
:ensure t
:mode "\\.tengo\\'")The default indentation is 4 spaces. You can change this by setting tengo-indent-offset:
(setq tengo-indent-offset 2) ; Set indentation to 2 spacesTo automatically close brackets and braces, it is recommended to enable electric-pair-mode globally or specifically for Tengo:
(add-hook 'tengo-mode-hook 'electric-pair-mode)tengo-mode inherits from prog-mode, so standard Emacs movement keys apply.
| Keybinding | Command | Description |
|---|---|---|
TAB | tengo-indent-line | Indent the current line contextually. |
C-M-a | beginning-of-defun | Move to the beginning of the current function. |
C-M-e | end-of-defun | Move to the end of the current function. |
M-g i | imenu | Jump to a function or variable definition. |
Based on the tengo-vim plugin and the official Tengo language documentation.