helix 官方文档
解决方案 shell
配置 即使 Helix 在零配置下也可以使用,如果想要更加符合自己的习惯还是需要一些配置。 erasin/helix-config 是我自己正在使用的配置文件。
在 Helix 中,加载配置的顺序是 默认配置
–>> .config/helix/
中自定义配置 –> self-project/.helix/
项目文件夹下自定义配置。在三层配置这种常规设计基本上可以满足各种使用的情况了。
配置文件结构主要有:
config.toml <– 编辑器配置
language.toml <– 语言支持配置
themes/ <– 自定义主题
icons/ <– 自定义图标
config.toml 配置主要提供 true-color 支持,自定义显示,以及自定义键盘布局。在编辑器器中使用 :set-option
可以看到配置选项,或者阅读官方文档配置。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 theme = "zed_onedark" [editor] true-color = true [editor.cursor-shape] insert = "bar" normal = "block" select = "underline" [editor.statusline] left = ["mode" , "spacer" , "spinner" , "spacer" , "file-name" , "file-modification-indicator" ]center = ["diagnostics" ,"workspace-diagnostics" ]right = ["position-percentage" , "file-encoding" , "file-type" , ][keys.normal] a = ["move_char_right" ,"insert_mode" ]"C-s" = ":write" "C-j" = ["save_selection" ]"C-r" = ":reload" "C-z" = "normal_mode" "C-q" = ":quit" "A-/" = "toggle_comments" "\\" = ":reflow" "X" = "extend_line_above" "Z" = { "Z" = [":quit" ] }[keys.normal.space] "x" = ":buffer-close" "w" = { "r" = ":config-reload" }"." = "file_picker_in_current_buffer_directory" [keys.insert]
Helix 提供 keymap 和 commands 命令, 这些命令在自定义键盘布局中自由组合,命令组会顺序处理。比如 a = ["move_char_right","insert_mode"]
Helix 中 a
默认为选区追加, 将其覆盖为字符向后移动一位编辑模式。详细的请参看 配置文档 。
lsp 通过 hx --health language
检查 lsp 内置语言支持 Tree-Sitter 查看项目的 languages.toml 可以看到支持的语言。How to install the default language servers · helix-editor/helix Wiki 编写 languages.toml
,保存在 ~/.config/helix/
路径下。参考官网的配置就好,内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 [[language]] name = "rust" auto-format = false [language-server.rust-analyzer.config.check] command = "clippy" [[language]] name = "python" scope = "source.python" injection-regex = "python" file-types = ["py" ,"pyi" ,"py3" ,"pyw" ,"ptl" ,".pythonstartup" ,".pythonrc" ,"SConstruct" ]shebangs = ["python" ]roots = ["setup.py" , "setup.cfg" , "pyproject.toml" ]comment-token = "#" language-server = { command = "pyright-langserver" , args = ["--stdio" ] }indent = { tab-width = 4 , unit = " " }config = {}
在配置文件中 “[[grammar]]
“ 底下有指定要安装某个语言的 LSP 服务器,但是我不理解其中一些配置参数。这个配置文件的内容我是仿照 Languages (helix-editor.com) 复制粘贴的。
可参考