Parameter extra_volumes for mounting additional volumes on the container#69
Parameter extra_volumes for mounting additional volumes on the container#69B3RR10 wants to merge 6 commits intolspcontainers:mainfrom
extra_volumes for mounting additional volumes on the container#69Conversation
WhyNotHugo
left a comment
There was a problem hiding this comment.
Haven't had a chance to test this, but the changes LGTM.
|
This looks good - can you possibly resolve the conflicts on this and I'll merge it? Thank you! |
* lspcontainers-main: docs: Add info for extra_volumes in README feat: add param extra_volumes for mounting multiple directories fix(gopls): networking mode depending on runtime (lspcontainers#76) fix(api): add runtime parameter to images_remove (lspcontainers#83) feat(server): Add tailwindcss language server (lspcontainers#81) Use lua to define custom commands (lspcontainers#66) fix(sysname): work with uname instead vim.fn.has (lspcontainers#71) feat(*): add prismals (lspcontainers#79) feat(selinux): add selinux labels to volumes for shared access (lspcontainers#72)
|
@erikreinert Sorry that it took so long... But the conflicts were resolved |
|
Would it be a good idea to maybe add named volumes as default values for this? I am doing this with my own setup at the moment. This enables persisting those directories between containers and even between projects even. I think this makes sense because these files are of no use mounted on the host anyways because the compilers and language servers that would use those are not installed on the host anyways when you run these tools in a container. |
|
An attribute for each LSP with the volume mappings as strings makes sense. |
|
I've been using network = true,
volumes = {
{
host = "/home/hugo/.local/state/rustup",
lsp = "/home/hugo/.local/state/rustup",
readonly = false
},
},This works well because it's easy to convert this into either docker or bubblewrap arguments. |
|
I should caution that mounting things like go's cache or rust's cache has some risks tho. In particular, a compromised LSP could pollute the shared cache, and this would be picked up by the compiler when building some other project on the host. |
Are you using bubblewrap as a runtime substitution for docker or podman? How does this work, are the CLIs compatible? Otherwise I think this is out of scope for this plugin. If you really want to use that configuration style you could just include the logic to convert from this style to a volume string in your config. For the configuration value I strongly prefer a string type instead of a table. With the table style the user would be unable to add SE Linux labels (the |
Essentially yes.
Not at all. But a lot of definitions are. Like volume mappings (+readonly), network (enabled/disabled), etc. Just looking to avoid duplicating all that TBH.
The configuration style I'm suggesting is rather backend-agnostic, and that's the whole point...
Appending this to the string is part of generating the cli, and not something that users need to provide IMHO. This is already the case now too, btw. |
|
Okay I'm sorry I was wrong then. How would a named volume setup look with the table style configuration? lua Something like this? |
|
Would allowing functions as parameters for the extra volumes make sense? I just thought of that because functions would then enable something like this: image = "docker.io/lspcontainers/gopls",
extra_volumes = {
function ()
local env = vim.api.nvim_eval('environ()')
local gopath = env.GOPATH or env.HOME.."/go"
return gopath..":"..gopath..":z"
end
}It is definitely not necessary but I think some people would like and use this. It would also be useful for setting default values in the plugin itself. |
|
@jgero Your function returns the same value each time it's run -- you could just execute that code once and pass its output to |
As proposed by @WhyNotHugo in the issue lspcontainers/dockerfiles#55, it could be useful to be able to mount additional directories to the containers.
This could be a start on solving the "customization" on the go-lsp case, and support global caches, which is very common in several languages such as rust, C# (omnisharp/nuget), ruby (solargraph/bundle), etc.