Skip to content

Commit

Permalink
feat!: use executables on $PATH (ayamir#738)
Browse files Browse the repository at this point in the history
* fix: use commands in environment variables instead of absolute paths

* fixup! fix: use commands in environment variables instead of absolute paths

---------

Co-authored-by: Jint-lzxy <[email protected]>
  • Loading branch information
2 people authored and singlemancombat committed May 16, 2023
1 parent dae292c commit 63ae1b3
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 41 deletions.
21 changes: 9 additions & 12 deletions lua/core/options.lua
Original file line number Diff line number Diff line change
Expand Up @@ -106,18 +106,15 @@ local function load_options()
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"
elseif global.is_mac then
vim.g.python_host_prog = "/usr/bin/python"
vim.g.python3_host_prog = "/usr/local/bin/python3"
else
vim.g.python_host_prog = "/usr/bin/python"
vim.g.python3_host_prog = "/usr/bin/python3"
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

for name, value in pairs(global_local) do
vim.o[name] = value
Expand Down
52 changes: 26 additions & 26 deletions lua/modules/configs/tool/dap/dap-debugpy.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ local function isempty(s)
end

dap.adapters.python = {
type = "executable",
command = "/usr/bin/python",
args = { "-m", "debugpy.adapter" },
type = "executable",
command = "python",
args = { "-m", "debugpy.adapter" },
}
dap.configurations.python = {
{
Expand All @@ -17,30 +17,30 @@ dap.configurations.python = {
name = "Launch file",
-- Options below are for debugpy, see https://github.com/microsoft/debugpy/wiki/Debug-configuration-settings for supported options

program = "${file}", -- This configuration will launch the current file if used.
pythonPath = function()
if not isempty(vim.env.CONDA_PREFIX) then
return vim.env.CONDA_PREFIX .. "/bin/python"
else
return "/usr/bin/python3"
end
end,
},
program = "${file}", -- This configuration will launch the current file if used.
pythonPath = function()
if not isempty(vim.env.CONDA_PREFIX) then
return vim.env.CONDA_PREFIX .. "/bin/python"
else
return "python3"
end
end,
},
}

-- NOTE: for people using venv
-- NOTE: This setting is for people using venv
-- pythonPath = function()
-- -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
-- -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
-- -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
-- local cwd, venv = vim.fn.getcwd(), os.getenv("VIRTUAL_ENV")
-- if venv and vim.fn.executable(venv .. "/bin/python") == 1 then
-- return venv .. "/bin/python"
-- elseif vim.fn.executable(cwd .. "/venv/bin/python") == 1 then
-- return cwd .. "/venv/bin/python"
-- elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then
-- return cwd .. "/.venv/bin/python"
-- else
-- return "/usr/bin/python"
-- end
-- -- debugpy supports launching an application with a different interpreter then the one used to launch debugpy itself.
-- -- The code below looks for a `venv` or `.venv` folder in the current directly and uses the python within.
-- -- You could adapt this - to for example use the `VIRTUAL_ENV` environment variable.
-- local cwd, venv = vim.fn.getcwd(), os.getenv("VIRTUAL_ENV")
-- if venv and vim.fn.executable(venv .. "/bin/python") == 1 then
-- return venv .. "/bin/python"
-- elseif vim.fn.executable(cwd .. "/venv/bin/python") == 1 then
-- return cwd .. "/venv/bin/python"
-- elseif vim.fn.executable(cwd .. "/.venv/bin/python") == 1 then
-- return cwd .. "/.venv/bin/python"
-- else
-- return "python3"
-- end
-- end,
6 changes: 3 additions & 3 deletions lua/modules/configs/tool/dap/dap-lldb.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
local dap = require("dap")

dap.adapters.lldb = {
type = "executable",
command = "/usr/bin/lldb-vscode",
name = "lldb",
type = "executable",
command = "lldb-vscode",
name = "lldb",
}
dap.configurations.cpp = {
{
Expand Down

0 comments on commit 63ae1b3

Please sign in to comment.