lsp-pyright
August 14, 2025 ยท View on GitHub
Table of Contents
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.disableLanguageServicesvialsp-pyright-disable-language-servicesbasedpyright./pyright.disableOrganizeImportsvialsp-pyright-disable-organize-importsbasedpyright./pyright.disableTaggedHintsvialsp-pyright-disable-tagged-hintsbasedpyright./python.typeCheckingModevialsp-pyright-type-checking-modebasedpyright.analysis.inlayHints.variableTypesvialsp-pyright-basedpyright-inlay-hints-variable-typesbasedpyright.analysis.inlayHints.callArgumentNamesvialsp-pyright-basedpyright-inlay-hints-call-argument-namesbasedpyright.analysis.inlayHints.functionReturnTypesvialsp-pyright-basedpyright-inlay-hints-function-return-typesbasedpyright.analysis.inlayHints.genericTypesvialsp-pyright-basedpyright-inlay-hints-generic-typespython.analysis.autoImportCompletionsvialsp-pyright-auto-import-completionspython.analysis.diagnosticModevialsp-pyright-diagnostic-modepython.analysis.logLevelvialsp-pyright-log-levelpython.analysis.autoSearchPathsvialsp-pyright-auto-search-pathspython.analysis.extraPathsvialsp-pyright-extra-pathspython.pythonPathvialsp-pyright-locate-pythonpython.venvPathvialsp-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
.venvorvenvvialsp-pyright--locate-python-venv. - Look for a python executable on your PATH via
lsp-pyright--locate-python-python.