From 38c3e961b79c71bd01b569ada440334a3f396d56 Mon Sep 17 00:00:00 2001 From: kawarimidoll Date: Thu, 18 Dec 2025 22:38:17 +0900 Subject: [PATCH 1/3] refactor(types): remove redundant quotes in type aliases Removed unnecessary quotes from Lua type alias annotations for better compatibility with both of lua-language-server and EmmyLua. --- lua/dial/augend/case.lua | 2 +- lua/dial/augend/date.lua | 2 +- lua/dial/augend/hexcolor.lua | 4 ++-- lua/dial/augend/integer.lua | 8 ++++---- lua/dial/augend/semver.lua | 2 +- lua/dial/types.lua | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lua/dial/augend/case.lua b/lua/dial/augend/case.lua index 47b3462..3639e1d 100644 --- a/lua/dial/augend/case.lua +++ b/lua/dial/augend/case.lua @@ -3,7 +3,7 @@ local util = require "dial.util" local M = {} ----@alias casetype '"PascalCase"' | '"camelCase"' | '"snake_case"' | '"kebab-case"' | '"SCREAMING_SNAKE_CASE"' +---@alias casetype "PascalCase" | "camelCase" | "snake_case" | "kebab-case" | "SCREAMING_SNAKE_CASE" ---@alias extractf fun(word: string) -> string[] | nil ---@alias constractf fun(terms: string[]) -> string ---@alias casepattern { word_regex: string, extract: extractf, constract: constractf } diff --git a/lua/dial/augend/date.lua b/lua/dial/augend/date.lua index b0a8eab..45e5c18 100644 --- a/lua/dial/augend/date.lua +++ b/lua/dial/augend/date.lua @@ -3,7 +3,7 @@ local common = require "dial.augend.common" local M = {} ----@alias datekind '"year"' | '"month"' | '"day"' | '"hour"' | '"min"' | '"sec"' +---@alias datekind "year" | "month" | "day" | "hour" | "min" | "sec" ---@alias dttable table ---@alias dateparser fun(string, osdate): osdate ---@alias dateformatter fun(osdate): string diff --git a/lua/dial/augend/hexcolor.lua b/lua/dial/augend/hexcolor.lua index 2132261..49d529b 100644 --- a/lua/dial/augend/hexcolor.lua +++ b/lua/dial/augend/hexcolor.lua @@ -10,8 +10,8 @@ local function cast_u8(n) return n end ----@alias colorcase '"upper"' | '"lower"' | '"prefer_upper"' | '"prefer_lower"' ----@alias colorkind '"r"' | '"g"' | '"b"' | '"all"' +---@alias colorcase "upper" | "lower" | "prefer_upper" | "prefer_lower" +---@alias colorkind "r" | "g" | "b" | "all" ---@class AugendHexColor ---@implement Augend diff --git a/lua/dial/augend/integer.lua b/lua/dial/augend/integer.lua index dc63c0d..4f90293 100644 --- a/lua/dial/augend/integer.lua +++ b/lua/dial/augend/integer.lua @@ -9,7 +9,7 @@ local util = require "dial.util" ---@field prefix string ---@field natural boolean ---@field query string ----@field case '"upper"' | '"lower"' +---@field case "upper" | "lower" ---@field delimiter string ---@field delimiter_digits integer local AugendInteger = {} @@ -22,7 +22,7 @@ local M = {} ---@field radix integer ---@field plus fun(self:BigInt, value:BigInt, natural:boolean):BigInt `value` must be positive ---@field minus fun(self:BigInt, value:BigInt, natural:boolean):BigInt `value` must be positive ----@field to_string fun(self:BigInt, case:'"upper"'|'"lower"'):string +---@field to_string fun(self:BigInt, case:"upper"|"lower"):string local BigInt = {} ---@param n string|integer @@ -163,7 +163,7 @@ function BigInt.new(n, radix) return self end - ---@param case '"upper"' | '"lower"' + ---@param case "upper" | "lower" ---@return string function self:to_string(case) local digits @@ -238,7 +238,7 @@ local function radix_to_query_character(radix) return "0-9a-" .. string.char(86 + radix) .. "A-" .. string.char(54 + radix) end ----@param config { radix?: integer, prefix?: string, natural?: boolean, case?: '"upper"' | '"lower"', delimiter?: string, delimiter_digits?: number } +---@param config { radix?: integer, prefix?: string, natural?: boolean, case?: "upper" | "lower", delimiter?: string, delimiter_digits?: number } ---@return Augend function M.new(config) vim.validate("radix", config.radix, "number", true) diff --git a/lua/dial/augend/semver.lua b/lua/dial/augend/semver.lua index 19b3faf..5da6345 100644 --- a/lua/dial/augend/semver.lua +++ b/lua/dial/augend/semver.lua @@ -13,7 +13,7 @@ end ---@class AugendSemver ---@implement Augend ----@field kind '"major"' | '"minor"' | '"patch"' +---@field kind "major" | "minor" | "patch" local AugendSemver = {} local M = {} diff --git a/lua/dial/types.lua b/lua/dial/types.lua index b0c3cc8..40250e3 100644 --- a/lua/dial/types.lua +++ b/lua/dial/types.lua @@ -1,8 +1,8 @@ -- define type annotations -- (See: https://github.com/sumneko/lua-language-server/wiki/Annotations) ----@alias direction '"increment"' | '"decrement"' ----@alias mode '"normal"' | '"gnormal"' | '"visual"' | '"gvisual"' +---@alias direction "increment" | "decrement" +---@alias mode "normal" | "gnormal" | "visual" | "gvisual" ---@alias textrange {from: integer, to: integer} ---@alias addresult {text?: string, cursor?: integer} From d539ee3e1da7db3b41ac932e66735a0fb0b3f3ac Mon Sep 17 00:00:00 2001 From: kawarimidoll Date: Thu, 18 Dec 2025 22:39:05 +0900 Subject: [PATCH 2/3] fix(types): correct Lua type annotation syntax Update type alias annotations to use the correct Lua syntax for function types, replacing '->' with ':' for return types. --- lua/dial/augend/case.lua | 4 ++-- lua/dial/types.lua | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lua/dial/augend/case.lua b/lua/dial/augend/case.lua index 3639e1d..09c77aa 100644 --- a/lua/dial/augend/case.lua +++ b/lua/dial/augend/case.lua @@ -4,8 +4,8 @@ local util = require "dial.util" local M = {} ---@alias casetype "PascalCase" | "camelCase" | "snake_case" | "kebab-case" | "SCREAMING_SNAKE_CASE" ----@alias extractf fun(word: string) -> string[] | nil ----@alias constractf fun(terms: string[]) -> string +---@alias extractf fun(word: string): string[] | nil +---@alias constractf fun(terms: string[]): string ---@alias casepattern { word_regex: string, extract: extractf, constract: constractf } ---@class AugendCase diff --git a/lua/dial/types.lua b/lua/dial/types.lua index 40250e3..0fb15c5 100644 --- a/lua/dial/types.lua +++ b/lua/dial/types.lua @@ -6,11 +6,11 @@ ---@alias textrange {from: integer, to: integer} ---@alias addresult {text?: string, cursor?: integer} ----@alias findf fun(line: string, cursor?: integer) -> textrange? ----@alias addf fun(text: string, addend: integer, cursor?: integer) -> addresult? +---@alias findf fun(line: string, cursor?: integer): textrange? +---@alias addf fun(text: string, addend: integer, cursor?: integer): addresult? ----@alias findmethod fun(self: Augend, line: string, cursor?: integer) -> textrange? ----@alias addmethod fun(self: Augend, text: string, addend: integer, cursor?: integer) -> addresult? +---@alias findmethod fun(self: Augend, line: string, cursor?: integer): textrange? +---@alias addmethod fun(self: Augend, text: string, addend: integer, cursor?: integer): addresult? ---@class Augend ---@field find findmethod From 63ebd18319c73787ebdd5c403a76ff1f65eb41c2 Mon Sep 17 00:00:00 2001 From: kawarimidoll Date: Thu, 18 Dec 2025 22:41:28 +0900 Subject: [PATCH 3/3] fix(type): correct param type annotation Replace `array` type with `any[]` in the type annotation. --- lua/dial/util.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/dial/util.lua b/lua/dial/util.lua index 33fa81c..03ee56e 100644 --- a/lua/dial/util.lua +++ b/lua/dial/util.lua @@ -76,7 +76,7 @@ end ---Returns the indices with the value nil. ---returns an index array ----@param tbl array +---@param tbl any[] ---@return integer[] function M.index_with_nil_value(tbl) -- local maxn, k = 0, nil