From cefab98959c1ad6af8c5c243735dcfb3de003242 Mon Sep 17 00:00:00 2001 From: ROCKTAKEY Date: Fri, 1 Nov 2024 11:54:29 +0900 Subject: [PATCH] Add configuration for basedpyright (#106) * feat: Add variables to customize inlay hints with basedpyright * doc: Update documentation for basedpyright configuration --- README.md | 4 ++++ lsp-pyright.el | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/README.md b/README.md index a32d11c..ab1e4fd 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,10 @@ lsp-mode client leveraging [pyright](https://github.com/microsoft/pyright) and [ - `basedpyright.` / `pyright.disableOrganizeImports` via `lsp-pyright-disable-organize-imports` - `basedpyright.` / `pyright.disableTaggedHints` via `lsp-pyright-disable-tagged-hints` - `basedpyright.` / `python.typeCheckingMode` via `lsp-pyright-type-checking-mode` +- `basedpyright.analysis.inlayHints.variableTypes` via `lsp-pyright-basedpyright-inlay-hints-variable-types` +- `basedpyright.analysis.inlayHints.callArgumentNames` via `lsp-pyright-basedpyright-inlay-hints-call-argument-names` +- `basedpyright.analysis.inlayHints.functionReturnTypes` via `lsp-pyright-basedpyright-inlay-hints-function-return-types` +- `basedpyright.analysis.inlayHints.genericTypes` via `lsp-pyright-basedpyright-inlay-hints-generic-types` - `python.analysis.autoImportCompletions` via `lsp-pyright-auto-import-completions` - `python.analysis.diagnosticMode` via `lsp-pyright-diagnostic-mode` - `python.analysis.logLevel` via `lsp-pyright-log-level` diff --git a/lsp-pyright.el b/lsp-pyright.el index c61390f..d6b5e3e 100644 --- a/lsp-pyright.el +++ b/lsp-pyright.el @@ -163,6 +163,34 @@ Only available in Emacs 27 and above." :type 'list :group 'lsp-pyright) +(defcustom lsp-pyright-basedpyright-inlay-hints-variable-types t + "Whether to show inlay hints on assignments to variables. + +Basedpyright only." + :type 'boolean + :group 'lsp-pyright) + +(defcustom lsp-pyright-basedpyright-inlay-hints-call-argument-names t + "Whether to show inlay hints on function arguments. + +Basedpyright only." + :type 'boolean + :group 'lsp-pyright) + +(defcustom lsp-pyright-basedpyright-inlay-hints-function-return-types t + "Whether to show inlay hints on function return types. + +Basedpyright only." + :type 'boolean + :group 'lsp-pyright) + +(defcustom lsp-pyright-basedpyright-inlay-hints-generic-types nil + "Whether to show inlay hints on inferred generic types. + +Basedpyright only." + :type 'boolean + :group 'lsp-pyright) + (defun lsp-pyright--locate-venv () "Look for virtual environments local to the workspace." (or lsp-pyright-venv-path @@ -228,6 +256,10 @@ Current LSP WORKSPACE should be passed in." (,(concat lsp-pyright-langserver-command ".disableOrganizeImports") lsp-pyright-disable-organize-imports t) (,(concat lsp-pyright-langserver-command ".disableTaggedHints") lsp-pyright-disable-tagged-hints t) (,(concat lsp-pyright-langserver-command ".typeCheckingMode") lsp-pyright-type-checking-mode) + ("basedpyright.analysis.inlayHints.variableTypes" lsp-pyright-basedpyright-inlay-hints-variable-types t) + ("basedpyright.analysis.inlayHints.callArgumentNames" lsp-pyright-basedpyright-inlay-hints-call-argument-names t) + ("basedpyright.analysis.inlayHints.functionReturnTypes" lsp-pyright-basedpyright-inlay-hints-function-return-types t) + ("basedpyright.analysis.inlayHints.genericTypes" lsp-pyright-basedpyright-inlay-hints-generic-types t) ("python.analysis.typeCheckingMode" lsp-pyright-type-checking-mode) ("python.analysis.autoImportCompletions" lsp-pyright-auto-import-completions t) ("python.analysis.diagnosticMode" lsp-pyright-diagnostic-mode)