more formatters, some cleaning
This commit is contained in:
parent
4653116fac
commit
97b8a1a802
4 changed files with 120 additions and 192 deletions
|
@ -44,17 +44,19 @@ ENV MASON_PKGS=" \
|
|||
markdownlint \
|
||||
ansible-language-server \
|
||||
ansible-lint \
|
||||
yamlfmt"
|
||||
yamlfmt \
|
||||
mdformat \
|
||||
shfmt"
|
||||
|
||||
ENV MASON_PKGS_NO_ARM="lemminx helm-ls lua-language-server"
|
||||
|
||||
|
||||
COPY . /root/.config/nvim
|
||||
# install system dependencies
|
||||
RUN dnf5 install -y \
|
||||
RUN dnf install -y \
|
||||
${GENERAL_PKGS} ${NEOVIM_PKGS} ${PYTHON_DEVEL_PKGS} ${BUILD_ONLY_PKGS} && \
|
||||
dnf5 -y autoremove && \
|
||||
dnf5 clean all && \
|
||||
dnf -y autoremove && \
|
||||
dnf clean all && \
|
||||
nvim --headless +"MasonInstall ${MASON_PKGS}" +qa || exit 1 ; \
|
||||
nvim --headless +"MasonInstall ${MASON_PKGS_NO_ARM}" +qa || true
|
||||
|
||||
|
|
95
README.md
95
README.md
|
@ -1,7 +1,7 @@
|
|||
# My personal **neovim as container** configuration
|
||||
|
||||
I made this public so I can easily clone without authentication,
|
||||
but since I treat this as a personal use only stuff,
|
||||
I made this public so I can easily clone without authentication,\
|
||||
but since I treat this as a personal use only stuff,\
|
||||
there can be some(read "a lot of") messy stuff.
|
||||
|
||||
Much of this might have been selectively copy pasted from plugin repos.
|
||||
|
@ -29,6 +29,7 @@ sudo dnf install -y \
|
|||
```bash
|
||||
podman pull ghcr.io/szwendacz99/neovim:latest
|
||||
```
|
||||
|
||||
#### or build
|
||||
|
||||
```bash
|
||||
|
@ -86,7 +87,7 @@ function nvim() {
|
|||
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")
|
||||
local MOUNT_FILE=(--workdir "/data$base_path" -v "$base_path:/data$base_path:rw")
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.gitconfig" ]; then
|
||||
|
@ -97,26 +98,30 @@ function nvim() {
|
|||
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$HOME/.ssh/known_hosts:/root/.ssh/known_hosts:ro")
|
||||
fi
|
||||
|
||||
if [ -S "$XDG_RUNTIME_DIR/ssh-agent.socket" ]; then
|
||||
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$XDG_RUNTIME_DIR/ssh-agent.socket:/runtime_dir/ssh-agent.socket:rw")
|
||||
if [ -d "$XDG_RUNTIME_DIR" ]; then
|
||||
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
|
||||
|
||||
# make sure there is a folder for sessions on default path
|
||||
mkdir -p ~/.local/share/nvim/sessions ~/.local/state/nvim/shada
|
||||
|
||||
echo "Files mount options: ${MOUNT_FILE[*]}"
|
||||
echo "Folder mount options: ${MOUNT_FOLDER[*]}"
|
||||
podman run --privileged -it --rm \
|
||||
--shm-size=0 \
|
||||
--init \
|
||||
--network host \
|
||||
--tz Europe/Warsaw \
|
||||
-e XDG_RUNTIME_DIR=/runtime_dir \
|
||||
-e SSH_AUTH_SOCK=/runtime_dir/ssh-agent.socket \
|
||||
-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 \
|
||||
-v ~/.local/state/nvim/shada/:/root/.local/state/nvim/shada/:rw \
|
||||
"${MOUNT_FILE[@]}" \
|
||||
"${MOUNT_FOLDER[@]}" \
|
||||
neovim:latest "$@"
|
||||
}
|
||||
```
|
||||
|
@ -128,19 +133,11 @@ then use function below.
|
|||
```bash
|
||||
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="$1"
|
||||
shift # skip first parameter as it can be name of a folder/file in
|
||||
# current dir so it could try mounting it later
|
||||
read -p "Enter container name: " container_name
|
||||
for arg in "$@"; do
|
||||
if [ -f "$arg" ] || [ -d "$arg" ]; then
|
||||
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$arg:$arg:rw")
|
||||
|
@ -152,7 +149,7 @@ 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_FILE=(--workdir "/data$base_path" -v "$base_path:/data$base_path:rw")
|
||||
fi
|
||||
|
||||
if [ -f "$HOME/.gitconfig" ]; then
|
||||
|
@ -163,18 +160,24 @@ function nvim_project() {
|
|||
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$HOME/.ssh/known_hosts:/root/.ssh/known_hosts:ro")
|
||||
fi
|
||||
|
||||
if [ -S "$XDG_RUNTIME_DIR/ssh-agent.socket" ]; then
|
||||
local MOUNT_FILE=("${MOUNT_FILE[@]}" -v "$XDG_RUNTIME_DIR/ssh-agent.socket:/runtime_dir/ssh-agent.socket:rw")
|
||||
if [ -d "$XDG_RUNTIME_DIR" ]; then
|
||||
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
|
||||
|
||||
# make sure there is a folder for sessions on default path
|
||||
mkdir -p ~/.local/share/nvim/sessions ~/.local/state/nvim/shada
|
||||
|
||||
echo "Files mount options: ${MOUNT_FILE[*]}"
|
||||
echo "Folder mount options: ${MOUNT_FOLDER[*]}"
|
||||
podman run --privileged -it \
|
||||
--shm-size=0 \
|
||||
--init \
|
||||
--network host \
|
||||
--tz Europe/Warsaw \
|
||||
-e XDG_RUNTIME_DIR=/runtime_dir \
|
||||
-e SSH_AUTH_SOCK=/runtime_dir/ssh-agent.socket \
|
||||
-e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
|
||||
|
@ -182,8 +185,8 @@ function nvim_project() {
|
|||
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \
|
||||
-v ~/.local/state/nvim/shada/:/root/.local/state/nvim/shada/:rw \
|
||||
"${MOUNT_FILE[@]}" \
|
||||
"${MOUNT_FOLDER[@]}" \
|
||||
--entrypoint bash \
|
||||
"$@" \
|
||||
--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
|
||||
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.
|
||||
Link to hacked fonts:
|
||||
Link to hacked fonts:\
|
||||
[https://www.nerdfonts.com/font-downloads](https://www.nerdfonts.com/font-downloads)
|
||||
|
||||
### General info
|
||||
|
@ -259,15 +262,15 @@ All that is saved in image, so that is why image is so heavy.
|
|||
|
||||
|keys|action|
|
||||
|----|----|
|
||||
|\<leader\>l|disable (search) highlighting|
|
||||
|\<leader\>cb|Close all buffers (:bufdo bd)|
|
||||
|\<leader>l|disable (search) highlighting|
|
||||
|\<leader>cb|Close all buffers (:bufdo bd)|
|
||||
|
||||
#### Opened files navigation
|
||||
|
||||
|keys|action|
|
||||
|----|----|
|
||||
|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 v | split vertically|
|
||||
|Ctrl w s| split horizontally|
|
||||
|
@ -287,7 +290,7 @@ All that is saved in image, so that is why image is so heavy.
|
|||
|----|----|
|
||||
|Ctrl+t | Toggle file explorer when not focused on it|
|
||||
|f | Toggle filtering when focused on explorer|
|
||||
|\<leader\> n | Move focus to explorer|
|
||||
|\<leader> n | Move focus to explorer|
|
||||
|d |Delete selected file|
|
||||
|rn |Rename file|
|
||||
|c |add file to clipboard|
|
||||
|
@ -297,10 +300,10 @@ All that is saved in image, so that is why image is so heavy.
|
|||
|
||||
|keys|action|
|
||||
|----|----|
|
||||
|\<leader\>ff |Find files|
|
||||
|\<leader\>fg| Live grep|
|
||||
|\<leader\>fb| Buffers|
|
||||
|\<leader\>fh |Help tags|
|
||||
|\<leader>ff |Find files|
|
||||
|\<leader>fg| Live grep|
|
||||
|\<leader>fb| Buffers|
|
||||
|\<leader>fh |Help tags|
|
||||
|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+u | Scroll preview up|
|
||||
|
@ -359,7 +362,6 @@ Bindings:
|
|||
|<leader>gc|git_commits|
|
||||
|<leader>gb|git_branches|
|
||||
|
||||
|
||||
GitSings provides some commands for displaying git stuff:
|
||||
|
||||
```bash
|
||||
|
@ -385,33 +387,32 @@ GitSings provides some commands for displaying git stuff:
|
|||
|
||||
|||
|
||||
|----|----|
|
||||
|\<space\>q | open list with diagnostics postions|
|
||||
|\<space\>e |open diagnostics floating window|
|
||||
|\<space>q | open list with diagnostics postions|
|
||||
|\<space>e |open diagnostics floating window|
|
||||
|\[d | next diagnostic|
|
||||
|\] | previous diagnostic|
|
||||
|\<leader\>k| open hoover box and enter it|
|
||||
|\<leader\>rn |rename element (function name, etc)|
|
||||
|\<leader\>f| format file|
|
||||
|\<leader>k| open hoover box and enter it|
|
||||
|\<leader>rn |rename element (function name, etc)|
|
||||
|\<leader>f| format file|
|
||||
|gd |go to definition|
|
||||
|gD| go to declaration|
|
||||
|\<space\>D| go to type definition|
|
||||
|\<space>D| go to type definition|
|
||||
|gi| go to implementation|
|
||||
|gr| go to references|
|
||||
|Ctrl+f |scroll down popup with docstring|
|
||||
|Ctrl+b |scroll up popup with docstring|
|
||||
|\<leader\>wa |add workspace folder|
|
||||
|\<leader\>wr |remove workspace folder|
|
||||
|\<leader\>wl | list workspace folders |
|
||||
|
||||
|\<leader>wa |add workspace folder|
|
||||
|\<leader>wr |remove workspace folder|
|
||||
|\<leader>wl | list workspace folders |
|
||||
|
||||
#### LSP diagnostics (custom and trouble.nvim)
|
||||
|
||||
|||
|
||||
|----|----|
|
||||
|\<leader\>vt| switch display of virtual text|
|
||||
|\<leader\>xx| Open diagnostics window|
|
||||
|\<leader>vt| switch display of virtual text|
|
||||
|\<leader>xx| Open diagnostics window|
|
||||
|gR | lsp references |
|
||||
|\<space\>ca | code action menu |
|
||||
|\<space>ca | code action menu |
|
||||
|
||||
#### Sessions
|
||||
|
||||
|
|
|
@ -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
|
||||
}
|
|
@ -6,6 +6,8 @@ return {
|
|||
-- Define your formatters
|
||||
formatters_by_ft = {
|
||||
yaml = { "yamlfmt" },
|
||||
markdown = { "mdformat" },
|
||||
bash = { "shfmt" },
|
||||
--lua = { "stylua" },
|
||||
--python = { "isort", "black" },
|
||||
--javascript = { "prettierd", "prettier", stop_after_first = true },
|
||||
|
@ -18,8 +20,8 @@ return {
|
|||
--format_on_save = { timeout_ms = 500 },
|
||||
-- Customize formatters
|
||||
formatters = {
|
||||
shfmt = {
|
||||
prepend_args = { "-i", "2" },
|
||||
yamlfmt = {
|
||||
prepend_args = { "-formatter", "retain_line_breaks=true,indentless_arrays=true" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue