diff --git a/Dockerfile b/Dockerfile index 34eecef..43f039b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,26 +1,27 @@ FROM registry.fedoraproject.org/fedora:37 -COPY . /root/.config/nvim - -# install system dependencies -RUN dnf install -y \ +ENV NEOVIM_PKGS="\ wget \ unzip \ git \ - python3-pip \ + python3-pip \ neovim \ ripgrep \ fd-find \ npm \ tree-sitter-cli \ wl-clipboard \ - clang \ - && \ - dnf clean all && \ - pip install pynvim - -# install lsp and liners using mason -RUN nvim --headless +TSUpdateSync +"MasonInstall \ + clang" + +ENV GENERAL_PKGS="\ + bash-completion \ + procps" + +ENV PYTHON_DEVEL_PKGS="\ + python3\ + conda" + +ENV MASON_PKGS=" \ bash-language-server \ css-lsp \ cssmodules-language-server \ @@ -41,7 +42,19 @@ RUN nvim --headless +TSUpdateSync +"MasonInstall \ sqlls \ typescript-language-server \ yaml-language-server \ - markdownlint" \ + markdownlint" + +COPY . /root/.config/nvim + +# install system dependencies +RUN dnf install -y \ + ${GENERAL_PKGS} ${NEOVIM_PKGS} ${PYTHON_DEVEL_PKGS} \ + && dnf clean all +RUN pip install pynvim + +# install lsp and linters using mason +RUN nvim --headless +TSUpdateSync \ + +"MasonInstall ${MASON_PKGS}" \ +qa || true ENTRYPOINT [ "/usr/bin/nvim" ] diff --git a/README.md b/README.md index d413b2e..da44cda 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Those repos are obviously listed in plugin setup part. # Basic usage of this config -
**Tested only with rootless podman, docker might require additional setup, or proper in-container user setup**
+**Tested only with rootless podman, docker might require additional setup, or proper in-container user setup** ### Host system Setup @@ -33,7 +33,7 @@ podman build -t neovim ./nvim pack to file with high compression: ```bash -podman save localhost/neovim:latest -o /dev/stdout | xz -z -9 -e -c > neovim.tar.xz +podman save localhost/neovim:latest -o /dev/stdout | xz -z -9 -e -c > neovim$(date +"%Y-%m-%dT%H-%M").tar.xz ``` import file back to local registry: @@ -52,33 +52,76 @@ 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 \ + - v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions \ --workdir /data \ -v "./:/data:rw" \ neovim:latest ``` -function to run neovim container easily, -allowing passing parameters and mounting files: +function for opening current dir or some files/folders in temporary container: ```bash function nvim() { - if [ $1 ] && [ -f $1 ]; then - MOUNT_FILE="-v "$1:$1""; - echo "mounting file $1"; - else - MOUNT_FOLDER="--workdir /data -v ./:/data:rw" + for arg in "$@"; do + if [ "$arg" ] && [ -f "$arg" -o -d "$arg" ] ; then + 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 + local MOUNT_FOLDER="--workdir /data -v "$(pwd):/data:rw"" fi + 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 \ - -v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions \ + -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 \ neovim:latest "$@" } ``` +If there is need to make more persistent container that will also start with bash so you can install project dependencies and stuff, then use function below. + +```bash +function nvim_project() { + if [ -z "$1" ]; then + echo "give project/container name as first parameter"; + return 1; + fi + for arg in "$@"; do + if [ "$arg" ] && [ -f "$arg" -o -d "$arg" ] ; then + 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 + local MOUNT_FOLDER="--workdir /data -v "$(pwd):/data:rw"" + fi + + 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 \ + --entrypoint bash \ + --name "$1" \ + neovim:latest +} +``` + +\*\*This container will not be removed on exit, you can reenter later with\*\* + +```bash +podman start -ai {project/container name} +``` + ##### Inside vim ``` diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua index 0838a58..60fd64f 100644 --- a/lua/plugins/treesitter.lua +++ b/lua/plugins/treesitter.lua @@ -1,7 +1,7 @@ return function() require 'nvim-treesitter.configs'.setup { -- A list of parser names, or "all" - ensure_installed = { "html", "dockerfile", "cpp", "css", "markdown", "c", "gitcommit", "bash", "phpdoc", "comment", "python", "http", "php", "regex", "json5", "lua", "gitattributes", "gitignore", "json", "git_rebase", "javascript", "perl", "sql", "yaml" }, + ensure_installed = { "vim", "markdown_inline", "html", "dockerfile", "cpp", "css", "markdown", "c", "gitcommit", "bash", "phpdoc", "comment", "python", "http", "php", "regex", "json5", "lua", "gitattributes", "gitignore", "json", "git_rebase", "javascript", "perl", "sql", "yaml" }, -- Install parsers synchronously (only applied to `ensure_installed`) sync_install = true,