Skip to content

Language Server Protocol implementation for the Haxe language

License

Notifications You must be signed in to change notification settings

vshaxe/haxe-language-server

Repository files navigation

Haxe Language Server

CI

This is a language server implementing Language Server Protocol for the Haxe language.

The goal of this project is to encapsulate haxe's completion API with all its quirks behind a solid and easy-to-use protocol that can be used by any editor/IDE.

Used by the Visual Studio Code Haxe Extension. It has also successfully been used in Neovim and Sublime Text[1][2], but no official extensions exist at this time.

Note that any issues should be reported to vshaxe directly (this is also the reason why the issue tracker is disabled). Pull requests are welcome however!

IMPORTANT: This requires Haxe 3.4.0 or newer due to usage of -D display-stdin, --wait stdio and tons of other fixes and additions related to IDE support.

Building From Source

The easiest way to work on the language server is probably to build it as part of the vshaxe VSCode extension as instructed here (even if you ultimately want to use it outside of VSCode), which allows for easy debugging.

However, you can also build it as a standalone project like so:

git clone https://github.com/vshaxe/haxe-language-server
cd haxe-language-server
npm ci
npx lix run vshaxe-build -t language-server

This creates a bin/server.js that can be started with node server.js.

Usage with (Neo)vim

There's a large amount of language client plugins for (Neo)vim, but the best choice currently seems to be coc.nvim. A coc-settings.json that is known to work with haxe-language-server looks like this:

{
    "languageserver": {
        "haxe": {
            "command": "node",
            "args": ["<path-to-server.js>"],
            "filetypes": ["haxe"],
            "trace.server": "verbose",
            "initializationOptions": {
                "displayArguments": ["build.hxml"]
            },
            "settings": {
                "haxe.executable": "haxe"
            }
        }
    }
}

Usage with Kate

Go to configure Kate (Ctrl+Shift+,) » LSP Client » User Server Settings » Add the following snippet to the JSON config within the servers object. Don't forget to change the path to the LSP server.

"haxe": {
    "command": ["node", "<path-to-server.js>"],
    "rootIndicationFileNames": ["*.hx", "*.hxml"],
    "url": "https://github.com/vshaxe/haxe-language-server",
    "initializationOptions": {"displayArguments": ["build.hxml"]},
    "settings": {"haxe": {"buildCompletionCache": true}},
    "highlightingModeRegex": "^Haxe$"
},

Click Apply, you can then close the window. Use File » Reload or F5 to reload the project. Accept when it asks you whether you want to start the LSP server.

Where <path-to-server.js> can either be a server.js you built from source or simply downloaded as part of the Haxe Visual Studio Code extension ("/<you-home-folder>/.vscode/extensions/nadako.vshaxe-<version>/bin/server.js").