Awesome
lsp-pyright
<!-- markdown-toc start - Don't edit this section. Run M-x markdown-toc-refresh-toc -->Table of Contents
<!-- markdown-toc end -->lsp-mode client leveraging pyright and basedpyright language server.
Quickstart
(use-package lsp-pyright
:ensure t
:custom (lsp-pyright-langserver-command "pyright") ;; or basedpyright
:hook (python-mode . (lambda ()
(require 'lsp-pyright)
(lsp)))) ; or lsp-deferred
Configuration
lsp-pyright
supports the following configuration. Each configuration is described in detail in
Pyright Settings.
basedpyright.
/pyright.disableLanguageServices
vialsp-pyright-disable-language-services
basedpyright.
/pyright.disableOrganizeImports
vialsp-pyright-disable-organize-imports
basedpyright.
/pyright.disableTaggedHints
vialsp-pyright-disable-tagged-hints
basedpyright.
/python.typeCheckingMode
vialsp-pyright-type-checking-mode
basedpyright.analysis.inlayHints.variableTypes
vialsp-pyright-basedpyright-inlay-hints-variable-types
basedpyright.analysis.inlayHints.callArgumentNames
vialsp-pyright-basedpyright-inlay-hints-call-argument-names
basedpyright.analysis.inlayHints.functionReturnTypes
vialsp-pyright-basedpyright-inlay-hints-function-return-types
basedpyright.analysis.inlayHints.genericTypes
vialsp-pyright-basedpyright-inlay-hints-generic-types
python.analysis.autoImportCompletions
vialsp-pyright-auto-import-completions
python.analysis.diagnosticMode
vialsp-pyright-diagnostic-mode
python.analysis.logLevel
vialsp-pyright-log-level
python.analysis.autoSearchPaths
vialsp-pyright-auto-search-paths
python.analysis.extraPaths
vialsp-pyright-extra-paths
python.pythonPath
vialsp-pyright-locate-python
python.venvPath
vialsp-pyright-venv-path
Projects can be further configured using pyrightconfig.json
file. For further details please see
Pyright Configuration.
Choosing the correct version of Python
lsp-pyright
will try its best to select the correct version of the
python executable to use. It will do so by iteratively executing
different search functions, going from most precise to most
general.
The list and order of the list can be modified by customizing
lsp-pyright-python-search-functions
. By default the order is:
- Look for a parent directory with a virtual-environment named
.venv
orvenv
vialsp-pyright--locate-python-venv
. - Look for a python executable on your PATH via
lsp-pyright--locate-python-python
.