refactor(config): nest view settings under view key (#103)
Problem: View-related config fields (`default_view`, `eol_format`, `category_order`, `folding`) are scattered as top-level siblings alongside unrelated fields like `data_path` and `date_syntax`. Solution: Group them under a `view` table with per-view sub-tables: `view.default`, `view.eol_format`, `view.category.order`, `view.category.folding`, and `view.queue` (empty, ready for #100). Update all call sites, tests, and vimdoc.
This commit is contained in:
parent
91cce0a82e
commit
a43f769383
5 changed files with 82 additions and 73 deletions
|
|
@ -49,22 +49,31 @@
|
|||
---@field next_task? string|false
|
||||
---@field prev_task? string|false
|
||||
|
||||
---@class pending.CategoryViewConfig
|
||||
---@field order? string[]
|
||||
---@field folding? boolean|pending.FoldingConfig
|
||||
|
||||
---@class pending.QueueViewConfig
|
||||
|
||||
---@class pending.ViewConfig
|
||||
---@field default? 'category'|'priority'
|
||||
---@field eol_format? string
|
||||
---@field category? pending.CategoryViewConfig
|
||||
---@field queue? pending.QueueViewConfig
|
||||
|
||||
---@class pending.Config
|
||||
---@field data_path string
|
||||
---@field default_view 'category'|'priority'
|
||||
---@field default_category string
|
||||
---@field date_format string
|
||||
---@field date_syntax string
|
||||
---@field recur_syntax string
|
||||
---@field someday_date string
|
||||
---@field input_date_formats? string[]
|
||||
---@field category_order? string[]
|
||||
---@field drawer_height? integer
|
||||
---@field debug? boolean
|
||||
---@field keymaps pending.Keymaps
|
||||
---@field folding? boolean|pending.FoldingConfig
|
||||
---@field view pending.ViewConfig
|
||||
---@field sync? pending.SyncConfig
|
||||
---@field eol_format? string
|
||||
---@field icons pending.Icons
|
||||
|
||||
---@class pending.config
|
||||
|
|
@ -73,15 +82,20 @@ local M = {}
|
|||
---@type pending.Config
|
||||
local defaults = {
|
||||
data_path = vim.fn.stdpath('data') .. '/pending/tasks.json',
|
||||
default_view = 'category',
|
||||
default_category = 'Todo',
|
||||
date_format = '%b %d',
|
||||
date_syntax = 'due',
|
||||
recur_syntax = 'rec',
|
||||
someday_date = '9999-12-30',
|
||||
eol_format = '%c %r %d',
|
||||
folding = true,
|
||||
category_order = {},
|
||||
view = {
|
||||
default = 'category',
|
||||
eol_format = '%c %r %d',
|
||||
category = {
|
||||
order = {},
|
||||
folding = true,
|
||||
},
|
||||
queue = {},
|
||||
},
|
||||
keymaps = {
|
||||
close = 'q',
|
||||
toggle = '<CR>',
|
||||
|
|
@ -132,7 +146,7 @@ end
|
|||
|
||||
---@return pending.ResolvedFolding
|
||||
function M.resolve_folding()
|
||||
local raw = M.get().folding
|
||||
local raw = M.get().view.category.folding
|
||||
if raw == false then
|
||||
return { enabled = false, foldtext = false }
|
||||
elseif raw == true or raw == nil then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue