Linux下超轻量级Rust开发环境搭建:二、安装Helix Editor

创建一个用户命令的目录:

$> mkdir ~/.bin

我习惯将用户自己的命令都放在这个.bin目录下。

$> echo "export PATH=\$HOME/.bin:\$PATH" >> ~/.bashrc
$> source ~/.bashrc

上面两个命令,将.bin目录加入到PATH环境变量上。

用curl命令从github上直接下载:

curl -L --proto '=https' --tlsv1.2 -sSf -o /tmp/helix-23.10-x86_64-linux.tar.xz https://github.com/helix-editor/helix/releases/download/23.10/helix-23.10-x86_64-linux.tar.xz

这里一定要有-L这个参数,因为github会回复302(HTTP状态码)给我们,我们需要跟随302给的新地址,去下载文件。

压缩文件helix-23.10-x86_64-linux.tar.xz放置到/tmp目录下。

$> curl -L --proxy "socks5://ip:port" --proto '=https' --tlsv1.2 -sSf -o /tmp/helix-23.10-x86_64-linux.tar.xz https://github.com/helix-editor/helix/releases/download/23.10/helix-23.10-x86_64-linux.tar.xz

这里依然可以通过--proxy参数来配置代理服务器。

然后解压缩到~/.bin目录下:

$> cd /tmp
$> tar -xf ./helix-23.10-x86_64-linux.tar.xz --strip-components 1 -C ~/.bin
$> rm helix-23.10-x86_64-linux.tar.xz

这里使用解压参数:--strip-components 1来忽略第一层目录。

我们来看一下.bin目录下的文件:

$> ll ~/.bin
总用量 18716
drwxr-xr-x. 3 rust rust       24 10月 26 01:32 contrib
-rwxr-xr-x. 1 rust rust 19137648 10月 26 01:24 hx
-rw-r--r--. 1 rust rust    16725 10月 26 01:32 LICENSE
-rw-r--r--. 1 rust rust     2579 10月 26 01:32 README.md
drwxr-xr-x. 5 rust rust       64 10月 26 01:24 runtime

可以看到hx可执行文件,和一些配置其他文件。

创建~/.config/helix目录,并在里面创建目录软链接:runtime指向~/.bin/runtime。

$> mkdir -p ~/.config/helix
$> ln -Ts ~/.bin/runtime ~/.config/helix/runtime

用hx --health rust命令检查一下环境:

$ hx --health rust
Configured language servers:
  ✓ rust-analyzer: /home/rust/.cargo/bin/rust-analyzer
Configured debug adapter: lldb-vscode
Binary for debug adapter: 'lldb-vscode' not found in $PATH
Highlight queries: ✓
Textobject queries: ✓
Indent queries: ✓

在~/.config/helix/目录下,创建一个文件:languages.toml。

内容如下:

[[language]]
name = "rust"
scope = "source.rust"
injection-regex = "rust"
file-types = ["rs"]
roots = ["Cargo.toml", "Cargo.lock"]
auto-format = true
comment-token = "//"
language-servers = [ "rust-analyzer" ]
indent = { tab-width = 4, unit = "    " }

好了。这样一个基本的Rust开发环境就完成了。

下面创建一个Rust工程,体验一下:

$> cargo new hello
$> cd hello
$> hx src/main.rs

相关推荐

  1. Linux轻量级Rust开发环境:一、安装Rust

    2023-12-05 16:00:07       37 阅读
  2. linux系统vscode portable版本的rust环境003:rust

    2023-12-05 16:00:07       32 阅读
  3. Rust介绍与开发环境

    2023-12-05 16:00:07       29 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-05 16:00:07       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-05 16:00:07       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-05 16:00:07       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-05 16:00:07       18 阅读

热门阅读

  1. 系统部署安装-Centos7-Kafka

    2023-12-05 16:00:07       44 阅读
  2. zxjy002- 后端项目环境搭建

    2023-12-05 16:00:07       33 阅读
  3. 振动和震动的区别?

    2023-12-05 16:00:07       106 阅读
  4. 创建Dataloader基础篇【一】

    2023-12-05 16:00:07       43 阅读
  5. 使用开源的frp进行内网穿透教程

    2023-12-05 16:00:07       43 阅读
  6. 第1节:Vue3 安装部署 创建应用(实例)

    2023-12-05 16:00:07       29 阅读
  7. tomcat 弱口令war远程部署

    2023-12-05 16:00:07       42 阅读
  8. Android 打包配置与输出教程

    2023-12-05 16:00:07       34 阅读
  9. 安陆FPGA调试中遇到的问题总结

    2023-12-05 16:00:07       49 阅读
  10. AWS中使用ECS时ecsTaskExecutionRole缺失

    2023-12-05 16:00:07       40 阅读
  11. 2-- 简要介绍 Kubernetes

    2023-12-05 16:00:07       35 阅读
  12. MiniDumpWriteDump函数生成dmp文件

    2023-12-05 16:00:07       44 阅读