Skip to content

Commit

Permalink
fix(provider): leave provider specifications to user (ayamir#887)
Browse files Browse the repository at this point in the history
* add(settings): dont_set_python_host_prog option

* fix(provider): leave provider specifications to user

* remove unused code

---------

Co-authored-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com>
  • Loading branch information
2 people authored and singlemancombat committed Jul 26, 2023
1 parent 9801078 commit 4b9b40d
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,23 @@ local function load_options()
wrapscan = true,
writebackup = false,
}
local function isempty(s)
return s == nil or s == ""
end

-- custom python provider
local conda_prefix = os.getenv("CONDA_PREFIX")
if not isempty(conda_prefix) then
vim.g.python_host_prog = conda_prefix .. "/bin/python"
vim.g.python3_host_prog = conda_prefix .. "/bin/python"
else
vim.g.python_host_prog = "python"
vim.g.python3_host_prog = "python3"
end
local function isempty(s)
return s == nil or s == ""
end
local function use_if_defined(val, fallback)
return val ~= nil and val or fallback
end

-- custom python provider
local conda_prefix = os.getenv("CONDA_PREFIX")
if not isempty(conda_prefix) then
vim.g.python_host_prog = use_if_defined(vim.g.python_host_prog, conda_prefix .. "/bin/python")
vim.g.python3_host_prog = use_if_defined(vim.g.python3_host_prog, conda_prefix .. "/bin/python")
else
vim.g.python_host_prog = use_if_defined(vim.g.python_host_prog, "python")
vim.g.python3_host_prog = use_if_defined(vim.g.python3_host_prog, "python3")
end

for name, value in pairs(global_local) do
vim.o[name] = value
Expand Down

0 comments on commit 4b9b40d

Please sign in to comment.