2025年11月14日 星期五

加rust到vimrc

新增rust.vim與coc.nvim 並且把tagfunc設成CocTagFunc

這樣就能使用tag對rust定義的跳轉

3 " set the runtime path to include Vundle and initialize↵
4 set rtp+=~/.vim/bundle/Vundle.vim↵
5 call vundle#begin()↵
6 "set rtp+=~/.vim/bundle/vundle/↵
7 "call vundle#rc()↵
8 ↵
9 "let Vundle manage Vundle↵
10 "required!↵
11 Plugin 'VundleVim/vundle.vim'↵
12 "Bundle 'Shougo/neocomplete.vim'↵
13 Plugin 'Shougo/vimproc.vim'↵
14 Plugin 'Shougo/vimshell.vim'↵
15 Plugin 'mbbill/echofunc'↵
16 Plugin 'derekwyatt/vim-scala'↵
17 Plugin 'rust-lang/rust.vim'↵
18 Plugin 'neoclide/coc.nvim', {'branch': 'release'}↵
19 ↵
20 " All of your Plugins must be added before the following line↵
21 call vundle#end() " required↵
22 filetype plugin indent on " required↵
121 set tagfunc=CocTagFunc↵

2025年10月30日 星期四

安裝Coc.nvim與coc plugin

 安裝完Coc.nvim之後

透過:CocInstall coc-rust-analyzer發生錯誤

透過檢查:CocOpenLog發現

Vim(redir):E930: Cannot use :redir inside execute() on function coc#api#Command

redir有問題

於是採用手動安裝的方式

cd ~/.config/coc/extensions

npm install coc-rust-analyzer --global-style --ignore-scripts --no-bin-links

然後在Vim裡透過

:CocList extensions

[No Name][+] [unix] [] [utf-8] [ASCII=000] [POS=0001,0001][100%] [LEN=1]                                                             []
 * coc-snippets 3.4.7 ~/.config/coc/extensions/node_modules/coc-snippets                                                               
 + coc-rust-analyzer 0.85.0 ~/.config/coc/extensions/node_modules/coc-rust-analyzer        

可以看到安裝成功

升級方法:

npm update coc-rust-analyzer --global-style

:CocRestart