Skip to content

standardgalactic/emacs-gdscript-mode

 
 

Repository files navigation

GDScript mode for Emacs

banner showing the "GDScript mode" title with GDScript code in the background

This package adds support for the GDScript programming language from the Godot game engine in Emacs. It gives syntax highlighting and indentations. Contributors are welcome!

Features

This mode already features all the essentials:

  • Syntax highlighting.
  • Code folding.
  • Imenu.
  • Support for scenes (.tscn) and script (.gd) files.
  • Comment wrapping when using fill-paragraph.
  • Indentation and auto-indentation: tab-based (default) and space-based.
  • Automatic pairing of parentheses, brackets, etc.
  • Code formatting using gdformat.
  • Auto-completion for all the keywords in the gdscript-keywords.el file.
  • Run or open the project and files with Godot.

Contributing

Contributors are welcome! Check the issues tab for tasks to work on and open a PR anytime.

If you find a bug, or would like to suggest an improvement, open a new issue.

For code style, we follow the Emacs lisp style guide by Bozhidar Batsov, and the tips and conventions from the Emacs manual.

You should also check for errors and linter warnings in your code. You can do so in Emacs with flymake or flycheck but we recommend running the tool makem.sh provided with the repository:

./makem.sh lint-compile

This program will tell you if there is any problem with your code. If there's no output, everything is fine. You can run all tests like so, but note it might give you spelling errors that aren't relevant in this project:

./makem.sh all

How to install

The package is available in the MELPA package archive. Once you set up MELPA you can install the package from Emacs:

M-x package-install gdscript-mode

Then, in your init.el file, you can require the package:

(require 'gdscript-mode)

Installing in Spacemacs

  1. Clone the repository to the private/local subdirectory of your .emacs.d directory, where you installed spacemacs.
  2. Add the package to the dotspacemacs-additional-packages and mark it as local. That's Spacemacs' feature to make it easy to load locally installed packages.
dotspacemacs-additional-packages '((gdscript-mode :location local))
  1. In your dotspacemacs/user-config function, require the package.
(defun dotspacemacs/user-config ()
  (require 'gdscript-mode))

Installing in Doom Emacs

Add the following package definition to your .doom.d/packages.el file:

(package! gdscript-mode
          :recipe (:host github
                   :repo "GDQuest/emacs-gdscript-mode"))

Require the package in your .doom.d/config.el file:

(require 'gdscript-mode)

Installing with use-package + straight.el

Add the call to use-package to your Emacs configuration:

(use-package gdscript-mode
    :straight (gdscript-mode
               :type git
               :host github
               :repo "GDQuest/emacs-gdscript-mode"))

Installing manually

  1. Clone the repository or download a stable release to your computer.
  2. In your init.el file, add a call to load and require the package.
(add-to-list 'load-path "/path/to/gdscript-mode")
(require 'gdscript-mode)

How to use

Opening the project in the editor

You can open the project in the Godot editor with M-x gdscript-godot-open-project-in-editor, or open files and more in Godot with the M-x gdscript-godot-* commands.

By default, these commands try to use an executable named godot on the system PATH environment variable.

If you don't have godot available there, you can set a custom executable name or path to use instead:

(setq gdscript-godot-executable "/path/to/godot")

You can also use customize to change this path: M-x customize and search for "godot".

Formatting code with gdformat

You can call the gdscript-format function to format the current buffer with gdformat. This feature requires the python package gdtoolkit to be installed and available on the system's PATH variable.

You can install gdtoolkit using the pip package manager from Python 3. Run this command in your shell to install it:

pip3 install gdtoolkit

Customization

To find all GDScript-mode settings, press M-x customize and search for "gdscript".

Code example:

(setq gdscript-use-tab-indents t) ;; If true, use tabs for indents. Default: t
(setq gdscript-indent-offset 4) ;; Controls the width of tab-based indents
(setq gdscript-godot-executable "/path/to/godot") ;; Use this executable instead of 'godot' to open the Godot editor.

About

An Emacs package to get GDScript support and syntax highlighting.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Emacs Lisp 85.2%
  • Shell 14.8%