Skip to content

CsBigDataHub/tengo-mode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

tengo-mode

https://melpa.org/packages/tengo-mode-badge.svg

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).

Features

  • 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).
  • Navigation:
    • Support for beginning-of-defun (C-M-a) and end-of-defun (C-M-e).
    • Works with named functions (func foo()) and variable-assigned anonymous functions (foo := func()).
  • Imenu Support: Indexing for top-level functions and variable declarations for quick navigation.
  • Electric Support: Integration with electric-indent-mode.

Installation

Manual Installation

  1. Download tengo-mode.el to a directory in your load-path (e.g., ~/.emacs.d/lisp/).
  2. Add the following to your Emacs configuration (.emacs or init.el):
(add-to-list 'load-path "~/.emacs.d/lisp/")
(require 'tengo-mode)

Using use-package

If you have the file saved locally:

(use-package tengo-mode
  :load-path "~/.emacs.d/lisp/"
  :mode "\\.tengo\\'")

From MELPA

(use-package tengo-mode
  :ensure t
  :mode "\\.tengo\\'")

Configuration

Indentation Width

The default indentation is 4 spaces. You can change this by setting tengo-indent-offset:

(setq tengo-indent-offset 2) ; Set indentation to 2 spaces

Electric Pairs

To 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)

Keybindings

tengo-mode inherits from prog-mode, so standard Emacs movement keys apply.

KeybindingCommandDescription
TABtengo-indent-lineIndent the current line contextually.
C-M-abeginning-of-defunMove to the beginning of the current function.
C-M-eend-of-defunMove to the end of the current function.
M-g iimenuJump to a function or variable definition.

Credits

Based on the tengo-vim plugin and the official Tengo language documentation.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •