oppiliappan / statix

lints and suggestions for the nix programming language
https://git.peppe.rs/languages/statix/about
MIT License
557 stars 21 forks source link

Json range output #3

Closed meck closed 2 years ago

meck commented 2 years ago

Nice tool! I was trying to integrate with null-ls using the json output, however the location output is a bit hard to parse it seems to be character position, an additional row/col output would be nice.

oppiliappan commented 2 years ago

Oh, null-ls looks neat, would you prefer having both the bytespan as well as line/col info? Or would you say bytespan data is useless?

meck commented 2 years ago

For this use case line/col is prob preferable as it would end up calling something likenvim_buf_set_text({buffer}, {start_row}, {start_col}, {end_row},{end_col}, {replacement})

null-sp is a good stopgap, I guess the proper thing would be to integrate with nix LSP

oppiliappan commented 2 years ago

The latest release improves JSON outputs:

{
  "file": "../tests/c.nix",
  "report": [
    {
      "note": "Assignment instead of inherit",
      "code": 3,
      "diagnostics": [
        {
          "at": {
            "from": {
              "line": 11,
              "column": 3
            },
            "to": {
              "line": 11,
              "column": 13
            }
          },
          "message": "This assignment is better written with `inherit`",
          "suggestion": {
            "at": {
              "from": {
                "line": 11,
                "column": 3
              },
              "to": {
                "line": 11,
                "column": 13
              }
            },
            "fix": "inherit foo;"
          }
        }
      ]
    }
  ]
}

at now includes an object with from and to, which in turn include line and column info. Hope that works!

meck commented 2 years ago

FYI, the config for null-ls is available if you want to add a note in the docs.

oppiliappan commented 2 years ago

Thank you! I will add a section about editor integrations to the readme, soon.