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

View file

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

View file

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