name: Lua Language Server Diagnostics
on:
  pull_request: ~
  push:
    branches:
      - '*'

jobs:
  luals-check:
    strategy:
      matrix:
        neovim: ["0.10"]
        lua: ["5.1", "luajit-master"]
    runs-on: ubuntu-latest

    steps:
    - name: Checkout
      uses: actions/checkout@v4

    - uses: luarocks/gh-actions-lua@v10
      with:
        luaVersion: ${{matrix.lua}}

    - name: Install lua-language-server
      uses: jdx/mise-action@v2
      with:
        mise_toml: |
          [tools]
          neovim = "${{ matrix.neovim }}"
          cargo-binstall = "latest"
          "cargo:emmylua_check" = "latest"
          "cargo:emmylua_ls" = "latest"
          lua-language-server = "3.13.9"

    - name: Run lua-language-server check
      run: |
        LUARC=".github/workflows/.luarc-${{ matrix.lua }}.json"
        make luals-check CONFIGURATION="$LUARC"

    - name: Run emmylua_check
      continue-on-error: true # Doesn't type-check well enough to be worth erroring on, but this runs so fast we might as well help test this out.
      run: |
        LUARC=".github/workflows/.luarc-${{ matrix.lua }}.json"
        make emmylua-check CONFIGURATION="$LUARC"
