hledger-lsp 0.1.0

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.
Files changed (99) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +632 -0
  3. package/out/extension.d.ts +1 -0
  4. package/out/extension.d.ts.map +1 -0
  5. package/out/extension.js +2 -0
  6. package/out/extension.js.map +1 -0
  7. package/out/features/codeActions.d.ts +73 -0
  8. package/out/features/codeActions.d.ts.map +1 -0
  9. package/out/features/codeActions.js +417 -0
  10. package/out/features/codeActions.js.map +1 -0
  11. package/out/features/completion.d.ts +94 -0
  12. package/out/features/completion.d.ts.map +1 -0
  13. package/out/features/completion.js +323 -0
  14. package/out/features/completion.js.map +1 -0
  15. package/out/features/definition.d.ts +12 -0
  16. package/out/features/definition.d.ts.map +1 -0
  17. package/out/features/definition.js +61 -0
  18. package/out/features/definition.js.map +1 -0
  19. package/out/features/documentLinks.d.ts +17 -0
  20. package/out/features/documentLinks.d.ts.map +1 -0
  21. package/out/features/documentLinks.js +68 -0
  22. package/out/features/documentLinks.js.map +1 -0
  23. package/out/features/findReferences.d.ts +33 -0
  24. package/out/features/findReferences.d.ts.map +1 -0
  25. package/out/features/findReferences.js +79 -0
  26. package/out/features/findReferences.js.map +1 -0
  27. package/out/features/foldingRanges.d.ts +27 -0
  28. package/out/features/foldingRanges.d.ts.map +1 -0
  29. package/out/features/foldingRanges.js +111 -0
  30. package/out/features/foldingRanges.js.map +1 -0
  31. package/out/features/formatter.d.ts +70 -0
  32. package/out/features/formatter.d.ts.map +1 -0
  33. package/out/features/formatter.js +373 -0
  34. package/out/features/formatter.js.map +1 -0
  35. package/out/features/hover.d.ts +66 -0
  36. package/out/features/hover.d.ts.map +1 -0
  37. package/out/features/hover.js +387 -0
  38. package/out/features/hover.js.map +1 -0
  39. package/out/features/inlayHints.d.ts +43 -0
  40. package/out/features/inlayHints.d.ts.map +1 -0
  41. package/out/features/inlayHints.js +221 -0
  42. package/out/features/inlayHints.js.map +1 -0
  43. package/out/features/selectionRange.d.ts +47 -0
  44. package/out/features/selectionRange.d.ts.map +1 -0
  45. package/out/features/selectionRange.js +273 -0
  46. package/out/features/selectionRange.js.map +1 -0
  47. package/out/features/semanticTokens.d.ts +83 -0
  48. package/out/features/semanticTokens.d.ts.map +1 -0
  49. package/out/features/semanticTokens.js +370 -0
  50. package/out/features/semanticTokens.js.map +1 -0
  51. package/out/features/symbols.d.ts +47 -0
  52. package/out/features/symbols.d.ts.map +1 -0
  53. package/out/features/symbols.js +249 -0
  54. package/out/features/symbols.js.map +1 -0
  55. package/out/features/transactionAnalyzer.d.ts +63 -0
  56. package/out/features/transactionAnalyzer.d.ts.map +1 -0
  57. package/out/features/transactionAnalyzer.js +127 -0
  58. package/out/features/transactionAnalyzer.js.map +1 -0
  59. package/out/features/validator.d.ts +142 -0
  60. package/out/features/validator.d.ts.map +1 -0
  61. package/out/features/validator.js +633 -0
  62. package/out/features/validator.js.map +1 -0
  63. package/out/parser/ast.d.ts +37 -0
  64. package/out/parser/ast.d.ts.map +1 -0
  65. package/out/parser/ast.js +606 -0
  66. package/out/parser/ast.js.map +1 -0
  67. package/out/parser/includes.d.ts +25 -0
  68. package/out/parser/includes.d.ts.map +1 -0
  69. package/out/parser/includes.js +106 -0
  70. package/out/parser/includes.js.map +1 -0
  71. package/out/parser/index.d.ts +54 -0
  72. package/out/parser/index.d.ts.map +1 -0
  73. package/out/parser/index.js +146 -0
  74. package/out/parser/index.js.map +1 -0
  75. package/out/server/deps.d.ts +19 -0
  76. package/out/server/deps.d.ts.map +1 -0
  77. package/out/server/deps.js +77 -0
  78. package/out/server/deps.js.map +1 -0
  79. package/out/server/settings.d.ts +60 -0
  80. package/out/server/settings.d.ts.map +1 -0
  81. package/out/server/settings.js +110 -0
  82. package/out/server/settings.js.map +1 -0
  83. package/out/server.d.ts +3 -0
  84. package/out/server.d.ts.map +1 -0
  85. package/out/server.js +420 -0
  86. package/out/server.js.map +1 -0
  87. package/out/types.d.ts +84 -0
  88. package/out/types.d.ts.map +1 -0
  89. package/out/types.js +6 -0
  90. package/out/types.js.map +1 -0
  91. package/out/utils/index.d.ts +38 -0
  92. package/out/utils/index.d.ts.map +1 -0
  93. package/out/utils/index.js +89 -0
  94. package/out/utils/index.js.map +1 -0
  95. package/out/utils/uri.d.ts +32 -0
  96. package/out/utils/uri.d.ts.map +1 -0
  97. package/out/utils/uri.js +215 -0
  98. package/out/utils/uri.js.map +1 -0
  99. package/package.json +58 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Patrick Timoney
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,632 @@
1
+ # hledger Language Server
2
+
3
+ A Language Server Protocol (LSP) implementation for
4
+ [hledger](https://hledger.org/), a plain text accounting tool.
5
+
6
+ ## Features
7
+
8
+ This language server provides comprehensive IDE support for hledger journal
9
+ files:
10
+
11
+ ### Code Completion
12
+
13
+ - **Account names** - Auto-complete from accounts (configurable: declared only
14
+ or all)
15
+ - **Payees** - Complete transaction descriptions from payees (configurable:
16
+ declared only or all)
17
+ - **Commodities** - Auto-complete currency symbols (configurable: declared only
18
+ or all)
19
+ - **Tags** - Complete tag names in comments (configurable: declared only or all)
20
+ - **Directives** - Complete hledger directives (account, commodity, payee, tag,
21
+ include, alias)
22
+ - **Include paths** - File path completion for include directives
23
+ - **Smart completions** - Context-aware account suggestions based on payee
24
+ history (learns from your transaction patterns)
25
+ - **Smart filtering** - By default, only declared items appear in completions
26
+ (can be configured to include all items)
27
+
28
+ ### Hover
29
+
30
+ - **Hover information** - Lightweight hover support for accounts, payees and
31
+ dates. Hover text is provided by the language server and can be extended to show
32
+ declarations, balances and commodity formats.
33
+
34
+ ### Validation
35
+
36
+ - **Transaction balance** - Verify transactions balance to zero per commodity
37
+ - **Missing amounts** - Ensure at most one posting omits an amount
38
+ - **Undeclared items** - Warn about undeclared accounts, payees, commodities,
39
+ and tags
40
+ - **Date ordering** - Detect out-of-order transactions
41
+ - **Balance assertions** - Verify balance assertions match calculated balances
42
+ - **Empty transactions** - Require at least 2 postings per transaction
43
+ - **Date validation** - Check for invalid dates (e.g., Feb 30, month 13)
44
+ - **Future dates** - Warn about future-dated transactions
45
+ - **Empty descriptions** - Warn about transactions with no description
46
+ - **Include files** - Detect missing include files
47
+ - **Circular includes** - Detect circular include dependencies
48
+
49
+ ### Include Directive Support
50
+
51
+ - **Multi-file journals** - Parse and merge multiple journal files via include
52
+ directives
53
+ - **Relative and absolute paths** - Support both path styles, including `../`
54
+ parent directory references
55
+ - **Tilde expansion** - Support for `~/` home directory paths
56
+ - **Paths with spaces** - Properly handles file paths containing spaces and
57
+ special characters (e.g., "Cloud Storage", "My Documents (2025)")
58
+ - **Circular detection** - Prevent infinite loops from circular includes
59
+ - **Caching** - Efficient parsing with include file caching
60
+ - **Dependency tracking** - Auto-revalidate files when included files change
61
+ - **Source tracking** - Track which file each entity originates from
62
+
63
+ ### Navigation
64
+
65
+ - **Document symbols** - Outline view showing directives and transactions with
66
+ postings
67
+ - **Workspace symbols** - Project-wide search across all accounts, payees,
68
+ commodities, tags, and transactions
69
+ - **Go to definition** - Jump to declarations for accounts, payees, commodities,
70
+ and tags
71
+ - **Find references** - Show all usages of accounts, payees, commodities, or
72
+ tags across the document
73
+
74
+ ### Code Actions & Quick Fixes
75
+
76
+ - **Add declarations** - Automatically add account, payee, commodity, or tag
77
+ declarations for undeclared items
78
+ - **Smart insertion** - Directives are inserted in appropriate locations,
79
+ grouped with similar directive types
80
+ - **Rename refactoring** - Rename accounts, payees, commodities, or tags across
81
+ all their references in the document
82
+ - **Context-aware actions** - Actions appear when cursor is positioned on
83
+ renameable items
84
+
85
+ ### Formatting
86
+
87
+ - **Document formatting** - Format entire journal files with consistent
88
+ indentation and spacing
89
+ - **Range formatting** - Format selected portions of your journal
90
+ - **On-type formatting** - Auto-indent postings when pressing Enter after
91
+ transaction headers
92
+ - **Decimal-point alignment** - Automatically align amounts by their decimal
93
+ point (or implied decimal position for whole numbers) within transactions,
94
+ making it easy to visually compare amounts
95
+ - **Negative amount support** - Properly aligns negative amounts regardless of
96
+ minus sign position (e.g., `-$100.00` or `$-100.00`)
97
+ - **Commodity format support** - Reformats amounts according to declared
98
+ commodity formats (symbol placement, decimal separators, thousands separators,
99
+ precision)
100
+ - **Precision preservation** - Maintains decimal precision even when commodity
101
+ format specifies fewer decimal places
102
+ - **Configurable** - Customize indentation width, alignment column, minimum
103
+ spacing, trailing whitespace handling, and more
104
+
105
+ ### Semantic Highlighting
106
+
107
+ - **Context-aware syntax highlighting** - Rich semantic highlighting based on
108
+ token type and meaning
109
+ - **Token types** - Distinct highlighting for dates, accounts, payees,
110
+ commodities, tags, directives, amounts, comments, and status indicators
111
+ - **Token modifiers** - Additional styling for declarations (directive
112
+ definitions) and readonly items (dates, amounts)
113
+ - **Hierarchical accounts** - Account names highlighted as namespaces to reflect
114
+ their hierarchical nature
115
+ - **Tag detection** - Automatic highlighting of tags within comments (key:value
116
+ pairs)
117
+
118
+ ### Inlay Hints
119
+
120
+ - **Inferred amounts** - Show calculated amounts for postings without explicit
121
+ amounts
122
+ - **Running balances** - Display running balances per account and commodity
123
+ after each posting
124
+ - **Cost conversions** - Show total cost in target commodity for postings with
125
+ cost notation (@ or @@)
126
+ - **Configurable** - Enable/disable each hint type independently
127
+ - **Range-aware** - Only show hints for visible portions of the document for
128
+ better performance
129
+
130
+ ### Editor Integration
131
+
132
+ - **Folding ranges** - Collapse/expand transactions to hide postings, fold
133
+ multi-line comment blocks
134
+ - **Document links** - Clickable include paths that open the referenced file
135
+ (supports relative and absolute paths)
136
+ - **Selection range** - Smart text selection expansion: Word → Account → Posting
137
+ → Transaction (requires editor keybinding setup, see configuration below)
138
+
139
+ ### User Configuration
140
+
141
+ All validations and completion behaviors can be individually configured per
142
+ workspace or document:
143
+
144
+ - **Validation settings** - Enable/disable individual validation rules and
145
+ customize severity levels
146
+ - **Completion filtering** - Control whether completions show only declared
147
+ items or all items (declared + undeclared)
148
+
149
+ ## Installation
150
+
151
+ ### Prerequisites
152
+
153
+ - Node.js >= 16.0.0
154
+ - npm or yarn
155
+
156
+ ### Install from npm (recommended)
157
+
158
+ Global install:
159
+
160
+ ```bash
161
+ npm install -g hledger-lsp
162
+ ```
163
+
164
+ This provides an `hledger-lsp` CLI on your `$PATH`:
165
+
166
+ ```bash
167
+ hledger-lsp --stdio
168
+ ```
169
+
170
+ You can also install it per project:
171
+
172
+ ```bash
173
+ npm install --save-dev hledger-lsp
174
+ ```
175
+
176
+ ### From source (development)
177
+
178
+ ```bash
179
+ # Clone the repository
180
+ git clone <repository-url>
181
+ cd hledger_lsp
182
+
183
+ # Install dependencies
184
+ npm install
185
+
186
+ # Build the project
187
+ npm run build
188
+
189
+ # Run the server directly
190
+ node server/out/server.js --stdio
191
+ ```
192
+
193
+ ## Usage
194
+
195
+ ### Neovim configuration examples
196
+
197
+ #### Global npm install
198
+
199
+ ```lua
200
+ local lspconfig = require("lspconfig")
201
+
202
+ lspconfig.hledger_lsp.setup({
203
+ cmd = { "hledger-lsp", "--stdio" },
204
+ filetypes = { "hledger", "journal" },
205
+ })
206
+ ```
207
+
208
+ #### Local (per-project) install
209
+
210
+ ```lua
211
+ local lspconfig = require("lspconfig")
212
+ local util = lspconfig.util
213
+
214
+ lspconfig.hledger_lsp.setup({
215
+ cmd = { util.path.join(vim.loop.cwd(), "node_modules", ".bin", "hledger-lsp"), "--stdio" },
216
+ filetypes = { "hledger", "journal" },
217
+ })
218
+ ```
219
+
220
+ ### Neovim Configuration
221
+
222
+ #### Minimal Configuration (Recommended for Most Users)
223
+
224
+ This minimal configuration uses all default settings. Add this to your Neovim
225
+ configuration (e.g., in `~/.config/nvim/lua/plugins/hledger.lua` if using
226
+ lazy.nvim):
227
+
228
+ ```lua
229
+ return {
230
+ {
231
+ "neovim/nvim-lspconfig",
232
+ opts = function(_, opts)
233
+ opts.servers = opts.servers or {}
234
+ opts.servers.hledger = {}
235
+
236
+ opts.setup = opts.setup or {}
237
+ opts.setup.hledger = function()
238
+ vim.lsp.config("hledger", {
239
+ cmd = { "node", vim.fn.expand("~/Development/hledger_lsp/out/server.js"), "--stdio" },
240
+ filetypes = { "hledger" },
241
+ root_markers = { ".hledger.journal", "main.journal", ".git" },
242
+ settings = {},
243
+ })
244
+ vim.lsp.enable("hledger")
245
+ return true
246
+ end
247
+ end,
248
+ },
249
+ }
250
+ ```
251
+
252
+ **Note:** Update the path in
253
+ `vim.fn.expand("~/Development/hledger_lsp/out/server.js")` to match where you
254
+ cloned this repository.
255
+
256
+ #### Full Configuration (For Customization)
257
+
258
+ If you want to customize specific settings, here's the complete configuration
259
+ with all options explicitly set to their defaults. Modify only the settings you
260
+ want to change:
261
+
262
+ ```lua
263
+ return {
264
+ {
265
+ "neovim/nvim-lspconfig",
266
+ opts = function(_, opts)
267
+ opts.servers = opts.servers or {}
268
+ opts.servers.hledger = {}
269
+
270
+ opts.setup = opts.setup or {}
271
+ opts.setup.hledger = function()
272
+ vim.lsp.config("hledger", {
273
+ cmd = { "node", vim.fn.expand("~/Development/hledger_lsp/out/server.js"), "--stdio" },
274
+ filetypes = { "hledger" },
275
+ root_markers = { ".hledger.journal", "main.journal", ".git" },
276
+ settings = {
277
+ hledgerLanguageServer = {
278
+ -- Maximum number of diagnostic problems to report
279
+ maxNumberOfProblems = 1000,
280
+
281
+ -- Path to hledger executable (reserved for future CLI integration)
282
+ hledgerPath = "hledger",
283
+
284
+ -- Validation settings (all default to true)
285
+ -- Set any to false to disable that validation
286
+ validation = {
287
+ balance = true, -- Verify transactions balance to zero
288
+ missingAmounts = true, -- Ensure at most one posting omits amount
289
+ undeclaredAccounts = true, -- Warn about undeclared accounts
290
+ undeclaredPayees = false, -- Warn about undeclared payees
291
+ undeclaredCommodities = true, -- Warn about undeclared commodities
292
+ undeclaredTags = true, -- Warn about undeclared tags
293
+ dateOrdering = true, -- Detect out-of-order transactions
294
+ balanceAssertions = true, -- Verify balance assertions
295
+ emptyTransactions = true, -- Require at least 2 postings
296
+ invalidDates = true, -- Check for invalid dates (Feb 30, etc.)
297
+ futureDates = true, -- Warn about future-dated transactions
298
+ emptyDescriptions = true, -- Warn about transactions with no description
299
+ includeFiles = true, -- Detect missing include files
300
+ circularIncludes = true, -- Detect circular include dependencies
301
+ },
302
+
303
+ -- Severity levels for undeclared items (error | warning | information | hint)
304
+ severity = {
305
+ undeclaredAccounts = "warning",
306
+ undeclaredPayees = "warning",
307
+ undeclaredCommodities = "warning",
308
+ undeclaredTags = "information",
309
+ },
310
+
311
+ -- Include directive settings
312
+ include = {
313
+ followIncludes = true, -- Parse and merge included journal files
314
+ maxDepth = 10, -- Maximum include depth
315
+ },
316
+
317
+ -- Completion settings (all default to true - only show declared items)
318
+ -- Set to false to include undeclared items in completions
319
+ completion = {
320
+ onlyDeclaredAccounts = true,
321
+ onlyDeclaredPayees = true,
322
+ onlyDeclaredCommodities = true,
323
+ onlyDeclaredTags = true,
324
+ },
325
+
326
+ -- Formatting settings
327
+ formatting = {
328
+ indentation = 4, -- Number of spaces for posting indentation
329
+ maxAccountWidth = 42, -- Maximum width for account names
330
+ maxCommodityWidth = 4, -- Maximum width for commodity symbols
331
+ maxAmountWidth = 12, -- Maximum width for amount numbers
332
+ minSpacing = 2, -- Minimum spaces between account and amount
333
+ decimalAlignColumn = 52, -- Target column for decimal alignment
334
+ assertionDecimalAlignColumn = 70, -- Target column for assertion decimal alignment
335
+ },
336
+
337
+ -- Inlay hints settings
338
+ inlayHints = {
339
+ showInferredAmounts = true, -- Show calculated amounts for postings without amounts
340
+ showRunningBalances = false, -- Show running balances after each posting
341
+ showCostConversions = true, -- Show total cost for @ and @@ notations
342
+ }
343
+ }
344
+ },
345
+ })
346
+ vim.lsp.enable("hledger")
347
+ return true
348
+ end
349
+ end,
350
+ },
351
+ }
352
+ ```
353
+
354
+ **Note:** Update the path in
355
+ `vim.fn.expand("~/Development/hledger_lsp/out/server.js")` to match where you
356
+ cloned this repository.
357
+
358
+ #### File Type Detection
359
+
360
+ You may also want to set up file type detection for hledger files:
361
+
362
+ ```lua
363
+ -- In your init.lua or ftdetect configuration
364
+ vim.filetype.add({
365
+ extension = {
366
+ journal = 'hledger',
367
+ hledger = 'hledger',
368
+ },
369
+ pattern = {
370
+ ['.*%.journal'] = 'hledger',
371
+ }
372
+ })
373
+ ```
374
+
375
+ ### General Settings
376
+
377
+ - `maxNumberOfProblems` (number, default: 1000): Maximum number of diagnostic
378
+ problems to report per file
379
+ - `hledgerPath` (string, default: "hledger"): Path to the hledger executable
380
+ (reserved for future CLI integration)
381
+
382
+ ### Validation Settings
383
+
384
+ All validation settings default to `true` and can be individually disabled:
385
+
386
+ - `validation.balance`: Verify transactions balance to zero per commodity
387
+ - `validation.missingAmounts`: Ensure at most one posting per transaction omits
388
+ an amount
389
+ - `validation.undeclaredAccounts`: Warn about accounts used but not declared
390
+ - `validation.undeclaredPayees`: Warn about payees used but not declared
391
+ - `validation.undeclaredCommodities`: Warn about commodities used but not
392
+ declared
393
+ - `validation.undeclaredTags`: Warn about tags used but not declared
394
+ - `validation.dateOrdering`: Detect transactions with dates out of chronological
395
+ order
396
+ - `validation.balanceAssertions`: Verify balance assertions match calculated
397
+ balances
398
+ - `validation.emptyTransactions`: Require at least 2 postings per transaction
399
+ - `validation.invalidDates`: Check for invalid dates (e.g., February 30, month 13)
400
+ - `validation.futureDates`: Warn about future-dated transactions
401
+ - `validation.emptyDescriptions`: Warn about transactions with no description
402
+ - `validation.includeFiles`: Detect missing include files
403
+ - `validation.circularIncludes`: Detect circular include dependencies
404
+
405
+ ### Severity Settings
406
+
407
+ Customize the severity level for undeclared item warnings. Options: `"error"`,
408
+ `"warning"`, `"information"`, `"hint"`
409
+
410
+ - `severity.undeclaredAccounts` (default: "warning")
411
+ - `severity.undeclaredPayees` (default: "warning")
412
+ - `severity.undeclaredCommodities` (default: "warning")
413
+ - `severity.undeclaredTags` (default: "information")
414
+
415
+ ### Include Settings
416
+
417
+ - `include.followIncludes` (boolean, default: true): Parse and merge included
418
+ journal files
419
+ - `include.maxDepth` (number, default: 10): Maximum include depth to prevent
420
+ infinite recursion
421
+
422
+ ### Completion Settings
423
+
424
+ Control which items appear in auto-completion suggestions. All settings default
425
+ to `true` (only show declared items):
426
+
427
+ - `completion.onlyDeclaredAccounts` (boolean, default: true): Only show accounts
428
+ declared with `account` directive in completions
429
+ - `completion.onlyDeclaredPayees` (boolean, default: true): Only show payees
430
+ declared with `payee` directive in completions
431
+ - `completion.onlyDeclaredCommodities` (boolean, default: true): Only show
432
+ commodities declared with `commodity` directive in completions
433
+ - `completion.onlyDeclaredTags` (boolean, default: true): Only show tags
434
+ declared with `tag` directive in completions
435
+
436
+ Set to `false` to include items that are used but not explicitly declared in
437
+ completions.
438
+
439
+ ### Formatting Settings
440
+
441
+ Configure document formatting behavior:
442
+
443
+ - `formatting.indentation` (number, default: 4): Number of spaces for posting
444
+ indentation
445
+ - `formatting.maxAccountWidth` (number, default: 42): Maximum width allocated
446
+ for account names before wrapping/truncation
447
+ - `formatting.maxCommodityWidth` (number, default: 4): Maximum width allocated
448
+ for commodity symbols
449
+ - `formatting.maxAmountWidth` (number, default: 12): Maximum width allocated for
450
+ amount numbers
451
+ - `formatting.minSpacing` (number, default: 2): Minimum number of spaces between
452
+ account names and amounts
453
+ - `formatting.decimalAlignColumn` (number, default: 52): Target column position
454
+ for aligning decimal points in amounts
455
+ - `formatting.assertionDecimalAlignColumn` (number, default: 70): Target column
456
+ position for aligning decimal points in balance assertions
457
+
458
+ ### Inlay Hints Settings
459
+
460
+ Configure which inline hints to display:
461
+
462
+ - `inlayHints.showInferredAmounts` (boolean, default: true): Show calculated
463
+ amounts for postings that omit explicit amounts
464
+ - `inlayHints.showRunningBalances` (boolean, default: false): Display running
465
+ balance after each posting (can be noisy for large files)
466
+ - `inlayHints.showCostConversions` (boolean, default: true): Show total cost in
467
+ target commodity for postings with @ or @@ notation
468
+
469
+ ## Development
470
+
471
+ ### Project Structure
472
+
473
+ ```
474
+ hledger_lsp/
475
+ ├── src/
476
+ │ ├── server.ts # Main LSP server implementation
477
+ │ ├── types.ts # Type definitions for hledger structures
478
+ │ ├── parser/ # Journal file parser
479
+ │ │ └── index.ts
480
+ │ ├── features/ # LSP feature implementations
481
+ │ └── utils/ # Utility functions
482
+ │ └── index.ts
483
+ ├── out/ # Compiled JavaScript output
484
+ ├── package.json
485
+ ├── tsconfig.json
486
+ └── README.md
487
+ ```
488
+
489
+ ### Building
490
+
491
+ ```bash
492
+ # Build once
493
+ npm run build
494
+
495
+ # Watch mode for development
496
+ npm run watch
497
+ ```
498
+
499
+ ### Linting
500
+
501
+ ```bash
502
+ npm run lint
503
+ ```
504
+
505
+ ### Testing
506
+
507
+ The project includes comprehensive test coverage using Jest:
508
+
509
+ ```bash
510
+ # Run all tests
511
+ npm test
512
+
513
+ # Run tests in watch mode
514
+ npm run test:watch
515
+
516
+ # Generate coverage report
517
+ npm run test:coverage
518
+
519
+ # Run tests with verbose output
520
+ npm run test:verbose
521
+
522
+ # Run specific test file
523
+ npx jest tests/parser/index.test.ts
524
+
525
+ # Run tests matching a pattern
526
+ npx jest --testNamePattern="balance"
527
+ ```
528
+
529
+ Test files mirror the `src/` directory structure (515 test cases total):
530
+
531
+ - `tests/utils/index.test.ts` - Utility function tests
532
+ - `tests/utils/uri.test.ts` - URI encoding/decoding tests for paths with spaces
533
+ - `tests/parser/index.test.ts` - Parser tests
534
+ - `tests/parser/parentInclude.test.ts` - Parent directory include tests
535
+ - `tests/parser/includeGlob.test.ts` - Glob pattern include tests
536
+ - `tests/features/completion.test.ts` - Completion provider tests
537
+ - `tests/features/validator.test.ts` - Validation tests
538
+ - `tests/features/validator-includes.test.ts` - Include directive validation
539
+ tests
540
+ - `tests/features/formatter.test.ts` - Formatting tests (30 test cases including
541
+ decimal alignment)
542
+ - `tests/features/symbols.test.ts` - Symbol provider tests
543
+ - `tests/features/codeActions.test.ts` - Code action tests (including rename
544
+ refactoring)
545
+ - `tests/features/hover.test.ts` - Hover provider tests
546
+ - `tests/features/definition.test.ts` - Definition provider tests
547
+ - `tests/features/findReferences.test.ts` - Find references tests
548
+ - `tests/features/inlayHints.test.ts` - Inlay hints tests
549
+ - `tests/features/semanticTokens.test.ts` - Semantic highlighting tests (20 test
550
+ cases)
551
+ - `tests/features/foldingRanges.test.ts` - Folding ranges tests (9 test cases)
552
+ - `tests/features/documentLinks.test.ts` - Document links tests (9 test cases)
553
+ - `tests/features/selectionRange.test.ts` - Selection range tests (11 test
554
+ cases)
555
+ - `tests/features/transactionAnalyzer.test.ts` - Transaction pattern analysis
556
+ tests
557
+ - `tests/features/smartCompletion.integration.test.ts` - Smart completion
558
+ integration tests
559
+ - `tests/integration/spaces-in-path.test.ts` - Integration tests for file paths
560
+ with spaces
561
+
562
+ ## Roadmap
563
+
564
+ ### Completed Features
565
+
566
+ - [x] Basic LSP server setup
567
+ - [x] Project scaffolding
568
+ - [x] Journal file parser with full hledger syntax support
569
+ - [x] Comprehensive validation (11+ validation rules)
570
+ - [x] Account name completion
571
+ - [x] Payee completion
572
+ - [x] Commodity completion
573
+ - [x] Tag completion
574
+ - [x] Directive completion
575
+ - [x] Include path completion
576
+ - [x] Configurable completion filtering (declared items only vs. all items)
577
+ - [x] Transaction balance validation
578
+ - [x] Balance assertions validation
579
+ - [x] Date validation and ordering
580
+ - [x] Undeclared items detection
581
+ - [x] Include directive support with circular detection
582
+ - [x] Multi-file journal support with dependency tracking
583
+ - [x] User-configurable validation and severity levels
584
+ - [x] Hover information
585
+ - [x] Source location tracking
586
+ - [x] Go to definition (accounts, payees, commodities, tags)
587
+ - [x] Document symbols (outline view showing directives and transactions)
588
+ - [x] Workspace symbols (project-wide search for accounts, payees, commodities,
589
+ tags, transactions)
590
+ - [x] Code actions and quick fixes (add declarations for undeclared items)
591
+ - [x] Rename refactoring (rename accounts, payees, commodities, tags across all
592
+ references)
593
+ - [x] Formatting support (document, range, and on-type formatting)
594
+ - [x] Enhanced formatting (amount alignment, commodity format support, precision
595
+ preservation)
596
+ - [x] Semantic highlighting (context-aware token highlighting with types and
597
+ modifiers)
598
+
599
+ ### Recently Added
600
+
601
+ - [x] Folding ranges (collapse transactions and comment blocks)
602
+ - [x] Document links (clickable include paths)
603
+ - [x] Selection range (smart text selection expansion)
604
+ - [x] URI encoding/decoding support for file paths with spaces and special
605
+ characters
606
+ - [x] Find references (show all usages of accounts, payees, commodities, tags)
607
+ - [x] Inlay hints (inferred amounts, running balances, cost conversions)
608
+ - [x] Transaction pattern analysis for smart completions
609
+ - [x] Comprehensive test coverage (515 tests)
610
+
611
+ ### Planned Features
612
+
613
+ - [ ] Integration with hledger CLI for validation
614
+ - [ ] Code lens (show account balances, transaction counts)
615
+ - [ ] More sophisticated hover information (balances, commodity info)
616
+
617
+ See [ROADMAP.md](ROADMAP.md) for a comprehensive list of proposed features and
618
+ future development ideas.
619
+
620
+ ## Contributing
621
+
622
+ Contributions are welcome! Please feel free to submit a Pull Request.
623
+
624
+ ## License
625
+
626
+ MIT
627
+
628
+ ## Resources
629
+
630
+ - [hledger Documentation](https://hledger.org/)
631
+ - [LSP Specification](https://microsoft.github.io/language-server-protocol/)
632
+ - [vscode-languageserver-node](https://github.com/microsoft/vscode-languageserver-node)
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=extension.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.d.ts","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=extension.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../src/extension.ts"],"names":[],"mappings":""}