natebosch / vim-lsc

A vim plugin for communicating with a language server
BSD 3-Clause "New" or "Revised" License
694 stars 79 forks source link

Invalid syntax - no visual indication of error #187

Closed drozdowsky closed 5 years ago

drozdowsky commented 5 years ago

Hi, I think screenshot will explain the problem the best: 2019-05-29-111829_1914x1056_scrot

As you can see last line has invalid syntax but there is no visual indication in buffer to show me that. I can see that there is a problem only when I have cursor on the same line. I use pyls. Also it would be cool if I could choose if I want to "color the line" if there is error OR only show e.g. "E>" at the begining of the line (as many vim linters do). Is it possible to bind completion to another key? I use <C-X><C-P> to complete words using tags (it is faster).

@edit I use VIM 8 AND visual indication works most of the time, it is just an example where it does not work (probably because the character is missing where with misspelling it would prob. work)

Thank you

Best Regards, H.

natebosch commented 5 years ago

but there is no visual indication in buffer to show me that

It should be highlighted with something like lscDiagnosticError (or lscDiagnosticWarning etc based on the severity). By default these are linked to other highlight groups. Is it possible that your Error, SpellBad, SpellCap, or CursorColumn highlight is set in such a way that you don't see it?

Try setting a custom highlighting for lscDiagnosticError, lscDiagnosticWarning, lscDiagnosticInfo and see if it shows up.

highlight lscDiagnosticError ctermbg=Red

See :help lsc-configure-highlight.

You can also use :lopen to open the location list and see all the diagnostics for the current file. If something shows up there and you're sure the highlighting would be visible it could be caused by being at the end of the line, or has zero width, or something.

Also it would be cool if I could choose if I want to "color the line" if there is error OR only show e.g. "E>" at the begining of the line (as many vim linters do).

Using the sign column is a feature request at https://github.com/natebosch/vim-lsc/issues/165. You can :+1: that issue if you'd like it to get implemented. I haven't had time to make it a priority so far.

drozdowsky commented 5 years ago

Hey thanks for reply

Try setting a custom highlighting for lscDiagnosticError, lscDiagnosticWarning, lscDiagnosticInfo and see if it shows up.

It does not :( Thanks for :lopen tip. Any tips on autocompletion? On big projects it is sometimes slow and sometimes it works fine.

natebosch commented 5 years ago

Any tips on autocompletion? On big projects it is sometimes slow and sometimes it works fine.

It depends on the server, if the server is slow to reply to an autocomplete request we can't do much about it on the client.

It does not :(

Hmm, I wonder if it's due to something like putting the error after the end of the line, or having a zero width range or something. When this is happening and there are diagnostics you know you're not seeing could you try running :echo lsc#diagnostics#forFile(expand('%:p')) and paste the output here along with the content of the file?

drozdowsky commented 5 years ago
{'11': [{'group': 'lscDiagnosticWarning', 'message': 'E901 TokenError: EOF in multi-line statement [E901]', 'type': 'W', 'lsp': {'source': 'pycodestyle', 'code': 'E901', 'message': 'E901 Toke
nError: EOF in multi-line statement', 'severity': 2, 'range': {'end': {'character': 100, 'line': 10}, 'start': {'character': 0, 'line': 10}}}, 'ranges': [[11, 1, 100]]}], '10': [{'group': 'ls
cDiagnosticError', 'message': 'invalid syntax', 'type': 'E', 'lsp': {'source': 'pyflakes', 'message': 'invalid syntax', 'severity': 1, 'range': {'end': {'character': 12, 'line': 9}, 'start':
{'character': 6, 'line': 9}}}, 'ranges': [[10, 7, 6]]}], '6': [{'group': 'lscDiagnosticWarning', 'message': 'E501 line too long (92 > 91 characters) [E501]', 'type': 'W', 'lsp': {'source': 'p
ycodestyle', 'code': 'E501', 'message': 'E501 line too long (92 > 91 characters)', 'severity': 2, 'range': {'end': {'character': 93, 'line': 5}, 'start': {'character': 91, 'line': 5}}}, 'rang
es': [[6, 92, 2]]}]}

code

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "*********_******.settings.development")
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)

test(

It depends on the server, if the server is slow to reply to an autocomplete request we can't do much about it on the client.

I understand but nonetheless it is not asynchronous, I do not see an option to change timeout time. I have to dig into lsc config more I think. Thank you for reply

pawel-slowik commented 5 years ago

Hmm, I wonder if it's due to something like putting the error after the end of the line,

I'm 99% sure that this is indeed the case.

The pycodestyle message range starts beyond the end of file:

        "source": "pycodestyle",
        "code": "E901",
        "message": "E901 Token Error: EOF in multi-line statement",
        "severity": 2,
        "range": {
          "end": {
            "character": 100,
            "line": 10
          },
          "start": {
            "character": 0,
            "line": 10
          }
        }

(line numbers are zero based, therefore the last line number is 9).

The pyflakes message range starts after the opening brace in the test( line, i.e. after the end of line:

        "source": "pyflakes",
        "message": "invalid syntax",
        "severity": 1,
        "range": {
          "end": {
            "character": 12,
            "line": 9
          },
          "start": {
            "character": 6,
            "line": 9
          }
        }

That would make this issue mostly a duplicate of https://github.com/natebosch/vim-lsc/issues/157

natebosch commented 5 years ago

@drozdowsky

it is not asynchronous, I do not see an option to change timeout time.

You're correct - when used as completefunc it is not asynchronous (I have no choice there), and there is no option to change the timeout.

I can certainly add an option for the timeout - would need to replace the hardcoded number here: https://github.com/natebosch/vim-lsc/blob/c491351fcfdb58d36da739912701d7132a33110e/autoload/lsc/complete.vim#L157

@pawel-slowik

Thanks for the confirmation! Will dedup with #157 after I fix the other issue.

natebosch commented 5 years ago

@drozdowsky - I added a g:lsc_complete_timeout so you can configure it to give up sooner on manual completions that are slow. Let me know if you think this configuration would be better on a per-server basis than global.

Closing for now since the remaining issue can be tracked at #157