地方エンジニアの学習日記

興味ある技術の雑なメモだったりを書いてくブログ。たまに日記とガジェット紹介。

【vim】いい感じの設定が入ったvimコンテナ

fzfやらemmetやらそれなりに使ってるプラグインをセットにしてどんな環境でも使えそうなのdockerコンテナ。

自前のdotfilesも同梱しようか悩み中。試行錯誤しつつやっていこうと思う。docker hubにはprivateで上げていてそこには一応dotfilseも入れてしまっている。

FROM alpine:latest as builder

WORKDIR /mnt/build/ctags

RUN apk --no-cache add \
    git \
    xfce4-dev-tools \
    build-base

RUN git clone https://github.com/universal-ctags/ctags \
    && cd ctags \
    && ./autogen.sh \
    && ./configure --prefix=/usr/local \
    && make \
    && make install

FROM alpine:latest

ENV WORKSPACE="/mnt/workspace"
ENV  NVIM_CONFIG="/home/neovim/.config/nvim"
ENV  NVIM_PCK="/home/neovim/.local/share/nvim/site/pack"
ENV  ENV_DIR="/home/neovim/.local/share/vendorvenv"
ENV  NVIM_PROVIDER_PYLIB="python3_neovim_provider"
ENV PATH="/home/neovim/.local/bin:${PATH}"

COPY --from=builder /usr/local/bin/ctags /usr/local/bin

RUN apk --no-cache add \
        curl \
        shadow \
        sudo \
            su-exec \
        python3 \
        py3-virtualenv \
            neovim \
            neovim-doc \
        fzf \
        bash \
    && apk --no-cache add --virtual build-dependencies \
        python3-dev \
        gcc \
        musl-dev \
        git \
    && addgroup "${GNAME}" \
    && adduser -D -G "${GNAME}" -g "" -s "${SHELL}" "${UNAME}" \
        && echo "${UNAME} ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers \
    && sudo -u neovim python3 -m venv "${ENV_DIR}/${NVIM_PROVIDER_PYLIB}" \
    && "${ENV_DIR}/${NVIM_PROVIDER_PYLIB}/bin/pip" install pynvim \
    && curl https://raw.githubusercontent.com/mitsuhiko/pipsi/master/get-pipsi.py | sudo -u neovim python3 \
    && sudo -u neovim pipsi install python-language-server \
    && mkdir -p "${NVIM_PCK}/common/start" "${NVIM_PCK}/filetype/start" "${NVIM_PCK}/colors/opt" \
    && git -C "${NVIM_PCK}/common/start" clone --depth 1 https://github.com/tpope/vim-commentary \
    && git -C "${NVIM_PCK}/common/start" clone --depth 1 https://github.com/junegunn/fzf.vim \
    && git -C "${NVIM_PCK}/common/start" clone --depth 1 https://github.com/tpope/vim-surround \
    && git -C "${NVIM_PCK}/common/start" clone --depth 1 https://github.com/tpope/vim-obsession \
    && git -C "${NVIM_PCK}/common/start" clone --depth 1 https://github.com/yuttie/comfortable-motion.vim \
    && git -C "${NVIM_PCK}/common/start" clone --depth 1 https://github.com/wellle/targets.vim \
    && git -C "${NVIM_PCK}/common/start" clone --depth 1 https://github.com/SirVer/ultisnips \
    && git -C "${NVIM_PCK}/filetype/start" clone --depth 1 https://github.com/mattn/emmet-vim \
    && git -C "${NVIM_PCK}/filetype/start" clone --depth 1 https://github.com/lervag/vimtex \
    && git -C "${NVIM_PCK}/filetype/start" clone --depth 1 https://github.com/captbaritone/better-indent-support-for-php-with-html \
    && git -C "${NVIM_PCK}/colors/opt" clone --depth 1 https://github.com/fxn/vim-monochrome \
    && git -C "${NVIM_PCK}/common/start" clone --depth 1 https://github.com/autozimu/LanguageClient-neovim \
    && cd "${NVIM_PCK}/common/start/LanguageClient-neovim/" && sh install.sh \
    && chown -R neovim:neovim /home/neovim/.local \
    && apk del build-dependencies

COPY entrypoint.sh /usr/local/bin/
ENTRYPOINT ["sh", "/usr/local/bin/entrypoint.sh"]