Gelio / Gelio/cmp-natdat

Customizable formatters

Open
#1 7 comments 0 reactions 0 assignees View on GitHub
enhancement good first issue
Dominant language
Lua
Stars
27
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Let's refactor the way formatting is done to allow users to plug in their own formatters if they do not like the default formatting.

This would involve:

1. Creating a `natdat.Formatter` type with methods for formatting different structs

```lua
---@class natdat.Formatter
---@field format_month fun(month: natdat.Month): string
---@field format_absolute_date fun(absolute_date: natdat.AbsoluteDate): string
---...
```

2. Creating 2 formatters:

- `ISOFormatter` with methods from existing `format_iso`
- `LabelFormatter` with methods from existing `format_original`

3. Replacing the `format_iso` and `format_original` methods on structures with a single `format fun(formatter: natdat.Formatter): string`. Each such method would call a corresponding `formatter` method.

4. Accepting a `formatter` for the `insertText` in the `cmp_natdat` source. By default, it would be the `ISOFormatter`

Contributor guide

Open the contributing guide

Research direction

Start by tracing the existing format_iso and format_original methods on the date structures, then inspect the cmp_natdat source where insertText is built. Define the Formatter interface and compare the proposed ISOFormatter and LabelFormatter responsibilities with the current behavior. Done means structures use format(formatter), both formatter styles are available, and insertText defaults to ISOFormatter while accepting a custom formatter.

Written by the indexing model from the issue text.

Assessment

Tech stack
lua
Domain
tooling
Issue type
Refactor
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.