Skip to content

Commit

Permalink
Add configuration for basedpyright (#106)
Browse files Browse the repository at this point in the history
* feat: Add variables to customize inlay hints with basedpyright

* doc: Update documentation for basedpyright configuration
  • Loading branch information
ROCKTAKEY authored Nov 1, 2024
1 parent 327edce commit cefab98
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
32 changes: 32 additions & 0 deletions lsp-pyright.el
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit cefab98

Please sign in to comment.