From 75f06d897cc8f280683faae668362c2e0f9ca954 Mon Sep 17 00:00:00 2001 From: Maciej Lebiest Date: Sun, 16 Jul 2023 14:23:44 +0200 Subject: [PATCH] add ansible lsp, update bashrc examples --- Dockerfile | 7 +++++-- README.md | 34 ++++++++++++++++++---------------- lua/plugins/nvim-lspconfig.lua | 4 ++++ 3 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3ce3e3f..223cde9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -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 diff --git a/README.md b/README.md index ae76b92..0921ed0 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/lua/plugins/nvim-lspconfig.lua b/lua/plugins/nvim-lspconfig.lua index 0f69a5c..5884ad6 100644 --- a/lua/plugins/nvim-lspconfig.lua +++ b/lua/plugins/nvim-lspconfig.lua @@ -196,5 +196,9 @@ return { on_attach = on_attach, capabilities = capabilities, } + require 'lspconfig'.ansiblels.setup { + on_attach = on_attach, + capabilities = capabilities, + } end }