hledger-lsp 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +167 -99
- package/out/server/settings.js +3 -3
- package/out/server/settings.js.map +1 -1
- package/out/server.js +0 -0
- package/package.json +1 -1
- package/out/features/formattingUtils.d.ts +0 -38
- package/out/features/formattingUtils.d.ts.map +0 -1
- package/out/features/formattingUtils.js +0 -107
- package/out/features/formattingUtils.js.map +0 -1
- package/out/parser/document.d.ts +0 -7
- package/out/parser/document.d.ts.map +0 -1
- package/out/parser/document.js +0 -70
- package/out/parser/document.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,8 +1,86 @@
|
|
|
1
1
|
# hledger Language Server
|
|
2
2
|
|
|
3
|
+
<!--toc:start-->
|
|
4
|
+
- [hledger Language Server](#hledger-language-server)
|
|
5
|
+
- [Installation](#installation)
|
|
6
|
+
- [IDE Integration](#ide-integration)
|
|
7
|
+
- [VS Code](#vs-code)
|
|
8
|
+
- [Neovim](#neovim)
|
|
9
|
+
- [Other Editors](#other-editors)
|
|
10
|
+
- [Features](#features)
|
|
11
|
+
- [Code Completion](#code-completion)
|
|
12
|
+
- [Hover](#hover)
|
|
13
|
+
- [Validation](#validation)
|
|
14
|
+
- [Include Directive Support](#include-directive-support)
|
|
15
|
+
- [Navigation](#navigation)
|
|
16
|
+
- [Code Actions and Quick Fixes](#code-actions-and-quick-fixes)
|
|
17
|
+
- [Formatting](#formatting)
|
|
18
|
+
- [Semantic Highlighting](#semantic-highlighting)
|
|
19
|
+
- [Inlay Hints](#inlay-hints)
|
|
20
|
+
- [Code Lens](#code-lens)
|
|
21
|
+
- [Editor Integration](#editor-integration)
|
|
22
|
+
- [Configuration](#configuration)
|
|
23
|
+
- [General Settings](#general-settings)
|
|
24
|
+
- [Validation Settings](#validation-settings)
|
|
25
|
+
- [Severity Settings](#severity-settings)
|
|
26
|
+
- [Include Settings](#include-settings)
|
|
27
|
+
- [Workspace Settings](#workspace-settings)
|
|
28
|
+
- [Completion Settings](#completion-settings)
|
|
29
|
+
- [Formatting Settings](#formatting-settings)
|
|
30
|
+
- [Inlay Hints Settings](#inlay-hints-settings)
|
|
31
|
+
- [Code Lens Settings](#code-lens-settings)
|
|
32
|
+
- [Development](#development)
|
|
33
|
+
- [Prerequisites](#prerequisites)
|
|
34
|
+
- [Building from Source](#building-from-source)
|
|
35
|
+
- [Project Structure](#project-structure)
|
|
36
|
+
- [Development Commands](#development-commands)
|
|
37
|
+
- [Contributing](#contributing)
|
|
38
|
+
- [License](#license)
|
|
39
|
+
- [Links](#links)
|
|
40
|
+
<!--toc:end-->
|
|
41
|
+
|
|
3
42
|
A Language Server Protocol (LSP) implementation for
|
|
4
43
|
[hledger](https://hledger.org/), a plain text accounting tool.
|
|
5
44
|
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
npm install -g hledger-lsp
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
This provides the `hledger-lsp` command globally. After installation, the
|
|
52
|
+
language server can be used with any LSP-compatible editor.
|
|
53
|
+
|
|
54
|
+
## IDE Integration
|
|
55
|
+
|
|
56
|
+
This language server can be used with any LSP-compatible editor. Official extensions:
|
|
57
|
+
|
|
58
|
+
### VS Code
|
|
59
|
+
|
|
60
|
+
**Extension**: [hledger-tools](https://marketplace.visualstudio.com/items?itemName=patrickt.hledger-tools)
|
|
61
|
+
|
|
62
|
+
Install from the VS Code Marketplace or Extensions view. The extension provides
|
|
63
|
+
all LSP features with zero configuration.
|
|
64
|
+
|
|
65
|
+
### Neovim
|
|
66
|
+
|
|
67
|
+
**Plugin**: [ptimoney/hledger-nvim](https://github.com/ptimoney/hledger-nvim)
|
|
68
|
+
|
|
69
|
+
Provides automatic LSP configuration, filetype detection, and workspace visualization.
|
|
70
|
+
|
|
71
|
+
### Other Editors
|
|
72
|
+
|
|
73
|
+
The server can be used with any LSP client. Example configuration:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"command": "hledger-lsp",
|
|
78
|
+
"args": ["--stdio"],
|
|
79
|
+
"filetypes": ["hledger", "journal"],
|
|
80
|
+
"rootPatterns": [".hledger-lsp.json", ".git"]
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
6
84
|
## Features
|
|
7
85
|
|
|
8
86
|
This language server provides comprehensive IDE support for hledger journal
|
|
@@ -71,7 +149,7 @@ and tags
|
|
|
71
149
|
- **Find references** - Show all usages of accounts, payees, commodities, or
|
|
72
150
|
tags across the document
|
|
73
151
|
|
|
74
|
-
### Code Actions
|
|
152
|
+
### Code Actions and Quick Fixes
|
|
75
153
|
|
|
76
154
|
- **Add declarations** - Automatically add account, payee, commodity, or tag
|
|
77
155
|
declarations for undeclared items
|
|
@@ -145,7 +223,7 @@ multi-line comment blocks
|
|
|
145
223
|
- **Selection range** - Smart text selection expansion: Word → Account → Posting
|
|
146
224
|
→ Transaction (requires editor keybinding setup, see configuration below)
|
|
147
225
|
|
|
148
|
-
|
|
226
|
+
## Configuration
|
|
149
227
|
|
|
150
228
|
All validations and completion behaviors can be individually configured per
|
|
151
229
|
workspace or document:
|
|
@@ -155,41 +233,6 @@ customize severity levels
|
|
|
155
233
|
- **Completion filtering** - Control whether completions show only declared
|
|
156
234
|
items or all items (declared + undeclared)
|
|
157
235
|
|
|
158
|
-
## Installation
|
|
159
|
-
|
|
160
|
-
### Prerequisites
|
|
161
|
-
|
|
162
|
-
- Node.js >= 16.0.0
|
|
163
|
-
|
|
164
|
-
### Install from npm
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
npm install -g hledger-lsp
|
|
168
|
-
```
|
|
169
|
-
|
|
170
|
-
This provides the `hledger-lsp` command globally. After installation, the
|
|
171
|
-
language server can be used with any LSP-compatible editor.
|
|
172
|
-
|
|
173
|
-
## Editor Configuration
|
|
174
|
-
|
|
175
|
-
### Neovim
|
|
176
|
-
|
|
177
|
-
Use the dedicated plugin: [ptimoney/hledger-nvim](https://github.com/ptimoney/hledger-nvim)
|
|
178
|
-
|
|
179
|
-
The plugin provides:
|
|
180
|
-
- Automatic LSP configuration
|
|
181
|
-
- Filetype detection for `.journal` and `.hledger` files
|
|
182
|
-
- Workspace graph visualization (`:HledgerGraph`)
|
|
183
|
-
- Easy configuration of all server settings
|
|
184
|
-
|
|
185
|
-
See the plugin repository for installation and configuration instructions.
|
|
186
|
-
|
|
187
|
-
### VS Code
|
|
188
|
-
|
|
189
|
-
The VS Code extension is published separately. Install it from the VS Code
|
|
190
|
-
marketplace or see the `vscode-client/` directory in the repository for
|
|
191
|
-
development instructions.
|
|
192
|
-
|
|
193
236
|
### General Settings
|
|
194
237
|
|
|
195
238
|
- `maxNumberOfProblems` (number, default: 1000): Maximum number of diagnostic
|
|
@@ -202,20 +245,31 @@ problems to report per file
|
|
|
202
245
|
Most validation settings default to `true` and can be individually disabled:
|
|
203
246
|
|
|
204
247
|
- `validation.balance` (default: true): Verify transactions balance to zero per commodity
|
|
205
|
-
- `validation.missingAmounts` (default: true): Ensure at most one posting per
|
|
206
|
-
|
|
207
|
-
- `validation.
|
|
208
|
-
|
|
209
|
-
- `validation.
|
|
210
|
-
|
|
211
|
-
- `validation.
|
|
212
|
-
|
|
213
|
-
- `validation.
|
|
248
|
+
- `validation.missingAmounts` (default: true): Ensure at most one posting per
|
|
249
|
+
transaction omits an amount
|
|
250
|
+
- `validation.undeclaredAccounts` (default: true): Warn about accounts used but
|
|
251
|
+
not declared
|
|
252
|
+
- `validation.undeclaredPayees` (default: **false**): Warn about payees used but
|
|
253
|
+
not declared
|
|
254
|
+
- `validation.undeclaredCommodities` (default: true): Warn about commodities
|
|
255
|
+
used but not declared
|
|
256
|
+
- `validation.undeclaredTags` (default: **false**): Warn about tags used but not
|
|
257
|
+
declared
|
|
258
|
+
- `validation.dateOrdering` (default: true): Detect transactions with dates out
|
|
259
|
+
of chronological order
|
|
260
|
+
- `validation.balanceAssertions` (default: true): Verify balance assertions
|
|
261
|
+
match calculated balances
|
|
262
|
+
- `validation.emptyTransactions` (default: true): Require at least 2 postings
|
|
263
|
+
per transaction
|
|
264
|
+
- `validation.invalidDates` (default: true): Check for invalid dates (e.g.,
|
|
265
|
+
February 30, month 13)
|
|
214
266
|
- `validation.futureDates` (default: true): Warn about future-dated transactions
|
|
215
|
-
- `validation.emptyDescriptions` (default: true): Warn about transactions with
|
|
267
|
+
- `validation.emptyDescriptions` (default: true): Warn about transactions with
|
|
268
|
+
no description
|
|
216
269
|
- `validation.includeFiles` (default: true): Detect missing include files
|
|
217
270
|
- `validation.circularIncludes` (default: true): Detect circular include dependencies
|
|
218
|
-
- `validation.markAllUndeclaredInstances` (default:
|
|
271
|
+
- `validation.markAllUndeclaredInstances` (default: true): Mark all
|
|
272
|
+
instances of undeclared resources with diagnostics, not just the first occurrence
|
|
219
273
|
|
|
220
274
|
### Severity Settings
|
|
221
275
|
|
|
@@ -236,15 +290,25 @@ infinite recursion
|
|
|
236
290
|
|
|
237
291
|
### Workspace Settings
|
|
238
292
|
|
|
239
|
-
Enable workspace-aware parsing for features that need global context (running
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
- `workspace.
|
|
243
|
-
|
|
293
|
+
Enable workspace-aware parsing for features that need global context (running
|
|
294
|
+
balances, completion, validation):
|
|
295
|
+
|
|
296
|
+
- `workspace.enabled` (boolean, default: true): Enable workspace-aware parsing.
|
|
297
|
+
When enabled, the server discovers all journal files in your workspace, builds
|
|
298
|
+
an include graph, and identifies a single root file. This allows features to
|
|
299
|
+
access workspace-wide state even when working with "leaf" files that don't
|
|
300
|
+
include other files.
|
|
301
|
+
- `workspace.eagerParsing` (boolean, default: true): Parse all discovered files
|
|
302
|
+
eagerly on startup. If disabled, files are parsed on-demand.
|
|
303
|
+
- `workspace.autoDetectRoot` (boolean, default: true): Automatically detect the
|
|
304
|
+
root file using heuristics (prefers files with no parents that include many
|
|
305
|
+
others, with names like "main", "all", or "index"). If disabled, only an
|
|
306
|
+
explicitly configured root file is used (see Configuration File Support below).
|
|
244
307
|
|
|
245
308
|
**Configuration File Support:**
|
|
246
309
|
|
|
247
|
-
You can create a `.hledger-lsp.json` file in your workspace to explicitly
|
|
310
|
+
You can create a `.hledger-lsp.json` file in your workspace to explicitly
|
|
311
|
+
configure workspace behavior:
|
|
248
312
|
|
|
249
313
|
```json
|
|
250
314
|
{
|
|
@@ -260,16 +324,26 @@ You can create a `.hledger-lsp.json` file in your workspace to explicitly config
|
|
|
260
324
|
```
|
|
261
325
|
|
|
262
326
|
Settings:
|
|
327
|
+
|
|
263
328
|
- `rootFile` (string): Explicit root file path (relative to config file location)
|
|
264
|
-
- `include` (array of glob patterns): File discovery patterns
|
|
265
|
-
|
|
329
|
+
- `include` (array of glob patterns): File discovery patterns
|
|
330
|
+
(default: `["**/*.journal", "**/*.hledger"]`)
|
|
331
|
+
- `exclude` (array of glob patterns): Files to exclude
|
|
332
|
+
(default: `["**/node_modules/**", "**/.git/**", "**/.*"]`)
|
|
266
333
|
- `workspace` (object): Same workspace settings as above
|
|
267
334
|
|
|
268
|
-
**Important**: The `.hledger-lsp.json` file is ONLY for workspace structure
|
|
335
|
+
**Important**: The `.hledger-lsp.json` file is ONLY for workspace structure
|
|
336
|
+
configuration (which files to discover, which are roots, etc.).
|
|
337
|
+
LSP feature settings like inlay hints, code lens, validation rules,
|
|
338
|
+
and formatting preferences should be configured in your editor/IDE
|
|
339
|
+
settings (VS Code `settings.json`, Neovim LSP config, etc.).
|
|
269
340
|
|
|
270
|
-
The configuration file will be automatically discovered by walking up the
|
|
341
|
+
The configuration file will be automatically discovered by walking up the
|
|
342
|
+
directory tree from your journal files. Settings from VS Code/editor
|
|
343
|
+
configuration override settings from the config file.
|
|
271
344
|
|
|
272
345
|
**Performance Tips:**
|
|
346
|
+
|
|
273
347
|
- For large workspaces (>100 files), use `exclude` patterns to skip unnecessary files
|
|
274
348
|
- Disable `eagerParsing` if initialization is slow
|
|
275
349
|
- Check LSP server logs for performance warnings and metrics
|
|
@@ -317,81 +391,75 @@ commodities (e.g., `-100.00 EUR`), which always show the sign before the number.
|
|
|
317
391
|
|
|
318
392
|
### Inlay Hints Settings
|
|
319
393
|
|
|
320
|
-
Configure which inline hints to display (
|
|
394
|
+
Configure which inline hints to display (running balances is disabled by default
|
|
395
|
+
as it can make the file busy):
|
|
321
396
|
|
|
322
|
-
- `inlayHints.showInferredAmounts` (boolean, default:
|
|
397
|
+
- `inlayHints.showInferredAmounts` (boolean, default: true): Show calculated
|
|
323
398
|
amounts for postings that omit explicit amounts
|
|
324
399
|
- `inlayHints.showRunningBalances` (boolean, default: false): Display running
|
|
325
400
|
balance after each posting
|
|
326
|
-
- `inlayHints.showCostConversions` (boolean, default:
|
|
401
|
+
- `inlayHints.showCostConversions` (boolean, default: true): Show total cost in
|
|
327
402
|
target commodity for postings with @ or @@ notation
|
|
328
403
|
|
|
329
404
|
### Code Lens Settings
|
|
330
405
|
|
|
331
|
-
Configure which code lenses to display (disabled by default
|
|
332
|
-
|
|
333
|
-
- `codeLens.showTransactionCounts` (boolean, default: false): Show transaction counts for each account on transaction headers
|
|
406
|
+
Configure which code lenses to display (disabled by default, largely a holding
|
|
407
|
+
for future features):
|
|
334
408
|
|
|
335
|
-
|
|
409
|
+
- `codeLens.showTransactionCounts` (boolean, default: false): Show transaction
|
|
410
|
+
counts for each account on transaction headers
|
|
336
411
|
|
|
337
412
|
## Development
|
|
338
413
|
|
|
339
|
-
###
|
|
414
|
+
### Prerequisites
|
|
340
415
|
|
|
341
|
-
|
|
416
|
+
- Node.js >= 16.0.0
|
|
417
|
+
|
|
418
|
+
### Building from Source
|
|
342
419
|
|
|
343
420
|
```bash
|
|
344
421
|
# Clone the repository
|
|
345
422
|
git clone https://github.com/ptimoney/hledger-lsp.git
|
|
346
423
|
cd hledger-lsp
|
|
347
424
|
|
|
348
|
-
# Install dependencies
|
|
425
|
+
# Install dependencies
|
|
349
426
|
npm install
|
|
350
427
|
|
|
351
428
|
# Build the server
|
|
352
|
-
npm run build
|
|
429
|
+
npm run build
|
|
353
430
|
|
|
354
431
|
# Run the server directly
|
|
355
|
-
node
|
|
432
|
+
node out/server.js --stdio
|
|
356
433
|
```
|
|
357
434
|
|
|
358
435
|
### Project Structure
|
|
359
436
|
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
│
|
|
364
|
-
│
|
|
365
|
-
│
|
|
366
|
-
│
|
|
367
|
-
│
|
|
368
|
-
│
|
|
369
|
-
|
|
370
|
-
|
|
437
|
+
```
|
|
438
|
+
hledger-lsp/
|
|
439
|
+
├── src/
|
|
440
|
+
│ ├── server.ts # Main LSP server implementation
|
|
441
|
+
│ ├── types.ts # Type definitions for hledger structures
|
|
442
|
+
│ ├── parser/ # Journal file parser
|
|
443
|
+
│ ├── features/ # LSP feature implementations
|
|
444
|
+
│ ├── server/ # Server infrastructure
|
|
445
|
+
│ └── utils/ # Utility functions
|
|
446
|
+
├── tests/ # Test suite (515+ test cases)
|
|
447
|
+
├── out/ # Compiled JavaScript output
|
|
448
|
+
└── package.json
|
|
449
|
+
```
|
|
371
450
|
|
|
372
451
|
### Development Commands
|
|
373
452
|
|
|
374
|
-
From the `server/` directory:
|
|
375
|
-
|
|
376
453
|
```bash
|
|
377
454
|
# Build once
|
|
378
455
|
npm run build
|
|
379
456
|
|
|
380
457
|
# Watch mode (rebuild on changes)
|
|
381
458
|
npm run watch
|
|
382
|
-
```
|
|
383
|
-
|
|
384
|
-
### Linting
|
|
385
459
|
|
|
386
|
-
|
|
460
|
+
# Lint code
|
|
387
461
|
npm run lint
|
|
388
|
-
```
|
|
389
462
|
|
|
390
|
-
### Testing
|
|
391
|
-
|
|
392
|
-
The project includes comprehensive test coverage using Jest:
|
|
393
|
-
|
|
394
|
-
```bash
|
|
395
463
|
# Run all tests
|
|
396
464
|
npm test
|
|
397
465
|
|
|
@@ -411,8 +479,6 @@ npx jest tests/parser/index.test.ts
|
|
|
411
479
|
npx jest --testNamePattern="balance"
|
|
412
480
|
```
|
|
413
481
|
|
|
414
|
-
Test files mirror the `src/` directory structure (515 test cases total)
|
|
415
|
-
|
|
416
482
|
## Contributing
|
|
417
483
|
|
|
418
484
|
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
@@ -421,8 +487,10 @@ Contributions are welcome! Please feel free to submit a Pull Request.
|
|
|
421
487
|
|
|
422
488
|
MIT
|
|
423
489
|
|
|
424
|
-
##
|
|
490
|
+
## Links
|
|
425
491
|
|
|
426
|
-
- [hledger
|
|
427
|
-
- [
|
|
428
|
-
- [
|
|
492
|
+
- **VS Code Extension**: [hledger-vscode](https://github.com/ptimoney/hledger-vscode)
|
|
493
|
+
- **Neovim Plugin**: [hledger-nvim](https://github.com/ptimoney/hledger-nvim)
|
|
494
|
+
- **Report Issues**: [GitHub Issues](https://github.com/ptimoney/hledger-lsp/issues)
|
|
495
|
+
- **hledger**: [Official Documentation](https://hledger.org/)
|
|
496
|
+
- **LSP Specification**: [Language Server Protocol](https://microsoft.github.io/language-server-protocol/)
|
package/out/server/settings.js
CHANGED
|
@@ -14,7 +14,7 @@ exports.defaultSettings = {
|
|
|
14
14
|
undeclaredAccounts: true,
|
|
15
15
|
undeclaredPayees: false,
|
|
16
16
|
undeclaredCommodities: true,
|
|
17
|
-
undeclaredTags:
|
|
17
|
+
undeclaredTags: false,
|
|
18
18
|
dateOrdering: true,
|
|
19
19
|
balanceAssertions: true,
|
|
20
20
|
emptyTransactions: true,
|
|
@@ -52,9 +52,9 @@ exports.defaultSettings = {
|
|
|
52
52
|
signPosition: 'after-symbol',
|
|
53
53
|
},
|
|
54
54
|
inlayHints: {
|
|
55
|
-
showInferredAmounts:
|
|
55
|
+
showInferredAmounts: true,
|
|
56
56
|
showRunningBalances: false,
|
|
57
|
-
showCostConversions:
|
|
57
|
+
showCostConversions: true,
|
|
58
58
|
},
|
|
59
59
|
codeLens: {
|
|
60
60
|
showTransactionCounts: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/server/settings.ts"],"names":[],"mappings":";;;AAkIA,8BAmBC;AAMD,kDAqBC;AAED,sDAEC;AAED,4DAEC;AAzHY,QAAA,eAAe,GAAoB;IAC9C,mBAAmB,EAAE,IAAI;IACzB,WAAW,EAAE,SAAS;IACtB,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,IAAI;QACpB,kBAAkB,EAAE,IAAI;QACxB,gBAAgB,EAAE,KAAK;QACvB,qBAAqB,EAAE,IAAI;QAC3B,cAAc,EAAE,
|
|
1
|
+
{"version":3,"file":"settings.js","sourceRoot":"","sources":["../../src/server/settings.ts"],"names":[],"mappings":";;;AAkIA,8BAmBC;AAMD,kDAqBC;AAED,sDAEC;AAED,4DAEC;AAzHY,QAAA,eAAe,GAAoB;IAC9C,mBAAmB,EAAE,IAAI;IACzB,WAAW,EAAE,SAAS;IACtB,UAAU,EAAE;QACV,OAAO,EAAE,IAAI;QACb,cAAc,EAAE,IAAI;QACpB,kBAAkB,EAAE,IAAI;QACxB,gBAAgB,EAAE,KAAK;QACvB,qBAAqB,EAAE,IAAI;QAC3B,cAAc,EAAE,KAAK;QACrB,YAAY,EAAE,IAAI;QAClB,iBAAiB,EAAE,IAAI;QACvB,iBAAiB,EAAE,IAAI;QACvB,YAAY,EAAE,IAAI;QAClB,WAAW,EAAE,IAAI;QACjB,iBAAiB,EAAE,IAAI;QACvB,YAAY,EAAE,IAAI;QAClB,gBAAgB,EAAE,IAAI;QACtB,0BAA0B,EAAE,IAAI;KACjC;IACD,QAAQ,EAAE;QACR,kBAAkB,EAAE,SAAS;QAC7B,gBAAgB,EAAE,SAAS;QAC3B,qBAAqB,EAAE,SAAS;QAChC,cAAc,EAAE,aAAa;KAC9B;IACD,OAAO,EAAE;QACP,cAAc,EAAE,IAAI;QACpB,QAAQ,EAAE,EAAE;KACb;IACD,UAAU,EAAE;QACV,oBAAoB,EAAE,IAAI;QAC1B,kBAAkB,EAAE,IAAI;QACxB,uBAAuB,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/package.json
CHANGED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Shared formatting utilities
|
|
3
|
-
*/
|
|
4
|
-
import { Amount, ParsedDocument, Commodity, Format } from '../types';
|
|
5
|
-
export interface FormattingOptions {
|
|
6
|
-
/** Number of spaces for posting indentation (default: 4) */
|
|
7
|
-
indentation?: number;
|
|
8
|
-
/** Maximum width for account names (default: 42) */
|
|
9
|
-
maxAccountWidth?: number;
|
|
10
|
-
/** Maximum width for commodity symbols (default: 4) */
|
|
11
|
-
maxCommodityWidth?: number;
|
|
12
|
-
/** Maximum width for amount numbers (default: 12) */
|
|
13
|
-
maxAmountWidth?: number;
|
|
14
|
-
/** Minimum spaces between account and amount (default: 2) */
|
|
15
|
-
minSpacing?: number;
|
|
16
|
-
/** Target column for decimal alignment (default: 52) */
|
|
17
|
-
decimalAlignColumn?: number;
|
|
18
|
-
/** Target column for assertion decimal alignment (default: 70) */
|
|
19
|
-
assertionDecimalAlignColumn?: number;
|
|
20
|
-
}
|
|
21
|
-
export interface AmountLayout {
|
|
22
|
-
commodityBefore: string;
|
|
23
|
-
isNegative: boolean;
|
|
24
|
-
amountIntegerString: string;
|
|
25
|
-
amountDecimalString: string;
|
|
26
|
-
demicalMark: string;
|
|
27
|
-
commodityAfter: string;
|
|
28
|
-
spaceBetweenCommodityAndAmount: boolean;
|
|
29
|
-
}
|
|
30
|
-
export declare const DEFAULT_OPTIONS: Required<FormattingOptions>;
|
|
31
|
-
/**
|
|
32
|
-
* Find the commodity format from parsed document
|
|
33
|
-
*/
|
|
34
|
-
export declare function findCommodity(commodityName: string, parsed: ParsedDocument): Commodity | undefined;
|
|
35
|
-
export declare function formatIntegerAmount(amount: Amount, format: Format): string;
|
|
36
|
-
export declare function formatDecimalAmount(amount: Amount, format: Format, targetPrecision?: number): string;
|
|
37
|
-
export declare function layoutAmount(amount: Amount, parsed: ParsedDocument, options: Required<FormattingOptions>): AmountLayout;
|
|
38
|
-
//# sourceMappingURL=formattingUtils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formattingUtils.d.ts","sourceRoot":"","sources":["../../src/features/formattingUtils.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAC9B,4DAA4D;IAC5D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,oDAAoD;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,uDAAuD;IACvD,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,qDAAqD;IACrD,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6DAA6D;IAC7D,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wDAAwD;IACxD,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,kEAAkE;IAClE,2BAA2B,CAAC,EAAE,MAAM,CAAC;CACxC;AAED,MAAM,WAAW,YAAY;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,UAAU,EAAE,OAAO,CAAC;IACpB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,mBAAmB,EAAE,MAAM,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,MAAM,CAAC;IACvB,8BAA8B,EAAE,OAAO,CAAC;CAC3C;AAED,eAAO,MAAM,eAAe,EAAE,QAAQ,CAAC,iBAAiB,CAQvD,CAAC;AAEF;;GAEG;AACH,wBAAgB,aAAa,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,GAAG,SAAS,GAAG,SAAS,CAElG;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAa1E;AAED,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAYpG;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,QAAQ,CAAC,iBAAiB,CAAC,GAAG,YAAY,CAsDvH"}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Shared formatting utilities
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.DEFAULT_OPTIONS = void 0;
|
|
7
|
-
exports.findCommodity = findCommodity;
|
|
8
|
-
exports.formatIntegerAmount = formatIntegerAmount;
|
|
9
|
-
exports.formatDecimalAmount = formatDecimalAmount;
|
|
10
|
-
exports.layoutAmount = layoutAmount;
|
|
11
|
-
exports.DEFAULT_OPTIONS = {
|
|
12
|
-
indentation: 4,
|
|
13
|
-
maxAccountWidth: 42,
|
|
14
|
-
maxCommodityWidth: 4,
|
|
15
|
-
maxAmountWidth: 12,
|
|
16
|
-
minSpacing: 2,
|
|
17
|
-
decimalAlignColumn: 52,
|
|
18
|
-
assertionDecimalAlignColumn: 70
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Find the commodity format from parsed document
|
|
22
|
-
*/
|
|
23
|
-
function findCommodity(commodityName, parsed) {
|
|
24
|
-
return parsed.commodities.get(commodityName);
|
|
25
|
-
}
|
|
26
|
-
function formatIntegerAmount(amount, format) {
|
|
27
|
-
const integerPart = Math.floor(Math.abs(amount.quantity)).toString();
|
|
28
|
-
// Format integer part with grouping if specified
|
|
29
|
-
let integerString = '';
|
|
30
|
-
if (format.thousandsSeparator) {
|
|
31
|
-
const regex = /\B(?=(\d{3})+(?!\d))/g;
|
|
32
|
-
integerString = integerPart.replace(regex, format.thousandsSeparator);
|
|
33
|
-
}
|
|
34
|
-
else {
|
|
35
|
-
integerString = integerPart;
|
|
36
|
-
}
|
|
37
|
-
return integerString;
|
|
38
|
-
}
|
|
39
|
-
function formatDecimalAmount(amount, format, targetPrecision) {
|
|
40
|
-
const decimalPart = Math.abs(amount.quantity) % 1;
|
|
41
|
-
// Format decimal part based on target precision
|
|
42
|
-
let decimalString = '';
|
|
43
|
-
if (targetPrecision !== undefined && targetPrecision > 0) {
|
|
44
|
-
decimalString = decimalPart.toFixed(targetPrecision).substring(2); // Skip "0."
|
|
45
|
-
}
|
|
46
|
-
else if (decimalPart > 0) {
|
|
47
|
-
decimalString = decimalPart.toString().substring(2); // Skip "0."
|
|
48
|
-
}
|
|
49
|
-
return decimalString;
|
|
50
|
-
}
|
|
51
|
-
function layoutAmount(amount, parsed, options) {
|
|
52
|
-
const commodity = findCommodity(amount.commodity, parsed);
|
|
53
|
-
let format = {};
|
|
54
|
-
let declaredPrecision = undefined;
|
|
55
|
-
if (commodity && commodity.format) {
|
|
56
|
-
format = commodity.format;
|
|
57
|
-
declaredPrecision = commodity.format.precision ?? undefined;
|
|
58
|
-
}
|
|
59
|
-
else if (amount.format) {
|
|
60
|
-
format = amount.format;
|
|
61
|
-
}
|
|
62
|
-
else {
|
|
63
|
-
// Default heuristic: common currencies go on left
|
|
64
|
-
const leftSymbols = ['$', '€', '£', '¥'];
|
|
65
|
-
if (leftSymbols.includes(amount.commodity)) {
|
|
66
|
-
format = { symbolOnLeft: true, symbol: amount.commodity, decimalMark: '.' };
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
// For other commodities, default to right with space if not empty
|
|
70
|
-
format = {
|
|
71
|
-
symbolOnLeft: false,
|
|
72
|
-
symbol: amount.commodity,
|
|
73
|
-
spaceBetween: !!amount.commodity,
|
|
74
|
-
decimalMark: '.'
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// Determine the actual precision to use based on the rules:
|
|
79
|
-
// 1. Never reduce precision if posting has higher precision than declared
|
|
80
|
-
// 2. Add zeros to match declared precision when actual < declared
|
|
81
|
-
// 3. Don't change formatting when commodity is not declared
|
|
82
|
-
const actualPrecision = amount.format?.precision ?? undefined;
|
|
83
|
-
let targetPrecision = undefined;
|
|
84
|
-
if (declaredPrecision !== undefined) {
|
|
85
|
-
// Commodity is declared - use max of actual and declared precision
|
|
86
|
-
if (actualPrecision !== undefined) {
|
|
87
|
-
targetPrecision = Math.max(actualPrecision, declaredPrecision);
|
|
88
|
-
}
|
|
89
|
-
else {
|
|
90
|
-
targetPrecision = declaredPrecision;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
else {
|
|
94
|
-
// Commodity is not declared - preserve original precision
|
|
95
|
-
targetPrecision = actualPrecision;
|
|
96
|
-
}
|
|
97
|
-
return {
|
|
98
|
-
commodityBefore: format.symbolOnLeft ? format.symbol || '' : '',
|
|
99
|
-
isNegative: amount.quantity < 0,
|
|
100
|
-
amountIntegerString: formatIntegerAmount(amount, format),
|
|
101
|
-
amountDecimalString: formatDecimalAmount(amount, format, targetPrecision),
|
|
102
|
-
demicalMark: targetPrecision && targetPrecision > 0 ? (format.decimalMark || '.') : '',
|
|
103
|
-
spaceBetweenCommodityAndAmount: format.spaceBetween || false,
|
|
104
|
-
commodityAfter: !format.symbolOnLeft ? format.symbol || '' : ''
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=formattingUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"formattingUtils.js","sourceRoot":"","sources":["../../src/features/formattingUtils.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA4CH,sCAEC;AAED,kDAaC;AAED,kDAYC;AAED,oCAsDC;AApGY,QAAA,eAAe,GAAgC;IACxD,WAAW,EAAE,CAAC;IACd,eAAe,EAAE,EAAE;IACnB,iBAAiB,EAAE,CAAC;IACpB,cAAc,EAAE,EAAE;IAClB,UAAU,EAAE,CAAC;IACb,kBAAkB,EAAE,EAAE;IACtB,2BAA2B,EAAE,EAAE;CAClC,CAAC;AAEF;;GAEG;AACH,SAAgB,aAAa,CAAC,aAAqB,EAAE,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G,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;QACnE,CAAC;aAAM,CAAC;YACJ,eAAe,GAAG,iBAAiB,CAAC;QACxC,CAAC;IACL,CAAC;SAAM,CAAC;QACJ,0DAA0D;QAC1D,eAAe,GAAG,eAAe,CAAC;IACtC,CAAC;IAED,OAAO;QACH,eAAe,EAAE,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;QAC/D,UAAU,EAAE,MAAM,CAAC,QAAQ,GAAG,CAAC;QAC/B,mBAAmB,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,CAAC;QACxD,mBAAmB,EAAE,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,eAAe,CAAC;QACzE,WAAW,EAAE,eAAe,IAAI,eAAe,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,WAAW,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;QACtF,8BAA8B,EAAE,MAAM,CAAC,YAAY,IAAI,KAAK;QAC5D,cAAc,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE;KAClE,CAAC;AACN,CAAC"}
|
package/out/parser/document.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ParsedDocument, Commodity, Account, Payee, Tag, Transaction } from "../types";
|
|
2
|
-
export declare function addCommodity(parsedDocument: ParsedDocument, commodity: Commodity): void;
|
|
3
|
-
export declare function addAccount(parsedDocument: ParsedDocument, account: Account): void;
|
|
4
|
-
export declare function addPayee(parsedDocument: ParsedDocument, payee: Payee): void;
|
|
5
|
-
export declare function addTag(parsedDocument: ParsedDocument, tag: Tag): void;
|
|
6
|
-
export declare function addTransaction(parsedDocument: ParsedDocument, transaction: Transaction): void;
|
|
7
|
-
//# sourceMappingURL=document.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/parser/document.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvF,wBAAgB,YAAY,CAAC,cAAc,EAAE,cAAc,EAAE,SAAS,EAAE,SAAS,GAAG,IAAI,CAYvF;AAED,wBAAgB,UAAU,CAAC,cAAc,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAajF;AAED,wBAAgB,QAAQ,CAAC,cAAc,EAAE,cAAc,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,CAY3E;AAED,wBAAgB,MAAM,CAAC,cAAc,EAAE,cAAc,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAYrE;AAED,wBAAgB,cAAc,CAAC,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,WAAW,GAAG,IAAI,CAE7F"}
|
package/out/parser/document.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*
|
|
3
|
-
Parsed Document helper functions
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.addCommodity = addCommodity;
|
|
7
|
-
exports.addAccount = addAccount;
|
|
8
|
-
exports.addPayee = addPayee;
|
|
9
|
-
exports.addTag = addTag;
|
|
10
|
-
exports.addTransaction = addTransaction;
|
|
11
|
-
function addCommodity(parsedDocument, commodity) {
|
|
12
|
-
const existingCommodity = parsedDocument.commodities.get(commodity.name);
|
|
13
|
-
if (existingCommodity) {
|
|
14
|
-
if (!existingCommodity.declared && commodity.declared) {
|
|
15
|
-
// If the commodity is not declared, we want to override it with the declared one
|
|
16
|
-
parsedDocument.commodities.set(commodity.name, commodity);
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
parsedDocument.commodities.set(commodity.name, commodity);
|
|
24
|
-
}
|
|
25
|
-
function addAccount(parsedDocument, account) {
|
|
26
|
-
const existingAccount = parsedDocument.accounts.get(account.name);
|
|
27
|
-
if (existingAccount) {
|
|
28
|
-
if (!existingAccount.declared && account.declared) {
|
|
29
|
-
// If the account is not declared, we want to override it with the declared one
|
|
30
|
-
parsedDocument.accounts.set(account.name, account);
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
parsedDocument.accounts.set(account.name, account);
|
|
38
|
-
}
|
|
39
|
-
function addPayee(parsedDocument, payee) {
|
|
40
|
-
const existingPayee = parsedDocument.payees.get(payee.name);
|
|
41
|
-
if (existingPayee) {
|
|
42
|
-
if (!existingPayee.declared && payee.declared) {
|
|
43
|
-
// If the payee is not declared, we want to override it with the declared one
|
|
44
|
-
parsedDocument.payees.set(payee.name, payee);
|
|
45
|
-
return;
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
parsedDocument.payees.set(payee.name, payee);
|
|
52
|
-
}
|
|
53
|
-
function addTag(parsedDocument, tag) {
|
|
54
|
-
const existingTag = parsedDocument.tags.get(tag.name);
|
|
55
|
-
if (existingTag) {
|
|
56
|
-
if (!existingTag.declared && tag.declared) {
|
|
57
|
-
// If the tag is not declared, we want to override it with the declared one
|
|
58
|
-
parsedDocument.tags.set(tag.name, tag);
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
parsedDocument.tags.set(tag.name, tag);
|
|
66
|
-
}
|
|
67
|
-
function addTransaction(parsedDocument, transaction) {
|
|
68
|
-
parsedDocument.transactions.push(transaction);
|
|
69
|
-
}
|
|
70
|
-
//#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