summaryrefslogtreecommitdiff
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/nvim/lua/plugins/lsp.lua17
1 files changed, 17 insertions, 0 deletions
diff --git a/config/nvim/lua/plugins/lsp.lua b/config/nvim/lua/plugins/lsp.lua
index 1470177..e87324c 100644
--- a/config/nvim/lua/plugins/lsp.lua
+++ b/config/nvim/lua/plugins/lsp.lua
@@ -87,7 +87,24 @@ local function configure_lsp() -- Setup LSP configurations using vim.lsp.config
})
-- Configure pyright (Python language server)
+ -- One client per project, so each service in a monorepo gets its own
+ -- interpreter: pyright resolves one pythonPath per server instance. The
+ -- nearest pyproject.toml wins over the usual markers, and the client uses
+ -- the nearest .venv at or above that root, so a uv workspace's shared venv
+ -- still applies to members that have none of their own.
vim.lsp.config('pyright', {
+ root_dir = function(bufnr, on_dir)
+ on_dir(vim.fs.root(bufnr, { 'pyproject.toml' })
+ or vim.fs.root(bufnr, { 'setup.py', 'setup.cfg', 'requirements.txt', 'Pipfile', 'pyrightconfig.json', '.git' }))
+ end,
+ -- config is the client's own copy, and client.settings is this table
+ before_init = function(_, config)
+ local venv = config.root_dir and vim.fs.root(config.root_dir, '.venv')
+ local py = venv and venv .. '/.venv/bin/python'
+ if py and vim.uv.fs_stat(py) then
+ config.settings.python.pythonPath = py
+ end
+ end,
settings = {
python = {
analysis = {