lspcontainers / lspcontainers.nvim

Neovim plugin for lspcontainers.
Apache License 2.0
308 stars 33 forks source link

How can you expose symbols that are installed in `/opt`, `/lib` on a custom devcontainer #101

Open kamiradi opened 9 months ago

kamiradi commented 9 months ago

Hi,

Thank you for your work. I have a few queries regarding workflow. I have a devcontainer with all my project related dependencies installed. Typically, I load my project workspace into the devcontainer and carry out development.

This package enables my local development to interact with an LSP server that runs inside its own separate container. How can I make this LSP serve system-level symbols (installed in system directories like /opt, /lib) to my development container.

kesor commented 9 months ago

Just had to include my OS /usr/include into the clangd container, did a hack like this -

local function extend_list(initial, ...)
  for _, list in ipairs{...} do
    vim.list_extend(initial, list)
  end
  return initial
end

lspconfig.clangd.setup {
  flags = { allow_incremental_sync = true },
  before_init = nopid,
  -- cmd = container.command('clangd'),
  cmd = extend_list(
    vim.list_slice(container.command('clangd'), 0, 8),
    { "--volume=/usr/include:/usr/include:ro" },
    { "docker.io/lspcontainers/clangd-language-server:debian" }
  ),
  capabilities = capabilities
}

Would be nicer to have an option where the cmd accepts a list of volumes, or just general "append to the docker command" strings. I'll look into implementing that in a PR later maybe.