From f48145e933dc60366d120d682ad3985fdd85d8a1 Mon Sep 17 00:00:00 2001 From: Timothy Churchard Date: Tue, 6 Aug 2024 10:42:54 +0100 Subject: [PATCH] Dockerfile/ Install wordgrinder and fix coc.nvim config --- Dockerfile | 19 +++++++++++++------ README.md | 7 ++++--- files/entrypoint.sh | 2 +- files/init.vim | 18 ++++++++++++++++-- 4 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index 50eb344..84c68b8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,12 @@ RUN apt install -y python3 python3-venv && \ ENV PATH=$PATH:/opt/venv/bin +# Install wordgrinder (https://github.com/davidgiven/wordgrinder) +RUN apt install -y ninja-build libncursesw5-dev zlib1g-dev libglfw3-dev build-essential pkg-config xxd python3 python3-pil && \ + mkdir -p /usr/local/man/man1/ && \ + git clone https://github.com/davidgiven/wordgrinder.git wordgrinder.git && \ + cd wordgrinder.git && make && make install + # Install neovim: https://github.com/neovim/neovim/wiki/Installing-Neovim ENV VIM_COMMIT=v0.10.0 RUN apt install -y luajit ruby-dev && \ @@ -62,8 +68,8 @@ RUN apt install -y ripgrep fd-find RUN apt-get autoclean -y && apt-get autoremove -y && apt-get clean -y # Install golang -ENV GOLANG_URL=https://golang.org/dl/go1.21.11.linux-amd64.tar.gz -ENV GOLANG_SHA256=54a87a9325155b98c85bc04dc50298ddd682489eb47f486f2e6cb0707554abf0 +ENV GOLANG_URL=https://golang.org/dl/go1.21.12.linux-amd64.tar.gz +ENV GOLANG_SHA256=121ab58632787e18ae0caa8ae285b581f9470d0f6b3defde9e1600e211f583c5 RUN curl -o golang.tgz -L ${GOLANG_URL} && \ echo "$GOLANG_SHA256 golang.tgz" > golang.tgz.sha256 && \ @@ -121,7 +127,7 @@ RUN curl -fLo ~/.config/nvim/autoload/plug.vim --create-dirs https://raw.githubu RUN mkdir -p ~/.config/nvim/plugged && cd ~/.config/nvim/plugged && \ git clone --depth 1 https://github.com/stevearc/aerial.nvim.git && \ git clone --depth 1 https://github.com/nvim-lua/plenary.nvim.git && \ - git clone --branch 0.1.5 --depth 1 https://github.com/nvim-telescope/telescope.nvim.git && \ + git clone --branch 0.1.8 --depth 1 https://github.com/nvim-telescope/telescope.nvim.git && \ git clone --depth 1 https://github.com/windwp/nvim-autopairs.git && \ git clone --depth 1 https://github.com/ntpeters/vim-better-whitespace.git && \ git clone --depth 1 https://github.com/neovim/nvim-lspconfig.git && \ @@ -132,7 +138,7 @@ RUN mkdir -p ~/.config/nvim/plugged && cd ~/.config/nvim/plugged && \ git clone --depth 1 https://github.com/ray-x/guihua.lua.git && \ git clone --depth 1 https://github.com/ray-x/lsp_signature.nvim.git && \ git clone --depth 1 https://github.com/ray-x/go.nvim.git && \ - git clone --depth 1 https://github.com/neoclide/coc.nvim.git && \ + git clone --branch release --depth 1 https://github.com/neoclide/coc.nvim.git && \ git clone --depth 1 https://github.com/kyazdani42/nvim-web-devicons.git && \ git clone --depth 1 https://github.com/kyazdani42/nvim-tree.lua.git && \ git clone --depth 1 https://github.com/vim-airline/vim-airline.git && \ @@ -157,11 +163,12 @@ COPY files/vimrc .config/nvim/ COPY files/init.vim .config/nvim/ COPY files/coc-settings.json .config/nvim/ -RUN zsh -c ". $NVM_DIR/nvm.sh && cd ~/.config/nvim/plugged/coc.nvim && npm ci" +RUN zsh -c ". $NVM_DIR/nvm.sh && cd ~/.config/nvim/plugged/coc.nvim && npm install && npm ci" RUN nvim +:PlugInstall +:qa \ nvim +:GoInstallBinaries +:qa \ - nvim "+:TSInstall go" +:qa + nvim "+:TSInstall go" +:qa \ + nvim "+:CocInstall coc-json coc-tsserver coc-go" +:qa # Copy in final bits for /opt COPY files/entrypoint.sh /opt/ diff --git a/README.md b/README.md index 8de7741..4346ebf 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ Portable IDE for golang with neovim, tmux, & zsh in docker. Based on [ubuntu](https://hub.docker.com/_/ubuntu) docker image. Extra tools: - [aws cli v2](https://github.com/aws/aws-cli/tree/v2) - [terraform](https://www.terraform.io/) (1.4.5) and [terragrunt](https://terragrunt.gruntwork.io/) v0.45.4 -- github [cli](https://github.com/cli/cli) (gh) +- [github cli](https://github.com/cli/cli) (gh) **Note** I built a docker image full of useful tools and setup for me. I do not care about size. Be aware the build and final image is large. @@ -51,8 +51,9 @@ vim-go is installed with [gofumpt](https://github.com/mvdan/gofumpt) as the defa ### golang -go 1.21.7 is installed with related tools like [golangci-lint](https://github.com/golangci/golangci-lint) and [delve](https://github.com/go-delve/delve. +go 1.21.12 is installed with related tools like [golangci-lint](https://github.com/golangci/golangci-lint) and [delve](https://github.com/go-delve/delve. ### other -- [rexi](https://github.com/royreznik/rexi) CLI tool for testing regex +- [rexi](https://github.com/royreznik/rexi) TUI tool for testing regex +- [wordgriner](https://github.com/davidgiven/wordgrinder) TUI for word processing diff --git a/files/entrypoint.sh b/files/entrypoint.sh index 1f96c4f..1dba702 100755 --- a/files/entrypoint.sh +++ b/files/entrypoint.sh @@ -13,4 +13,4 @@ fi chown -R ubuntu: /home/ubuntu/.??* & # Step down to ubuntu user -gosu ubuntu sh -c "nvim -s /tmp/gib.txt ; if [ ! -z \"$GIT_USER_NAME\" ]; then git config --global user.name \"$GIT_USER_NAME\"; git config --global user.email \"$GIT_USER_EMAIL\"; fi; cd /workspace ; mkdir -p .vim-tmp ; tmux -u -2 $@" \ No newline at end of file +gosu ubuntu sh -c "if [ ! -z \"$GIT_USER_NAME\" ]; then git config --global user.name \"$GIT_USER_NAME\"; git config --global user.email \"$GIT_USER_EMAIL\"; fi; cd /workspace ; mkdir -p .vim-tmp ; tmux -u -2 $@" diff --git a/files/init.vim b/files/init.vim index d1dfb6d..ea0500b 100644 --- a/files/init.vim +++ b/files/init.vim @@ -173,6 +173,20 @@ nnoremap fg Telescope live_grep nnoremap fb Telescope buffers nnoremap fh Telescope help_tags +" enable "enter to complete" in coc +" inoremap coc#pum#visible() ? coc#pum#confirm() : "\" + +" use to trigger completion and navigate to the next complete item +function! CheckBackspace() abort + let col = col('.') - 1 + return !col || getline('.')[col - 1] =~# '\s' +endfunction + +inoremap + \ coc#pum#visible() ? coc#pum#next(1) : + \ CheckBackspace() ? "\" : + \ coc#refresh() + " toggle the tag bar nnoremap a :AerialToggle float @@ -244,8 +258,8 @@ require("toggleterm").setup{ require 'go'.setup({ goimports = 'gopls', -- if set to 'gopls' will use golsp format - gofmt = 'gopls', -- if set to gopls will use golsp format - --max_line_len = 160, + gofmt = 'gofmt', -- if set to gopls will use golsp format + max_line_len = 160, tag_transform = false, -- gomodifytag overwrite eg snakecase camelcase test_dir = '', comment_placeholder = ' ',