Skip to content

Latest commit

 

History

History
359 lines (274 loc) · 14.4 KB

reference.md

File metadata and controls

359 lines (274 loc) · 14.4 KB

Neovim IDE setup

Try to find the better solution for neovim IDE (golang, c, c++, java, lua, html, css, vim script, markdown, javascript)

Base image

docker pull alpine:edge

docker run -it -h neovim --env TZ=Asia/Shanghai  --name neovim \
--mount source=proj-vol,target=/home/ide/proj \
--mount type=bind,source=/Users/qiwang/proj,target=/home/ide/develop \
alpine:edge

go language server

grpc-go project in nvide

Thanks to go module, It's easy to start with grpc-go project. Please enjoy the go language server: gopls.

% git clone https://github.com/grpc/grpc-go.git
% cd grpc-go
% go mod tidy
% vi clientconn.go
  • git command clones the grpc-go project.
  • go mod tidy add missing and remove unused modules.
  • vi command will start the gopls language server. Now, you can navigate code, format code, diagnose code, etc.

c/c++ language server

cmake, autoconf, automake and bear are general tools for c/c++ Development. So it's build-in packages for nvide.

ccls project in nvide

ccls build suggest the following commands for alpine. Which means ccls project needs more packages to build from the source.

% apk add alpine-sdk cmake make clang clang-static clang-dev llvm-dev llvm-static \
	&& git clone --depth=1 --recursive https://github.com/MaskRay/ccls \
	&& cd ccls \
	&& cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release \
	&& cmake --build Release --target install

With nvide in hands, you still need to install the following packages to compile the project. Otherwise, the compiler will complains some library is missing. Note, you need to install the following package with the root privilege for nvide.

# apk add clang-static llvm-dev llvm-static zlib-dev libxslt-dev

Next, the key point is to generate the compile_commands.json file for ccls project. You can use the following command to create the compile_commands.json file.

% git clone --depth=1 --recursive https://github.com/MaskRay/ccls
% cd ccls
% cmake -H. -BRelease -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=YES
-- Using local RapidJSON
fatal: No names found, cannot describe anything.
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ide/proj/ccls/Release
% ln -s Release/compile_commands.json .
% vi src/main.cc
  • Note the -DCMAKE_EXPORT_COMPILE_COMMANDS=YES option is used.
  • You can ignore the fatal error reported by cmake.
  • Also note the compile_commands.json file is located in .Release directory. The link command set the root directory for clangd.

lua language server

lua project in nvide

nvide uses lua script to setup the neovim plugins. In ~/.config/nvim/ directory, there is a complete lua project (which contains a .git directory). Use the following command to enjoy the lua language server.

% cd ~/.config/nvim/
% vi init.lua

After Installation

reference or implementation quickfix window

lua vim.lsp.buf.references() and lua vim.lsp.buf.implementation() use quickfix window to show the list. The following is the command to operate the quickfix window. Refer to How do you use vim's quickfix feature? for detail.

:copen " Open the quickfix window
:ccl   " Close it
:cw    " Open it if there are "errors", close it otherwise (some people prefer this)
:cn    " Go to the next error in the window
:cp    " Go to the previous error in the window
:cnf   " Go to the first error in the next file
:.cc   " Go to error under cursor (if cursor is in quickfix window)

Terminal

How the terminal works? Who is responsible for terminal rendering? Does GPU-rendering in terminal matter?

typing

reference links

ssh in container

docker build -t nide:0.1 -f nvim-tmux.dockerfile .

docker run -it -d -h ggg --env TZ=Asia/Shanghai -u ide --name ggg -p 8654:22 nide:0.1 bash

ssh ide@localhost -p 8654 -t "tmux a -t golangide"

tmux new-session -s "IDE"  -n "editor" -d "nvim"

tmux  attach-session -t "IDE"

server:
docker run -d -p 50001:22 --env TZ=Asia/Shanghai -h nvimIDE  --name nvimIDE \
	nvim:ide /usr/sbin/sshd -D

client:
ssh ide@localhost -p 50001

NvChad

tmux in container

  1. copy .vimrc.
  2. copy yank to PAHT and chmod +x for it.
  3. edit ~/.config/nvim/init.lua and add the following content.
  4. yank what you want.
-- Here is the content for ~/.config/nvim/init.lua
--

-- source a vimscript file
vim.cmd('source ~/.vimrc')

vim.o.clipboard = 'unnamedplus' -- copy/paste to system clipboard
vim.opt.clipboard = 'unnamedplus' -- copy/paste to system clipboard

tmux on alacritty (mac)

docker container exec -u ide -ti neovim ash

See here for the official tmux clipboard document. For tmux, use the following configuration in .tmux.conf,

set -s set-clipboard on

For neovim, use the following configuration in ~/.config/nvim/init.lua

vim.o.clipboard = 'unnamedplus' -- copy/paste to system clipboard
vim.opt.clipboard = 'unnamedplus' -- copy/paste to system clipboard

when you run :checkhealth, neovim reports

## Clipboard (optional)
  - OK: Clipboard tool found: pbcopy

true color test:

curl -s https://raw.githubusercontent.com/JohnMorales/dotfiles/master/colors/24-bit-color.sh | ash

Guide for neovim and lua

TODO: install lua language server.

$ apk add alpine-sdk curl bash unzip
$ apk add lua5.3
$ wget https://luarocks.org/releases/luarocks-3.8.0.tar.gz
$ tar zxpf luarocks-3.8.0.tar.gz
$ cd luarocks-3.8.0
$ apk add lua5.3-dev
$ ./configure --lua-version=5.3
$ make
$ make install

check the result.
$ luarocks path --help

$ luarocks install --server=https://luarocks.org/dev luaformatter

.profile

$more .profile
export GOPATH=/go
export PATH=$PATH:$GOPATH/bin
export PS1='\u@\h:\w $ '
alias vi=nvim

homebrew font

% brew tap homebrew/cask-fonts
% brew install --cask font-hack-nerd-font
% brew install --cask font-cousine-nerd-font

docker file

apk part

  • apk add neovim neovim-doc (30m)
  • apk add git curl tzdata htop (48m)
  • apk add go (538m, 50 packages)
  • apk add tmux (539m, 52 packages)

neovim environment and packer

  • export HOME=/home/ide
  • export GOPATH=/go
  • mkdir /go
  • addgroup develop && adduser -D -h $HOME -s /bin/ash -G develop ide
  • chown -R ide:develop $GOPATH
  • su - ide
  • git clone --depth 1 https://github.com/wbthomason/packer.nvim ~/.local/share/nvim/site/pack/packer/start/packer.nvim
  • git clone https://github.com/brainfucksec/neovim-lua.git
  • cd neovim-lua
  • mkdir -p ~/.config/
  • cp -r nvim/ ~/.config/
  • disable color scheme first, run :PackerSync
  • mkdir -p .config/alacritty/
  • touch .config/alacritty/alacritty.yml
  • apk add g++ "need g++ to compile treesitter"
  • apk add ccls "c/c++ language server need npm" (860 MiB in 64 packages)

for vista

  • apk add ctags fzf

Telescope

  • apk add ripgrep

others