2

In my latex.nanorc file, I have the following instructions:

syntax "LaTeX" "\.(la)?tex$"
linter lacheck

However, when I press the keyboard shortcut to run the linter, I get an error message La commande « lacheck » n'a produit aucune ligne analysable (i.e The 'lacheck' command did not produce any analysable lines in English).

When I run lacheck by its own on my tex file it produces this output:

"article.tex", line 21: missing `\ ' after "e.g.".

My guess is that the format of the message is not understood by nano (version 5.8). Is there a standard protocol a linter must comply to in order to be recognised by nano?

3
  • When I run lacheck by its own on my tex file it produces "article.tex", line 21: missing `\ ' after "e.g.". My guess is that the format of the message is not understood by nano
    – Laravel
    Jul 28, 2021 at 8:38
  • See also: extendsyntax in the nano docs: "This allows you to add a new ... linter ... command to an already defined syntax"
    – muru
    Jul 28, 2021 at 8:43
  • extendsyntax is just a way to add an instruction to an already defined syntax (for example by an included file) but I'm defining my own syntax from scratch for LaTeX, extendsyntax is irrelevant to me. And since nano refers to lacheck in its error message, my instruction is correctly taken into account
    – Laravel
    Jul 28, 2021 at 8:45

1 Answer 1

3

There's a de facto standard format for compiler or linter error messages, which is the same format as grep -n: FILE_NAME:LINE_NUMBER:MESSAGE. Experimentally, nano supports that. I haven't researched if it supports any other format, but in any case it doesn't support lacheck's format.

You can define a wrapper to the lacheck command that rewrites its messages in the standard format, and tell nano to invoke that wrapper instead of invoking lacheck directly.

#!/usr/bin/env bash
set -o pipefail
lacheck "$@" 2>&1 | sed 's/^"\([^"]*\)", line /\1:/'
1
  • Works perfectly, thank you!
    – Laravel
    Jul 28, 2021 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.