python: Replace pyright with basedpyright (#35362)
Follow-up to #35250. Let's experiment with having this by default on nightly. Release Notes: - Added built-in support for the basedpyright language server for Python code. basedpyright is now enabled by default, and pyright (previously the primary Python language server) remains available but is disabled by default. This supersedes the basedpyright extension, which can be uninstalled. Advantages of basedpyright over pyright include support for inlay hints, semantic highlighting, auto-import code actions, and stricter type checking. To switch back to pyright, add the following configuration to settings.json: ```json { "languages": { "Python": { "language_servers": ["pyright", "pylsp", "!basedpyright"] } } } ``` --------- Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com> Co-authored-by: Lukas Wirth <lukas@zed.dev>
This commit is contained in:
co-authored by
Piotr Osiewicz
Lukas Wirth
parent
99102a84fa
commit
fa0df6da1c
@@ -35,7 +35,7 @@ use std::{
|
||||
sync::Arc,
|
||||
};
|
||||
use task::{ShellKind, TaskTemplate, TaskTemplates, VariableName};
|
||||
use util::ResultExt;
|
||||
use util::{ResultExt, maybe};
|
||||
|
||||
pub(crate) struct PyprojectTomlManifestProvider;
|
||||
|
||||
@@ -1619,23 +1619,37 @@ impl LspAdapter for BasedPyrightLspAdapter {
|
||||
}
|
||||
}
|
||||
|
||||
// Always set the python interpreter path
|
||||
// Get or create the python section
|
||||
let python = object
|
||||
// Set both pythonPath and defaultInterpreterPath for compatibility
|
||||
if let Some(python) = object
|
||||
.entry("python")
|
||||
.or_insert(Value::Object(serde_json::Map::default()))
|
||||
.as_object_mut()
|
||||
.unwrap();
|
||||
|
||||
// Set both pythonPath and defaultInterpreterPath for compatibility
|
||||
python.insert(
|
||||
"pythonPath".to_owned(),
|
||||
Value::String(interpreter_path.clone()),
|
||||
);
|
||||
python.insert(
|
||||
"defaultInterpreterPath".to_owned(),
|
||||
Value::String(interpreter_path),
|
||||
);
|
||||
{
|
||||
python.insert(
|
||||
"pythonPath".to_owned(),
|
||||
Value::String(interpreter_path.clone()),
|
||||
);
|
||||
python.insert(
|
||||
"defaultInterpreterPath".to_owned(),
|
||||
Value::String(interpreter_path),
|
||||
);
|
||||
}
|
||||
// Basedpyright by default uses `strict` type checking, we tone it down as to not surpris users
|
||||
maybe!({
|
||||
let basedpyright = object
|
||||
.entry("basedpyright")
|
||||
.or_insert(Value::Object(serde_json::Map::default()));
|
||||
let analysis = basedpyright
|
||||
.as_object_mut()?
|
||||
.entry("analysis")
|
||||
.or_insert(Value::Object(serde_json::Map::default()));
|
||||
if let serde_json::map::Entry::Vacant(v) =
|
||||
analysis.as_object_mut()?.entry("typeCheckingMode")
|
||||
{
|
||||
v.insert(Value::String("standard".to_owned()));
|
||||
}
|
||||
Some(())
|
||||
});
|
||||
}
|
||||
|
||||
user_settings
|
||||
|
||||
Reference in New Issue
Block a user