jamestthompson3 / nvim-remote-containers

Develop inside docker containers, just like VSCode
Other
876 stars 26 forks source link

[Feature request] Allow to be able to choose custom Docker path. #19

Open CleoMenezesJr opened 2 years ago

CleoMenezesJr commented 2 years ago

For those who work with sandbox apps, it is common to create symlinks for other Docker paths, or even use the Podman instead of the Docker. It would be nice to be able to have an option for this. Nowadays, I modify this manually, but in each update it will end up breaking.

function M.attachToContainer()
    local containers = {}
~   local foundContainers = fn.systemlist("~/.local/bin/docker container ls -a --format '{{.Names}} {{.Image}}'")
    if fn.len(foundContainers) == 0 then
        buildFromImage()
        return
    end
    for i, container in pairs(foundContainers) do
        print(string.format("%d. %s", i, container))
        local name = vim.split(container, "%s")
        table.insert(containers, { image = name[2], name = name[1] })
    end
    local selected = tonumber(fn.input("Select container number: "))
    if not selected then
        return
    end
    local containerName = containers[selected]
~   local containerIsRunning = fn.system("~/.local/bin/docker container ps --format '{{.Names}}'"):find(containerName.name)
    if not containerIsRunning then
~       local containerIsCreated = fn.system("~/.local/bin/docker container ps -a --format '{{.Names}}'"):find(containerName.name)
        if not containerIsCreated then
            runContainer(containerName)
        else
            startContainer(containerName)
        end
    end
end
jamestthompson3 commented 2 years ago

Great idea! This would be an excellent feature for a first contribution to the codebase :)

CleoMenezesJr commented 2 years ago

Unfortunately, I don't have enough knowledge to contribute plugins to Neovim. Certainly this here would not be an issue, but a PR. lmao