#!/bin/sh
set -eu

# node vorhanden?
command -v node >/dev/null 2>&1 || {
  echo "ERROR: node not found"
  exit 1
}

# npm vorhanden?
command -v npm >/dev/null 2>&1 || {
  echo "ERROR: npm not found"
  exit 1
}

# neovim provider installieren (idempotent)
if ! command -v neovim-node-host >/dev/null 2>&1; then
  echo "Installing Neovim Node provider (npm neovim)"
  npm install -g neovim
fi

# Verifikation
command -v neovim-node-host >/dev/null 2>&1 || {
  echo "ERROR: neovim-node-host not found in PATH"
  exit 1
}

echo "Neovim Node provider ready:"
neovim-node-host --version 2>/dev/null || true
