hledger-lsp 0.1.0 → 0.1.2

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 (2) hide show
  1. package/README.md +71 -198
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -151,226 +151,80 @@ items or all items (declared + undeclared)
151
151
  ### Prerequisites
152
152
 
153
153
  - Node.js >= 16.0.0
154
- - npm or yarn
155
154
 
156
- ### Install from npm (recommended)
157
-
158
- Global install:
155
+ ### Install from npm
159
156
 
160
157
  ```bash
161
158
  npm install -g hledger-lsp
162
159
  ```
163
160
 
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:
161
+ This provides the `hledger-lsp` command globally. After installation, the language server can be used with any LSP-compatible editor.
171
162
 
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
- ```
163
+ ## Editor Configuration
192
164
 
193
- ## Usage
165
+ ### Neovim
194
166
 
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):
167
+ Add this to your lazy.nvim configuration (e.g., `~/.config/nvim/lua/plugins/hledger.lua`):
227
168
 
228
169
  ```lua
229
170
  return {
230
171
  {
231
172
  "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,
173
+ opts = {
174
+ servers = {
175
+ hledger_lsp = {
176
+ cmd = { "hledger-lsp", "--stdio" },
177
+ filetypes = { "hledger", "journal" },
178
+ },
179
+ },
180
+ },
248
181
  },
249
182
  }
250
183
  ```
251
184
 
252
- **Note:** Update the path in
253
- `vim.fn.expand("~/Development/hledger_lsp/out/server.js")` to match where you
254
- cloned this repository.
185
+ And add this to your `init.lua` for file type detection:
255
186
 
256
- #### Full Configuration (For Customization)
187
+ ```lua
188
+ vim.filetype.add({
189
+ extension = {
190
+ journal = "hledger",
191
+ hledger = "hledger",
192
+ },
193
+ })
194
+ ```
257
195
 
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:
196
+ **Optional:** Customize settings by adding a `settings` block:
261
197
 
262
198
  ```lua
263
199
  return {
264
200
  {
265
201
  "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" },
202
+ opts = {
203
+ servers = {
204
+ hledger_lsp = {
205
+ cmd = { "hledger-lsp", "--stdio" },
206
+ filetypes = { "hledger", "journal" },
276
207
  settings = {
277
208
  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
209
  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
210
+ undeclaredPayees = true, -- Enable payee validation
315
211
  },
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
212
  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
- }
213
+ showRunningBalances = true, -- Show running balances
214
+ },
215
+ -- See settings documentation below for all options
216
+ },
344
217
  },
345
- })
346
- vim.lsp.enable("hledger")
347
- return true
348
- end
349
- end,
218
+ },
219
+ },
220
+ },
350
221
  },
351
222
  }
352
223
  ```
353
224
 
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
225
+ ### VS Code
359
226
 
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
- ```
227
+ The VS Code extension is published separately. Install it from the VS Code marketplace or see the `vscode-client/` directory in the repository for development instructions.
374
228
 
375
229
  ### General Settings
376
230
 
@@ -468,31 +322,50 @@ target commodity for postings with @ or @@ notation
468
322
 
469
323
  ## Development
470
324
 
325
+ ### Building from Source
326
+
327
+ If you want to contribute or modify the language server:
328
+
329
+ ```bash
330
+ # Clone the repository
331
+ git clone https://github.com/ptimoney/hledger-lsp.git
332
+ cd hledger-lsp
333
+
334
+ # Install dependencies (from repository root)
335
+ npm install
336
+
337
+ # Build the server
338
+ npm run build:server
339
+
340
+ # Run the server directly
341
+ node server/out/server.js --stdio
342
+ ```
343
+
471
344
  ### Project Structure
472
345
 
473
346
  ```
474
347
  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
348
+ ├── server/
349
+ │ ├── src/
350
+ ├── server.ts # Main LSP server implementation
351
+ ├── types.ts # Type definitions for hledger structures
352
+ │ │ ├── parser/ # Journal file parser
353
+ ├── features/ # LSP feature implementations
354
+ └── utils/ # Utility functions
355
+ ├── out/ # Compiled JavaScript output
356
+ │ └── package.json
357
+ └── vscode-client/ # VS Code extension
487
358
  ```
488
359
 
489
- ### Building
360
+ ### Development Commands
361
+
362
+ From the `server/` directory:
490
363
 
491
364
  ```bash
492
365
  # Build once
493
366
  npm run build
494
367
 
495
- # Watch mode for development
368
+ # Watch mode (rebuild on changes)
496
369
  npm run watch
497
370
  ```
498
371
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hledger-lsp",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "Language Server Protocol implementation for hledger plain text accounting",
5
5
  "main": "./out/server.js",
6
6
  "bin": {