<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi William,<div class=""><br class=""></div><div class="">I see couple things you could do.</div><div class=""><br class=""></div><div class="">1. Get the remote workflow support in LSP</div><div class="">Seems like the proper solution but might take significant time and effort. It might be worth trying to resume the discussion about LSP proposal anyway.</div><div class=""><br class=""></div><div class="">2. Solve the “remote" dependency paths issue</div><div class="">I assume you should be able to somehow expose any file from within a docker container or a remote machine. I remember that back in the day I’d use something like nfs or sshfs to expose /usr/include from the remote machine and tweak code search paths in IDE. I am not familiar enough with Docker to give you any specific solution but I wouldn’t assume there’s none. I also assume you don’t want to use the "same location on host and remote/container” approach for things like /usr/include you’d still need to translate paths though.</div><div class=""><br class=""></div><div class="">3. Path translation</div><div class="">I’m personally not opposed to your suggestion of adding path mapping to clangd. Let’s wait for others to respond. Maybe you could use some trivial script to wrap clangd and translate paths in JSON requests/responses as a temporary workaround? </div><div class=""><br class=""></div><div class="">Hope this helps.</div><div class=""><br class=""></div><div class="">Jan</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jan 8, 2019, at 8:58 PM, William Wagner via clangd-dev <<a href="mailto:clangd-dev@lists.llvm.org" class="">clangd-dev@lists.llvm.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class=""><span style="font-size:0.8125rem" class="">Hello,</span><br class=""></div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">I’ve been using clangd for developing a C++ project at work. Our development setup requires that we build and run our code inside a docker container. From a language server perspective this presents a few challenges:</div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><ol style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><li style="list-style-type:decimal" class=""><div style="font-size:0.8125rem" class="">Communicating with the language server running in the container</div></li><li style="list-style-type:decimal" class=""><div style="font-size:0.8125rem" class="">Synchronizing the files between the host and the container</div></li><li style="list-style-type:decimal" class=""><div style="font-size:0.8125rem" class="">Translating file paths between the host lsp client  and docker lsp server</div></li><li style="list-style-type:decimal" class=""><div style="font-size:0.8125rem" class="">Having dependency files that are only in the container available to view on the host (for textDocument/definition on dependencies installed only in the container)</div></li></ol><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">Fortunately, docker’s facilities make 1) and 2) pretty easy to deal with. </div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">1) can be solved by creating a bash script that contains something similar to:</div><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class=""> `docker exec -i <build_container> /path/to/clangd ${@:1}`</div><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">and pointing clangd.path to this script</div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">2) can be solved by using a docker bind mount, which maps the directory of the project you’re working on into the container</div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">3) can be solved by mounting the host:/path/to/project to an identical path in the container. Then there doesn't have to be any translation between the requests/responses between the file uris that the client and server send back and forth. However, this may not always be possible and still leaves the problem of external dependency paths.</div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">4) has no easy solution yet afaik. A potentially simple one would be to copy just the dependency headers from the container over to some directory on the host, and be able to translate clangd response file uris to the appropriate path on the host. The way I envision that is an extra arg to the clangd server that supports path substitution, such as:</div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">`clangd -path-mappings=’/host/home/project/deps:/container/deps;/host/home/project/:container/project`</div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">So if I “Go To Definition” on an external symbol e.g. Foo, which is defined in /container/deps/foo.hh”, and I have the foo.hh header in /host/home/project/.deps/foo.hh, then the response from the servers textDocument/definition would substitute the /container/deps/foo.hh → /host/home/project/.deps/foo.hh and all would be well. </div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">I believe sourcegraph has implemented an extension to the LSP to handle missing files on the client/server, but I cannot find the proposed spec. Also these are some github discussions that touch on the topics above:</div><ul style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><li style="list-style-type:disc" class=""><div style="font-size:0.8125rem" class="">Ccls supports a path Mappings config option that allows substitution, see <a href="https://github.com/MaskRay/ccls/issues/75" target="_blank" class=""><span style="font-size:0.8125rem" class="">https://github.com/MaskRay/ccls/issues/75</span></a></div></li><li style="list-style-type:disc" class=""><div style="font-size:0.8125rem" class="">Discussion on remote langauge server proposal <span style="font-size:0.8125rem" class=""><a href="https://github.com/Microsoft/language-server-protocol/issues/528" target="_blank" class="">https://github.com/Microsoft/language-server-protocol/issues/528</a></span></div></li></ul><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">I’d be happy to implement this path mapping functionality, but thought it’d be prudent to see what everyone else thinks before doing so.</div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><div style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px;font-size:0.8125rem" dir="auto" class="">Thanks!</div><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class=""><br style="color:rgb(49,49,49);font-family:Arial,"BB.Proportional";white-space:pre-wrap;word-spacing:1px" class="">
_______________________________________________<br class="">clangd-dev mailing list<br class=""><a href="mailto:clangd-dev@lists.llvm.org" class="">clangd-dev@lists.llvm.org</a><br class="">http://lists.llvm.org/cgi-bin/mailman/listinfo/clangd-dev<br class=""></div></blockquote></div><br class=""></div></body></html>