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

[Draft] Notify the user when using the python-language-server backend #22

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions Scripts/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,39 @@ function getSettingsPyLSNamespace() {
}
}

// Display a notification to the user if the plugin is configured to use 'python-language-server' as a server.
function alertDeprecatedServerIfNeeded(serverBinPath) {
const ignoreConfigName = nova.extension.identifier + '.alerted-deprecated-server'
const isIgnoringAlert = nova.config.get(ignoreConfigName) === serverBinPath

if (isIgnoringAlert || nova.path.basename(serverBinPath) !== 'pyls') {
return
}

let notification = new NotificationRequest("python-nova-deprecated-server");

notification.title = nova.localize("python-language-server is deprecated");
notification.body = nova.localize('You should install python-lsp-server instead, and update your "language server executable" path accordingly in the preferences.');

notification.actions = [nova.localize("OK"), nova.localize("More info"), nova.localize("Ignore")];

let promise = nova.notifications.add(notification);
promise.then(reply => {
if (reply.actionIdx == 1) {
nova.openURL("https://github.com/mmshivesh/Python-Nova.novaextension/pull/18")
} else if (reply.actionIdx == 2) {
nova.config.set(ignoreConfigName, serverBinPath)
}
}, error => {
console.error(error);
});
}

function resetDeprecatedServerAlert() {
const ignoreConfigName = nova.extension.identifier + '.alerted-deprecated-server'
nova.config.remove(ignoreConfigName)
}

// Get and return the preferences dictionary
function getSettings() {
return {
Expand Down Expand Up @@ -322,6 +355,10 @@ class PythonLanguageServer {
}, this);
}

nova.config.onDidChange('pyls.executable', async function(newValue, oldValue) {
resetDeprecatedServerAlert()
}, this);

let workspaceKeys = [
'pyls.plugins.jedi.workspace.environment'
];
Expand Down