https://github.com/themkat/playdate-mode
Simple mode built upon lua-mode for Emacs for developing Playdate applications and games.
https://github.com/themkat/playdate-mode
emacs game-development lua playdate
Last synced: 8 months ago
JSON representation
Simple mode built upon lua-mode for Emacs for developing Playdate applications and games.
- Host: GitHub
- URL: https://github.com/themkat/playdate-mode
- Owner: themkat
- Created: 2024-03-15T12:29:58.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-10-28T16:30:51.000Z (about 1 year ago)
- Last Synced: 2025-06-13T10:09:35.560Z (8 months ago)
- Topics: emacs, game-development, lua, playdate
- Language: Emacs Lisp
- Homepage:
- Size: 889 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.org
Awesome Lists containing this project
README
* playdate-mode (Lua)
Simple derived mode built upon lua-mode for Emacs for developing Playdate applications and games in Lua. Uses lsp-mode for language server protocols, as well as some nice settings for Playdate development.
#+ATTR_ORG: :width 600
[[./screenshot.png]]
(window size has been shrinked a bit, which is why the documentation popup from [[https://github.com/sebastiencs/company-box][company-box]] looks so crammed. Theme is my own [[https://github.com/themkat/pink-bliss-uwu][pink-bliss-uwu-theme]])
Still a work in progress, as I'm fairly new to developing for the Playdate. Feel free to post your suggestions in the issue tracker if you are more experienced and would find something like this useful.
** Why?
While Lua-mode and lsp-mode provides a lot of what you need, there are still some settings that are useful to have set for you:
- The extended Lua syntax like the =+== operator will be default give an error in lua-language-server. This can be tweaked with a setting. Having a simple Emacs mode making this setting for you, can save time.
- import as an extra keyword, both syntax highlighted and set to not give errors with the language server.
- Setting up completion symbols for Playdate, so the language server gives you relevant documentation and completion while typing.
** Dependencies
- lsp-mode
- lua-mode
- git.el
- f.el
- s.el
++ some Playdate tooling described below. Most notably the SDK.
** Usage
There are a few requirements to get this working:
1. [[https://play.date/dev/][Playdate SDK]] should be installed. Currently, playdate-mode expects pdc (the compiler). to be in your path.
2. Set =playdate-luacats-dir= to the place you want Playdate Luacats (completion helpers) installed to. Run =playdate-setup= in Emacs, or manually clone the [[https://github.com/notpeter/playdate-luacats][playdate-luacats repo]] to this directory. This will be used to provide auto completion and symbols as you type.
3. The Emacs packages lsp-mode, lua-mode and projectile. If this package is ever released on Melpa, those will probably be handled automatically.
You need to set two properties/variables in your Emacs configuration:
- =playdate-luacats-dir= to the directory you copied the repo to in point 2 above.
- =playdate-simulator-executable= to the Playdate simulator binary in your SDK install. This is ="/Users/marie/Developer/PlaydateSDK/bin/Playdate Simulator.app/Contents/MacOS/Playdate Simulator"= on my machine. Don't worry about spaces, playdate-mode will escape them before running :)
Now you can simply activate =playdate-mode= in your Lua-buffer (e.g, =M-x playdate-mode=), and everything should work. Special Playdate Lua extensions like =+== should work without error, and import should look like any other keyword in the language. You should also have completion. If you don't have the language server installed, lsp-mode should prompt you for its download.
You might also want to set:
- =playdate-no-pdxinfo-name-fallback=. This sets the name of the pdx file when compiling and running. The plan is to read pdxinfo for the name if available, so in the future this variable will only work as a fallback.
Interactive functions you can use:
- =playdate-compile-program= to build your Playdate pdx file.
- =playdate-run-program= to run the program that your current Lua file is part of.
** Assumptions made by this mode
To group lua files into a project, two approaches are used (prioritized from top to bottom):
1. Finding the closes =main.lua= to find logical entry directories to pdx file creation. This is done to support multiple directories with different pdx executables within Git repositories and similar. One example is [[https://github.com/Whitebrim/AnimatedSprite/blob/master/tests/unit-tests/source/main.lua][the main executable and unit tests in AnimatedSprite library]].
2. The projectile project. This might be your git repository or similar. This is useful where you only intend to make a single pdx file from your repo, and it might be called something else than main.lua. (I've seen many of these when looking at other peoples code here at Github).
Currently, only lua-language-server is set up with the Playdate related settings. The reason being that it is the only language server for Lua that I have used.
** Contributing
Contributions are most welcome :heart: Constructive criticism and wishlists are also welcome in issues.