nvim: Attach ruff client to active python environment
This commit is contained in:
parent
8a5381a4aa
commit
41934d3000
1 changed files with 17 additions and 3 deletions
|
@ -126,15 +126,29 @@ lsp.setup({
|
||||||
|
|
||||||
local lspconfig = require("lspconfig")
|
local lspconfig = require("lspconfig")
|
||||||
|
|
||||||
|
local python_path
|
||||||
-- ensure python virtualenv is determined automatically on lsp start
|
-- ensure python virtualenv is determined automatically on lsp start
|
||||||
lspconfig.pyright.setup({
|
lspconfig.pyright.setup({
|
||||||
on_attach = function(client, bufnr)
|
on_attach = function(client, bufnr)
|
||||||
on_attach(client, bufnr)
|
if python_path == nil then
|
||||||
local python_path, _ = require("util").get_python_venv(client.config.root_dir)
|
python_path, _ = require("util").get_python_venv(client.config.root_dir)
|
||||||
vim.notify_once(string.format("[PYTHON VENV]\n%s", python_path))
|
end
|
||||||
|
print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
|
||||||
client.config.settings.python.pythonPath = python_path
|
client.config.settings.python.pythonPath = python_path
|
||||||
|
on_attach(client, bufnr)
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
lspconfig.ruff_lsp.setup({
|
||||||
|
on_attach = function(client, bufnr)
|
||||||
|
if python_path == nil then
|
||||||
|
python_path, _ = require("util").get_python_venv(client.config.root_dir)
|
||||||
|
end
|
||||||
|
print(string.format("[PYTHON VENV]: %s", vim.inspect(python_path)))
|
||||||
|
client.config.settings.python.pythonPath = python_path
|
||||||
|
on_attach(client, bufnr)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
-- set up arduino with the help of arduino.nvim plugin
|
-- set up arduino with the help of arduino.nvim plugin
|
||||||
if require("util").is_available("arduino") then
|
if require("util").is_available("arduino") then
|
||||||
lspconfig.arduino_language_server.setup({
|
lspconfig.arduino_language_server.setup({
|
||||||
|
|
Loading…
Reference in a new issue