Skip to content

Conversation

@arntanguy
Copy link

I recently got into trying out plugin development for neovim in order to improve my workflow.
To do so I use a local plugins folder that is then used by lazy.nvim instead of pulling from github. In order to be able to use these plugins in remote environments, I thus need to copy them over onto the remote, and have lazy.nvim correctly configure the path there.

Thus:

  • This PR handles the copying of a 'local plugin' folder onto the remote
    copy_dirs = {
      local_plugins = {
        base = "/home/arnaud/devel/nvim",
        dirs = "*",
        compression = {
          enabled = true,
        },
      },
  • I then configure lazy.nvim as follows to use the proper path on the remote.
local lazy_config = {
  dev = {
    -- Directory where you store your local plugin projects. If a function is used,
    -- the plugin directory (e.g. `~/projects/plugin-name`) must be returned.
    path = function(plugin)
      if vim.g.remote_neovim_host then
        return vim.fn.stdpath('config') .. '/../local_plugins/nvim/' .. plugin.name
      else
        return "~/devel/nvim/" .. plugin.name
      end
    end,
}
  • Added bonus, I've added the variable vim.g.remote_neovim_unique_host_id to store the name of the running container, which can then be displayed when running any neovim instance connected to the remote. This is helpful when using multiple containers simultaneously to keep track of them.
    For example for 'mini.nvim'
    -- You can configure sections in the statusline by overriding their
    -- default behavior. For example, here we replace the section for
    -- cursor information with codeium status instead (it appears on the furthest right of the statusline).
    ---@diagnostic disable-next-line: duplicate-set-field
    statusline.section_location = function()
      local value = ''
      local codeium = require('codeium.virtual_text').status_string()
      value = value .. codeium

      -- check if this is an nvim-remote instance
      if vim.g.remote_neovim_host then
        local remote_name = (" | Remote: %s"):format(vim.g.remote_neovim_unique_host_id) or ""
        value = value .. remote_name
      end

      return value
    end

Retrospectively it might have been better to implement a mechanism to copy any directory onto the remote, not just something specific to the local plugins.

What do you think?

arntanguy added a commit to arntanguy/kickstart.nvim that referenced this pull request Feb 3, 2025
remote-nvim:
- TMUX integration
- Copy local plugins, needs amitds1997/remote-nvim.nvim#190
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant