mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
feat: support venv in Mypy
Specify the correct python executable path for mypy to work well.
This commit is contained in:
parent
e2f348cb37
commit
450f058da5
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user