1.Fitten code是一个vim的ai插件可以通过注释或上下文自动补全代码
下载代码如下
# github install
mkdir -p ~/.vim/plugin
curl -o ~/.vim/plugin/fittencode.vim https://raw.githubusercontent.com/FittenTech/fittencode.vim/master/plugin/fittencode.vim
2.下载后使用vim时报错
Error detected while processing VimEnter Autocommands for "*"..function FittenMa
pping:
line 1:
E117: Unknown function: keytrans
Press ENTER or type command to continue
Error detected while processing VimEnter Autocommands for "*"..function FittenMa
pping:
line 3:
E117: Unknown function: keytrans
Press ENTER or type command to continue
这是因为vim插件管理问题
3.可以下载管理器vim-plug
sudo curl -fLo ~/.vim/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
如果报错
curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 61 ms: Connection refused
bash: syntax error near unexpected token `7'
这是因为github 的一些域名的 DNS 解析被污染
具体而言:
打开 https://www.ipaddress.com/ 输入访问不了的域名,获得对应的IP。
使用vim /etc/hosts命令打开不能访问的机器的hosts文件,添加如下内容:
199.232.68.133 raw.githubusercontent.com
199.232.68.133 user-images.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
注:上面内容中199.232.68.133是raw.githubusercontent.com所在的服务器IP(通过 https://www.ipaddress.com/ 获知)。
保存该文件,再使用即可正常访问。引用自
重新下载vim-plug
4.如果继续报错
Error detected while processing VimEnter Autocommands for "*"..function FittenMa
pping:
line 1:
E117: Unknown function: keytrans
Press ENTER or type command to continue
Error detected while processing VimEnter Autocommands for "*"..function FittenMa
pping:
line 3:
E117: Unknown function: keytrans
Press ENTER or type command to continue
可能是因为vim版本过低,下载vim8(非官方下载有一定风险)(官方没有将此版本加入更新包)
sudo add-apt-repository ppa:jonathonf/vim
sudo apt-get update
sudo apt-get install vim
5.如果报错
E: The repository 'https://ppa.launchpadcontent.net/fcitx-team/nightly/ubuntu jammy Release' does not have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
进入到 /etc/apt/sources.list.d
目录下
sudo vim fossfreedom-ubuntu-indicator-sysmonitor-jammy.list
修改
fossfreedom-ubuntu-indicator-sysmonitor-jammy.list文件(文件名因系统版本而异,大体相似即可)
由
deb https://ppa.launchpadcontent.net/fossfreedom/indicator-sysmonitor/ubuntu/ jammy main
变
# deb https://ppa.launchpadcontent.net/fossfreedom/indicator-sysmonitor/ubuntu/ jammy main
再重新下载vim8
sudo add-apt-repository ppa:jonathonf/vim
sudo apt-get update
sudo apt-get install vim
下载成功后再使用vim报错消失,插件成功加载
6.使用
fitten code 连接完成键入
:Fittenlogin 用户名 密码
显示
Login successful, API key saved
成功接入
在代码补充处<ctrl+l>自动补全,<tab>接受补全,<ctrl+n>补全列表,目前仅有以上功能。(可以用注释说明需求)