container experience improvements
This commit is contained in:
parent
8e4a6745d7
commit
eca00d215f
3 changed files with 82 additions and 26 deletions
37
Dockerfile
37
Dockerfile
|
@ -1,26 +1,27 @@
|
||||||
FROM registry.fedoraproject.org/fedora:37
|
FROM registry.fedoraproject.org/fedora:37
|
||||||
|
|
||||||
COPY . /root/.config/nvim
|
ENV NEOVIM_PKGS="\
|
||||||
|
|
||||||
# install system dependencies
|
|
||||||
RUN dnf install -y \
|
|
||||||
wget \
|
wget \
|
||||||
unzip \
|
unzip \
|
||||||
git \
|
git \
|
||||||
python3-pip \
|
python3-pip \
|
||||||
neovim \
|
neovim \
|
||||||
ripgrep \
|
ripgrep \
|
||||||
fd-find \
|
fd-find \
|
||||||
npm \
|
npm \
|
||||||
tree-sitter-cli \
|
tree-sitter-cli \
|
||||||
wl-clipboard \
|
wl-clipboard \
|
||||||
clang \
|
clang"
|
||||||
&& \
|
|
||||||
dnf clean all && \
|
|
||||||
pip install pynvim
|
|
||||||
|
|
||||||
# install lsp and liners using mason
|
ENV GENERAL_PKGS="\
|
||||||
RUN nvim --headless +TSUpdateSync +"MasonInstall \
|
bash-completion \
|
||||||
|
procps"
|
||||||
|
|
||||||
|
ENV PYTHON_DEVEL_PKGS="\
|
||||||
|
python3\
|
||||||
|
conda"
|
||||||
|
|
||||||
|
ENV MASON_PKGS=" \
|
||||||
bash-language-server \
|
bash-language-server \
|
||||||
css-lsp \
|
css-lsp \
|
||||||
cssmodules-language-server \
|
cssmodules-language-server \
|
||||||
|
@ -41,7 +42,19 @@ RUN nvim --headless +TSUpdateSync +"MasonInstall \
|
||||||
sqlls \
|
sqlls \
|
||||||
typescript-language-server \
|
typescript-language-server \
|
||||||
yaml-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
|
+qa || true
|
||||||
|
|
||||||
ENTRYPOINT [ "/usr/bin/nvim" ]
|
ENTRYPOINT [ "/usr/bin/nvim" ]
|
||||||
|
|
67
README.md
67
README.md
|
@ -9,7 +9,7 @@ Those repos are obviously listed in plugin setup part.
|
||||||
|
|
||||||
# Basic usage of this config
|
# Basic usage of this config
|
||||||
|
|
||||||
<p class="callout warning">**Tested only with rootless podman, docker might require additional setup, or proper in-container user setup**</p>
|
**Tested only with rootless podman, docker might require additional setup, or proper in-container user setup**
|
||||||
|
|
||||||
### Host system Setup
|
### Host system Setup
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ podman build -t neovim ./nvim
|
||||||
pack to file with high compression:
|
pack to file with high compression:
|
||||||
|
|
||||||
```bash
|
```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:
|
import file back to local registry:
|
||||||
|
@ -52,33 +52,76 @@ podman run --privileged -it --rm \
|
||||||
-e XDG_RUNTIME_DIR=/runtime_dir \
|
-e XDG_RUNTIME_DIR=/runtime_dir \
|
||||||
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
|
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
|
||||||
-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY \
|
-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY \
|
||||||
|
- v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions \
|
||||||
--workdir /data \
|
--workdir /data \
|
||||||
-v "./:/data:rw" \
|
-v "./:/data:rw" \
|
||||||
neovim:latest
|
neovim:latest
|
||||||
```
|
```
|
||||||
|
|
||||||
function to run neovim container easily,
|
function for opening current dir or some files/folders in temporary container:
|
||||||
allowing passing parameters and mounting files:
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
function nvim() {
|
function nvim() {
|
||||||
if [ $1 ] && [ -f $1 ]; then
|
for arg in "$@"; do
|
||||||
MOUNT_FILE="-v "$1:$1"";
|
if [ "$arg" ] && [ -f "$arg" -o -d "$arg" ] ; then
|
||||||
echo "mounting file $1";
|
local MOUNT_FILE="$MOUNT_FILE -v "$arg:$arg:rw"";
|
||||||
else
|
echo "Mounting $arg"
|
||||||
MOUNT_FOLDER="--workdir /data -v ./:/data:rw"
|
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
|
fi
|
||||||
|
|
||||||
podman run --privileged -it --rm \
|
podman run --privileged -it --rm \
|
||||||
-e XDG_RUNTIME_DIR=/runtime_dir \
|
-e XDG_RUNTIME_DIR=/runtime_dir \
|
||||||
-e WAYLAND_DISPLAY=$WAYLAND_DISPLAY \
|
-e WAYLAND_DISPLAY="$WAYLAND_DISPLAY" \
|
||||||
-v $XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY \
|
-v "$XDG_RUNTIME_DIR/$WAYLAND_DISPLAY:/runtime_dir/$WAYLAND_DISPLAY:rw" \
|
||||||
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions \
|
-v ~/.local/share/nvim/sessions:/root/.local/share/nvim/sessions:rw \
|
||||||
$MOUNT_FILE \
|
$MOUNT_FILE \
|
||||||
$MOUNT_FOLDER \
|
$MOUNT_FOLDER \
|
||||||
neovim:latest "$@"
|
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
|
##### Inside vim
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
return function()
|
return function()
|
||||||
require 'nvim-treesitter.configs'.setup {
|
require 'nvim-treesitter.configs'.setup {
|
||||||
-- A list of parser names, or "all"
|
-- 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`)
|
-- Install parsers synchronously (only applied to `ensure_installed`)
|
||||||
sync_install = true,
|
sync_install = true,
|
||||||
|
|
Loading…
Reference in a new issue