Skip to content

A GitHub action that lets you leverage sumneko lua-language-server and EmmyLua to statically type check lua code.

License

Notifications You must be signed in to change notification settings

mrcjkb/lua-typecheck-action

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Repository files navigation

lua-language-server type check action

A GitHub action that lets you leverage lua-language-server and luaCATS to statically type check and lint lua code.

Introduction

What I found the most frustrating about developing Neovim plugins in Lua is the lack of type safety.

When I added some LuaCATS annotations to one of my plugins (to generate Vimdoc using lemmy-help), I noticed lua-language-server was giving me diagnostics based on my documentation. This was something I was not getting from linters like luacheck. So I asked myself, "Can I leverage lua-language-server and EmmyLua to statically type check my Lua code?"

The result is this GitHub action, which type checks itself:

Type Check Code Base

Usage

Create .github/workflows/typecheck.yml in your repository with the following contents:

---
name: Type Check Code Base
on:
  pull_request: ~
  push:
    branches:
      - master

jobs:
  build:
    name: Type Check Code Base
    runs-on: ubuntu-latest

    steps:
      - name: Checkout Code
        uses: actions/checkout@v3

      - name: Type Check Code Base
        uses: mrcjkb/lua-typecheck-action@v0

Inputs

The following optional inputs can be specified using with:

checklevel

The diagnostics severity level to fail on. One of:

  • Error
  • Warning (default)
  • Information
  • Hint

Example:

- name: Type Check Code Base
  uses: mrcjkb/lua-typecheck-action@v0
  with:
    checklevel: Error

directories

Directories to lint (relative to the repostitory root). Defaults to the repository root if none are specified.

Example:

- name: Type Check Code Base
  uses: mrcjkb/lua-typecheck-action@v0
  with:
    directories: |
     lua
     tests

configpath

Path to a .luarc.json (relative to the repository root).

Example:

- name: Type Check Code Base
  uses: mrcjkb/lua-typecheck-action@v0
  with:
    configpath: ".luarc.json"

Wiki

See the wiki for usage examples.

Can I use this with a non-GPLv2 licensed project?

Yes. Because it is not distributed with any binaries, you can use it in any project.

About

A GitHub action that lets you leverage sumneko lua-language-server and EmmyLua to statically type check lua code.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •