Skip to content

Commit 308c5b6

Browse files
authored
docs: add config type annotations (#28)
# Motivation Add LuaLS annotations for the bullets.nvim configuration shape so users get completion and diagnostics when configuring the plugin. # Summary of Changes - Adds `bullets.Config` and custom mapping annotation types. - Annotates config defaults, active options, and setup entrypoints. - Documents lazy.nvim `opts` usage with `bullets.Config` annotations. # Testing - `mise run fmt:check` - `mise run test` - `git diff --check` # Dependencies/Special Considerations none
1 parent 0bb80df commit 308c5b6

4 files changed

Lines changed: 46 additions & 1 deletion

File tree

AGENTS.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Agent Notes
22

3+
## Documentation Maintenance
4+
5+
Whenever adding an option to @lua/bullets/config.lua be sure to also document it
6+
in README.md
7+
38
## OpenSpec
49

510
OpenSpec specs live under `openspec/specs/<capability>/spec.md`. Keep specs split by user-facing capability instead of by Lua module or test file.

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ With [lazy.nvim](https://github.com/folke/lazy.nvim):
1616
Configure options through `opts`:
1717

1818
```lua
19-
{
19+
-- automatic bulleted lists
20+
---@type LazySpec
21+
return {
2022
"bullets-vim/bullets.nvim",
23+
---@type bullets.Config
2124
opts = {
2225
enabled_file_types = { "markdown", "text", "gitcommit" },
2326
mapping_leader = "",
@@ -38,7 +41,11 @@ Configure this plugin only with `require("bullets").setup({})` or lazy.nvim `opt
3841

3942
Defaults from `lua/bullets/config.lua`:
4043

44+
The `bullets.Config` type annotation gives LuaLS completion and diagnostics for
45+
available options when this plugin is in your editor's Lua workspace.
46+
4147
```lua
48+
---@type bullets.Config
4249
{
4350
enabled_file_types = { "markdown", "text", "gitcommit" },
4451
enable_in_empty_buffers = false,

lua/bullets/config.lua

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
local M = {}
22

3+
---@alias bullets.MappingMode string|string[]
4+
---@alias bullets.MappingRhs string|function
5+
6+
---@class bullets.CustomMapping
7+
---@field [1] bullets.MappingMode
8+
---@field [2] string
9+
---@field [3] bullets.MappingRhs
10+
11+
---@class bullets.Config
12+
---@field enabled_file_types? string[] Filetypes where bullets.nvim attaches.
13+
---@field enable_in_empty_buffers? boolean Attach to buffers with an empty filetype.
14+
---@field set_mappings? boolean Install default buffer-local mappings.
15+
---@field mapping_leader? string Prefix added before default mappings.
16+
---@field custom_mappings? bullets.CustomMapping[] Extra buffer-local mappings passed to `vim.keymap.set` as `{ mode, lhs, rhs }`.
17+
---@field delete_last_bullet_if_empty? 0|1|2 Behavior when continuing an empty bullet.
18+
---@field line_spacing? integer Blank lines inserted between continued bullets.
19+
---@field pad_right? boolean Pad ordered-list prefixes to keep text aligned.
20+
---@field max_alpha_characters? integer Maximum length for alphabetic list markers.
21+
---@field enable_roman_list? boolean Enable roman numeral list markers.
22+
---@field list_item_styles? string[] List marker styles recognized by the parser.
23+
---@field outline_levels? string[] Marker styles used when promoting or demoting bullets.
24+
---@field renumber_on_change? boolean Renumber affected lists after structural changes.
25+
---@field nested_checkboxes? boolean Recompute parent checkbox states from children.
26+
---@field enable_wrapped_lines? boolean Keep wrapped list text aligned.
27+
---@field checkbox_markers? string Characters used as checkbox states.
28+
---@field checkbox_partials_toggle? 0|1 How partial checkbox states toggle.
29+
---@field auto_indent_after_colon? boolean Indent a new child item after a bullet ending in `:`.
30+
31+
---@type bullets.Config
332
M.defaults = {
433
enabled_file_types = { 'markdown', 'text', 'gitcommit' },
534
enable_in_empty_buffers = false,
@@ -21,8 +50,11 @@ M.defaults = {
2150
auto_indent_after_colon = true,
2251
}
2352

53+
---@type bullets.Config
2454
M.options = vim.deepcopy(M.defaults)
2555

56+
---@param options? bullets.Config
57+
---@return bullets.Config
2658
function M.setup(options)
2759
M.options = vim.tbl_deep_extend('force', vim.deepcopy(M.defaults), options or {})
2860
return M.options

lua/bullets/init.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ local function add_autocmds()
168168
end
169169
end
170170

171+
---@param options? bullets.Config
171172
function M.setup(options)
172173
M.did_setup = true
173174
config.setup(options)

0 commit comments

Comments
 (0)