mfussenegger / nvim-lint

An asynchronous linter plugin for Neovim complementary to the built-in Language Server Protocol support.
GNU General Public License v3.0
2k stars 208 forks source link

[Feature request] Allow having a lint line offset #354

Closed itaranto closed 1 year ago

itaranto commented 1 year ago

I'm writing a json parser using jq, and I came up with the following configuration:

    lint.linters.jq = {
      name = 'jq',
      cmd = 'jq',
      stdin = true,
      stream = 'stderr',
      ignore_exitcode = true,
      parser = require('lint.parser').from_pattern(
        '^(.*): (.+) at line (%d+), column (%d+)$',
        { 'code', 'message', 'lnum', 'col' },
        nil,
        nil,
        nil
      ),
    }

An example jq error message would be: parse error: Expected another key-value pair at line 27, column 1

This works fine with the exception that the messages are shifted one line below:

image

efm-langserver has lint-offset and lint-offset-columns to correct line and column-wise respectively.

An equivalent configuration for efm-langserver would be:

  json-jq: &json-jq
    lint-command: 'jq'
    lint-stdin: true
    lint-offset: 1
    lint-formats:
      - '%m at line %l, column %c'

I wonder if those could be implemented, specially lint-offset.

mfussenegger commented 1 year ago

Does https://github.com/mfussenegger/nvim-lint/pull/356 solve this?

itaranto commented 1 year ago

Does #356 solve this?

Yup, { lnum_offset = -1 } did the trick.

Thank you!