refactor: cleanup config
All checks were successful
Container build / container-build (push) Successful in 4m52s

This commit is contained in:
Job 2024-12-12 20:42:39 +01:00
parent 7fdb0e0fc0
commit e180de3a7b
Signed by: Job79
SSH Key Fingerprint: SHA256:BezbKv3jZaqu7SdNrZM0e42b8nlNwh63zaVj/pUxc7U
9 changed files with 83 additions and 100 deletions

View File

@ -1,3 +1,8 @@
# ========================================= #
# Containerfile v1.0; job79 #
# Configure and setup a neovim devcontainer #
# for go and nodejs development. #
# ========================================= #
FROM quay.io/fedora/fedora:41 FROM quay.io/fedora/fedora:41
# === setup system === # === setup system ===

View File

@ -1,2 +0,0 @@
#!/bin/sh
podman build . $@ -t git.plabble.org/job79/dev

View File

@ -1,24 +1,21 @@
-- Keymaps are automatically loaded on the VeryLazy event
-- Default keymaps that are always set: https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/config/keymaps.lua
-- Add any additional keymaps here
local keymap = vim.keymap.set local keymap = vim.keymap.set
local delkeymap = vim.keymap.del local delkeymap = vim.keymap.del
local opts = { noremap = true, silent = true } local opts = { noremap = true, silent = true }
-- Better line start/end -- Improved line start/end
keymap("n", "H", "^", opts) keymap("n", "H", "^", opts)
keymap("n", "L", "$", opts) keymap("n", "L", "$", opts)
keymap("v", "H", "^", opts) keymap("v", "H", "^", opts)
keymap("v", "L", "$", opts) keymap("v", "L", "$", opts)
-- Better escape -- Improved escape
keymap("n", "<ESC>", "<ESC>:noh<CR>", opts) keymap("n", "<ESC>", "<ESC>:noh<CR>", opts)
keymap("t", "<ESC><ESC>", "<C-\\><C-n>", opts) keymap("t", "<ESC><ESC>", "<C-\\><C-n>", opts)
-- Disable alt j/k to move lines -- Improved <ctrl> + movement
delkeymap({ "i", "v" }, "<A-j>")
delkeymap({ "i", "v" }, "<A-k>")
-- Better <ctrl> + movement
keymap("n", "<C-d>", "<C-d>zz", opts) keymap("n", "<C-d>", "<C-d>zz", opts)
keymap("n", "<C-u>", "<C-u>zz", opts) keymap("n", "<C-u>", "<C-u>zz", opts)
-- Disable alt j/k to move lines (conflict with default vim motions)
delkeymap({ "i", "v" }, "<A-j>")
delkeymap({ "i", "v" }, "<A-k>")

View File

@ -8,8 +8,5 @@
"lazyvim.plugins.extras.lang.typescript", "lazyvim.plugins.extras.lang.typescript",
"lazyvim.plugins.extras.test.core" "lazyvim.plugins.extras.test.core"
], ],
"news": { "version": 7
"NEWS.md": "6520"
},
"version": 6
} }

View File

@ -1,10 +0,0 @@
-- Disable autocomplete on enter.
return {
"hrsh7th/nvim-cmp",
opts = function(_, opts)
local cmp = require("cmp")
opts.mapping = vim.tbl_deep_extend("force", opts.mapping, {
["<CR>"] = cmp.config.disable,
})
end,
}

View File

@ -1,12 +1,9 @@
-- Configure rose-pine and gruvbox-material colorschemes.
return { return {
{ "rose-pine/neovim" }, { "rose-pine/neovim" },
{ "sainnhe/gruvbox-material" },
{ {
"sainnhe/gruvbox-material", -- Set default colorscheme.
opts = function()
vim.g.gruvbox_material_foreground = "original"
end,
},
{
"LazyVim/LazyVim", "LazyVim/LazyVim",
opts = { opts = {
colorscheme = "gruvbox-material", colorscheme = "gruvbox-material",

View File

@ -1,13 +1,32 @@
-- Disable some unneeded plugins by default. -- Disable unused plugins and functionality.
return { return {
{ {
-- Disable the dashboard.
"folke/snacks.nvim", "folke/snacks.nvim",
opts = function(_, opts) opts = function(_, opts)
opts.dashboard = { enabled = false } opts.dashboard = { enabled = false }
end, end,
}, },
{ {
-- Disable the bufferline.
"bufferline.nvim", "bufferline.nvim",
enabled = false, enabled = false,
}, },
{
-- Disable inline hints by default.
"neovim/nvim-lspconfig",
opts = {
inlay_hints = { enabled = false },
},
},
{
"hrsh7th/nvim-cmp",
opts = function(_, opts)
-- Disable autocomplete on enter.
local cmp = require("cmp")
opts.mapping = vim.tbl_deep_extend("force", opts.mapping, {
["<CR>"] = cmp.config.disable,
})
end,
},
} }

View File

@ -1,7 +0,0 @@
-- Disable inline hints by default.
return {
"neovim/nvim-lspconfig",
opts = {
inlay_hints = { enabled = false },
},
}

107
enter.sh
View File

@ -3,93 +3,80 @@
# enter.sh v1.0; job79 # # enter.sh v1.0; job79 #
# Enter into an existing or new dev container and # # Enter into an existing or new dev container and #
# automatically handle dev container updates. # # automatically handle dev container updates. #
# #
# TODO #
# ----------------------------------------------- #
# remove --security-opt label=disable #
# configurable mount directories #
# =============================================== # # =============================================== #
set -e set -e
# podman_run opens a shell into a newly created dev container. # run_args returns the arguments required for the podman run
podman_run() { # command.
args="--name $name" run_args() {
arg() { args="$args $@"; } arg() { echo -n " $@"; }
arg "--name $name"
# Automatically update the container when a newer # Disable some security settings to make it possible to
# image is available. # mount host directories without problems.
[ "$no_pull" = 1 ] || arg "--pull newer" arg "--security-opt label=disable" # disable labeling so mounts don't need to be labeled.
# Disable some security settings to make it possible to mount
# host directories without problems.
arg "--security-opt label=disable" # disable labeling so mounts don't need to be labbeled.
arg "--userns=keep-id" # required for ~/.ssh which is usually 700. arg "--userns=keep-id" # required for ~/.ssh which is usually 700.
arg "--net=host" # use host networking
# Use host networking.
arg "--net=host"
# Mount the wayland socket. Required to get the system # Mount the wayland socket. Required to get the system
# clipbard (wl-copy) working. # clipbard (wl-copy) working.
arg "-v /run/user/$UID/wayland-0:/run/user/1000/wayland-0" [ -e "/run/user/$UID/wayland-0" ] && arg "-v /run/user/$UID/wayland-0:/run/user/1000/wayland-0"
# Mount the ssh socket, directory and git directory. This # Mount the ssh socket, directory and the git config
# gets the host ssh and git configuration working inside # directory. This gets the host ssh and git configuration
# the container. # working inside the container.
arg "-v $SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock" [ -e "$SSH_AUTH_SOCK" ] && arg "-v $SSH_AUTH_SOCK:/run/user/1000/ssh-auth-sock"
[ -d ~/.ssh ] && arg "-v $HOME/.ssh:/home/user/.ssh" [ -d "$HOME/.ssh" ] && arg "-v $HOME/.ssh:/home/user/.ssh"
[ -d ~/.config/git ] && arg "-v $HOME/.config/git:/home/user/.config/git" [ -d "$HOME/.config/git" ] && arg "-v $HOME/.config/git:/home/user/.config/git"
# Mount host directories with programming projects. # Mount host directories with programming projects.
[ -d ~/Documents ] && arg "-v $HOME/Documents:/home/user/Documents" [ -d "$HOME/Documents" ] && arg "-v $HOME/Documents:/home/user/Documents"
[ -d ~/.local/share/devcontainer ] && arg "-v $HOME/.local/share/devcontainer:/home/user/.dev" [ -d "$HOME/.local/share/devcontainer" ] && arg "-v $HOME/.local/share/devcontainer:/home/user/.dev"
# Add volumes for .local and .cache so these survive # Add volumes for .local and .cache so these survive
# container restarts. # container restarts.
arg "-v $name-local:/home/user/.local" arg "-v $name-local:/home/user/.local"
arg "-v $name-cache:/home/user/.cache" arg "-v $name-cache:/home/user/.cache"
podman run -it $args "$image"
} }
# podman_exec opens a shell into an existing dev container.
podman_exec() { podman exec -it "$name" bash -l; }
# podman_start starts a stopped existing dev container.
podman_start() { podman start "$name" 1>/dev/null; }
# podman_delete deletes a dev container.
podman_delete() { podman container rm -f -t 1 "$name" 1>/dev/null; }
### MAIN ### ### MAIN ###
name="dev" name="dev"
image="git.plabble.org/job79/dev:latest" image="git.plabble.org/job79/dev:latest"
recreate=false
while test $# -gt 0; do while test $# -gt 0; do
case "$1" in case "$1" in
--recreate | -r) podman_delete ;; --image | -i)
--no-pull | -np) no_pull=1 ;; shift
-*) echo "unknown option '$1'" ;; image="$1"
*) name="$1" ;; ;;
--name | -n)
shift
name="$1"
;;
--recreate | -r)
recreate=true
;;
*) echo "unknown argument '$1'" ;;
esac esac
shift shift
done done
if ! podman container exists "$name"; then if
podman_run [ "$recreate" = true ] ||
exit { [ "$(podman container inspect "$name" -f {{.State.Running}})" = 'false' ] &&
fi [ "$(podman pull -q "$image")" != "$(podman container inspect "$name" -f {{.Image}})" ]; }
then
if [ "$(podman container inspect "$name" -f {{.State.Running}} 2>&1)" = 'true' ]; then podman container rm -f -t 1 "$name" 1>/dev/null
podman_exec podman run -it $(run_args) "$image"
exit
fi
if [ "$no_pull" = 1 ]; then
podman_start
podman_exec
exit
fi
iid="$(podman image inspect "$image" -f {{.Id}})"
podman pull "$image"
if [ "$(podman image inspect "$image" -f {{.Id}})" != "$iid" ]; then
# When container is stopped and a newer image is available,
# recreate the container instead of starting the existing one.
podman_delete
podman_run
else else
podman_start podman start "$name" 1>/dev/null
podman_exec podman exec -it "$name" bash -l
fi fi