aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lua/config/lsp.lua16
1 files changed, 15 insertions, 1 deletions
diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua
index 765a2ef..a3c5595 100644
--- a/lua/config/lsp.lua
+++ b/lua/config/lsp.lua
@@ -114,6 +114,15 @@ local capabilities = require('cmp_nvim_lsp').default_capabilities()
local lspconfig = require("lspconfig")
if utils.executable("pylsp") then
+ local venv_path = os.getenv('VIRTUAL_ENV')
+ local py_path = nil
+ -- decide which python executable to use for mypy
+ if venv_path ~= nil then
+ py_path = venv_path .. "/bin/python3"
+ else
+ py_path = vim.g.python3_host_prog
+ end
+
lspconfig.pylsp.setup {
on_attach = custom_attach,
settings = {
@@ -129,7 +138,12 @@ if utils.executable("pylsp") then
pyflakes = { enabled = false },
pycodestyle = { enabled = false },
-- type checker
- pylsp_mypy = { enabled = true, report_progress = true, live_mode = false },
+ pylsp_mypy = {
+ enabled = true,
+ overrides = { "--python-executable", py_path, true },
+ report_progress = true,
+ live_mode = false
+ },
-- auto-completion options
jedi_completion = { fuzzy = true },
-- import sorting