-
Notifications
You must be signed in to change notification settings - Fork 37
Add some util for neovim developing, and switch default compile toolchain #47
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+109
−5
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,2 @@ | ||
| CONTAINER_USER=ubuntu | ||
| CONTAINER_HOME=/home/${CONTAINER_USER} | ||
| HOST_NVIM_DIR=${HOME}/.config/nvim |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,16 @@ | ||
| #! /bin/bash | ||
| #!/bin/bash | ||
|
|
||
| source /opt/ros/jazzy/setup.bash | ||
|
|
||
| cd ${RMCS_PATH}/rmcs_ws | ||
| cd "${RMCS_PATH}"/rmcs_ws || exit | ||
|
|
||
| colcon build --symlink-install --merge-install $@ | ||
| [[ -x /opt/cmake/bin/cmake ]] && | ||
| export PATH="/opt/cmake/bin:$PATH" | ||
|
|
||
| command -v clang &>/dev/null && | ||
| export CC=clang | ||
|
|
||
| command -v clang++ &>/dev/null && | ||
| export CXX=clang++ | ||
|
|
||
| colcon build --symlink-install --merge-install "$@" --cmake-args -G Ninja |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| readonly DEVELOPER_NAME="ubuntu" | ||
| readonly NVIM_PATH="/opt/nvim-linux-x86_64/bin/nvim" | ||
| readonly NVIM_PORT=6666 | ||
| readonly NVIM_HOST="localhost" | ||
|
|
||
| function show_help() { | ||
| local project_dir="$1" | ||
| local service="$2" | ||
| echo "Usage: $(basename "$0") [path] [zsh|n|nvim|neovide|vim|ide]" | ||
| echo " Project dir: $project_dir" | ||
| echo " Service: $service" | ||
| } | ||
|
|
||
| function rmcs_zsh() { | ||
| local service="$1" | ||
| echo "Starting and entering container..." | ||
| docker compose up -d | ||
| docker compose exec "$service" zsh | ||
| } | ||
|
|
||
| function rmcs_nvim() { | ||
| local service="$1" | ||
| local timeout=10 | ||
| local success=0 | ||
| local port=$NVIM_PORT | ||
|
|
||
| echo "Starting container..." | ||
| docker compose up -d | ||
|
|
||
| echo "Checking available port and starting nvim headless server..." | ||
| while nc -z "$NVIM_HOST" "$port" 2>/dev/null; do | ||
| echo "Port $port is occupied, trying next..." | ||
| port=$((port + 1)) | ||
| done | ||
|
|
||
| echo "Starting nvim server on port $port..." | ||
| docker compose exec -u "$DEVELOPER_NAME" -d "$service" \ | ||
| "$NVIM_PATH" --headless --listen "$NVIM_HOST:$port" | ||
|
|
||
| for i in $(seq 1 $timeout); do | ||
| if nc -z "$NVIM_HOST" "$port" 2>/dev/null; then | ||
| echo "nvim server started on port $port" | ||
| success=1 | ||
| break | ||
| fi | ||
| echo "Waiting for nvim server to start... ($i/$timeout)" | ||
| sleep 1 | ||
| done | ||
|
|
||
| if [ $success -eq 1 ]; then | ||
| echo "Starting neovide..." | ||
| nohup neovide --server="$NVIM_HOST:$port" >/dev/null 2>&1 & | ||
| else | ||
| echo "nvim server failed to start within $timeout seconds, neovide not launched" | ||
| exit 1 | ||
| fi | ||
| } | ||
|
|
||
| function main() { | ||
| local project_dir command | ||
|
|
||
| if [ -d "${1:-}" ]; then | ||
| project_dir="$(cd "$1" && pwd)" | ||
| command="${2:-}" | ||
| else | ||
| project_dir="$(pwd)" | ||
| command="${1:-}" | ||
| fi | ||
|
|
||
| cd "$project_dir" || exit 1 | ||
|
|
||
| if [ ! -f "docker-compose.yml" ]; then | ||
| echo "Error: docker-compose.yml not found in current directory" | ||
| exit 1 | ||
| fi | ||
|
|
||
| local service="rmcs-develop" | ||
|
|
||
| case "$command" in | ||
| zsh) | ||
| rmcs_zsh "$service" | ||
| ;; | ||
| n | nvim | neovide | vim | ide) | ||
| rmcs_nvim "$service" | ||
| ;; | ||
| *) | ||
| show_help "$project_dir" "$service" | ||
| ;; | ||
| esac | ||
| } | ||
|
|
||
| main "$@" | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.