Skip to content

Instantly share code, notes, and snippets.

@usrbinkat
Last active October 2, 2024 01:09
Show Gist options
  • Save usrbinkat/3213e3460613745dba4fe4e9bca35abb to your computer and use it in GitHub Desktop.
Save usrbinkat/3213e3460613745dba4fe4e9bca35abb to your computer and use it in GitHub Desktop.
Docker + Neovim + LazyVim

CleanShot 2024-09-30 at 23 01 46

vscode ➜ ~ $ nvim --headless +'checkhealth' +'w!./health.log' +qa; echo; echo; cat health.log
Running healthchecks..."./health.log" "./health.log" [New] 195L, 8637B
[nvim-treesitter] [0/2] Downloading tree-sitter-typescript...
[nvim-treesitter] [0/2] Downloading tree-sitter-vim...


==============================================================================
lazy: require("lazy.health").check()

lazy.nvim ~
- {lazy.nvim} version `11.14.1`
- OK {git} `version 2.46.2`
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found

luarocks ~
- checking `luarocks` installation
- OK no plugins require `luarocks`, so you can ignore any warnings below
- OK {luarocks} `/usr/bin/luarocks 3.8.0`
- OK {lua5.1} `Lua 5.1.5  Copyright (C) 1994-2012 Lua.org, PUC-Rio`

==============================================================================
lazyvim: require("lazyvim.health").check()

LazyVim ~
- OK Using Neovim >= 0.9.0
- OK `git` is installed
- OK `rg` is installed
- OK `fdfind` is installed
- OK `lazygit` is installed

==============================================================================
nvim: require("nvim.health").check()

Configuration ~
- OK no issues found

Runtime ~
- OK $VIMRUNTIME: /usr/local/share/nvim/runtime

Performance ~
- OK Build type: Release

Remote Plugins ~
- OK Up to date

terminal ~
- key_backspace (kbs) terminfo entry: `key_backspace=\177`
- key_dc (kdch1) terminfo entry: `key_dc=\E[3~`

External Tools ~
- OK ripgrep 13.0.0 (/usr/bin/rg)

==============================================================================
nvim-treesitter: require("nvim-treesitter.health").check()

Installation ~
- OK `tree-sitter` found 0.23.1 (78c41e3cedb1906b5dd7cbe82ca41cee30f440b1) (parser generator, only needed for :TSInstallFromGrammar)
- OK `node` found v20.17.0 (only needed for :TSInstallFromGrammar)
- OK `git` executable found.
- OK `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
  Version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
- OK Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

OS Info:
{
  machine = "aarch64",
  release = "6.6.32-linuxkit",
  sysname = "Linux",
  version = "#1 SMP Thu Jun 13 14:13:01 UTC 2024"
} ~

Parser/Features         H L F I J
  - bash                ✓ ✓ ✓ .
  - c                   ✓ ✓ ✓ ✓ ✓
  - diff                ✓ ..
  - html                ✓ ✓ ✓ ✓ ✓
  - javascript          ✓ ✓ ✓ ✓ ✓
  - jsdoc               ✓ . . . .
  - json                ✓ ✓ ✓ ✓ .
  - jsonc               ✓ ✓ ✓ ✓ ✓
  - lua                 ✓ ✓ ✓ ✓ ✓
  - luadoc              ✓ . . . .
  - luap                ✓ . . . .
  - markdown            ✓ . ✓ ✓ ✓
  - markdown_inline     ✓ . . .
  - printf. . . .
  - python              ✓ ✓ ✓ ✓ ✓
  - query               ✓ ✓ ✓ ✓ ✓
  - regex               ✓ . . . .
  - toml                ✓ ✓ ✓ ✓ ✓
  - tsx                 ✓ ✓ ✓ ✓ ✓
  - vim                 ✓ ✓ ✓ .
  - vimdoc              ✓ . . .
  - xml                 ✓ ✓ ✓ ✓ ✓
  - yaml                ✓ ✓ ✓ ✓ ✓

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang} ~

==============================================================================
provider.clipboard: require("provider.clipboard.health").check()

Clipboard (optional) ~
- WARNING No clipboard tool found. Clipboard registers (`"+` and `"*`) will not work.
  - ADVICE:
    - :help |clipboard|

==============================================================================
provider.node: require("provider.node.health").check()

Node.js provider (optional) ~
- Node.js: v20.17.0

- Nvim node.js host: /usr/lib/node_modules/neovim/bin/cli.js
- OK Latest "neovim" npm/yarn/pnpm package is installed: 5.2.1


==============================================================================
provider.perl: require("provider.perl.health").check()

Perl provider (optional) ~
- perl executable: /usr/bin/perl
- WARNING Module "Neovim::Ext" is out-of-date. Installed: 0.06, latest: 5.34.0
  - ADVICE:
    - Run in shell: cpanm -n Neovim::Ext

==============================================================================
provider.python: require("provider.python.health").check()

Python 3 provider (optional) ~
- `g:python3_host_prog` is not set. Searching for python3 in the environment.
- Executable: /usr/bin/python3
- Python version: 3.10.12
- pynvim version: 0.5.0
- OK Latest pynvim is installed.

Python virtualenv ~
- OK no $VIRTUAL_ENV

==============================================================================
provider.ruby: require("provider.ruby.health").check()

Ruby provider (optional) ~
- Ruby: ruby 3.0.2p107 (2021-07-07 revision 0db68f0233) [aarch64-linux-gnu]
- Host: /usr/local/bin/neovim-ruby-host
- OK Latest "neovim" gem is installed: 0.10.0


==============================================================================
vim.lsp: require("vim.lsp.health").check()

- LSP log level : WARN
- Log path: /home/vscode/.local/state/nvim/lsp.log
- Log size: 0 KB

vim.lsp: Active Clients ~
- No active clients

vim.lsp: File Watcher ~
- file watching "(workspace/didChangeWatchedFiles)" disabled on all clients

vim.lsp: Position Encodings ~
- No active clients

==============================================================================
vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14
- OK Parser: bash                 ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/bash.so
- OK Parser: c                    ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/c.so
- OK Parser: diff                 ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/diff.so
- OK Parser: html                 ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/html.so
- OK Parser: javascript           ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/javascript.so
- OK Parser: jsdoc                ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/jsdoc.so
- OK Parser: json                 ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/json.so
- OK Parser: jsonc                ABI: 13, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/jsonc.so
- OK Parser: lua                  ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/lua.so
- OK Parser: luadoc               ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/luadoc.so
- OK Parser: luap                 ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/luap.so
- OK Parser: markdown             ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/markdown.so
- OK Parser: markdown_inline      ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/markdown_inline.so
- OK Parser: printf               ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/printf.so
- OK Parser: python               ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/python.so
- OK Parser: query                ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/query.so
- OK Parser: regex                ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/regex.so
- OK Parser: toml                 ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/toml.so
- OK Parser: tsx                  ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/tsx.so
- OK Parser: vimdoc               ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/vimdoc.so
- OK Parser: xml                  ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/xml.so
- OK Parser: yaml                 ABI: 14, path: /home/vscode/.local/share/nvim/lazy/nvim-treesitter/parser/yaml.so
- OK Parser: c                    ABI: 14, path: /usr/local/lib/nvim/parser/c.so
- OK Parser: lua                  ABI: 14, path: /usr/local/lib/nvim/parser/lua.so
- OK Parser: markdown             ABI: 14, path: /usr/local/lib/nvim/parser/markdown.so
- OK Parser: markdown_inline      ABI: 14, path: /usr/local/lib/nvim/parser/markdown_inline.so
- OK Parser: query                ABI: 14, path: /usr/local/lib/nvim/parser/query.so
- OK Parser: vim                  ABI: 14, path: /usr/local/lib/nvim/parser/vim.so
- OK Parser: vimdoc               ABI: 14, path: /usr/local/lib/nvim/parser/vimdoc.so
###############################################################################
# Use:
# - docker build --progress plain --tag docker.io/testing/devcontainer:nvim -f Dockerfile .
# - docker run --rm -d --name devcontainer --hostname devcontainer docker.io/testing/devcontainer:nvim
###############################################################################
# Base Devcontainer Image
FROM mcr.microsoft.com/devcontainers/base:ubuntu
LABEL tag="slim"
ENV DEVCONTAINER="slim"
SHELL ["/bin/bash", "-c", "-e"]
#################################################################################
# Environment Variables
# Set locale to en_US.UTF-8
ENV LANG=en_US.UTF-8
ENV LANGUAGE=en_US:en
ENV LC_ALL=en_US.UTF-8
# Disable timezone prompts
ENV TZ=UTC
# Disable package manager prompts
ENV DEBIAN_FRONTEND=noninteractive
# Add go and nix to path
ENV PATH="/home/vscode/.krew/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/local/go/bin:/nix/var/nix/profiles/default/bin"
# Set necessary nix environment variable
ENV NIX_INSTALLER_EXTRA_CONF='filter-syscalls = false'
# Set default bin directory for new packages
ENV BIN="/usr/local/bin"
# Set default binary install command
ENV INSTALL="install -m 755 -o root -g root"
# Set additional environment variables
ENV REGISTRY_AUTH_FILE='/home/vscode/.docker/config.json'
ENV XDG_CONFIG_HOME=/home/vscode/.config
# Common Dockerfile Container Build Functions
ENV apt_update="apt-get update"
ENV apt_install="TERM=linux DEBIAN_FRONTEND=noninteractive apt-get install -q --yes --no-install-recommends"
ENV apt_clean="apt-get clean && apt-get autoremove -y && apt-get purge -y --auto-remove"
ENV curl="/usr/bin/curl --silent --show-error --tlsv1.2 --location"
ENV curl_github="/usr/bin/curl --silent --show-error --tlsv1.2 --request GET --url"
ENV dir_clean="\
rm -rf \
/var/lib/{apt,cache,log} \
/usr/share/{doc,man,locale} \
/var/cache/apt \
/home/*/.cache \
/root/.cache \
/var/tmp/* \
/tmp/* \
"
#################################################################################
# Base package and user configuration
#################################################################################
# Apt Packages
ARG APT_PKGS="\
tar \
gcc \
curl \
locales \
ripgrep \
fd-find \
xclip \
perl \
ruby \
ruby-dev \
python3 \
python3-pip \
luarocks \
libmsgpack-dev \
"
# Install Base Packages and Remove Unnecessary Ones
RUN echo \
&& export TEST="echo" \
&& ${apt_update} \
&& bash -c "${apt_install} software-properties-common ca-certificates" \
&& bash -c "${apt_install} ${APT_PKGS}" \
&& ln -s $(which fdfind) /usr/local/bin/fd \
&& apt-get remove -y --purge nano \
&& curl -L https://cpanmin.us | perl - --notest App::cpanminus \
&& bash -c "${apt_clean}" \
&& ${dir_clean} \
&& ${TEST} \
&& echo
# Install lazygit
RUN echo \
&& export NAME="lazygit" \
&& export TEST="${NAME} --version" \
&& export REPOSITORY="jesseduffield/lazygit" \
&& export VERSION="$(${curl} https://api.github.com/repos/${REPOSITORY}/releases/latest | jq --raw-output .tag_name)" \
&& export ARCH=$(uname -m | awk '{ if ($1 == "x86_64") print "x86_64"; else if ($1 == "aarch64" || $1 == "arm64") print "arm64"; else print "unknown" }') \
&& export PKG="${NAME}_${VERSION#v}_Linux_${ARCH}.tar.gz" \
&& export URL="https://github.com/${REPOSITORY}/releases/download/${VERSION}/${PKG}" \
&& echo "---------------------------------------------------------"\
&& echo "INFO[${NAME}] Installed:" \
&& echo "INFO[${NAME}] Command: ${NAME}" \
&& echo "INFO[${NAME}] Package: ${PKG}" \
&& echo "INFO[${NAME}] Latest Release: ${VERSION}" \
&& echo "INFO[${NAME}] Architecture: ${ARCH}" \
&& echo "INFO[${NAME}] Source: ${URL}" \
&& echo "---------------------------------------------------------"\
&& ${curl} ${URL} | tar xzvf - --directory /tmp \
&& chmod 755 /tmp/${NAME} \
&& chown root:root /tmp/${NAME} \
&& mv /tmp/${NAME} /usr/local/bin/ \
&& ${dir_clean} \
&& ${TEST} \
&& echo
# Generate and Set Locale
RUN echo "en_US.UTF-8 UTF-8" > /etc/locale.gen \
&& locale-gen \
&& update-locale LANG=en_US.UTF-8
# Install Python Packages
RUN pip3 install --no-cache-dir pynvim
# Install Perl Neovim Extension
RUN sudo cpanm --notest Neovim::Ext
# Install Ruby Neovim Gem
RUN gem install neovim
#################################################################################
# Install Programming Language Tooling
# - nodejs
# - npm
# - yarn
RUN echo \
&& export NODE_MAJOR=20 \
&& apt-get remove -y nodejs npm libnode-dev \
&& mkdir -p /etc/apt/keyrings \
&& curl -L https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key \
| gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" \
> /etc/apt/sources.list.d/nodesource.list \
&& apt-get update \
&& apt-get install -y nodejs \
&& apt-get clean \
&& apt-get autoremove -y \
&& apt-get purge -y --auto-remove \
&& ${dir_clean} \
&& node --version \
&& npm --version \
&& npm install --global yarn \
&& yarn --version \
&& true
#################################################################################
# Build and Install Neovim from Source
#################################################################################
# Build Packages
ARG BUILD_PKGS="\
make \
wget \
build-essential \
ninja-build \
gettext \
libtool \
libtool-bin \
autoconf \
automake \
cmake \
pkg-config \
unzip \
doxygen \
"
# Optional: replace vim with nvim
# && update-alternatives --install /usr/bin/vim vim /usr/local/bin/nvim 100 \
# && update-alternatives --set vim /usr/local/bin/nvim \
# && apt-get purge -y --auto-remove $(echo "${BUILD_PKGS}" | tr -d '\n' | sed 's/ */ /g') \
RUN echo \
&& export NAME="neovim" \
&& export TEST="nvim --version" \
&& export REPOSITORY="neovim/neovim" \
&& export VERSION="$(${curl_github} https://api.github.com/repos/${REPOSITORY}/releases/latest | jq --raw-output .tag_name)" \
&& echo "---------------------------------------------------------" \
&& echo "INFO[${NAME}] Building Neovim Version: ${VERSION}" \
&& echo "---------------------------------------------------------" \
&& ${apt_update} \
&& bash -c "${apt_install} ${BUILD_PKGS}" \
&& git clone --depth 1 --branch ${VERSION} https://github.com/${REPOSITORY}.git /tmp/neovim \
&& cd /tmp/neovim \
&& make CMAKE_BUILD_TYPE=Release \
&& make install \
&& rm -rf /tmp/neovim \
&& bash -c "${apt_clean}" \
&& ${dir_clean} \
&& ${TEST} \
&& echo
USER vscode
RUN set -ex \
&& git clone https://github.com/LazyVim/starter ~/.config/nvim \
&& nvim --headless "+Lazy! sync" +qa \
&& true
# Install Node.js Neovim Package and tree-sitter-cli
RUN sudo npm install -g neovim tree-sitter-cli
#################################################################################
# Set the default command
#################################################################################
CMD ["bash"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment