From 2cb16dd72e568a6fc6c4e6a228f3c6577f5413b8 Mon Sep 17 00:00:00 2001 From: MagicDuck Date: Wed, 30 Jul 2025 14:19:21 -0700 Subject: [PATCH] attempt to use emmylua_check for type checking --- .emmyrc.json | 9 +++++++++ .github/workflows/.luarc.json | 8 -------- .github/workflows/lint.yml | 26 +++++++++++++++++--------- lua/grug-far/test/helpers.lua | 4 +++- 4 files changed, 29 insertions(+), 18 deletions(-) create mode 100644 .emmyrc.json delete mode 100644 .github/workflows/.luarc.json diff --git a/.emmyrc.json b/.emmyrc.json new file mode 100644 index 00000000..58a6811e --- /dev/null +++ b/.emmyrc.json @@ -0,0 +1,9 @@ +{ + "runtime": { + "version": "LuaJIT", + "requirePattern": ["lua/?.lua", "lua/?/init.lua"] + }, + "workspace": { + "library": ["$VIMRUNTIME", "$LLS_Addons/luvit"] + } +} diff --git a/.github/workflows/.luarc.json b/.github/workflows/.luarc.json deleted file mode 100644 index b0d5afc4..00000000 --- a/.github/workflows/.luarc.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", - "runtime.version": "LuaJIT", - "runtime.path": ["?.lua", "?/init.lua"], - "runtime.path.pathStrict": true, - "Lua.diagnostics.libraryFiles": "Disable", - "Lua.workspace.checkThirdParty": "Disable" -} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index c1c20f76..b6f630cd 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -37,7 +37,7 @@ jobs: version: latest args: --check . - typecheck: + typecheck-emmylua: name: Typecheck sources strategy: matrix: @@ -45,12 +45,20 @@ jobs: neovim_version: ["v0.11.0"] runs-on: ${{ matrix.os }} steps: - - name: Checkout sources - uses: actions/checkout@v4 - - name: Type Check Code Base - uses: stevearc/nvim-typecheck-action@v2 + - name: Install emmylua_check from crates.io + uses: baptiste0928/cargo-install@v3 + with: + crate: emmylua_check + version: '^0.10.0' + - name: Setup neovim + uses: rhysd/action-setup-vim@v1 with: - configpath: .github/workflows/.luarc.json - path: lua - level: Warning - nvim-version: v0.11.0 + neovim: true + version: ${{ matrix.neovim_version }} + - uses: actions/checkout@v4 + # TODO (sbadragan): need to fetch LLS_Addons -> luvit library as well + - name: Run emmylua_check + run: | + export VIMRUNTIME=$( nvim -u NORC --headless -c 'echo $VIMRUNTIME' -c 'q' 2>&1) + echo $VIMRUNTIME + emmylua_check -c .emmyrc.json ./lua ./tests diff --git a/lua/grug-far/test/helpers.lua b/lua/grug-far/test/helpers.lua index f6d87ec0..9b64716f 100644 --- a/lua/grug-far/test/helpers.lua +++ b/lua/grug-far/test/helpers.lua @@ -24,6 +24,7 @@ function M.getBufExtmarksVirtText(buf, namespaceName) for i = 1, #marks do local _, _, _, details = unpack(marks[i]) + ---@diagnostic disable-next-line: need-check-nil local virt_lines = details.virt_lines if virt_lines then for j = 1, #virt_lines do @@ -36,6 +37,7 @@ function M.getBufExtmarksVirtText(buf, namespaceName) end end + ---@diagnostic disable-next-line: need-check-nil local virt_text = details.virt_text if virt_text then for l = 1, #virt_text do @@ -248,7 +250,7 @@ end --- writes files given based on given spec to temp test dir --- clears out temp test dir beforehand ----@param files {[string]: string} +---@param files {filename: string, content: string}[] ---@param dirs? string[] function M.writeTestFiles(files, dirs) vim.fn.delete('./temp_test_dir', 'rf')