当前位置: 代码迷 >> 综合 >> Go IDE vscode (by quqi99)
  详细解决方案

Go IDE vscode (by quqi99)

热度:50   发布时间:2023-12-13 08:52:05.0

作者:张华 发表于:2021-11-19
版权声明:可以任意转载,转载时请务必以超链接形式标明文章原始出处和作者信息及本版权声明
(http://blog.csdn.net/quqi99 )

go环境设置

#https://golang.org/doc/install
GO_VERSION=1.18.2
GO_ARCH=linux-amd64
curl -o go.tgz https://dl.google.com/go/go${GO_VERSION}.${GO_ARCH}.tar.gz
sudo rm -rf /usr/lib/go && sudo tar -C /usr/lib -xzf go.tgz
go version
sudo chown -R $USER /usr/lib/go
export GOROOT=/usr/lib/go
export GOPATH=/bak/golang
export PATH=$GOROOT/bin:$GOPATH/bin:$PATH
alias gosrc="cd $GOROOT/src"
alias gopath="cd $GOPATH"
alias gomod="cd $GOMOD"
alias gorm='gormt -g=true'
alias gotest='gotests -all -w ./'
alias goformat='gofmt -l -w -s ./'
alias goimport='goimports -l -w ./'
alias gorace='go run -race .'
alias cover="go test -coverprofile=cover.out"
alias covers="go tool cover -html=cover.out"#GO111MODULE=on means go will ignore GOPATH and vendor to search the package, just uses go.mod
go env -w GO111MODULE=off
#go env -w GOPROXY=https://goproxy.cn,direct
go env -w GOROOT=/usr/lib/go
go env -w GOBIN=/usr/lib/go/bin
go env -w GOPATH=/bak/golangcd /bak/golang/src
unset GO111MODULE && go env -w GO111MODULE=on
go mod init mymods
go mod tidy
cat go.mod
go get -u golang.org/x/tools/cmd/goimports
go get -u golang.org/x/tools/cmd/gorename
go get -u github.com/sqs/goreturns
go get -u github.com/nsf/gocode
go get -u github.com/alecthomas/gometalinter
go get -u github.com/zmb3/gogetdoc
go get -u github.com/rogpeppe/godef
go get -u golang.org/x/tools/cmd/guru
go install mvdan.cc/gofumpt@latest
go get -u -v github.com/ofabry/go-callvis
go get -u -v github.com/google/gops
go get -u -v golang.org/x/tools/gopls
go get -u -v github.com/uudashr/gopkgs/v2/cmd/gopkgs
go get -u -v github.com/ramya-rao-a/go-outline
go get -u -v github.com/acroca/go-symbols
go get -u -v github.com/go-delve/delve/cmd/dlv
go get -u -v golang.org/x/lint/golint
go get -u -v github.com/cweill/gotests/...
go get -u -v github.com/fatih/gomodifytags
go get -u -v github.com/josharian/impl
go get -u -v github.com/davidrjenni/reftools/cmd/fillstruct
go get -u -v github.com/haya14busa/goplay/cmd/goplay
go get -u -v github.com/godoctor/godoctor
go get -u -v github.com/smartystreets/goconvey  
go get -u -v github.com/jstemmer/gotags
go get -u -v golang.org/x/tools/cmd/godoc
go get -u -v github.com/golangci/golangci-lint/cmd/golangci-lint
go get -u -v github.com/xxjwxc/gormt@master (gormt -g=true)
go get -u -v google.golang.org/protobuf/cmd/protoc-gen-go 
go get -u -v google.golang.org/grpc/cmd/protoc-gen-go-grpc
go get -u -v github.com/envoyproxy/protoc-gen-validate
#make up for golint's shortcomings
sudo snap install golangci-lint

之前的CLI方式

之前一直使用cscope和ctag(往前跳和往后跳仍然是Ctrl+O以及Ctrl+I)来查看go代码,

find . ! -name '*test.go' ! -path '*test*' -name '*.go' > cscope.files
cscope -Rbkq
ctags -R
find . ! -name '*test.go' ! -path '*test*' -name '*.go' |xargs -i grep --color -H 'a' {}

并使用YCM (https://github.com/chxuan/vimplus.git)来做代码提示,
同时在~/.vimrc修改了cscope的快捷键, 并添加ConqueGdb用于go调试。

set colorcolumn=80                                                              
set belloff=all                                                                 
let g:ycm_server_python_interpreter = '/usr/bin/python2.7'" ConqueGdb for go debug - https://michaelthessel.com/go-vim-debugging-with-gdb/
let g:ConqueTerm_Color = 2                                                      
let g:ConqueTerm_CloseOnEnd = 1                                                 
let g:ConqueTerm_StartMessages = 0                                              function DebugSession()                                                         silent make -o vimgdb -gcflags "-N -l"                                      redraw!                                                                     if (filereadable("vimgdb"))                                                 ConqueGdb vimgdb                                                        else                                                                        echom "Couldn't find debug file"                                        endif                                                                       
endfunction                                                                     
function DebugSessionCleanup(term)                                              if (filereadable("vimgdb"))                                                 let ds=delete("vimgdb")                                                 endif                                                                       
endfunction                                                                     
call conque_term#register_function("after_close", "DebugSessionCleanup")        
nmap <leader>d :call DebugSession()<CR>;
if has("cscope")                                                                set cscopetag                                                                " set to 1 if you want the reverse search order.                             set csto=1                                                                   " add any cscope database in current directory                               if filereadable("cscope.out")                                                cs add cscope.out                                                         " else add the database pointed to by environment variable                   elseif \$CSCOPE_DB !=""                                                       cs add \$CSCOPE_DB                                                         endif                                                                        " show msg when any other cscope db added                                    set cscopeverbose                                                            nmap css :cs find s <C-R>=expand("<cword>")<CR><CR>                          nmap csg :cs find g <C-R>=expand("<cword>")<CR><CR>                          nmap csc :cs find c <C-R>=expand("<cword>")<CR><CR>                          nmap cst :cs find t <C-R>=expand("<cword>")<CR><CR>                          nmap cse :cs find e <C-R>=expand("<cword>")<CR><CR>                          nmap csf :cs find f <C-R>=expand("<cfile>")<CR><CR>                          nmap csi :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>                        nmap csd :cs find d <C-R>=expand("<cword>")<CR><CR>                          nmap hello :echo "hello"<CR>                                                 
endif                   

基本全部使用CLI, 调试go代码也是使用dlv CLI

现在的GUI方式

但是YCM提示go代码还是不够强大,微软的vscope作为一款GUI的IDE, 可以:

  • 应用商店搜索vim插件安装,这样让使用vscope的习惯和CLI一样。 注意:因为安装了vim插件,所以得按i才能输入字符。别忘了。
  • 搜索ai插件安装,让代码提示更智能

现在代码提示是智能了,但仍然有一个不好用的地方,就是包的自动导入。

  1. 搜索安装’auto import’插件
  2. 参考(https://medium.com/backend-habit/setting-golang-plugin-on-vscode-for-autocomplete-and-auto-import-30bf5c58138a)安装一些工具,on VsCode click View -> Command Pallete or type Ctrl+Shift+P and type goinstall update/tools.
  3. 不用在setting.json中编辑: go.autocompleteUnimportedPackages=True也能生效,注意:是不用。
  4. 一定要重启vscode,之前一直不行是因为没重启
  5. 然后保存代码时,会自动导入包。

但是这个功能非常不好用,它是它只能导入标准包,不能导入第三方包。例如对于一个rpc包,我希望导入的是/bak/golang/src/github.com/ethereum/go-ethereum/rpc/,而不是:

import "net/rpc"

按’Ctrl + shift + p"搜"Add import"手动导入包也不能将这个第三方包列出来。

网上说要在setting.json中添加下列参数,试过了,不好使。

 "go.inferGopath": true,

无解了,用得不太顺

用vscode写C

vscode可以编译单个C文件,但对于多个C文件好像不能自动编译,它只是一个编辑器不是一个IDE, 见:
https://www.cnblogs.com/shadowfish/p/12059872.html

vim-go

用cscope可以调到call它的函数处,这是它的最大优点.
但是使用cscope需要人工敲命令建索引,如果有时候只想像ctags(用于C的)来查看go语言的代码定义的话可以使用vim-go(它不需要人工建索引,方便,但是不能到call 它的函数处).

使用vimplus配置vim

1, 安装vimplus

sudo apt install vim -y
git clone https://github.com/chxuan/vimplus.git ~/.vimplus
cd ~/.vimplus
./install.sh
./update.sh
# Set the terminal fout to 'Droid Sans Mono Nerd Font' to prevent garbled code
# https://github.com/chxuan/vimplus/blob/master/help.md
Display Help:,h

2, 安装vim-go插件

cat << EOF |tee -a ~/.vimrc.custom.plugins
Plug 'fatih/vim-go'
EOF
#use vim to open a file(eg: vim ~/.vimrc.custom.plugins), then type ',,i' to install the plugin

按’,i’安装vim-go插件之后,继续用’:GoInstallBinaries’命令可安装gocode等插件。vim实际上已经自带提示功能,将gocode的gocomplete.vim放到vim的 /usr/share/vim/vim82/autoload/目录就可以使用vim自带的提示了,方法如下(我们不需要做这一步,因为我们将使用ycm来对 go做提示)

:GoInstallBinaries
ls $GOPATH/bin
#vim itself has code prompt function
#go get -u github.com/nsf/gocode
ls /usr/share/vim/vim82/autoload/*complete.vim
wget https://raw.githubusercontent.com/nsf/gocode/master/vim/autoload/gocomplete.vim
sudo cp gocomplete.vim /usr/share/vim/vim82/autoload/vim ~/.vimrc.custom.config
" wget https://raw.githubusercontent.com/nsf/gocode/master/vim/autoload/gocomplete.vim
" sudo cp gocomplete.vim /usr/share/vim/vim82/autoload/
filetype plugin indent on
autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
autocmd FileType xml set omnifunc=xmlcomplete#CompleteTags
autocmd FileType java set omnifunc=javacomplete#Complete
autocmd FileType go set omnifunc=gocomplete#Complete

3, 配置fcitx-vim, cscope等

cat << EOF |tee -a ~/.vimrc.custom.plugins
Plug 'fatih/vim-go'
EOFcat << EOF |tee -a ~/.vimrc.custom.config
"##### auto fcitx  ###########
let g:input_toggle = 1
function! Fcitx2en()let s:input_status = system("fcitx-remote")if s:input_status == 2let g:input_toggle = 1let l:a = system("fcitx-remote -c")endif
endfunctionfunction! Fcitx2zh()let s:input_status = system("fcitx-remote")if s:input_status != 2 && g:input_toggle == 1let l:a = system("fcitx-remote -o")let g:input_toggle = 0endif
endfunctionset ttimeoutlen=150
"exit insert mode
autocmd InsertLeave * call Fcitx2en()
"enter insert mode
autocmd InsertEnter * call Fcitx2zh()
"##### auto fcitx end ######" cscope
if has("cscope")set cscopetag" set to 1 if you want the reverse search order.set csto=1" add any cscope database in current directoryif filereadable("cscope.out")cs add cscope.out" else add the database pointed to by environment variableelseif $CSCOPE_DB !=""cs add $CSCOPE_DBendif" show msg when any other cscope db addedset cscopeverbosenmap css :cs find s <C-R>=expand("<cword>")<CR><CR>nmap csg :cs find g <C-R>=expand("<cword>")<CR><CR>nmap csc :cs find c <C-R>=expand("<cword>")<CR><CR>nmap cst :cs find t <C-R>=expand("<cword>")<CR><CR>nmap cse :cs find e <C-R>=expand("<cword>")<CR><CR>nmap csf :cs find f <C-R>=expand("<cfile>")<CR><CR>nmap csi :cs find i ^<C-R>=expand("<cfile>")<CR>$<CR>nmap csd :cs find d <C-R>=expand("<cword>")<CR><CR>nmap hello :echo "hello"<CR>
endif" inconsistent use of tabs and spaces in indentation, then run: :retab
set softtabstop=4
set tabstop=4
set shiftwidth=4
set expandtab
EOF

4, 我主要使用vimplus的NerdTree + ctags + cscope三大插件

1, 使用NerdTree, 用',n'打开关闭目录, 用',t'打开关闭函数. 用'ctrl+w'在窗口间切换,在左侧目录树按?可显示帮助. 按':q'关闭窗口
2, 延用ctags的ctrl+]与ctrl+O实现函数的跳转与返回
3, 跳转到函数的调用处得用cscope (:css查找符号,:csc调用函数的地方, :csg函数定义的地方相当于ctags的ctrl+], 用ctrl+O返回)
find . \( -path '*test*' -o -path '*.tox' -o -path '*venv*' -o -path '*.git' \) -prune -o -type f -name '*.py' -print > cscope.files
cscope -Rbkq
ctags -R
find . \( -path '*test*' -o -path '*.tox' -o -path '*venv*' -o -path '*.git' \) -prune -o -type f -name '*.py' -print |xargs -i grep --color -H 'htb' {}

5, 基他vim技巧

缩进多行:或者用v选定多行后再用<和>缩进,还有更简单的不用v,直接用n>>或n>>缩进n行。但一次缩进是4个空格,如当前位置不是4个空格可以先缩到行首然后再往后缩注:在python中用此缩进可能产生:TabError: inconsistent use of tabs and spaces in indentation, 可在~/.vimrc中添加下列内容然后运行':retab'" inconsistent use of tabs and spaces in indentation, then run: :retabset softtabstop=4set tabstop=4set shiftwidth=4set expandtab
复制多行:[n]yy
移动:行首^, 行尾$, 删除单词dw, 删3单词3dw 删除到末尾d$, 往后移动1个单词w(往回移动单词是b), 往后移动3个单词3w
多行注释:按ESC然后按Ctrl+v(不是单v)进入区块模式,选多行,然后按I,再输出注释#, 最后一定要按EsC等一会才会出现多行注释。若取消多行注释将按I这步改成x
查找: 转到下一个n, 转到上一个N
翻半页: ctrl-d, ctrl-u, 翻全页: ctrl-f, ctrl-b

6, 安装ycm支持代码提示
安装ycm前要先安装python3, go, rust, java等环境, 安装go的方法见如上,下面是rust的方法(也见:https://blog.csdn.net/quqi99/article/details/122744892):

#install rust and rust-analyzer
export CARGO_HOME=/bak/rust
export RUSTUP_HOME=/bak/rust
curl https://sh.rustup.rs -sSf |sh
rustc --version
proxychains4 rustup component add rust-src rustc-dev llvm-tools-preview
#failed to install component: 'rust-src', detected conflict: 'lib/rustlib/src/rust/Cargo.lock'
rustup toolchain list
rustup toolchain uninstall stable-x86_64-unknown-linux-gnu
rustup toolchain install stable
#use '--system-libclang' to avoid 'No prebuilt Clang 15.0.1 binaries for this system'

vimplus中自带的ycm版本太老以致于报"The ycmd server SHUT DOWN",所以需要从源码重新安装:

 #The ycmd server SHUT DOWN (restart with ':YcmRestartServer'). Unexpected exit code 1.
#https://github.com/chxuan/vimplus/issues/407
cd ~/.vim/plugged
mv YouCompleteMe YouCompleteMe_OLD
git clone https://github.com/ycm-core/YouCompleteMe.git
cd .vim/plugged/YouCompleteMe
git submodule update --init --recursive
sudo ln -s /usr/bin/python3 /usr/bin/python
python3 ./install.py --help
sudo apt install build-essential cmake python3-dev libclang1 libclang-dev librust-clang-sys-dev -y
wget https://github.com/OmniSharp/omnisharp-roslyn/releases/download/v1.37.11/omnisharp.http-linux-x64.tar.gz
cp omnisharp.http-linux-x64.tar.gz ./third_party/ycmd/third_party/omnisharp-roslyn/v1.37.11/omnisharp.http-linux-x64.tar.gz
wget https://github.com/ycm-core/llvm/releases/download/15.0.1/clangd-15.0.1-x86_64-unknown-linux-gnu.tar.bz2
cp clangd-15.0.1-x86_64-unknown-linux-gnu.tar.bz2 ./third_party/ycmd/third_party/clangd/cache/clangd-15.0.1-x86_64-unknown-linux-gnu.tar.bz2
graftcp ./install.py --clangd-completer --go-completer --rust-completer --java-completer --ts-completer --skip-build --verbose

20230303更新 - 上面安装的go-completer会使用gopls,这样在打开一个go源码vim-go都会初始化gopls从而很容易造成vim死掉,在.vim中添加了go_gopls_enabled=0来禁用gopls(但似乎不work机器还是容易死机), 以使用goimports来fmt go代码

let g:go_gopls_enabled = 0
let g:go_fmt_command = "goimports"

注意几点:

  • 如用c/c++, 最好使用异步的clangd-completer来代替clang-completer, 因为选择clang-completer的话很容易挂在’[100%] Built target ycm_core’这个地方,那可以试试–skip-build. 另外,一定要用clang-completer的话最好也使用–system-libclang这样来使用deb安装的clang(sudo apt install llvm clang libclang-dev libboost-all-dev cmake python3-dev)从而避免从源码来安装clang
  • 可使用graftcp,它支持静态编译的, proxychain只支持动态DDL的程序
  • 卡着不动时是由于urllib.request在下载一些文件时(如clangd-15.0.1)时卡在那,那是因为特色网络太慢的问题

附录1 - 使用预编译的llvm-clang

若ycm没有用clangd-completer, 而是肜clang-completer时,要提示c/c++代码时才需要llvm-clang. YCM里程序里编译太慢了,这里尝试使用预编译的llvm-clang但还是因为特色网络的原因失败了。做个记录

sudo apt install llvm clang libclang-dev libboost-all-dev cmake python3-dev
#avoid 'No prebuilt Clang 15.0.1 binaries for this system'
#https://github.com/ycm-core/llvm/releases
#it's too slow, so download in vps, then use python3 to set up http server for it
wget https://github.com/ycm-core/llvm/releases/download/15.0.1/clang+llvm-15.0.1-x86_64-unknown-linux-gnu.tar.xz
mkdir /tmp/build && cd /tmp/build
cmake -G "Unix Makefiles" -DPATH_TO_LLVM_ROOT=/bak/soft/clang_llvm/clang+llvm-15.0.1-x86_64-unknown-linux-gnu . ~/.vim/plugged/YouCompleteMe/third_party/ycmd/cpp
cmake --build . --target ycm_core --config Release
ls ~/.vim/plugged/YouCompleteMe/third_party/ycmd/ycm_core.cpython-310-x86_64-linux-gnu.so
# download libclang from https://github.com/ycm-core/llvm/releases to ./third_party/ycmd/clang_archives/
ls ./third_party/ycmd/clang_archives/libclang-15.0.1-x86_64-unknown-linux-gnu.tar.bz2#./third_party/ycmd/cpp/CMakeLists.txt
#./third_party/ycmd/build.py
EXTRA_CMAKE_ARGS='-DPATH_TO_LLVM_ROOT=/bak/soft/clang_llvm/clang+llvm-15.0.1-x86_64-unknown-linux-gnu' ./install.py --clang-completer --go-completer --java-completer --rust-completer --ts-completer --enable-coverage --verbose

附录2 - llvm源码编译clang

也尝试了从源码编译,实际都没必要,使用’–system-libclang’即可((sudo apt install llvm clang libclang-dev libboost-all-dev cmake python3-dev)).

git clone --recursive https://gitee.com/mirrors/LLVM.git llvm
cd llvm
mkdir -p build && cd build
sudo apt install cmake python3-dev gcc g++ -y
#cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \
#  -DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;" -DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi" /bak/soft/llvm/llvm/
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE="Release" -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ \-DLLVM_ENABLE_PROJECTS="clang;clang-tools-extra;" /bak/soft/llvm/llvm/
make -j8 && sudo make install

附录3 - 断点续传的python代码

安装ycm最大的困难就在于特色网络,ycm中使用urllib.request来下载一些文件,但出口宽带被限速了过慢无法下载导致各种hang和错误。也尝试了通过断点续传,但也是慢不可行。记录一下。

#!/usr/bin/env python
# coding=utf-8
import urllib
import urllib.request
import os
import requests
from urllib.request import urlopen
#sudo apt install python3-tqdm
from tqdm import tqdmdef download_from_url(url, dst):#import pdb;pdb.set_trace()proxies = { "http": "http://quqi99:xxxx@proxy:3128", "https": "http://quqi99:xxxx@proxy:3128", }#response = requests.get(url, timeout=8, proxies=proxies)response = requests.get(url, timeout=8)if response.ok:print(dst.split('\\')[-1] + ' success')file_size = int(urlopen(url).info().get('Content-Length', -1))if os.path.exists(dst):first_byte = os.path.getsize(dst)else:first_byte = 0if first_byte >= file_size:return file_sizeheader = {"Range": "bytes=%s-%s" % (first_byte, file_size)}pbar = tqdm(total=file_size, initial=0,unit='B', unit_scale=True, desc=dst.split('\\')[-1])req = requests.get(url, headers=header, stream=True)with(open(dst, 'ab')) as f:for chunk in req.iter_content(chunk_size=1024):if chunk:f.write(chunk)pbar.update(1024)pbar.close()return file_sizeelse:print(dst.split('\\')[-1] + ' fail')return 0download_url = 'https://download.eclipse.org/jdtls/snapshots/jdt-language-server-1.14.0-202207211651.tar.gz'
file_path = '/tmp/tmp.tar.gz'
#download_from_url(download_url, file_path)
print('start to test urllib')
urllib.request.HTTPSHandler(debuglevel=1)
try:with urllib.request.urlopen( download_url, None, 10 ) as response:with open( file_path, 'wb' ) as package_file:data = response.read()package_file.write(data)
except BaseException as e:print('bad urlopen, wait next time, error: {}')

附录4 - graftcp + proxychains

为了在特色网络中正常安装ycm, 也研究了各种代理类型,记录一下:

  • 有的程序支持了代理, 如proxies=proxies:requests.get(url, timeout=8, proxies=proxies),而ycm使用的urllib.request.urlopen并没有额外设置urllib.request.ProxyHandler来支持代理,这种情况(也如git)可以通过设置环境变量使用代理(如: ALL_PROXY=socks5://proxyAddress:port, http_proxy=http://proxyAddress:port).
  • proxychains,tsocks这些是通过LD_PRELOAD来劫持共享库的 connect()、getaddrinfo()等系列函数达到重定向目的。这种方法显示只对C/C++且使用DDL的程序有效,它对python的urllib也有效因为它用了glibc(见:https://github.com/rofl0r/proxychains-ng/issues/55).所以proxychains对静态编译的程序无效(eg: proxychains4 go get -v golang.org/x/net/proxy)
  • 对于静态编译的程序就得用graftcp了, 它可将任何程序的TCP重定向到代理.
    它通过fork+execve来启动这个程序,然后通过ptrace跟踪,这样在程序进行每一个tcp连接时捕获并拦截这次
    connect系统调用,修改目标地址为graftcp-local的地址,然后恢复执行被中断的系统调用,从而移花接木。
go get -u -d -v github.com/hmgle/graftcp/...
cd $GOPATH/src/github.com/hmgle/graftcp
make && sudo make install && sudo make install_systemd
cat << EOF |sudo tee -a /etc/graftcp-local/graftcp-local.conf 
socks5 = 192.168.99.1:7071
EOF
sudo systemctl restart graftcp-local.service
$ graftcp bash
$ wget https://www.google.com

20230323更新

试了一下集成在VS Code和neovim中的基于Chat GPU GPT-4大模型的代码提示功能,感觉还不错
1, 安装VS Code + Copilot

#https://code.visualstudio.com/docs/setup/linux
sudo dpkg -i ~/code_1.76.2-1678817801_amd64.deb
#then open it, and press 'ctrl+p' to run: ext install GitHub.copilot
Alt + ]: See next suggestion
Alt + [: See previous sugession
Tab: accept a suggestion
Esc: reject all suggestions

2, 安装neovim + Copilot

sudo apt install neovim -y
tee -a $HOME/.bashrc <<EOF
# Configure for nvim
export EDITOR=nvim
alias vi="nvim"
EOF
vi --versioncurl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt purge libnode-dev -y
sudo apt-get install -y nodejs
sudo npm install hexo-cli -g
#https://docs.github.com/zh/copilot/getting-started-with-github-copilot/getting-started-with-github-copilot-in-neovim
git clone https://github.com/github/copilot.vim ~/.config/nvim/pack/github/start/copilot.vim
vim /tmp/tmp.txt
:Copilot setup
:Copilot enable
:help copilot

下面第一张图是 neovim + copilot, 第两张是VS Code + copilot, 第三张是之前的vim + go-vim的图
在这里插入图片描述
在这里插入图片描述
![](https://img-blog.csdnimg.cn/90e53c26ac794ff98e44370f07b4e2ea.png#pic_center
在这里插入图片描述