Skip to content

Commit

Permalink
Update hashmap type annotations
Browse files Browse the repository at this point in the history
  • Loading branch information
m00qek committed May 31, 2024
1 parent 8df9770 commit 026ac78
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion lua/baleia/locations/offsets.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

---@class OffsetConfig
---@field global Offset
---@field lines? table<integer, Offset>
---@field lines? { integer: Offset }

local M = {}

Expand Down
2 changes: 1 addition & 1 deletion lua/baleia/nvim/highlight.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ local nvim = {
---@param namespace integer
---@param buffer integer
---@param marks Mark[]
---@param highlights table<string, HighlightAttributes>
---@param highlights { string: HighlightAttributes }
function module.all(logger, namespace, buffer, marks, highlights)
vim.schedule(function()
local hl = nvim.api.highlights(logger, 0)
Expand Down
2 changes: 1 addition & 1 deletion lua/baleia/styles.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ M.ANSI_CODES_PATTERN = ansi.PATTERN
---@field background ColorAttribute
---@field foreground ColorAttribute
---@field special ColorAttribute
---@field modes table<string, ModeAttribute>
---@field modes { string: ModeAttribute }
---@field offset? integer

---@class HighlightAttributes
Expand Down
10 changes: 5 additions & 5 deletions lua/baleia/styles/ansi.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,24 @@ local modes = require("baleia.styles.modes")

---@class AttributeGenerator
---@field params integer
---@field fn table<string, function>
---@field fn { string: fun() }

---@class AttributeGenerator
---@field generators table<integer, AttributeGenerator>
---@field generators { integer: AttributeGenerator }

---@class ModeAttributeDefinition
---@field definition table<string, ModeAttribute>
---@field definition { string: ModeAttribute }

---@class ColorAttributeDefinition
---@field definition table<string, ColorAttribute>
---@field definition { string: ColorAttribute }

local M = {}

-- selene: allow(bad_string_escape) because it does not recognize \x1b
---@type string
M.PATTERN = "\x1b[[0-9][:;0-9]*m"

---@type table<integer, ColorAttributeDefinition|AttributeGenerator>
---@type { integer: ColorAttributeDefinition|AttributeGenerator }
M.colors = {
[30] = { definition = { foreground = colors.from_xterm(0) } },
[31] = { definition = { foreground = colors.from_xterm(1) } },
Expand Down
2 changes: 1 addition & 1 deletion lua/baleia/styles/themes.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
local M = {}

---@alias Theme table<integer, string>
---@alias Theme { integer: string }

---@type Theme
M.NR_16 = {
Expand Down
2 changes: 1 addition & 1 deletion lua/baleia/styles/xterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function M.from_rgb(red, green, blue)
return color_code
end

---@type table<integer, string>
---@type { integer: string }
M.colors = {
[000] = "000000",
[001] = "800000",
Expand Down
4 changes: 2 additions & 2 deletions lua/baleia/text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ local locations = require("baleia.locations")
local styles = require("baleia.styles")

---@class TextColors
---@field highlights table<string, HighlightAttributes>
---@field highlights { string: HighlightAttributes }
---@field marks Mark[]

local M = {}
Expand Down Expand Up @@ -34,7 +34,7 @@ end
---@param options BasicOptions
---@param lines string[]
---@param offset OffsetConfig
---@return Mark[], table<string, HighlightAttributes>
---@return Mark[], { string: HighlightAttributes }
function M.colors(options, lines, offset)
local locs = locations.extract(options, offset, lines)
if not next(locs) then
Expand Down
4 changes: 2 additions & 2 deletions lua/baleia/text/highlights.lua
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ end

---@param options BasicOptions
---@param locations Location[]
---@return Mark[], table<string, HighlightAttributes>
---@return Mark[], { string: HighlightAttributes }
function M.from_locations(options, locations)
---@type table<string, HighlightAttributes>
---@type { string: HighlightAttributes }
local highlights = {}
---@type Mark[]
local marks = {}
Expand Down

0 comments on commit 026ac78

Please sign in to comment.