Skip to content
This repository has been archived by the owner on Sep 20, 2023. It is now read-only.

hdevtools: Multi-line error messages not formatted properly #1700

Open
nomeata opened this issue Feb 17, 2016 · 4 comments
Open

hdevtools: Multi-line error messages not formatted properly #1700

nomeata opened this issue Feb 17, 2016 · 4 comments

Comments

@nomeata
Copy link

nomeata commented Feb 17, 2016

The haskell compiler usually provides nice multi-line error messages, such as

$ hdevtools check "$PWD/Writer.hs"
/home/jojo/uni/info/Vorträge/2016-02-19 BobKonf/Writer.hs:87:5:
    No instance for (MonadFix Write) arising from a do statement
    In a stmt of an 'mdo' block:
      rec { writeWord8 pos1;
            writeWord8 pos2;
            pos1 <- getPos;
            writeList writeWord16 ws1;
            pos2 <- getPos }
    In the second argument of ‘($)’, namely
      ‘mdo { rec { writeWord8 pos1;
                   writeWord8 pos2;
                   pos1 <- getPos;
                   .... };
             writeList writeWord16 ws2 }’
    In the expression:
      execWrite
      $ mdo { rec { writeWord8 pos1;
                    writeWord8 pos2;
                    pos1 <- getPos;
                    .... };
              writeList writeWord16 ws2 }

Currenty, the hdevtools plugin collapses all whitespace using

return SyntasticMake({
        \ 'makeprg': makeprg,
        \ 'errorformat': errorformat,
        \ 'defaults': {'vcol': 1},
        \ 'postprocess': ['compressWhitespace'] })

in syntax_checkers/haskell/hdevtools.vim, which make such an error message hard to read.

If I remove the compressWhitespace, I get the nicely formatted error message, with two quirks: It starts with an empty line (probably the \n after the :), and it is unnecessarily indented.

I suggest to replace compressWhitespace by some unindent which

  • removes empty lines at the beginning and
  • removes the least indentation of all lines, so that the line with the least whitespace in front starts with a non-whitespace character, and the other lines are shorted by the same amount.

@lcd047, you last touched that line file.

@lcd047
Copy link
Collaborator

lcd047 commented Feb 17, 2016

Vim's loclists don't support multiline messages.

@nomeata
Copy link
Author

nomeata commented Feb 17, 2016

I don’t use the loclists, just the message in the status bar, the indicator in the left column, and the tooltip, and with my changes above, this works nicely:

tooltip

Also, the error list (:Errors) looks okish with multi-line messages (it simply replaces them by spaces as before).

nomeata added a commit to nomeata/syntastic that referenced this issue Feb 17, 2016
but trim unnecessary line white space above (empty lines) and left
(commont indentation). This fixes vim-syntastic#1700.
@lcd047
Copy link
Collaborator

lcd047 commented Feb 17, 2016

Sadly, there are good reasons for removing newlines from error messages, and syntastic implicitly assumes that. Vim replaces newlines on input with ASCII NULs, and various functions are not prepared to deal with that. Your suggestion would break a number of tiny details, such as calculating lengths when expanding tabs, sorting, and filtering in various scenarios.

To make it work, formatted copies of the error messages would need to be kept along with the "linearised" ones. Making those survive through all layers of syntastic would be possible, but not trivial. I don't see any reasonable way around that.

@nomeata
Copy link
Author

nomeata commented Feb 17, 2016

How unfortunate :-(

I’ll keep using my patch for a while and if I notice any breakage, and if not, I might be able to at least use the patch locally.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants