@@ -14,12 +14,31 @@ exports.deactivate = function() {
14
14
}
15
15
}
16
16
17
+ function parseSpaceSeparated ( string ) {
18
+ if ( string == "" || string == null ) {
19
+ return [ ]
20
+ } else {
21
+ return string . split ( / [ \s , ] + / ) ;
22
+ }
23
+ }
24
+
25
+ function getPreference ( string , def ) {
26
+ var pref = nova . config . get ( string )
27
+
28
+ if ( pref == null ) {
29
+ console . log ( `${ string } : ${ pref } is null. Returning ${ def } ` )
30
+ return def
31
+ } else {
32
+ console . log ( `${ string } : ${ pref } ` )
33
+ return pref
34
+ }
35
+ }
17
36
18
37
class ExampleLanguageServer {
19
38
constructor ( ) {
20
39
// Observe the configuration setting for the server's location, and restart the server on change
21
- nova . config . observe ( 'pyls.executable' , function ( path ) {
22
- this . start ( path ) ;
40
+ nova . config . observe ( 'pyls.executable' , function ( ) {
41
+ this . start ( getPreference ( 'pyls.executable' , '/usr/local/bin/pyls' ) ) ;
23
42
} , this ) ;
24
43
}
25
44
@@ -33,58 +52,100 @@ class ExampleLanguageServer {
33
52
nova . subscriptions . remove ( this . languageClient ) ;
34
53
}
35
54
36
- // Use the default server path
37
- if ( ! path ) {
38
- // path = nova.extension.path + '/run.sh';
39
- path = '/usr/local/bin/pyls' ;
40
- // console.log(path);
41
- }
42
-
43
55
// Create the client
44
56
var serverOptions = {
45
57
path : path ,
46
- args : [ '-vv' , '--log-file' , ' /tmp/pyls.log']
58
+ args : [ '-vv' , '--log-file' , getPreference ( 'pyls.logPath' , ' /tmp/pyls.log') ]
47
59
} ;
48
60
var clientOptions = {
49
61
// The set of document syntaxes for which the server is valid
50
62
syntaxes : [ 'python' ] ,
51
63
} ;
52
- var client = new LanguageClient ( 'JediLS' , 'Jedi Language Server' , serverOptions , clientOptions ) ;
53
-
54
-
64
+ var client = new LanguageClient ( 'PyLS' , 'Python Language Server' , serverOptions , clientOptions ) ;
55
65
56
66
try {
57
67
// Start the client
58
68
client . start ( ) ;
59
69
60
70
client . sendNotification ( "workspace/didChangeConfiguration" , {
61
- // settings: {
62
- // "initializationOptions": {
63
- // "markupKindPreferred": null,
64
- // "jediSettings": {
65
- // "autoImportModules": []
66
- // },
67
- // "completion": {
68
- // "disableSnippets": false
69
- // }
70
- // }
71
- // }
72
71
settings : {
73
72
"pyls" : {
74
- "plugins" : {
75
- "pycodestyle" : {
76
- "enabled" : true ,
77
- "ignore" : [
78
- "E501"
79
- ]
80
- }
81
- } ,
73
+ "env" : { } ,
82
74
"configurationSources" : [
83
- "pycodestyle" ,
84
- "flake8"
85
- ]
86
- }
87
- }
75
+ getPreference ( 'pyls.configurationSources' )
76
+ ] ,
77
+ "plugins" : {
78
+ "jedi" : {
79
+ "enabled" : getPreference ( 'pyls.plugins.jedi.enabled' ) ,
80
+ "extra_paths" : [ ] ,
81
+ } ,
82
+ "jedi_completion" : {
83
+ "enabled" : getPreference ( 'pyls.plugins.jedi_completion.enabled' ) ,
84
+ "fuzzy" : true , // Enable fuzzy when requesting autocomplete
85
+ "include_params" : true
86
+ } ,
87
+ "jedi_definition" : {
88
+ "enabled" : getPreference ( 'pyls.plugins.jedi_definition.enabled' )
89
+ } ,
90
+ "jedi_hover" : {
91
+ "enabled" : getPreference ( 'pyls.plugins.jedi_hover.enabled' )
92
+ } ,
93
+ "jedi_references" : {
94
+ "enabled" : getPreference ( 'pyls.plugins.jedi_references.enabled' )
95
+ } ,
96
+ "jedi_signature_help" : {
97
+ "enabled" : getPreference ( 'pyls.plugins.jedi_signature_help.enabled' )
98
+ } ,
99
+ "jedi_symbols" : {
100
+ "enabled" : getPreference ( 'pyls.plugins.jedi_symbols.enabled' )
101
+ } ,
102
+ "preload" : {
103
+ "enabled" : getPreference ( 'pyls.plugins.preload.enabled' )
104
+ } ,
105
+ "rope_completion" : {
106
+ "enabled" : getPreference ( 'pyls.plugins.rope_completion.enabled' )
107
+ } ,
108
+ "pydocstyle" : {
109
+ "enabled" : getPreference ( 'pyls.plugins.pydocstyle.enabled' )
110
+ } ,
111
+ "pyflakes" : {
112
+ "enabled" : getPreference ( 'pyls.plugins.pyflakes.enabled' )
113
+ } ,
114
+ "pylint" : {
115
+ "enabled" : getPreference ( 'pyls.plugins.pylint.enabled' )
116
+ } ,
117
+ "yapf" : {
118
+ "enabled" : getPreference ( 'pyls.plugins.yapf.enabled' )
119
+ } ,
120
+ "mccabe" : {
121
+ "enabled" : getPreference ( 'pyls.plugins.mccabe.enabled' )
122
+ } ,
123
+ "pycodestyle" : {
124
+ "enabled" : getPreference ( 'pyls.plugins.pycodestyle.enabled' ) ,
125
+ "exclude" : [ // Exclude files or directories which match these patterns
126
+ ] ,
127
+ "ignore" : [ // Ignore errors and warnings
128
+ "E501" , // Line too long (82 > 79 characters)
129
+ "W293" ,
130
+ "W292" ,
131
+ "W291"
132
+ ] ,
133
+ // "maxLineLength": 80, // Set maximum allowed line length
134
+ } ,
135
+ "pydocstyle" : {
136
+ "enabled" : getPreference ( 'pyls.plugins.pydocstyle.enabled' )
137
+ } ,
138
+ "pylint" : {
139
+ "enabled" : getPreference ( 'pyls.plugins.pylint.enabled' )
140
+ } ,
141
+ // pyls' 3rd Party Plugins, Mypy type checking for Python 3, Must be installed via pip before enabling
142
+ "pyls_mypy" : {
143
+ "enabled" : false ,
144
+ "live_mode" : true
145
+ }
146
+ }
147
+ }
148
+ }
88
149
} ) ;
89
150
// console.log(nova.extension.path);
90
151
// Add the client to the subscriptions to be cleaned up
0 commit comments