Skip to content

Instantly share code, notes, and snippets.

@pstuifzand
Last active August 1, 2023 15:10
Show Gist options
  • Save pstuifzand/6efa1bac4618252d9e44297c36c0ef77 to your computer and use it in GitHub Desktop.
Save pstuifzand/6efa1bac4618252d9e44297c36c0ef77 to your computer and use it in GitHub Desktop.
Install Home Assistant Language Server on Neovim (v0.5 prerelease)

Install on Neovim (v0.5 prerelease)

The Home Assistant language server can be used with Neovim.

Install vscode-home-assistant

  1. Download the latest release from the releases.
  2. Unpack the archive.
  3. Run npm install
  4. Run npm run compile
  5. The language server is ready to be run
  6. Set HASS_SERVER=... and HASS_TOKEN=... in your environment. See also: Configure connection to HA.

Install in Neovim

  1. Requires neovim v0.5 prerelease. See nvim-lspconfig for more information.
  2. Add the language server to your init.vim.
lua << EOF
local lspconfig = require('lspconfig')
local util = require('lspconfig/util')

install_dir = '/home/peter/tmp/vscode-home-assistant-1.18.0/'

-- add the default config for homeassistant
lspconfig.configs.homeassistant = {
    default_config = {
        cmd = {install_dir .. '/node_modules/.bin/ts-node', install_dir .. '/out/server/server.js', '--stdio'},
        filetypes = {'yaml'},
        root_dir = util.root_pattern("configuration.yaml"),
        settings = {}
    }
}

-- setup the language server (use the `on_attach` from [nvim-lspconfig][lspconfig-keybindings])
lspconfig.homeassistant.setup({ on_attach = on_attach})
EOF
@Hubro
Copy link

Hubro commented Oct 8, 2021

Any idea if it's possible to run all the neat reload actions through Neovim LSP? Or are those only part of the vscode plugin?

@pstuifzand
Copy link
Author

It should be possible to run the actions, but I'm haven't yet found how this can be done in NeoVim. For vscode, the calls and commands are registered here: https://github.com/keesschollaart81/vscode-home-assistant/blob/e02988464985e1b8ef67f5822ee762251ad5a4ed/src/extension.ts#L259-L263
This should help a little.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment