Created
July 14, 2022 07:54
-
-
Save sbmueller/62032706f08db397c2679c5184776ead to your computer and use it in GitHub Desktop.
Wrapper around clangd that executes the server on host or in a docker container - from https://github.com/neovim/nvim-lspconfig/wiki/Running-language-servers-in-containers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# The name of the container to run `clangd` in must be passed as the first and only argument | |
[ "$#" -ne 1 ] && echo "Container name required as first and only argument" >&2 && exit 1 | |
CLANGD_ARGS="--clang-tidy --background-index --all-scopes-completion --header-insertion=iwyu --suggest-missing-includes --completion-style=detailed" | |
PATH_MAPPINGS="host=docker,host=docker" # change me | |
# Verify that a contianer by this name actually exists, and is running | |
if [ -z "$(docker ps -q -f name=$1 -f status=running)" ]; then | |
clangd $CLANGD_ARGS | |
else | |
# Important part here is both the '-i' and the redirection of STDERR | |
docker exec -i "$(docker ps -q -f name=$1 -f status=running)" /home/dev/.local/bin/clangd $CLANGD_ARGS --path-mappings="$PATH_MAPPINGS" 2>/dev/null | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment