2. init.clj 里可用的 API
coxn.user 里预置了这些函数(clojure.core 全部可用,另 require 了 coxn.editor(别名 ed,含 defcommand)、coxn.keymap(km)、coxn.i18n、 coxn.hooks、coxn.bus、coxn.config、coxn.layers):
| API | 作用 |
|---|---|
(set-option! k v) | 设选项,如 (set-option! :tab-width 4)。全部选项见下文各节 |
(bind-key! "C-c g" 'find-file) | 绑全局键 |
(unbind-key! "C-c g") | 解绑 |
(prefix-name! "C-c l" "lsp") | 给前缀键起名(which-key 显示用) |
(set-theme! :doom-dark) | 换主题(见 §10) |
(set-face! :region {:bg "#3a3a5a"}) | 覆盖单个 face,换主题后仍生效(见 §10) |
(register-theme! {...}) | 注册自己的主题(见 §10) |
(palette :space-dark) / (palette-with pal :keyword "#ff79c6") | 取 / 小改内置调色板 |
(add-hook! :after-save-hook f) / (remove-hook! ...) | 挂钩子;f 收 editor 返回 editor(见 §12) |
(subscribe! :document-opened f) / (unsubscribe! ...) | 订阅事实事件;f 收 [event payload](见 §12) |
(configuration-layers! [:treemacs :lsp ...]) | 选用 layer;不调用 = 全部启用(见 §9) |
(set-language! :zh) | 界面语言(见 §11) |
(defcommand name "doc" [ed] ...) | 定义自己的命令(注册进 M-x) |
原始 Markdown:coxn 使用手册(Markdown) · 安装包:coxn 产品页