add ansible lsp, update bashrc examples

This commit is contained in:
Maciej Lebiest 2023-07-16 14:23:44 +02:00
parent 1d046edf88
commit 75f06d897c
3 changed files with 27 additions and 18 deletions

View file

@ -76,30 +76,32 @@ function nvim() {
for arg in "$@"; do
if [ -f "$arg" ] || [ -d "$arg" ] ; then
local MOUNT_FILE="$MOUNT_FILE -v "$arg:$arg:rw""
echo "Mounting $arg"
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$arg:$arg:rw")
echo "Mounting $arg"
fi
done
if [ -z "$MOUNT_FILE" ]; then
# mount current workdir if no arguments with path
# mount on base_path to make sessions saving work
local base_path
base_path="$(pwd)"
local MOUNT_FOLDER="--workdir /data$base_path -v "$base_path:/data$base_path:rw""
local base_path="$(pwd)"
# use list as a trick to allow paths with spaces
local MOUNT_FOLDER=(--workdir "/data$base_path" -v "$base_path:/data$base_path:rw")
fi
# make sure there is a folder for sessions on default path
mkdir -p ~/.local/share/nvim/sessions
echo "Files mount options: ${MOUNT_FILE[*]}"
echo "Folder mount options: ${MOUNT_FOLDER[*]}"
podman run --privileged -it --rm \
-e XDG_RUNTIME_DIR=/runtime_dir \
-e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
-v "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY:rw" \
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \
$MOUNT_FILE \
$MOUNT_FOLDER \
"${MOUNT_FILE[@]}" \
"${MOUNT_FOLDER[@]}" \
neovim:latest "$@"
}
```
If there is need to make more persistent container that will also start with
@ -119,14 +121,13 @@ function nvim_project() {
echo "give project/container name as first parameter"
return 1
fi
local container_name
container_name="$1"
local container_name="$1"
shift # skip first parameter as it can be name of a folder/file in
# current dir so it could try mounting it later
for arg in "$@"; do
if [ -f "$arg" ] || [ -d "$arg" ] ; then
local MOUNT_FILE="$MOUNT_FILE -v "$arg:$arg:rw""
echo "Mounting $arg"
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$arg:$arg:rw")
echo "Mounting $arg"
fi
done
if [ -z "$MOUNT_FILE" ]; then
@ -134,23 +135,24 @@ function nvim_project() {
# mount on base_path to make sessions saving work
local base_path
base_path="$(pwd)"
local MOUNT_FOLDER="--workdir /data$base_path -v "$base_path:/data$base_path:rw""
local MOUNT_FOLDER=(--workdir "/data$base_path" -v "$base_path:/data$base_path:rw")
fi
# make sure there is a folder for sessions on default path
mkdir -p ~/.local/share/nvim/sessions
echo "Files mount options: ${MOUNT_FILE[*]}"
echo "Folder mount options: ${MOUNT_FOLDER[*]}"
podman run --privileged -it \
-e XDG_RUNTIME_DIR=/runtime_dir \
-e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
-v "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY:rw" \
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \
$MOUNT_FILE \
$MOUNT_FOLDER \
"${MOUNT_FILE[@]}" \
"${MOUNT_FOLDER[@]}" \
--entrypoint bash \
--name $container_name \
neovim:latest
}
```
This container will not be removed on exit, you can reenter later with: