Using Emacs for Pascal development

2025-09-26

[2025-10-22: I am just publishing this as-is for now. It's not complete.]

This is a guide for using Emacs for Pascal development with the tools I either worked on or with other tools.

I only describe things that I specifically use. This will be updated periodically as I improve the process.

Why do you not use Lazarus?

Using a text editor can complement a full IDE UI.

Emacs is something I am used to, but the Lazarus UI would be preferred for desktop application development and for a lot of configuration tasks.

In this, I will also present things that I think are useful for editing within

Tools

The tools I use are either custom developed or are provided elsewhere. The main things I want to do are: 1. Get proper syntax highlighting. I use opascal-mode for indentation for now, but do not use the syntax highlighter. I wrote a tree sitter mode for this purpose. 2. Using compliation-mode (M-x compile) to make compilations fast. Emacs does not come by default with any way to recognize Free Pascal output, so this is provided with the syntax highlighting mode. 3. Flycheck support for error reporting. This is not provided in default implementations, so I include that also with the syntax highlighting mode. The LSP server highlights syntax, but I haven't been able to use it to its fullest potential. The small flycheck plugin uses the FPC compiler directly with some tweaks to grab error messages. 4. LSP: I (will) provide a customized version of lsp-pascal, which implements extra features. There are a few forks, but the one I rely on now is the one from genericptr (the link is below). 5. Yasnippet: I (will) provide snippets of all sorts of scenarios. Pascal is slightly verbose, so these can help a lot. 6. Formatting with PtoP or JCF: I (will) provide tooling to make this possible. The LSP server should provide it, but I haven't got it to work yet.

Links

  1. https://github.com/bolsen/pascal-ts-mode
  2. https://github.com/bolsen/tree-sitter-pascal [this is a fork to support any small changes until upstream handles it.]
  3. https://github.com/genericptr/pascal-language-server

I use GitLab as primary places to store my own repositories. You can see them here: https://github.com/bolsen80 . GitHub is used for exposure for specific projects like development tools that I have worked on.

The pascal-ts-mode is not yet published to (M)ELPA since it is a work in progress. However, it has been useable mostly, with all the features I added.

Setup

In: pascal emacs