Skip to content

fix: add pkl eval linter to catch diagnostics pkl-lsp misses#329

Merged
djensenius merged 2 commits into
mainfrom
djensenius/pkl-lint-diagnostics
Jun 25, 2026
Merged

fix: add pkl eval linter to catch diagnostics pkl-lsp misses#329
djensenius merged 2 commits into
mainfrom
djensenius/pkl-lint-diagnostics

Conversation

@djensenius

Copy link
Copy Markdown
Owner

Summary

pkl-lsp 0.7.1 doesn't reliably publish diagnostics in neovim — notably it misses missing required properties (e.g. an unset address field whose address.street is then undefined; see apple/pkl-lsp#103). This adds a nvim-lint linter that runs pkl eval and parses its error output to fill that gap.

Changes

  • nvim/lua/plugins/nvim-lint.lua: New pkl linter using pkl eval. The parser:
    • Attaches in-buffer errors (e.g. type mismatches) to their exact line/col.
    • Surfaces errors reported at an imported/amended definition site on line 1 with the render path (e.g. address.street: Tried to read property…) so they aren't lost.
  • nvim/lua/plugins/pkl.lua: Set pkl_cli_path to an absolute path via vim.fn.exepath('pkl') so the LSP resolves the mise-managed pkl binary.
  • nvim/lua/plugins/lualine.lua: Switch the LSP click handler from :LspInfo to :checkhealth vim.lsp for more detailed LSP info.

Testing

Verified in headless neovim against real .pkl files:

  • Type mismatch (y: Int = "str") → diagnostic at exact line/col (matches LSP).
  • Missing required property → diagnostic on line 1 with render path (LSP misses this).

stylua --check passes.

Notes

The LSP is kept for completions, hover, and goto-definition. When the next pkl-lsp release fixes diagnostics, the lint linter can be revisited to avoid duplicates.

pkl-lsp 0.7.1 does not reliably publish diagnostics (e.g. missing
required properties, apple/pkl-lsp#103), so add a nvim-lint linter that
runs `pkl eval` and parses its error output. In-buffer errors attach to
the exact line/col; errors reported at an imported/amended definition
site are surfaced on line 1 with the render path for context.

Also set pkl_cli_path to an absolute path via vim.fn.exepath('pkl') so
the LSP resolves the mise-managed pkl binary, and switch the lualine LSP
click handler to :checkhealth vim.lsp for more detailed LSP info.
Pre-existing formatting issue flagged by the Lint Fish Files CI job:
fish_indent normalizes `> ~/...` to `>~/...`.
@djensenius
djensenius merged commit 0364d3a into main Jun 25, 2026
5 checks passed
@djensenius
djensenius deleted the djensenius/pkl-lint-diagnostics branch June 25, 2026 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant