-
Notifications
You must be signed in to change notification settings - Fork 30
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
[Docs] improve language server config instructions, including config examples for different editors #581
Comments
the language server specific options are documented here. not sure why some settings are under
try |
I put it under the python.venvPath = "/Users/me/miniconda3/envs/react_jax" still doesn't work.
Also, those are the pyright settings - not the |
the the way config is handled in (based)pyright is kind of a mess (#64). the code that reads the language server config is separate to the code that reads the can you see if setting # pyproject.toml
[tool.basedpyright]
venvPath = "/Users/me/miniconda3/envs/react_jax"
venv = ".venv" or // pyrightconfig.json
{
"venvPath": "/Users/me/miniconda3/envs/react_jax"
"venv": ".venv"
} note that this assumes your i also just noticed that the language server config doesn't have a sorry i'm probably just giving you more questions than answers lol |
No thats the directory to a conda environment, so it doesn't have a And it doesn't make sense to use the toml/json files as I want this setting LSP wide - so it resolves to that conda environment no matter the context of the project/folder. |
that's probably the issue then. i'm not familiar with conda but it sounds like the only way to get pyright to work with it is to activate the venv first |
Cool, but what about |
you mean the new rules exclusive to basedpyright like |
you need the [language-server.basedpyright.config]
basedpyright.analysis.typeCheckingMode = "standard"
...
basedpyright.analysis.reportPrivateUsage = false if that's still not working, if you happened to add a if that still doesn't help, i might need a self-contained repro since i'm not familiar with conda or helix. the exact steps you took to set everything up if possible also, which version of basedpyright are you using? |
The latest - I installed it yesterday from homebrew.
I think you can just spin up any environment, do: brew install basedpyright
brew install helix
pip3 install jax ruff and put this in the ~/.config/helix/languages.toml
[[language]]
name = "python"
scope = "source.python"
injection-regex = "python"
file-types = ["py","pyi","py3","pyw",".pythonstartup",".pythonrc"]
shebangs = ["python"]
roots = [".", "pyproject.toml", "pyrightconfig.json"]
comment-token = "#"
language-servers = ["basedpyright", "ruff"]
indent = { tab-width = 4, unit = " " }
auto-format = true
[language.formatter]
command = "ruff"
[language.debugger]
name = "debugpy"
transport = "stdio"
command = "python3"
args = ["-m", "debugpy.adapter"]
[[language.debugger.templates]]
name = "source"
request = "launch"
completion = [ { name = "entrypoint", completion = "filename", default = "." } ]
args = { mode = "debug", program = "{0}" }
[language-server.basedpyright]
command = "basedpyright-langserver"
args = ["--stdio"]
[language-server.basedpyright.config]
basedpyright.analysis.typeCheckingMode = "standard"
basedpyright.analysis.autoSearchPaths = true
basedpyright.analysis.useLibraryCodeForTypes = true
basedpyright.analysis.reportMissingTypeStubs = true
basedpyright.analysis.analyzeUnannotatedFunctions = true
basedpyright.analysis.strictParameterNoneValue = true
basedpyright.analysis.reportImportCycles = true
basedpyright.analysis.reportUnreachable = true
basedpyright.analysis.reportPrivateUsage = false
[language-server.ruff]
command = "ruff-lsp"
[language-server.ruff.config.settings]
args = ["--ignore", "E402", "E731"]
[language-server.ruff.config.settings.format]
preview = true
[[language]]
name = "markdown"
formatter = { command = 'prettier', args = ["--parser", "markdown"] }
auto-format = true helix's and then do, in a newly created import jax
jax.distributed.initialize() No need to run it ofc, and see if it gives you a warning. |
thanks, i'll play around with it and try to get back to you within a day or so. appreciate your patience, i know how much of a pain it is configuring stuff like this |
sorry i dunno how i missed this. the issue was that you need to specify the diagnostic severity overrides under [language-server.basedpyright.config]
basedpyright.analysis.typeCheckingMode = "standard"
basedpyright.analysis.diagnosticSeverityOverrides.autoSearchPaths = true
basedpyright.analysis.diagnosticSeverityOverrides.useLibraryCodeForTypes = true
basedpyright.analysis.diagnosticSeverityOverrides.reportMissingTypeStubs = true
basedpyright.analysis.diagnosticSeverityOverrides.analyzeUnannotatedFunctions = true
basedpyright.analysis.diagnosticSeverityOverrides.strictParameterNoneValue = true
basedpyright.analysis.diagnosticSeverityOverrides.reportImportCycles = true
basedpyright.analysis.diagnosticSeverityOverrides.reportUnreachable = true
basedpyright.analysis.diagnosticSeverityOverrides.reportPrivateImportUsage = false |
That works! How did you find that? and how can someone find it for other config settings as well 👍 |
it's mentioned in the docs for the language server settings, but it's easy to miss:
i should probably add some examples for how to configure these, including examples for different editors |
That would be amazing 🔥 Thank you for such prompt responses, especially during a weekend. I appreciate you taking out the time here to fix silly problems. Would definitely recommend PS: The inlay hints work wonderfully well. Can't believe I lived so long without them |
glad i could help, i'll keep this issue until i update the docs with helix (and other editor) specific examples |
helix
?
I am using basedpyright with helix and rye. It works fine until I add a [tool.basedpyright] section to myproject.toml to configure it, and then it reports missing imports. I have tried adding the venv and venvPath settings that were working with pyright but with or without them basedpyright is unable to resolve imports. |
can you send the full |
It was an issue with having left my pyright config in. It works after I removed the tool.pyright section. # [tool.pyright]
# exclude = [ ".venv" ]
# venvPath = "."
# venv = ".venv"
[tool.basedpyright]
venvPath = "."
venv = ".venv" |
yeah there should be an error warning you about that (#614) |
Hi, thank you for this amazing fork. Especially loving the inlay hints with python 😄
The docs mention a couple IDEs, but not
helix
- how exactly can you set it up in that editor?For reference, in
helix
'slanguages.toml
, I believe you can set the analysis options like this:However, how/why do we know that the
toml
key here happened to bebasedpyright.analysis
and not just specifying the config, liketypeCheckingMode
directly?Plus for something like
venvPath
- it's not working for me, I have to activate the conda environment before I openhelix
in my shell to get it to work. So clearly, its the wrong key.If you could document/explain what
toml
key corresponds to toggling what features, it would be really helpful forhelix
users setting it up, as they won't have to mess with the internalbasedpyright.{json | toml}
config.Thank you so much! let me know if there's some other information you'd need from me.
cc @lemontheme who figured out the config options I'm using above :)
The text was updated successfully, but these errors were encountered: