luaneovim

Device depending neovim configuration


I have a short question.

Currently, I am spending (way too much time) modding my neovim setup. I have multiple devices where I use my setup and sync those with git (second-best feature, after restoring my config every time I destroy everything) but there are some small differences in my configuration like plugins, which I don't need on my on-the-way-notebook.

Is there any way to differ in the lua configuration, on which device is currently running neovim?

Sure, multi-branching would be a way, but I'd like a more comfortable way. Thanks for helping


Solution

  • You could use hostname to determine your device and use it to create configuration with conditions.

    Lua code to get hostname :

    local function get_hostname()
        local f = io.popen ("/bin/hostname")
        local hostname = f:read("*a") or ""
        f:close()
        hostname =string.gsub(hostname, "\n$", "")
        return hostname
    end
    

    Neovim configuration :

    if get_hostname() == "foo" then
      do_something
    else
      do_otherthing
    end