Skip to content
Full Haxe support inside Emacs: code completion, find references, Eldoc and more...
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

battle-haxe - a new weapon for your Emacs

A development system for the Haxe programming language.


Battle-haxe adds code-completion and IDE-like features when editing Haxe code, provided by the
Haxe compiler’s “compiler services” feature in server mode.

See Installation section to get started.

The main quirk is that the system has to force automatic saving of the edited Haxe File. ( Big issue )


  • Member completion (via company-mode), for example after “myObject.” or “override ”
  • Type completion, for example after “new ” or “import ”
  • If you auto-complete a class name, for example after “new ” completion, it will automatically import the class as well
  • Jump to the definition of the current symbol with a key. Press another key to go back to where you were
  • Find all references of the current symbol (choose between them using helm)
  • Eldoc support
  • Optionally expand method calls completions using yasnippet.

Big issue

  • Before a compiler services action is called, the document is always automatically saved without question. This is because the Haxe compiler doesn’t accept compiler services calls when using other (temporary) files, so for now I had Haxe process the real file path instead and had the document forcibly saved. This is not an issue for me at all, but if it is for you, don’t use the package!


  • You MUST have a file with .hxml extension in the root project folder. ( You must have it for the compiler to know what to check and which libraries you depend on. This file however does not exist in frameworks that compile your project differently (For example Lime/OpenFL projects, see that section for a solution).
  • This package doesn’t handle multiple simultaneous projects or running multiple Haxe completion servers yet. If you want to switch to another project, run the battle-haxe-start-server command in the new project.


  • First install the following packages which are required as dependencies:
    • company, helm, async, dash, dash-functional, f, s, and optionally, yasnippet.
  • Download this package and add it to your load path, for example:
;; Tell Emacs where your elisp library sits
(add-to-list 'load-path "~/.emacs.d/lisp/battle-haxe")
  • If you have use-package, this is a template you can insert to your init file to load the package:
;; This isn't really a package, it just provides a `haxe-mode' to work with
(use-package haxe-mode
  :mode ("\\.hx\\'" . haxe-mode)
  :no-require t
  (require 'js)
  (define-derived-mode haxe-mode js-mode "Haxe"
    "Haxe syntax highlighting mode. This is simply using js-mode for now."))

(use-package battle-haxe
  :hook (haxe-mode . battle-haxe-mode)
  :bind (("S-<f4>" . #'pop-global-mark) ;To get back after visiting a definition
         :map battle-haxe-mode-map
         ("<f4>" . #'battle-haxe-goto-definition)
         ("<f12>" . #'battle-haxe-helm-find-references))
  (battle-haxe-yasnippet-completion-expansion t "Keep this if you want yasnippet to expand completions when it's available.")
  (battle-haxe-immediate-completion nil "Toggle this if you want to immediately trigger completion when typing '.' and other relevant prefixes."))
  • Customize this as you will.

Lime/OpenFL projects

The package uses the Haxe compiler directly and doesn’t use Lime’s “Project.xml” config file,
but here is a template “some-project.hxml” to get you started for this use case:

-cp src
-lib lime
-lib openfl


  • This package is intended to support only the latest and greatest Haxe compiler version (currently 4.0.0-rc.2).
  • There is no haxe-specific syntax highlighting/indentation mode included. However the js-mode (that drives the haxe-mode) does a good enough job with most Haxe code that it’s less urgent to create a specialized mode. The use-package block for defining a haxe-mode is useful for things such as yasnippet storing your snippets under a predictable “haxe-mode” folder.

Package naming

I just found it funny that the language’s creator gave it the name “Haxe” but pronounces it as “Axe”.

You can’t perform that action at this time.