From 5543af4bbc557d84a9c2c6e5d09891a3d1cd1ebe Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Sun, 2 Jan 2022 22:06:47 -0800 Subject: [PATCH] Get Docker install permissions working and TS --- Dockerfile | 23 +++++++----- docker-entry.sh | 12 +++++-- neovim/lua/plugins.lua | 2 +- neovim/lua/plugins/treesitter.lua | 58 +++++++++++++++++++------------ nvim-container.sh | 5 ++- vim-sync-append.sh | 1 + 6 files changed, 64 insertions(+), 37 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5c13b92..cd27184 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,7 +26,7 @@ RUN apk add gcc g++ python3-dev RUN pip3 install pynvim # Create user -RUN adduser -D -h /home/vividboarder -s /bin/bash vividboarder +RUN adduser -D -h /home/vividboarder -s /bin/bash --ingroup users vividboarder USER vividboarder WORKDIR /home/vividboarder @@ -34,10 +34,6 @@ ENV HOME /home/vividboarder ENV XDG_CONFIG_HOME $HOME/.config RUN mkdir -p $XDG_CONFIG_HOME -# Create persistent data dir -RUN mkdir -p /home/vividboarder/.data -VOLUME /home/vividboarder/.data - # Configure go path ENV GOPATH $HOME/go RUN mkdir -p $GOPATH/bin @@ -50,18 +46,27 @@ ENV PATH $PATH:$NPM_PACKAGES/bin ENV PATH $HOME/.local/bin:$PATH # Install Language servers -COPY --chown=vividboarder:vividboarder ./install-language-servers.sh ./ +COPY --chown=vividboarder:users ./install-language-servers.sh ./ RUN ./install-language-servers.sh # Install golangci-lint RUN curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $GOPATH/bin v1.43.0 # Add config -COPY --chown=vividboarder:vividboarder ./neovim $HOME/.config/nvim +COPY --chown=vividboarder:users ./neovim $HOME/.config/nvim # Sync packer plugins RUN nvim --headless -c "autocmd User PackerComplete quitall" -c "PackerBootstrap" -# This may not actually do anyting. Haven't figured out how to get compiled ts files into the image -RUN nvim --headless -c "TSUpdateSync" -c "quitall" +# Bootstrap treesitter parsers +RUN nvim --headless -c "lua require('plugins.treesitter').bootstrap()" -c quitall + +# Create persistent data dir +RUN mkdir -p /home/vividboarder/.data +# VOLUME /home/vividboarder/.data + +# Make home dir read/write for everyone +# RUN chown -R ":users" /home/vividboarder +# RUN chmod -R a+rw /home/vividboarder +# RUN chmod -R a-s /home/vividboarder # Generate workdir RUN mkdir /home/vividboarder/data diff --git a/docker-entry.sh b/docker-entry.sh index ab3baf0..c5aad72 100755 --- a/docker-entry.sh +++ b/docker-entry.sh @@ -17,9 +17,15 @@ VOLUME_DATA=/home/vividboarder/.data [ -d "$VOLUME_DATA/nvim/backup" ] || mkdir -p "$VOLUME_DATA/nvim/backup" [ -d "$XDG_CONFIG_HOME/nvim/backup" ] || ln -s "$VOLUME_DATA/nvim/backup" "$XDG_CONFIG_HOME/nvim/backup" -TS_PARSERS="share/nvim/site/pack/packer/start/nvim-treesitter/parser" -[ -d "$VOLUME_DATA/ts-parsers" ] || mkdir -p "$VOLUME_DATA/ts-parsers" -rm -fr "$HOME/.local/$TS_PARSERS" || ln -s "$VOLUME_DATA/ts-parsers" "$HOME/.local/$TS_PARSERS" +# TS_PARSERS="$HOME/.local/share/nvim/site/pack/packer/start/nvim-treesitter/parser" +# [ -d "$VOLUME_DATA/ts-parsers" ] || mkdir -p "$VOLUME_DATA/ts-parsers" +# rm -fr "$TS_PARSERS" +# ln -s "$VOLUME_DATA/ts-parsers" "$TS_PARSERS" +# +# TS_PARSERS="$HOME/.local/share/nvim/site/parser" +# [ -d "$VOLUME_DATA/ts-parsers" ] || mkdir -p "$VOLUME_DATA/ts-parsers" +# rm -fr "$TS_PARSERS" +# ln -s "$VOLUME_DATA/ts-parsers" "$TS_PARSERS" if [ "$1" == "bash" ]; then exec "$@" diff --git a/neovim/lua/plugins.lua b/neovim/lua/plugins.lua index cbb442c..b8b920c 100644 --- a/neovim/lua/plugins.lua +++ b/neovim/lua/plugins.lua @@ -234,7 +234,7 @@ return require("packer").startup({ "nvim-treesitter/nvim-treesitter", run = ":TSUpdate", config = function() - require("utils").require_with_local("plugins.treesitter") + require("plugins.treesitter").setup() end, }) use({ diff --git a/neovim/lua/plugins/treesitter.lua b/neovim/lua/plugins/treesitter.lua index 203e384..03632da 100644 --- a/neovim/lua/plugins/treesitter.lua +++ b/neovim/lua/plugins/treesitter.lua @@ -1,24 +1,36 @@ -- Configures nvim-treesitter -require("nvim-treesitter.configs").setup({ - incremental_selection = { enable = true }, - -- Indent appears to be broken right now - indent = { enable = false }, - textobjects = { enable = true }, - highlight = { - enable = true, - disable = {}, - }, - ensure_installed = { - "bash", - "css", - "fish", - "go", - "gomod", - "javascript", - "json", - "lua", - "python", - "rust", - "yaml", - }, -}) +local M = {} + +local ensure_installed = { + "bash", + "css", + "fish", + "go", + "gomod", + "javascript", + "json", + "lua", + "python", + "rust", + "yaml", +} + +function M.bootstrap() + require("nvim-treesitter.install").ensure_installed_sync(ensure_installed) +end + +function M.setup() + require("nvim-treesitter.configs").setup({ + incremental_selection = { enable = true }, + -- Indent appears to be broken right now + indent = { enable = false }, + textobjects = { enable = true }, + highlight = { + enable = true, + disable = {}, + }, + ensure_installed = ensure_installed, + }) +end + +return M diff --git a/nvim-container.sh b/nvim-container.sh index 44b9a33..4fd9645 100755 --- a/nvim-container.sh +++ b/nvim-container.sh @@ -1,5 +1,7 @@ #! /bin/bash +set -ex + if ! docker image ls -q nvim > /dev/null ;then echo "no nvim image found" exit 1 @@ -18,6 +20,7 @@ docker run --interactive --rm --tty \ --volume "$(pwd):/home/vividboarder/data" \ --workdir /home/vividboarder/data \ --entrypoint /docker-entry.sh \ - --user "$(id -u):$(id -g)" \ + --user "vividboarder:$(id -g)" \ + --group-add users \ nvim "$@" # vividboarder/my-neovim nvim "$@" diff --git a/vim-sync-append.sh b/vim-sync-append.sh index d98faaa..b435847 100755 --- a/vim-sync-append.sh +++ b/vim-sync-append.sh @@ -27,6 +27,7 @@ if hash nvim 2>/dev/null; then echo "If using Neovim, install the python modules in your environment" nvim --headless -c PlugInstall -c qall nvim --headless -c "autocmd User PackerComplete quitall" -c "PackerBootstrap" -c "PackerSync" + nvim --headless -c "lua require('plugins.treesitter').bootstrap()" -c quitall nvim --headless -c "TSUpdateSync" -c "quitall" fi if hash vim 2>/dev/null; then