[Neovim][LSP] Having issues setting up haxe lsp with Neovim

Hello!

I recently found out about the Haxe programming language and I wanted to try it out.

Unfortunately I can’t seem for the life of me to setup the haxe LSP.

I’m following everything that is both in the:

  • nvim-lspconfig repo - link
  • haxe-language-server repo - link

The LSP just doesn’t attach. (I have build.hxml).

Are there any Neovim users using native lsp that have haxe-language-server running?

local status_ok, lsp_installer = pcall(require, "nvim-lsp-installer")
if not status_ok then
	return
end

local servers = {
    -- .....
	"haxe_language_server",
}

lsp_installer.setup({
	ensure_installed = servers,
})

local lspconfig_status_ok, lspconfig = pcall(require, "lspconfig")
if not lspconfig_status_ok then
	return
end

local opts = {}

for _, server in pairs(servers) do
	opts = {
		on_attach = require("user.lsp.handlers").on_attach,
		capabilities = require("user.lsp.handlers").capabilities,
	}

    -- .....

	if server == "haxe_language_server" then
		opts = vim.tbl_deep_extend("force", {
			cmd = { "node", "/home/hristo-laptop/Projects/haxe-language-server/bin/server.js" },
		}, opts)
	end

	lspconfig[server].setup(opts)
end

Hi, I did end up with a somewhat working neovim setup, so I’ll try my best to help you out.

My lsp config file looks pretty similar. (Note: cmp_nvim_lsp is a plugin for completion)

local capabilities = vim.lsp.protocol.make_client_capabilities()
capabilities = require('cmp_nvim_lsp').update_capabilities(capabilities)

local lspconfig = require('lspconfig')

local bindings = require('config.bindings')

bindings.general()

lspconfig.haxe_language_server.setup({
  cmd = {"node", "/home/.../Dev/haxe/haxe-language-server/bin/server.js"},
  capabilities = capabilities,
  on_attach = bindings.on_attach
})

And here’s a full config from someone on the Haxe discord who also managed to get their nvim set up with Haxe: dots/.config/nvim at main · snsvrno/dots · GitHub

Are you seeing an error of some sort? What exactly is telling you that the LSP isn’t working?

Just in case your main goal is simply to try out Haxe, you don’t need to set up a language server. The page of your second link states that VSCode’s Haxe extension already uses that code for its own language server.

If you did in fact wish to try out a more complex language server system, any help I can offer is completely useless. :slight_smile:

Hey!

No error at all.

When I run :LspInfo I can see that the server is not attached to the buffer. Super weird. I ended up booting up VSCode to try out Haxe.

Thanks for the help <3

Hey!

I actually booted up VSCode to try out Haxe because this issue with the LSP was driving me insane lol.

Thanks for the help!

Haxe is amazing!

1 Like

Ah I see. That’s odd. If you still want to try to fix it, you could see if there’s anything when you run :checkhealth or if anything comes up in $HOME/.cache/nvim/lsp.log.

Hi hristo

I think there is nothing wrong with the neovim config, the main problem is that haxe filetype is not detected.

try:
:setfiletype haxe

and check if the lsp is working.

Keep that in mind LSP works if you have cmp working so it gives you auto completion.
And there is no syntax highlighting, for syntax highlighting you might need vaxe too.

I don’t know yet if it works or not tho this is a simple lspconfig without lsp-installer:

lspconfig['haxe_language_server'].setup({
  cmd = {'node', '/path/to/haxe-language-server/bin/server.js'},
})

Edit:
You can also use treesitter with tree-sitter-haxe for syntax highlighting.