more formatters, some cleaning
All checks were successful
Build neovim image / build-neovim-amd64 (push) Successful in 9m11s
Build neovim image / build-neovim-arm64 (push) Successful in 10m54s
Build neovim image / update-images-manifest (push) Successful in 19s

This commit is contained in:
Maciej Lebiest 2024-12-17 20:37:16 +01:00
parent 4653116fac
commit 97b8a1a802
4 changed files with 120 additions and 192 deletions

View file

@ -8,8 +8,8 @@ ENV LC_ALL="C.UTF-8"
ENV NEOVIM_PKGS="\ ENV NEOVIM_PKGS="\
wget \ wget \
unzip \ unzip \
git \ git \
neovim \ neovim \
ripgrep \ ripgrep \
fd-find \ fd-find \
npm \ npm \
@ -44,17 +44,19 @@ ENV MASON_PKGS=" \
markdownlint \ markdownlint \
ansible-language-server \ ansible-language-server \
ansible-lint \ ansible-lint \
yamlfmt" yamlfmt \
mdformat \
shfmt"
ENV MASON_PKGS_NO_ARM="lemminx helm-ls lua-language-server" ENV MASON_PKGS_NO_ARM="lemminx helm-ls lua-language-server"
COPY . /root/.config/nvim COPY . /root/.config/nvim
# install system dependencies # install system dependencies
RUN dnf5 install -y \ RUN dnf install -y \
${GENERAL_PKGS} ${NEOVIM_PKGS} ${PYTHON_DEVEL_PKGS} ${BUILD_ONLY_PKGS} && \ ${GENERAL_PKGS} ${NEOVIM_PKGS} ${PYTHON_DEVEL_PKGS} ${BUILD_ONLY_PKGS} && \
dnf5 -y autoremove && \ dnf -y autoremove && \
dnf5 clean all && \ dnf clean all && \
nvim --headless +"MasonInstall ${MASON_PKGS}" +qa || exit 1 ; \ nvim --headless +"MasonInstall ${MASON_PKGS}" +qa || exit 1 ; \
nvim --headless +"MasonInstall ${MASON_PKGS_NO_ARM}" +qa || true nvim --headless +"MasonInstall ${MASON_PKGS_NO_ARM}" +qa || true

215
README.md
View file

@ -1,7 +1,7 @@
# My personal **neovim as container** configuration # My personal **neovim as container** configuration
I made this public so I can easily clone without authentication, I made this public so I can easily clone without authentication,\
but since I treat this as a personal use only stuff, but since I treat this as a personal use only stuff,\
there can be some(read "a lot of") messy stuff. there can be some(read "a lot of") messy stuff.
Much of this might have been selectively copy pasted from plugin repos. Much of this might have been selectively copy pasted from plugin repos.
@ -29,6 +29,7 @@ sudo dnf install -y \
```bash ```bash
podman pull ghcr.io/szwendacz99/neovim:latest podman pull ghcr.io/szwendacz99/neovim:latest
``` ```
#### or build #### or build
```bash ```bash
@ -50,7 +51,7 @@ import file back to local registry:
podman load -i ./neovim.tar.xz podman load -i ./neovim.tar.xz
``` ```
### Image usage examples ### Image usage examples
basic startup for editing current folder: basic startup for editing current folder:
@ -75,10 +76,10 @@ function nvim() {
# Also pass all parameters to neovim as its arguments. # Also pass all parameters to neovim as its arguments.
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
@ -86,7 +87,7 @@ function nvim() {
local base_path="$(pwd)" local base_path="$(pwd)"
# use list as a trick to allow paths with spaces # use list as a trick to allow paths with spaces
local MOUNT_FOLDER=(--workdir "/data$base_path" -v "$base_path:/data$base_path:rw") local MOUNT_FILE=(--workdir "/data$base_path" -v "$base_path:/data$base_path:rw")
fi fi
if [ -f "$HOME/.gitconfig" ]; then if [ -f "$HOME/.gitconfig" ]; then
@ -97,27 +98,31 @@ function nvim() {
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$HOME/.ssh/known_hosts:/root/.ssh/known_hosts:ro") local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$HOME/.ssh/known_hosts:/root/.ssh/known_hosts:ro")
fi fi
if [ -S "$XDG_RUNTIME_DIR/ssh-agent.socket" ]; then if [ -d "$XDG_RUNTIME_DIR" ]; then
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$XDG_RUNTIME_DIR/ssh-agent.socket:/runtime_dir/ssh-agent.socket:rw") local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$XDG_RUNTIME_DIR:/runtime_dir:rw")
else
local MOUNT_FILE=("${MOUNT_FILE[@]}" --tmpfs "/runtime_dir")
fi
if [ -S "$SSH_AUTH_SOCK" ]; then
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$SSH_AUTH_SOCK:/runtime_dir/ssh-agent.socket: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 ~/.local/state/nvim/shada mkdir -p ~/.local/share/nvim/sessions ~/.local/state/nvim/shada
echo "Files mount options: ${MOUNT_FILE[*]}" echo "Files mount options: ${MOUNT_FILE[*]}"
echo "Folder mount options: ${MOUNT_FOLDER[*]}"
podman run --privileged -it --rm \ podman run --privileged -it --rm \
--network host \ --shm-size=0 \
--tz Europe/Warsaw \ --init \
-e XDG_RUNTIME_DIR=/runtime_dir \ --network host \
-e SSH_AUTH_SOCK=/runtime_dir/ssh-agent.socket \ -e XDG_RUNTIME_DIR=/runtime_dir \
-e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \ -e SSH_AUTH_SOCK=/runtime_dir/ssh-agent.socket \
-v "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY:rw" \ -e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \ -v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \
-v ~/.local/state/nvim/shada/:/root/.local/state/nvim/shada/:rw \ -v ~/.local/state/nvim/shada/:/root/.local/state/nvim/shada/:rw \
"${MOUNT_FILE[@]}" \ "${MOUNT_FILE[@]}" \
"${MOUNT_FOLDER[@]}" \ neovim:latest "$@"
neovim:latest "$@"
} }
``` ```
@ -128,31 +133,23 @@ then use function below.
```bash ```bash
function nvim_project() { function nvim_project() {
# Mount current folder to a container that will not be removed on exit. # Mount current folder to a container that will not be removed on exit.
# Requires first argument to be a name for the container so it can be
# easily reentered later.
# If you specify some paths as latter parameters, then these paths will # If you specify some paths as latter parameters, then these paths will
# be mounted instead of current folder. # be mounted instead of current folder.
# Also mounts wayland for clipboard sync. # Also mounts wayland for clipboard sync.
if [ -z "$1" ]; then read -p "Enter container name: " container_name
echo "give project/container name as first parameter"
return 1
fi
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 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
base_path="$(pwd)" base_path="$(pwd)"
local MOUNT_FOLDER=(--workdir "/data$base_path" -v "$base_path:/data$base_path:rw") local MOUNT_FILE=(--workdir "/data$base_path" -v "$base_path:/data$base_path:rw")
fi fi
if [ -f "$HOME/.gitconfig" ]; then if [ -f "$HOME/.gitconfig" ]; then
@ -163,29 +160,35 @@ function nvim_project() {
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$HOME/.ssh/known_hosts:/root/.ssh/known_hosts:ro") local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$HOME/.ssh/known_hosts:/root/.ssh/known_hosts:ro")
fi fi
if [ -S "$XDG_RUNTIME_DIR/ssh-agent.socket" ]; then if [ -d "$XDG_RUNTIME_DIR" ]; then
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$XDG_RUNTIME_DIR/ssh-agent.socket:/runtime_dir/ssh-agent.socket:rw") local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$XDG_RUNTIME_DIR:/runtime_dir:rw")
else
local MOUNT_FILE=("${MOUNT_FILE[@]}" --tmpfs "/runtime_dir")
fi
if [ -S "$SSH_AUTH_SOCK" ]; then
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$SSH_AUTH_SOCK:/runtime_dir/ssh-agent.socket: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 ~/.local/state/nvim/shada mkdir -p ~/.local/share/nvim/sessions ~/.local/state/nvim/shada
echo "Files mount options: ${MOUNT_FILE[*]}" echo "Files mount options: ${MOUNT_FILE[*]}"
echo "Folder mount options: ${MOUNT_FOLDER[*]}"
podman run --privileged -it \ podman run --privileged -it \
--network host \ --shm-size=0 \
--tz Europe/Warsaw \ --init \
-e XDG_RUNTIME_DIR=/runtime_dir \ --network host \
-e SSH_AUTH_SOCK=/runtime_dir/ssh-agent.socket \ -e XDG_RUNTIME_DIR=/runtime_dir \
-e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \ -e SSH_AUTH_SOCK=/runtime_dir/ssh-agent.socket \
-v "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY:rw" \ -e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \ -v "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY:rw" \
-v ~/.local/state/nvim/shada/:/root/.local/state/nvim/shada/:rw \ -v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \
"${MOUNT_FILE[@]}" \ -v ~/.local/state/nvim/shada/:/root/.local/state/nvim/shada/:rw \
"${MOUNT_FOLDER[@]}" \ "${MOUNT_FILE[@]}" \
--entrypoint bash \ --entrypoint bash \
--name "nvim-$container_name" \ "$@" \
neovim:latest --name "nvim-$container_name" \
neovim:latest
} }
``` ```
@ -242,7 +245,7 @@ There is need to make sure your system can display (almost) any unicode
character. Hacked fonts may be needed for filetype icons but there is also character. Hacked fonts may be needed for filetype icons but there is also
need for a dedicated package with unicode fonts (like unifont-fonts.noarch) need for a dedicated package with unicode fonts (like unifont-fonts.noarch)
that will have every character missing from default font used in Neovim editor. that will have every character missing from default font used in Neovim editor.
Link to hacked fonts: Link to hacked fonts:\
[https://www.nerdfonts.com/font-downloads](https://www.nerdfonts.com/font-downloads) [https://www.nerdfonts.com/font-downloads](https://www.nerdfonts.com/font-downloads)
### General info ### General info
@ -259,57 +262,57 @@ All that is saved in image, so that is why image is so heavy.
|keys|action| |keys|action|
|----|----| |----|----|
|\<leader\>l|disable (search) highlighting| |\<leader>l|disable (search) highlighting|
|\<leader\>cb|Close all buffers (:bufdo bd)| |\<leader>cb|Close all buffers (:bufdo bd)|
#### Opened files navigation #### Opened files navigation
|keys|action| |keys|action|
|----|----| |----|----|
|Ctrl w w| Move to next splitted frame| |Ctrl w w| Move to next splitted frame|
|Ctrl w \<arrow\> | moving throught splitted frame| |Ctrl w \<arrow> | moving throught splitted frame|
|Ctrl w c | close split| |Ctrl w c | close split|
|Ctrl w v | split vertically| |Ctrl w v | split vertically|
|Ctrl w s| split horizontally| |Ctrl w s| split horizontally|
|Ctrl w x| swap places of two splits| |Ctrl w x| swap places of two splits|
|gt |next tab| |gt |next tab|
|gT| previous tab| |gT| previous tab|
|:tabnew |Create new tab| |:tabnew |Create new tab|
|Ctrl+g Ctrl+t |(when in file tree) open selected file in new tab| |Ctrl+g Ctrl+t |(when in file tree) open selected file in new tab|
|:bd | close buffer| |:bd | close buffer|
|:bnext | next buffer| |:bnext | next buffer|
|:b3 |switch to buffer 3| |:b3 |switch to buffer 3|
|:buffers | list buffers and their numbers | |:buffers | list buffers and their numbers |
#### File explorer #### File explorer
|keys|action| |keys|action|
|----|----| |----|----|
|Ctrl+t | Toggle file explorer when not focused on it| |Ctrl+t | Toggle file explorer when not focused on it|
|f | Toggle filtering when focused on explorer| |f | Toggle filtering when focused on explorer|
|\<leader\> n | Move focus to explorer| |\<leader> n | Move focus to explorer|
|d |Delete selected file| |d |Delete selected file|
|rn |Rename file| |rn |Rename file|
|c |add file to clipboard| |c |add file to clipboard|
|p | paste (file) from clipboard | |p | paste (file) from clipboard |
#### File searching / Telescope #### File searching / Telescope
|keys|action| |keys|action|
|----|----| |----|----|
|\<leader\>ff |Find files| |\<leader>ff |Find files|
|\<leader\>fg| Live grep| |\<leader>fg| Live grep|
|\<leader\>fb| Buffers| |\<leader>fb| Buffers|
|\<leader\>fh |Help tags| |\<leader>fh |Help tags|
|Ctrl+/|Show mappings for picker actions (insert mode)| |Ctrl+/|Show mappings for picker actions (insert mode)|
|Ctrl+q| Open search result list as a dedicated split (quickfix list) (will overwrite previous one created this way in current tab)| |Ctrl+q| Open search result list as a dedicated split (quickfix list) (will overwrite previous one created this way in current tab)|
|Ctrl+u | Scroll preview up| |Ctrl+u | Scroll preview up|
|Ctrl+d | Scroll preview down| |Ctrl+d | Scroll preview down|
|Ctrl+f|Scroll left in preview window| |Ctrl+f|Scroll left in preview window|
|Ctrl+k|Scroll right in preview window| |Ctrl+k|Scroll right in preview window|
|Ctrl+x |Open selection as a split| |Ctrl+x |Open selection as a split|
|Ctrl+v | Open selection as a vsplit| |Ctrl+v | Open selection as a vsplit|
|Ctrl+t | Open selection in new tab | |Ctrl+t | Open selection in new tab |
##### Usefull Telescope commands ##### Usefull Telescope commands
@ -359,7 +362,6 @@ Bindings:
|<leader>gc|git_commits| |<leader>gc|git_commits|
|<leader>gb|git_branches| |<leader>gb|git_branches|
GitSings provides some commands for displaying git stuff: GitSings provides some commands for displaying git stuff:
```bash ```bash
@ -385,33 +387,32 @@ GitSings provides some commands for displaying git stuff:
||| |||
|----|----| |----|----|
|\<space\>q | open list with diagnostics postions| |\<space>q | open list with diagnostics postions|
|\<space\>e |open diagnostics floating window| |\<space>e |open diagnostics floating window|
|\[d | next diagnostic| |\[d | next diagnostic|
|\] | previous diagnostic| |\] | previous diagnostic|
|\<leader\>k| open hoover box and enter it| |\<leader>k| open hoover box and enter it|
|\<leader\>rn |rename element (function name, etc)| |\<leader>rn |rename element (function name, etc)|
|\<leader\>f| format file| |\<leader>f| format file|
|gd |go to definition| |gd |go to definition|
|gD| go to declaration| |gD| go to declaration|
|\<space\>D| go to type definition| |\<space>D| go to type definition|
|gi| go to implementation| |gi| go to implementation|
|gr| go to references| |gr| go to references|
|Ctrl+f |scroll down popup with docstring| |Ctrl+f |scroll down popup with docstring|
|Ctrl+b |scroll up popup with docstring| |Ctrl+b |scroll up popup with docstring|
|\<leader\>wa |add workspace folder| |\<leader>wa |add workspace folder|
|\<leader\>wr |remove workspace folder| |\<leader>wr |remove workspace folder|
|\<leader\>wl | list workspace folders | |\<leader>wl | list workspace folders |
#### LSP diagnostics (custom and trouble.nvim) #### LSP diagnostics (custom and trouble.nvim)
||| |||
|----|----| |----|----|
|\<leader\>vt| switch display of virtual text| |\<leader>vt| switch display of virtual text|
|\<leader\>xx| Open diagnostics window| |\<leader>xx| Open diagnostics window|
|gR | lsp references | |gR | lsp references |
|\<space\>ca | code action menu | |\<space>ca | code action menu |
#### Sessions #### Sessions
@ -421,5 +422,5 @@ To save new session on specific path, just use :SaveSession, then when opening n
||| |||
|----|----| |----|----|
|:Notifications |show recent notifications| |:Notifications |show recent notifications|
|:Telescope notify | show recent notifications in telescope gui| |:Telescope notify | show recent notifications in telescope gui|

View file

@ -1,77 +0,0 @@
#!/bin/bash
function nvim() {
# Mount current folder OR folders/files given as parameters, then
# open neovim. Container will be removed on neovim exit.
# Mount wayland for clipboard sync.
# Also pass all parameters to neovim as its arguments.
for arg in "$@"; do
if [ -f "$arg" ] || [ -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
# 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""
fi
# make sure there is a folder for sessions on default path
mkdir -p ~/.local/share/nvim/sessions
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 \
neovim:latest "$@"
}
function nvim_project() {
# Mount current folder to a container that will not be removed on exit.
# Requires first argument to be a name for the container so it can be
# easily reentered later.
# If you specify some paths as latter parameters, then these paths will
# be mounted instead of current folder.
# Also mounts wayland for clipboard sync.
if [ -z "$1" ]; then
echo "give project/container name as first parameter"
return 1
fi
local container_name
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"
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""
fi
# make sure there is a folder for sessions on default path
mkdir -p ~/.local/share/nvim/sessions
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 $container_name \
neovim:latest
}

View file

@ -6,6 +6,8 @@ return {
-- Define your formatters -- Define your formatters
formatters_by_ft = { formatters_by_ft = {
yaml = { "yamlfmt" }, yaml = { "yamlfmt" },
markdown = { "mdformat" },
bash = { "shfmt" },
--lua = { "stylua" }, --lua = { "stylua" },
--python = { "isort", "black" }, --python = { "isort", "black" },
--javascript = { "prettierd", "prettier", stop_after_first = true }, --javascript = { "prettierd", "prettier", stop_after_first = true },
@ -18,8 +20,8 @@ return {
--format_on_save = { timeout_ms = 500 }, --format_on_save = { timeout_ms = 500 },
-- Customize formatters -- Customize formatters
formatters = { formatters = {
shfmt = { yamlfmt = {
prepend_args = { "-i", "2" }, prepend_args = { "-formatter", "retain_line_breaks=true,indentless_arrays=true" },
}, },
}, },
} }