File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ from pyls import hookimpl , lsp
2
+
3
+ @hookimpl
4
+ def pyls_lint (config , document ):
5
+ errors = document .jedi_script ().get_syntax_errors ()
6
+ diagnostics = []
7
+
8
+ for error in errors :
9
+ err_range = {
10
+ 'start' : {
11
+ 'line' : error .line - 1 ,
12
+ # Index columns start from 0
13
+ 'character' : error .column ,
14
+ },
15
+ 'end' : {
16
+ 'line' : error .until_line - 1 ,
17
+ # It's possible that we're linting an empty file. Even an empty
18
+ # file might fail linting if it isn't named properly.
19
+ 'character' : error .until_column ,
20
+ },
21
+ }
22
+ diagnostics .append ({
23
+ 'source' : 'jedi' ,
24
+ 'range' : err_range ,
25
+ 'message' : error .get_message (),
26
+ 'severity' : lsp .DiagnosticSeverity .Error ,
27
+ })
28
+ return diagnostics
Original file line number Diff line number Diff line change 97
97
'jedi_rename = pyls.plugins.jedi_rename' ,
98
98
'jedi_signature_help = pyls.plugins.signature' ,
99
99
'jedi_symbols = pyls.plugins.symbols' ,
100
+ 'jedi_lint = pyls.plugins.jedi_lint' ,
100
101
'mccabe = pyls.plugins.mccabe_lint' ,
101
102
'preload = pyls.plugins.preload_imports' ,
102
103
'pycodestyle = pyls.plugins.pycodestyle_lint' ,
You can’t perform that action at this time.
0 commit comments