aboutsummaryrefslogtreecommitdiffstats
path: root/lsp/basedpyright.lua
diff options
context:
space:
mode:
authorTrevor Hauter <trevor@hauter.dev>2025-10-30 20:04:48 -0400
committerGitHub <noreply@github.com>2025-10-30 17:04:48 -0700
commit8de923287e5005bcbacff8cbdebe1aa9aadc6939 (patch)
tree734a0d56be1afef7761126fb2676cfd03dde150b /lsp/basedpyright.lua
parentdocs: update configs.md (diff)
downloadnvim-lspconfig-8de923287e5005bcbacff8cbdebe1aa9aadc6939.tar
nvim-lspconfig-8de923287e5005bcbacff8cbdebe1aa9aadc6939.tar.gz
nvim-lspconfig-8de923287e5005bcbacff8cbdebe1aa9aadc6939.tar.bz2
nvim-lspconfig-8de923287e5005bcbacff8cbdebe1aa9aadc6939.tar.lz
nvim-lspconfig-8de923287e5005bcbacff8cbdebe1aa9aadc6939.tar.xz
nvim-lspconfig-8de923287e5005bcbacff8cbdebe1aa9aadc6939.tar.zst
nvim-lspconfig-8de923287e5005bcbacff8cbdebe1aa9aadc6939.zip
fix(pyright): prioritize "pyrightconfig.json" root marker #4171
**Problem**: When working in a python monorepo with a base `pyproject.toml`, and `pyrightconfig.json` files that extend this base configuration in subdirectories, `pyright` will not recognize these `pyrightconfig.json` and identify these subdirectories (project1 | project2) as root directories because `pyproject.toml` takes precedence. ```sh # Example structure monorepo ├── project1 │   ├── pyrightconfig.json │   └── src │   └── main.py ├── project2 │   ├── pyrightconfig.json │   └── src │   └── main.py └── pyproject.toml ``` From the pyright docs [1] > A “pyrightconfig.json” file always takes precedent over “pyproject.toml” if both are present **Solution**: Update the order of the `root_markers` to prefer `pyrightconfig.json` so priority is in line with pyrights documentation. **Testing**: When creating a simple monorepo structure with the following command ```sh mkdir monorepo && touch monorepo/pyproject.toml && mkdir monorepo/project1 && touch monorepo/project1/pyrightconfig.json && mkdir monorepo/project1/src && touch monorepo/project1/src/main.py && cp -r monorepo/project1 monorepo/project2 ``` You should be able to open one of the subdirectories `nvim monorepo/project1/src/main.py` and check your LSP root dir with `:LspInfo`, and it should be attached to the subdirectory. 1. https://github.com/microsoft/pyright/blob/main/docs/configuration.md#pyright-configuration
Diffstat (limited to 'lsp/basedpyright.lua')
-rw-r--r--lsp/basedpyright.lua2
1 files changed, 1 insertions, 1 deletions
diff --git a/lsp/basedpyright.lua b/lsp/basedpyright.lua
index 5f54c3d2..0dcaaa3b 100644
--- a/lsp/basedpyright.lua
+++ b/lsp/basedpyright.lua
@@ -25,12 +25,12 @@ return {
cmd = { 'basedpyright-langserver', '--stdio' },
filetypes = { 'python' },
root_markers = {
+ 'pyrightconfig.json',
'pyproject.toml',
'setup.py',
'setup.cfg',
'requirements.txt',
'Pipfile',
- 'pyrightconfig.json',
'.git',
},
settings = {