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

@ -48,7 +48,10 @@ ENV MASON_PKGS=" \
sqlls \
typescript-language-server \
yaml-language-server \
markdownlint"
markdownlint\
ansiblels"
ENV PIP_PKGS = "pynvim ansible ansible-lint"
COPY . /root/.config/nvim
# install system dependencies
@ -56,7 +59,7 @@ RUN dnf install -y \
${GENERAL_PKGS} ${NEOVIM_PKGS} ${PYTHON_DEVEL_PKGS} ${PERL_DEVEL_PKGS} \
&& dnf clean all && \
cpanm PLS && \
pip install pynvim
pip install ${PIP_PKGS}
RUN rm /root/.config/nvim/lazy-lock.json || true
# install lsp and linters using mason

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:

View file

@ -196,5 +196,9 @@ return {
on_attach = on_attach,
capabilities = capabilities,
}
require 'lspconfig'.ansiblels.setup {
on_attach = on_attach,
capabilities = capabilities,
}
end
}