Switch to emmylua for type-checking
Some checks failed
NeoVim tests / code-quality (push) Failing after 1m6s
Some checks failed
NeoVim tests / code-quality (push) Failing after 1m6s
This commit is contained in:
parent
9fcc803805
commit
fd7b53ab05
17
.emmyrc.json
Normal file
17
.emmyrc.json
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"$schema": "https://raw.githubusercontent.com/EmmyLuaLs/emmylua-analyzer-rust/refs/heads/main/crates/emmylua_code_analysis/resources/schema.json",
|
||||||
|
"diagnostics": {
|
||||||
|
"enable": true,
|
||||||
|
"globals": ["vim", "it", "describe", "before_each", "after_each"]
|
||||||
|
},
|
||||||
|
"runtime": {
|
||||||
|
"version": "LuaJIT"
|
||||||
|
},
|
||||||
|
"workspace": {
|
||||||
|
"library": [
|
||||||
|
"$VIMRUNTIME",
|
||||||
|
"library/busted",
|
||||||
|
"library/luassert"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
20
.gitmodules
vendored
Normal file
20
.gitmodules
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
; [submodule "library/busted"]
|
||||||
|
; path = library/busted
|
||||||
|
; url = https://github.com/LuaCATS/busted
|
||||||
|
; branch = main
|
||||||
|
; [submodule "library/luassert"]
|
||||||
|
; path = library/luassert
|
||||||
|
; url = https://github.com/LuaCATS/luassert
|
||||||
|
; branch = main
|
||||||
|
; [submodule "library/luv"]
|
||||||
|
; path = library/luv
|
||||||
|
; url = https://github.com/LuaCATS/luv
|
||||||
|
; branch = main
|
||||||
|
[submodule "library/busted"]
|
||||||
|
path = library/busted
|
||||||
|
url = https://github.com/LuaCATS/busted
|
||||||
|
branch = main
|
||||||
|
[submodule "library/luassert"]
|
||||||
|
path = library/luassert
|
||||||
|
url = https://github.com/LuaCATS/luassert
|
||||||
|
branch = main
|
@ -1,2 +0,0 @@
|
|||||||
-- :vim set ft=lua
|
|
||||||
globals = { "vim" }
|
|
4
Makefile
4
Makefile
@ -1,8 +1,10 @@
|
|||||||
|
export VIMRUNTIME := $(shell nvim -u NORC --headless +'echo $$VIMRUNTIME' +'quitall' 2>&1)
|
||||||
|
|
||||||
all: lint fmt-check test
|
all: lint fmt-check test
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@echo "## Typechecking"
|
@echo "## Typechecking"
|
||||||
@lua-language-server --check=lua/u/ --checklevel=Error
|
@emmylua_check .
|
||||||
|
|
||||||
fmt-check:
|
fmt-check:
|
||||||
@echo "## Checking code format"
|
@echo "## Checking code format"
|
||||||
|
@ -10,8 +10,8 @@
|
|||||||
-- change on the underlying filesystem.
|
-- change on the underlying filesystem.
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- @alias u.examples.FsDir { kind: 'dir'; path: string; expanded: boolean; children: u.examples.FsNode[] }
|
--- @alias u.examples.FsDir { kind: 'dir', path: string, expanded: boolean, children: u.examples.FsNode[] }
|
||||||
--- @alias u.examples.FsFile { kind: 'file'; path: string }
|
--- @alias u.examples.FsFile { kind: 'file', path: string }
|
||||||
--- @alias u.examples.FsNode u.examples.FsDir | u.examples.FsFile
|
--- @alias u.examples.FsNode u.examples.FsDir | u.examples.FsFile
|
||||||
--- @alias u.examples.ShowOpts { root_path?: string, width?: number, focus_path?: string }
|
--- @alias u.examples.ShowOpts { root_path?: string, width?: number, focus_path?: string }
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ function H.relative(path, base)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @param root_path string
|
--- @param root_path string
|
||||||
--- @return { tree: u.examples.FsDir; path_to_node: table<string, u.examples.FsNode> }
|
--- @return { tree: u.examples.FsDir, path_to_node: table<string, u.examples.FsNode> }
|
||||||
function H.get_tree_inf(root_path)
|
function H.get_tree_inf(root_path)
|
||||||
logger:info { 'get_tree_inf', root_path }
|
logger:info { 'get_tree_inf', root_path }
|
||||||
--- @type table<string, u.examples.FsNode>
|
--- @type table<string, u.examples.FsNode>
|
||||||
@ -113,10 +113,10 @@ function H.populate_dir_children(tree, path_to_node)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @param opts {
|
--- @param opts {
|
||||||
--- bufnr: number;
|
--- bufnr: number,
|
||||||
--- prev_winnr: number;
|
--- prev_winnr: number,
|
||||||
--- root_path: string;
|
--- root_path: string,
|
||||||
--- focus_path?: string;
|
--- focus_path?: string
|
||||||
--- }
|
--- }
|
||||||
---
|
---
|
||||||
--- @return { expand: fun(path: string), collapse: fun(path: string) }
|
--- @return { expand: fun(path: string), collapse: fun(path: string) }
|
||||||
@ -310,7 +310,7 @@ local function _render_in_buffer(opts)
|
|||||||
--
|
--
|
||||||
local renderer = Renderer.new(opts.bufnr)
|
local renderer = Renderer.new(opts.bufnr)
|
||||||
tracker.create_effect(function()
|
tracker.create_effect(function()
|
||||||
--- @type { tree: u.examples.FsDir; path_to_node: table<string, u.examples.FsNode> }
|
--- @type { tree: u.examples.FsDir, path_to_node: table<string, u.examples.FsNode> }
|
||||||
local tree_inf = s_tree_inf:get()
|
local tree_inf = s_tree_inf:get()
|
||||||
local tree = tree_inf.tree
|
local tree = tree_inf.tree
|
||||||
|
|
||||||
@ -407,9 +407,9 @@ end
|
|||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- @type {
|
--- @type {
|
||||||
--- bufnr: number;
|
--- bufnr: number,
|
||||||
--- winnr: number;
|
--- winnr: number,
|
||||||
--- controller: { expand: fun(path: string), collapse: fun(path: string) };
|
--- controller: { expand: fun(path: string), collapse: fun(path: string) }
|
||||||
--- } | nil
|
--- } | nil
|
||||||
local current_inf = nil
|
local current_inf = nil
|
||||||
|
|
||||||
|
@ -23,10 +23,10 @@ vim.api.nvim_create_autocmd('VimResized', {
|
|||||||
})
|
})
|
||||||
|
|
||||||
--- @alias u.examples.Notification {
|
--- @alias u.examples.Notification {
|
||||||
--- kind: number;
|
--- kind: number,
|
||||||
--- id: number;
|
--- id: number,
|
||||||
--- text: string;
|
--- text: string,
|
||||||
--- timer: uv.uv_timer_t;
|
--- timer: uv.uv_timer_t
|
||||||
--- }
|
--- }
|
||||||
|
|
||||||
local M = {}
|
local M = {}
|
||||||
|
@ -44,22 +44,22 @@ local function shallow_copy_arr(arr) return vim.iter(arr):totable() end
|
|||||||
-- shortest portion of this function.
|
-- shortest portion of this function.
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
|
|
||||||
--- @alias u.examples.SelectController {
|
--- @alias u.examples.SelectController<T> {
|
||||||
--- get_items: fun(): T[];
|
--- get_items: fun(): T[],
|
||||||
--- set_items: fun(items: T[]);
|
--- set_items: fun(items: T[]),
|
||||||
--- set_filter_text: fun(filter_text: string);
|
--- set_filter_text: fun(filter_text: string),
|
||||||
--- get_selected_indices: fun(): number[];
|
--- get_selected_indices: fun(): number[],
|
||||||
--- get_selected_items: fun(): T[];
|
--- get_selected_items: fun(): T[],
|
||||||
--- set_selected_indices: fun(indicies: number[], ephemeral?: boolean);
|
--- set_selected_indices: fun(indicies: number[], ephemeral?: boolean),
|
||||||
--- close: fun();
|
--- close: fun()
|
||||||
--- }
|
--- }
|
||||||
--- @alias u.examples.SelectOpts<T> {
|
--- @alias u.examples.SelectOpts<T> {
|
||||||
--- items: `T`[];
|
--- items: `T`[],
|
||||||
--- multi?: boolean;
|
--- multi?: boolean,
|
||||||
--- format_item?: fun(item: T): u.renderer.Tree;
|
--- format_item?: (fun(item: T): u.renderer.Tree),
|
||||||
--- on_finish?: fun(items: T[], indicies: number[]);
|
--- on_finish?: (fun(items: T[], indicies: number[])),
|
||||||
--- on_selection_changed?: fun(items: T[], indicies: number[]);
|
--- on_selection_changed?: fun(items: T[], indicies: number[]),
|
||||||
--- mappings?: table<string, fun(select: u.examples.SelectController)>;
|
--- mappings?: table<string, fun(select: u.examples.SelectController)>
|
||||||
--- }
|
--- }
|
||||||
|
|
||||||
--- @generic T
|
--- @generic T
|
||||||
@ -326,7 +326,7 @@ function M.create_picker(opts) -- {{{
|
|||||||
safe_wrap(function()
|
safe_wrap(function()
|
||||||
local items = s_items:get()
|
local items = s_items:get()
|
||||||
local selected_indices = s_selected_indices: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 filtered_items = s_filtered_items:get()
|
||||||
local cursor_index = s_cursor_index:get()
|
local cursor_index = s_cursor_index:get()
|
||||||
local indices = shallow_copy_arr(selected_indices)
|
local indices = shallow_copy_arr(selected_indices)
|
||||||
@ -477,7 +477,7 @@ function M.create_picker(opts) -- {{{
|
|||||||
local selected_indices = s_selected_indices:get()
|
local selected_indices = s_selected_indices:get()
|
||||||
local top_offset = s_top_offset:get()
|
local top_offset = s_top_offset:get()
|
||||||
local cursor_index = s_cursor_index: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()
|
local visible_items = s_visible_items:get()
|
||||||
|
|
||||||
-- The above has to run in the execution context for the signaling to work, but
|
-- The above has to run in the execution context for the signaling to work, but
|
||||||
@ -791,14 +791,14 @@ function M.buffers() -- {{{
|
|||||||
-- ensure that `cwd` ends with a trailing slash:
|
-- ensure that `cwd` ends with a trailing slash:
|
||||||
if cwd[#cwd] ~= '/' then cwd = cwd .. '/' end
|
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 }
|
local bufs = vim.fn.getbufinfo { buflisted = 1 }
|
||||||
|
|
||||||
M.create_picker {
|
M.create_picker {
|
||||||
multi = true,
|
multi = true,
|
||||||
items = bufs,
|
items = bufs,
|
||||||
|
|
||||||
--- @param item { name: string; changed: number; bufnr: number }
|
--- @param item { name: string, changed: number, bufnr: number }
|
||||||
format_item = function(item)
|
format_item = function(item)
|
||||||
local item_name = item.name
|
local item_name = item.name
|
||||||
if item_name == '' then item_name = '[No Name]' end
|
if item_name == '' then item_name = '[No Name]' end
|
||||||
|
@ -21,10 +21,10 @@ local surrounds = {
|
|||||||
['`'] = { left = '`', right = '`' },
|
['`'] = { left = '`', right = '`' },
|
||||||
}
|
}
|
||||||
|
|
||||||
--- @type { left: string; right: string } | nil
|
--- @type { left: string, right: string } | nil
|
||||||
local CACHED_BOUNDS = nil
|
local CACHED_BOUNDS = nil
|
||||||
|
|
||||||
--- @return { left: string; right: string }|nil
|
--- @return { left: string, right: string }|nil
|
||||||
local function prompt_for_bounds()
|
local function prompt_for_bounds()
|
||||||
if vim_repeat.is_repeating() then
|
if vim_repeat.is_repeating() then
|
||||||
-- If we are repeating, we don't want to prompt for bounds, because
|
-- If we are repeating, we don't want to prompt for bounds, because
|
||||||
@ -55,7 +55,7 @@ local function prompt_for_bounds()
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @param range u.Range
|
--- @param range u.Range
|
||||||
--- @param bounds { left: string; right: string }
|
--- @param bounds { left: string, right: string }
|
||||||
local function do_surround(range, bounds)
|
local function do_surround(range, bounds)
|
||||||
local left = bounds.left
|
local left = bounds.left
|
||||||
local right = bounds.right
|
local right = bounds.right
|
||||||
|
1
library/busted
Submodule
1
library/busted
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit 5ed85d0e016a5eb5eca097aa52905eedf1b180f1
|
1
library/luassert
Submodule
1
library/luassert
Submodule
@ -0,0 +1 @@
|
|||||||
|
Subproject commit d3528bb679302cbfdedefabb37064515ab95f7b9
|
@ -62,7 +62,7 @@ end
|
|||||||
function Buffer:lines(start, stop) return Range.from_lines(self.bufnr, start, stop) end
|
function Buffer:lines(start, stop) return Range.from_lines(self.bufnr, start, stop) end
|
||||||
|
|
||||||
--- @param motion string
|
--- @param motion string
|
||||||
--- @param opts? { contains_cursor?: boolean; pos?: u.Pos }
|
--- @param opts? { contains_cursor?: boolean, pos?: u.Pos }
|
||||||
function Buffer:motion(motion, opts)
|
function Buffer:motion(motion, opts)
|
||||||
opts = vim.tbl_extend('force', opts or {}, { bufnr = self.bufnr })
|
opts = vim.tbl_extend('force', opts or {}, { bufnr = self.bufnr })
|
||||||
return Range.from_motion(motion, opts)
|
return Range.from_motion(motion, opts)
|
||||||
|
@ -5,7 +5,6 @@ local __U__OpKeymapOpFunc_rhs = nil
|
|||||||
|
|
||||||
--- This is the global utility function used for operatorfunc
|
--- This is the global utility function used for operatorfunc
|
||||||
--- in opkeymap
|
--- in opkeymap
|
||||||
--- @type nil|fun(range: u.Range): fun():any|nil
|
|
||||||
--- @param ty 'line'|'char'|'block'
|
--- @param ty 'line'|'char'|'block'
|
||||||
-- selene: allow(unused_variable)
|
-- selene: allow(unused_variable)
|
||||||
function _G.__U__OpKeymapOpFunc(ty)
|
function _G.__U__OpKeymapOpFunc(ty)
|
||||||
|
@ -112,7 +112,7 @@ function Range.from_lines(bufnr, start_line, stop_line)
|
|||||||
end
|
end
|
||||||
|
|
||||||
--- @param motion string
|
--- @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
|
--- @return u.Range|nil
|
||||||
function Range.from_motion(motion, opts)
|
function Range.from_motion(motion, opts)
|
||||||
-- Options handling:
|
-- Options handling:
|
||||||
@ -513,7 +513,7 @@ function Range:text() return vim.fn.join(self:lines(), '\n') end
|
|||||||
|
|
||||||
--- @param l number
|
--- @param l number
|
||||||
-- luacheck: ignore
|
-- 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)
|
function Range:line(l)
|
||||||
if l < 0 then l = self:line_count() + l + 1 end
|
if l < 0 then l = self:line_count() + l + 1 end
|
||||||
if l > self:line_count() then return end
|
if l > self:line_count() then return end
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
{
|
{
|
||||||
pkgs ?
|
pkgs ?
|
||||||
import
|
import
|
||||||
# nixos-25.05 (neovim@0.11.2):
|
# nixos-unstable (neovim@0.11.4):
|
||||||
(fetchTarball {
|
(fetchTarball {
|
||||||
url = "https://github.com/nixos/nixpkgs/archive/1c1c9b3f5ec0421eaa0f22746295466ee6a8d48f.tar.gz";
|
url = "https://github.com/nixos/nixpkgs/archive/0b4defa2584313f3b781240b29d61f6f9f7e0df3.tar.gz";
|
||||||
sha256 = "0szvq1swpzyjmyyw929ngxy1khdnd9ba96qds2bm6l6kg4iq3cq0";
|
sha256 = "0p3rrd8wwlk0iwgzm7frkw1k98ywrh0avi7fqjjk87i68n3inxrs";
|
||||||
})
|
})
|
||||||
{ },
|
{ },
|
||||||
}:
|
}:
|
||||||
@ -12,7 +12,7 @@ pkgs.mkShell {
|
|||||||
packages = [
|
packages = [
|
||||||
pkgs.git
|
pkgs.git
|
||||||
pkgs.gnumake
|
pkgs.gnumake
|
||||||
pkgs.lua-language-server
|
pkgs.emmylua-ls
|
||||||
pkgs.lua51Packages.busted
|
pkgs.lua51Packages.busted
|
||||||
pkgs.lua51Packages.luacov
|
pkgs.lua51Packages.luacov
|
||||||
pkgs.lua51Packages.luarocks
|
pkgs.lua51Packages.luarocks
|
||||||
|
Loading…
x
Reference in New Issue
Block a user