Appsilon / box.linters

lintr-compatible linters for box modules in R
https://appsilon.github.io/box.linters/
10 stars 0 forks source link

[GENERAL] Linter links to the documentation #141

Open Gotfrid opened 3 weeks ago

Gotfrid commented 3 weeks ago

Is it possible to somehow hook into the languageserver to replace lintr linnks in the "Problems" tab?

Buy default any lintr issues are leading to the lintr website, but I would very much like if box.linters issues would lead to the box.linters reference website.

Not sure if it's even possible, so just leaving it here as an idea - see the video below.

https://github.com/user-attachments/assets/81ffcbc3-7b7f-4ff1-a2f0-a8652fc037c7

radbasa commented 1 week ago

That would indeed be nice to have. As far as we know, {languageserver} only has public hooks for the document parser. This might be need a modification of languageserver itself.

radbasa commented 1 week ago

The link to {lintr} documentation is in the following {languageserver} function

diagnostic_from_lint <- function(result, content) {
    list(
        range = diagnostic_range(result, content),
        severity = diagnostic_severity(result),
        source = "lintr",
        message = result$message,
        code = result$linter,
        codeDescription = list(
            href = sprintf("https://lintr.r-lib.org/reference/%s.html", result$linter)
        )
    )
}

https://github.com/REditorSupport/languageserver/blob/9b300181f2588462cb5a6f7ecd55fcbeb083d028/R/diagnostics.R#L51-L62