Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invalid syntax - no visual indication of error #187

Closed
drozdowsky opened this issue May 29, 2019 · 7 comments
Closed

Invalid syntax - no visual indication of error #187

drozdowsky opened this issue May 29, 2019 · 7 comments

Comments

@drozdowsky
Copy link

drozdowsky commented May 29, 2019

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
Copy link
Owner

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 #165. You can 👍 that issue if you'd like it to get implemented. I haven't had time to make it a priority so far.

@drozdowsky
Copy link
Author

drozdowsky commented Jun 19, 2019

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
Copy link
Owner

natebosch commented Jun 20, 2019

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
Copy link
Author

drozdowsky commented Jun 25, 2019

{'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
Copy link
Contributor

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 #157

@natebosch
Copy link
Owner

@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:

\ && reltimefloat(reltime(l:searchStart)) <= 5.0

@pawel-slowik

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

natebosch added a commit that referenced this issue Jul 30, 2019
@natebosch
Copy link
Owner

@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

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

No branches or pull requests

3 participants