From 9199a9bc3a3cec77dcc0176cd9a2695f36bf03ce Mon Sep 17 00:00:00 2001 From: Jonathan Apodaca Date: Sun, 18 Jan 2026 21:01:05 -0700 Subject: [PATCH] convert to mise --- .emmyrc.json | 22 ++++++++ .github/workflows/ci.yaml | 69 +++++++++++++++++------- .gitignore | 1 + .gitmodules | 12 +++++ .luarc.json | 16 ++++++ .styluaignore | 1 + Makefile | 24 --------- examples/filetree.lua | 32 ++++++------ examples/notify.lua | 11 ++-- examples/picker.lua | 40 +++++++------- examples/surround.lua | 6 +-- library/busted | 1 + library/luv | 1 + lua/u/buffer.lua | 2 +- lua/u/opkeymap.lua | 4 +- lua/u/range.lua | 4 +- lua/u/renderer.lua | 37 ++++++------- mise.toml | 107 ++++++++++++++++++++++++++++++++++++++ nvimv | 1 + scripts/env.sh | 6 +++ spec/buffer_spec.lua | 1 + spec/codewriter_spec.lua | 1 + spec/pos_spec.lua | 1 + spec/range_spec.lua | 1 + spec/renderer_spec.lua | 1 + spec/tracker_spec.lua | 1 + u-0.0.0-0.rockspec | 16 ++++++ 27 files changed, 304 insertions(+), 115 deletions(-) create mode 100644 .emmyrc.json create mode 100644 .gitmodules create mode 100644 .luarc.json create mode 100644 .styluaignore delete mode 100644 Makefile create mode 160000 library/busted create mode 160000 library/luv create mode 100644 mise.toml create mode 160000 nvimv create mode 100644 scripts/env.sh create mode 100644 u-0.0.0-0.rockspec diff --git a/.emmyrc.json b/.emmyrc.json new file mode 100644 index 0000000..4825843 --- /dev/null +++ b/.emmyrc.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://raw.githubusercontent.com/EmmyLuaLs/emmylua-analyzer-rust/refs/heads/main/crates/emmylua_code_analysis/resources/schema.json", + "diagnostics": { + "disable": [ + "access-invisible", + "redefined-local" + ] + }, + "runtime": { + "version": "LuaJIT" + }, + "workspace": { + "ignoreDir": [ + ".prefix" + ], + "library": [ + "$VIMRUNTIME", + "library/busted", + "library/luv" + ] + } +} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 55d9ab4..a74cf7f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,29 +1,60 @@ # yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json -name: NeoVim tests -on: [push] +name: ci + +on: + workflow_dispatch: + pull_request: + push: + tags: ["*"] + branches: ["*"] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +env: + MISE_EXPERIMENTAL: true + jobs: - code-quality: + ci: runs-on: ubuntu-latest - env: - XDG_CONFIG_HOME: ${{ github.workspace }}/.config/ + timeout-minutes: 10 steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v31 with: - nix_path: nixpkgs=channel:nixos-unstable + submodules: true - - name: Populate Nix store - run: - nix-shell --pure --run 'true' + - name: Install apt dependencies + run: | + sudo apt-get update + sudo apt-get install -y libreadline-dev - - name: Type-check with lua-language-server - run: - nix-shell --pure --run 'make lint' + - name: Setup environment + run: | + if [ -n "${{secrets.TOKEN}}" ]; then + export GITHUB_TOKEN="${{secrets.TOKEN}}" + fi + export MISE_GITHUB_TOKEN="$GITHUB_TOKEN" + echo "$GITHUB_TOKEN" >> $GITHUB_ENV + echo "$MISE_GITHUB_TOKEN" >> $GITHUB_ENV - - name: Check formatting with stylua - run: - nix-shell --pure --run 'make fmt-check' + - name: Install mise + run: | + curl https://mise.run | sh + echo "$HOME/.local/bin" >> $GITHUB_PATH + echo "$HOME/.local/share/mise/bin" >> $GITHUB_PATH + echo "$HOME/.local/share/mise/shims" >> $GITHUB_PATH - - name: Run busted tests - run: - nix-shell --pure --run 'make test' + - name: Install mise dependencies + run: | + mise install + mise list --local + + - name: Check Lua formatting + run: mise run fmt:check + + - name: Check for type-errors + run: mise run lint + + - name: Run tests + run: mise run test:all diff --git a/.gitignore b/.gitignore index 202f9f8..6eac4e6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.prefix/ *.src.rock *.aider* luacov.*.out diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..072ad6f --- /dev/null +++ b/.gitmodules @@ -0,0 +1,12 @@ +[submodule "library/busted"] + path = library/busted + url = https://github.com/LuaCATS/busted + branch = main +[submodule "library/luv"] + path = library/luv + url = https://github.com/LuaCATS/luv + branch = main +[submodule "nvimv"] + path = nvimv + url = https://github.com/jrop/nvimv + branch = main diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..a659baf --- /dev/null +++ b/.luarc.json @@ -0,0 +1,16 @@ +{ + "$schema": "https://raw.githubusercontent.com/LuaLS/vscode-lua/refs/heads/master/setting/schema.json", + "runtime": { + "version": "LuaJIT" + }, + "workspace": { + "ignoreDir": [ + ".prefix" + ], + "library": [ + "$VIMRUNTIME", + "library/busted", + "library/luv" + ] + } +} diff --git a/.styluaignore b/.styluaignore new file mode 100644 index 0000000..69fb129 --- /dev/null +++ b/.styluaignore @@ -0,0 +1 @@ +library/ diff --git a/Makefile b/Makefile deleted file mode 100644 index 4e5b84f..0000000 --- a/Makefile +++ /dev/null @@ -1,24 +0,0 @@ -all: lint fmt-check test - -lint: - @echo "## Typechecking" - @lua-language-server --check=lua/u/ --checklevel=Error - -fmt-check: - @echo "## Checking code format" - @stylua --check . - -fmt: - @echo "## Formatting code" - @stylua . - -test: - @rm -f luacov.*.out - @echo "## Running tests" - @busted --coverage --verbose - @echo "## Generating coverage report" - @luacov - @awk '/^Summary$$/{flag=1;next} flag{print}' luacov.report.out - -watch: - @watchexec -c -e lua make diff --git a/examples/filetree.lua b/examples/filetree.lua index ed175b0..7e8b359 100644 --- a/examples/filetree.lua +++ b/examples/filetree.lua @@ -10,8 +10,12 @@ -- change on the underlying filesystem. -------------------------------------------------------------------------------- ---- @alias u.examples.FsDir { kind: 'dir'; path: string; expanded: boolean; children: u.examples.FsNode[] } ---- @alias u.examples.FsFile { kind: 'file'; path: string } +--- @class u.examples.FsDir +--- @field kind 'dir' +--- @field path string +--- @field expanded boolean +--- @field children u.examples.FsNode[] +--- @alias u.examples.FsFile table --- @alias u.examples.FsNode u.examples.FsDir | u.examples.FsFile --- @alias u.examples.ShowOpts { root_path?: string, width?: number, focus_path?: string } @@ -58,7 +62,7 @@ function H.relative(path, base) end --- @param root_path string ---- @return { tree: u.examples.FsDir; path_to_node: table } +--- @return { tree: u.examples.FsDir, path_to_node: table } function H.get_tree_inf(root_path) logger:info { 'get_tree_inf', root_path } --- @type table @@ -112,12 +116,11 @@ function H.populate_dir_children(tree, path_to_node) end) end ---- @param opts { ---- bufnr: number; ---- prev_winnr: number; ---- root_path: string; ---- focus_path?: string; ---- } +--- @class u.examples.RenderOpts +--- @field bufnr number +--- @field prev_winnr number +--- @field root_path string +--- @field focus_path? string --- --- @return { expand: fun(path: string), collapse: fun(path: string) } local function _render_in_buffer(opts) @@ -310,7 +313,7 @@ local function _render_in_buffer(opts) -- local renderer = Renderer.new(opts.bufnr) tracker.create_effect(function() - --- @type { tree: u.examples.FsDir; path_to_node: table } + --- @type { tree: u.examples.FsDir, path_to_node: table } local tree_inf = s_tree_inf:get() local tree = tree_inf.tree @@ -406,11 +409,10 @@ end -- Public API functions: -------------------------------------------------------------------------------- ---- @type { ---- bufnr: number; ---- winnr: number; ---- controller: { expand: fun(path: string), collapse: fun(path: string) }; ---- } | nil +--- @class u.examples.CurrentInf +--- @field bufnr number +--- @field winnr number +--- @field controller table local current_inf = nil --- Show the filetree: diff --git a/examples/notify.lua b/examples/notify.lua index bce6db3..3e078d1 100644 --- a/examples/notify.lua +++ b/examples/notify.lua @@ -22,12 +22,11 @@ vim.api.nvim_create_autocmd('VimResized', { end, }) ---- @alias u.examples.Notification { ---- kind: number; ---- id: number; ---- text: string; ---- timer: uv.uv_timer_t; ---- } +--- @class u.examples.Notification +--- @field kind number +--- @field id number +--- @field text string +--- @field timer uv.uv_timer_t local M = {} diff --git a/examples/picker.lua b/examples/picker.lua index 1075f46..eaadd0c 100644 --- a/examples/picker.lua +++ b/examples/picker.lua @@ -44,23 +44,21 @@ local function shallow_copy_arr(arr) return vim.iter(arr):totable() end -- shortest portion of this function. -------------------------------------------------------------------------------- ---- @alias u.examples.SelectController { ---- get_items: fun(): T[]; ---- set_items: fun(items: T[]); ---- set_filter_text: fun(filter_text: string); ---- get_selected_indices: fun(): number[]; ---- get_selected_items: fun(): T[]; ---- set_selected_indices: fun(indicies: number[], ephemeral?: boolean); ---- close: fun(); ---- } ---- @alias u.examples.SelectOpts { ---- items: `T`[]; ---- multi?: boolean; ---- format_item?: fun(item: T): u.renderer.Tree; ---- on_finish?: fun(items: T[], indicies: number[]); ---- on_selection_changed?: fun(items: T[], indicies: number[]); ---- mappings?: table; ---- } +--- @class u.examples.SelectController +--- @field get_items fun(): T[] +--- @field set_items fun(items: T[]) +--- @field set_filter_text fun(filter_text: string) +--- @field get_selected_indices fun(): number[] +--- @field get_selected_items fun(): T[] +--- @field set_selected_indices fun(indices: number[], ephemeral?: boolean) +--- @field close fun() +--- @class u.examples.SelectOpts +--- @field items T[] +--- @field multi? boolean +--- @field format_item? fun(item: T): u.renderer.Tree +--- @field on_finish? fun(items: T[], indices: number[]) +--- @field on_selection_changed? fun(items: T[], indices: number[]) +--- @field mappings? table --- @generic T --- @param opts u.examples.SelectOpts @@ -326,7 +324,7 @@ function M.create_picker(opts) -- {{{ safe_wrap(function() local items = s_items:get() local selected_indices = s_selected_indices:get() - --- @type { orig_idx: number; item: T }[] + --- @type { orig_idx: number, item: T }[] local filtered_items = s_filtered_items:get() local cursor_index = s_cursor_index:get() local indices = shallow_copy_arr(selected_indices) @@ -477,7 +475,7 @@ function M.create_picker(opts) -- {{{ local selected_indices = s_selected_indices:get() local top_offset = s_top_offset:get() local cursor_index = s_cursor_index:get() - --- @type { filtered_idx: number; orig_idx: number; item: T; formatted: string }[] + --- @type { filtered_idx: number, orig_idx: number, item: T, formatted: string }[] local visible_items = s_visible_items:get() -- The above has to run in the execution context for the signaling to work, but @@ -791,14 +789,14 @@ function M.buffers() -- {{{ -- ensure that `cwd` ends with a trailing slash: if cwd[#cwd] ~= '/' then cwd = cwd .. '/' end - --- @type { name: string; changed: number; bufnr: number }[] + --- @type { name: string, changed: number, bufnr: number }[] local bufs = vim.fn.getbufinfo { buflisted = 1 } M.create_picker { multi = true, items = bufs, - --- @param item { name: string; changed: number; bufnr: number } + --- @param item { name: string, changed: number, bufnr: number } format_item = function(item) local item_name = item.name if item_name == '' then item_name = '[No Name]' end diff --git a/examples/surround.lua b/examples/surround.lua index 1b1c1fc..db4aa31 100644 --- a/examples/surround.lua +++ b/examples/surround.lua @@ -21,10 +21,10 @@ local surrounds = { ['`'] = { left = '`', right = '`' }, } ---- @type { left: string; right: string } | nil +--- @type { left: string, right: string } | nil local CACHED_BOUNDS = nil ---- @return { left: string; right: string }|nil +--- @return { left: string, right: string }|nil local function prompt_for_bounds() if vim_repeat.is_repeating() then -- If we are repeating, we don't want to prompt for bounds, because @@ -55,7 +55,7 @@ local function prompt_for_bounds() end --- @param range u.Range ---- @param bounds { left: string; right: string } +--- @param bounds { left: string, right: string } local function do_surround(range, bounds) local left = bounds.left local right = bounds.right diff --git a/library/busted b/library/busted new file mode 160000 index 0000000..5ed85d0 --- /dev/null +++ b/library/busted @@ -0,0 +1 @@ +Subproject commit 5ed85d0e016a5eb5eca097aa52905eedf1b180f1 diff --git a/library/luv b/library/luv new file mode 160000 index 0000000..3615eb1 --- /dev/null +++ b/library/luv @@ -0,0 +1 @@ +Subproject commit 3615eb12c94a7cfa7184b8488cf908abb5e94c9c diff --git a/lua/u/buffer.lua b/lua/u/buffer.lua index b380a61..f27f5c0 100644 --- a/lua/u/buffer.lua +++ b/lua/u/buffer.lua @@ -62,7 +62,7 @@ end function Buffer:lines(start, stop) return Range.from_lines(self.bufnr, start, stop) end --- @param motion string ---- @param opts? { contains_cursor?: boolean; pos?: u.Pos } +--- @param opts? { contains_cursor?: boolean, pos?: u.Pos } function Buffer:motion(motion, opts) opts = vim.tbl_extend('force', opts or {}, { bufnr = self.bufnr }) return Range.from_motion(motion, opts) diff --git a/lua/u/opkeymap.lua b/lua/u/opkeymap.lua index 0942495..9a83a9d 100644 --- a/lua/u/opkeymap.lua +++ b/lua/u/opkeymap.lua @@ -3,9 +3,7 @@ local Range = require 'u.range' --- @type fun(range: u.Range): nil|(fun():any) local __U__OpKeymapOpFunc_rhs = nil ---- This is the global utility function used for operatorfunc ---- in opkeymap ---- @type nil|fun(range: u.Range): fun():any|nil +--- This is the global utility function used for operatorfunc in opkeymap --- @param ty 'line'|'char'|'block' -- selene: allow(unused_variable) function _G.__U__OpKeymapOpFunc(ty) diff --git a/lua/u/range.lua b/lua/u/range.lua index 6baed0d..ff5900a 100644 --- a/lua/u/range.lua +++ b/lua/u/range.lua @@ -112,7 +112,7 @@ function Range.from_lines(bufnr, start_line, stop_line) end --- @param motion string ---- @param opts? { bufnr?: number; contains_cursor?: boolean; pos?: u.Pos, user_defined?: boolean } +--- @param opts? { bufnr?: number, contains_cursor?: boolean, pos?: u.Pos, user_defined?: boolean } --- @return u.Range|nil function Range.from_motion(motion, opts) -- Options handling: @@ -513,7 +513,7 @@ function Range:text() return vim.fn.join(self:lines(), '\n') end --- @param l number -- luacheck: ignore ---- @return { line: string; idx0: { start: number; stop: number; }; lnum: number; range: fun():u.Range; text: fun():string }|nil +--- @return { line: string, idx0: { start: number, stop: number }, lnum: number, range: fun():u.Range, text: fun():string }|nil function Range:line(l) if l < 0 then l = self:line_count() + l + 1 end if l > self:line_count() then return end diff --git a/lua/u/renderer.lua b/lua/u/renderer.lua index 73abb8c..fbd59d5 100644 --- a/lua/u/renderer.lua +++ b/lua/u/renderer.lua @@ -15,7 +15,7 @@ local H = {} --- @alias u.renderer.TagEventHandler fun(tag: u.renderer.Tag, mode: string, lhs: string): string ---- @alias u.renderer.TagAttributes { [string]?: unknown; imap?: table; nmap?: table; vmap?: table; xmap?: table; omap?: table, on_change?: fun(text: string): unknown } +--- @alias u.renderer.TagAttributes { [string]?: unknown, imap?: table, nmap?: table, vmap?: table, xmap?: table, omap?: table, on_change?: fun(text: string): unknown } --- @class u.renderer.Tag --- @field kind 'tag' @@ -56,8 +56,8 @@ M.h = setmetatable({}, { --- @field bufnr number --- @field ns number --- @field changedtick number ---- @field old { lines: string[]; extmarks: u.renderer.RendererExtmark[] } ---- @field curr { lines: string[]; extmarks: u.renderer.RendererExtmark[] } +--- @field old { lines: string[], extmarks: u.renderer.RendererExtmark[] } +--- @field curr { lines: string[], extmarks: u.renderer.RendererExtmark[] } local Renderer = {} Renderer.__index = Renderer M.Renderer = Renderer @@ -98,10 +98,9 @@ function Renderer.new(bufnr) -- {{{ return self end -- }}} ---- @param opts { ---- tree: u.renderer.Tree; ---- on_tag?: fun(tag: u.renderer.Tag, start0: [number, number], stop0: [number, number]): any; ---- } +--- @class u.renderer.MarkupOpts +--- @field tree u.renderer.Tree +--- @field on_tag? fun(tag: u.renderer.Tag, start0: [number, number], stop0: [number, number]): any function Renderer.markup_to_lines(opts) -- {{{ --- @type string[] local lines = {} @@ -158,10 +157,9 @@ function Renderer.markup_to_lines(opts) -- {{{ return lines end -- }}} ---- @param opts { ---- tree: u.renderer.Tree; ---- format_tag?: fun(tag: u.renderer.Tag): string; ---- } +--- @class u.renderer.StringOpts +--- @field tree u.renderer.Tree +--- @field format_tag? fun(tag: u.renderer.Tag): string function Renderer.markup_to_string(opts) return table.concat(Renderer.markup_to_lines(opts), '\n') end --- @param bufnr number @@ -534,9 +532,9 @@ end -- }}} --- (outermost). --- --- @private (private for now) ---- @param pos0 [number; number] +--- @param pos0 [number, number] --- @param mode string? ---- @return { extmark: u.renderer.RendererExtmark; tag: u.renderer.Tag; }[] +--- @return { extmark: u.renderer.RendererExtmark, tag: u.renderer.Tag }[] function Renderer:get_tags_at(pos0, mode) -- {{{ local cursor_line0, cursor_col0 = pos0[1], pos0[2] if not mode then mode = vim.api.nvim_get_mode().mode end @@ -560,9 +558,8 @@ function Renderer:get_tags_at(pos0, mode) -- {{{ --- @type u.renderer.RendererExtmark[] local mapped_extmarks = vim .iter(raw_overlapping_extmarks) - --- @return u.renderer.RendererExtmark :map(function(ext) - --- @type number, number, number, { end_row?: number; end_col?: number }|nil + --- @type number, number, number, { end_row?: number, end_col?: number }|nil local id, line0, col0, details = unpack(ext) local start = { line0, col0 } local stop = { line0, col0 } @@ -575,7 +572,6 @@ function Renderer:get_tags_at(pos0, mode) -- {{{ local intersecting_extmarks = vim .iter(mapped_extmarks) - --- @param ext u.renderer.RendererExtmark :filter(function(ext) if ext.stop[1] ~= nil and ext.stop[2] ~= nil then -- If we've "ciw" and "collapsed" an extmark onto the cursor, @@ -640,10 +636,9 @@ function Renderer:get_tags_at(pos0, mode) -- {{{ -- created extmarks in self.curr.extmarks, which also has which tag each -- extmark is associated with. Cross-reference with that list to get a list -- of tags that we need to fire events for: - --- @type { extmark: u.renderer.RendererExtmark; tag: u.renderer.Tag }[] + --- @type { extmark: u.renderer.RendererExtmark, tag: u.renderer.Tag }[] local matching_tags = vim .iter(intersecting_extmarks) - --- @param ext u.renderer.RendererExtmark :map(function(ext) for _, extmark_cache in ipairs(self.curr.extmarks) do if extmark_cache.id == ext.id then return { extmark = ext, tag = extmark_cache.tag } end @@ -656,7 +651,7 @@ end -- }}} --- @private --- @param tag_or_id string | u.renderer.Tag ---- @return { start: [number, number]; stop: [number, number] } | nil +--- @return { start: [number, number], stop: [number, number] } | nil function Renderer:get_tag_bounds(tag_or_id) -- {{{ for _, x in ipairs(self.curr.extmarks) do local pos = { start = x.start, stop = x.stop } @@ -733,12 +728,12 @@ function TreeBuilder:tree() return self.nodes end -- Levenshtein utility {{{ -- luacheck: ignore ---- @alias u.renderer.LevenshteinChange ({ kind: 'add'; item: T; index: number; } | { kind: 'delete'; item: T; index: number; } | { kind: 'change'; from: T; to: T; index: number; }) +--- @alias u.renderer.LevenshteinChange ({ kind: 'add', item: T, index: number } | { kind: 'delete', item: T, index: number } | { kind: 'change', from: T, to: T, index: number }) --- @private --- @generic T --- @param x `T`[] --- @param y T[] ---- @param cost? { of_delete?: fun(x: T): number; of_add?: fun(x: T): number; of_change?: fun(x: T, y: T): number; } +--- @param cost? { of_delete?: (fun(x: T): number), of_add?: (fun(x: T): number), of_change?: (fun(x: T, y: T): number) } --- @return u.renderer.LevenshteinChange[] The changes, from last (greatest index) to first (smallest index). function H.levenshtein(x, y, cost) -- At the moment, this whole `cost` plumbing is not used. Deletes have the diff --git a/mise.toml b/mise.toml new file mode 100644 index 0000000..362d6bf --- /dev/null +++ b/mise.toml @@ -0,0 +1,107 @@ +################################################################################ +## Tool Alias +################################################################################ + +################################################################################ +## Tools +################################################################################ + +[tools] +# nvimv needs jq: +jq = "1.8.1" +"asdf:mise-plugins/mise-lua" = "5.1.5" +# Since we have busted configured to look for "nvim", have a "default" version +# installed. In the tests, we will override with `eval $(nvimv env VERSION)`, +# but to avoid having to litter a bunch of commands with that environment +# initialization, this just makes things simpler: +neovim = "0.11.5" +stylua = "2.3.1" +"cargo:emmylua_ls" = "0.20.0" +"cargo:emmylua_check" = "0.20.0" + +################################################################################ +# Env +################################################################################ + +[env] +ASDF_LUA_LUAROCKS_VERSION = "3.12.2" +_.source = { path = "./scripts/env.sh", tools = true } + +################################################################################ +# Tasks +################################################################################ + +[tasks] +lint = "emmylua_check --ignore '.prefix/**/*.*' ." +fmt = "stylua ." +"fmt:check" = "stylua --check ." +"test:prepare" = ''' +# Install Lua test dependencies (busted, etc.): +luarocks test --prepare +echo + +# Check that the nightly version of Neovim is not more than a day old: +if find .prefix -path '**/nightly/**/nvim' -mtime -1 2>/dev/null | grep -q .; then + echo "Neovim Nightly is up-to-date" +else + if ./nvimv/nvimv ls | grep nightly >/dev/null; then + ./nvimv/nvimv upgrade nightly + else + ./nvimv/nvimv install nightly + fi +fi +echo +''' + +[tasks."test:version:no-prep"] +hide = true +usage = ''' +arg "" help="The version of Neovim to test with" +''' +run = ''' +echo +echo ----------------------------- +echo ----------------------------- +echo Neovim version=$usage_version +echo ----------------------------- +echo ----------------------------- +echo +./nvimv/nvimv install $usage_version +eval $(./nvimv/nvimv env $usage_version) +busted --verbose +''' + +[tasks."test:version"] +depends = ["test:prepare"] +usage = ''' +arg "" help="The version of Neovim to test with" +''' +run = 'mise test:version:no-prep $usage_version' + +[tasks."test"] +run = 'mise test:version 0.11.5' + +[tasks."test:all"] +depends = ["test:prepare"] +run = ''' +VERSIONS="0.11.5 nightly" +for v in $VERSIONS; do + mise test:version:no-prep $v +done +''' + +[tasks."test:coverage"] +depends = ["test:prepare"] +run = ''' +rm -f ./luacov.*.* +busted --coverage --verbose +luacov +awk '/^Summary$/{flag=1;next} flag{print}' luacov.report.out +''' + +[tasks."ci"] +run = ''' +mise run fmt:check +mise run lint +mise run test:all +''' diff --git a/nvimv b/nvimv new file mode 160000 index 0000000..bd5c243 --- /dev/null +++ b/nvimv @@ -0,0 +1 @@ +Subproject commit bd5c243b9606a93ec7034a9a8cbd5671951b90ff diff --git a/scripts/env.sh b/scripts/env.sh new file mode 100644 index 0000000..85e0f19 --- /dev/null +++ b/scripts/env.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +export PREFIX="$(pwd)/.prefix" +export VIMRUNTIME="$(nvim -u NORC --headless +'echo $VIMRUNTIME' +'quitall' 2>&1)" + +eval $(luarocks path) diff --git a/spec/buffer_spec.lua b/spec/buffer_spec.lua index f54129e..f56fdeb 100644 --- a/spec/buffer_spec.lua +++ b/spec/buffer_spec.lua @@ -1,3 +1,4 @@ +--- @diagnostic disable: undefined-field, need-check-nil local Buffer = require 'u.buffer' local withbuf = loadfile './spec/withbuf.lua'() diff --git a/spec/codewriter_spec.lua b/spec/codewriter_spec.lua index c4596de..ddfc63a 100644 --- a/spec/codewriter_spec.lua +++ b/spec/codewriter_spec.lua @@ -1,3 +1,4 @@ +--- @diagnostic disable: undefined-field, need-check-nil, need-check-nil local CodeWriter = require 'u.codewriter' describe('CodeWriter', function() diff --git a/spec/pos_spec.lua b/spec/pos_spec.lua index 8420311..357a2e3 100644 --- a/spec/pos_spec.lua +++ b/spec/pos_spec.lua @@ -1,3 +1,4 @@ +--- @diagnostic disable: undefined-field, need-check-nil local Pos = require 'u.pos' local withbuf = loadfile './spec/withbuf.lua'() diff --git a/spec/range_spec.lua b/spec/range_spec.lua index 4e74ad9..ee40e68 100644 --- a/spec/range_spec.lua +++ b/spec/range_spec.lua @@ -1,3 +1,4 @@ +--- @diagnostic disable: undefined-field, need-check-nil local Pos = require 'u.pos' local Range = require 'u.range' local withbuf = loadfile './spec/withbuf.lua'() diff --git a/spec/renderer_spec.lua b/spec/renderer_spec.lua index 5c4c670..dbe8cfb 100644 --- a/spec/renderer_spec.lua +++ b/spec/renderer_spec.lua @@ -1,3 +1,4 @@ +--- @diagnostic disable: undefined-field, need-check-nil local R = require 'u.renderer' local withbuf = loadfile './spec/withbuf.lua'() diff --git a/spec/tracker_spec.lua b/spec/tracker_spec.lua index fa81607..7457d6b 100644 --- a/spec/tracker_spec.lua +++ b/spec/tracker_spec.lua @@ -1,3 +1,4 @@ +--- @diagnostic disable: undefined-field, need-check-nil local tracker = require 'u.tracker' local Signal = tracker.Signal local ExecutionContext = tracker.ExecutionContext diff --git a/u-0.0.0-0.rockspec b/u-0.0.0-0.rockspec new file mode 100644 index 0000000..29f673b --- /dev/null +++ b/u-0.0.0-0.rockspec @@ -0,0 +1,16 @@ +rockspec_format = '3.0' +package = 'u' +version = '0.0.0-0' + +source = { + url = 'https://github.com/jrop/u.nvim', +} + +dependencies = { + 'lua = 5.1', +} + +test_dependencies = { + 'busted == 2.2.0-1', + 'luacov == 0.16.0-1', +}