Skip to content

Commit e8e0a46

Browse files
committed
Preferences implementation progess. Some preferences connected to LSP
1 parent 57e1725 commit e8e0a46

File tree

4 files changed

+241
-121
lines changed

4 files changed

+241
-121
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
.DS_Store
2+
.nova

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Version 0.0.2
2+
- Preferences Update
3+
- Comma separated string parser added
4+
15
## Version 0.0.1
26

37
Pre Release

Scripts/main.js

+98-37
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,31 @@ exports.deactivate = function() {
1414
}
1515
}
1616

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+
}
1736

1837
class ExampleLanguageServer {
1938
constructor() {
2039
// 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'));
2342
}, this);
2443
}
2544

@@ -33,58 +52,100 @@ class ExampleLanguageServer {
3352
nova.subscriptions.remove(this.languageClient);
3453
}
3554

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-
4355
// Create the client
4456
var serverOptions = {
4557
path: path,
46-
args: ['-vv', '--log-file', '/tmp/pyls.log']
58+
args: ['-vv', '--log-file', getPreference('pyls.logPath', '/tmp/pyls.log')]
4759
};
4860
var clientOptions = {
4961
// The set of document syntaxes for which the server is valid
5062
syntaxes: ['python'],
5163
};
52-
var client = new LanguageClient('JediLS', 'Jedi Language Server', serverOptions, clientOptions);
53-
54-
64+
var client = new LanguageClient('PyLS', 'Python Language Server', serverOptions, clientOptions);
5565

5666
try {
5767
// Start the client
5868
client.start();
5969

6070
client.sendNotification("workspace/didChangeConfiguration", {
61-
// settings: {
62-
// "initializationOptions": {
63-
// "markupKindPreferred": null,
64-
// "jediSettings": {
65-
// "autoImportModules": []
66-
// },
67-
// "completion": {
68-
// "disableSnippets": false
69-
// }
70-
// }
71-
// }
7271
settings: {
7372
"pyls": {
74-
"plugins": {
75-
"pycodestyle": {
76-
"enabled": true,
77-
"ignore": [
78-
"E501"
79-
]
80-
}
81-
},
73+
"env": {},
8274
"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+
}
88149
});
89150
// console.log(nova.extension.path);
90151
// Add the client to the subscriptions to be cleaned up

0 commit comments

Comments
 (0)