Corfu 补全的使用姿势

Corfu 现在可以通过 M-Space 来启动在自动补全开启的情况更好的使用 orderless,这样鱼和熊掌可以兼得了😄。

可以直接用官方推荐的自动补全配置

更新:
要在 eglot 下使用 orderless,因为 eglot 会更改completion-category-defaults 这个变量。 需要通过修改 completion-category-overrides 改为 orderless

(use-package orderless
  :demand t
  :config
  (setq completion-styles '(orderless flex)
        completion-category-overrides '((eglot (styles . (orderless flex))))))

详细内容可以参考这个issue: How to make corfu + orderless work well with eglot + clangd · Issue #136 · minad/corfu · GitHub

5 个赞

最近给 Corfu 加了 kind-icon,通过 svg-lib 启用了新的图标。可是这些图标不是一次性全部下载下来,而是第一次使用到才会到 GitHub 去下载,速度很慢,非常影响使用体验。

我这里手动去上游仓库把所有的图标下载后,整理到一起,需要的朋友从我的个人Github仓库直接下载然后拷贝到 .emacs.d/.cache/svg-lib/ 文件夹下即可。

同时,通过 kind-icon ,用户可以替换所有的图标为自己喜欢的图标,更多的图标可以在Templarian/MaterialDesign-SVG 下载

5 个赞

OT 一下,这是啥字体。

Bookerly, 亚马逊专门为 Kindle 开发的字体,比较适合电子设备。

我主要在 org-mode ,Info-mode 看文档,gnus 看邮件列表,以及 mode-line 用这个变宽字体,很舒服 :grinning_face_with_smiling_eyes:

Corfu 的用户主要一下,如果把 延迟改为 0 以及前缀改为 1,在这种情况下会和 flyspell-mode 冲突,造成补全列表的候选不全。如果喜欢这种即时显示补全窗口的话,建议手动运行 flyspell 进行拼写检查。

比如这种设置:

(use-package corfu
  :demand t
  :custom
  (corfu-auto t)
  (corfu-max-width 110)
  (corfu-auto-delay 0.0)
  (corfu-auto-prefix 1)
  (corfu-preview-current nil)
  (corfu-echo-documentation t)
  :bind (:map corfu-map
              ("C-d" . corfu-info-documentation)
              ("M-." . corfu-info-location))
  :init
  (global-corfu-mode))

我在 macOS 上开了 flyspell 也不影响,在 Windows 下就有影响,估计是因为 Windows 下性能较差。

参考这个 issue:

1 个赞

Corfu 可以通过 corfu-popup 这个包在终端里面使用了。但只支持基于文本的 kind-icon 图标

这是在 iterm2 中的效果:

8 个赞

corfu 看着很强大呀。

Corfu 在除了在后端方面没 Company 那么丰富,其他方面都挺不错的,值得一试。

Company 相当于大而全,Corfu 是小而美,自由组合 :smile:

  1. 因为用的是 childframe 来显示,弹窗可以越过其他窗口。Company 的弹窗是overlay 实现,只能在窗口内显示。
  2. 通过 kind-icon 支持漂亮的 UI 图标。
  3. 通过 cape 支持更多的后端,甚至可以直接用 company 的后端。
  4. 配合 orderless 补全体验和 minibuffer 中的 vertico 保持一致。
5 个赞

哈哈哈, 感觉不错,等我把 lsp-bridge 弄完了尝试一下。

1 个赞

好耶!tty党无比开心 :smiling_face_with_three_hearts:

1 个赞

看起来很不错。说到这个,我发现 kind-icon 即使提前在 .cache/svg-lib 下载了图标,他也会从 github 下载。最难受的是,他会卡住 emacs。。就算 C-g 也没用

不会啊,本地有图标是不会再去下载的。那说明你本地的图标还没下载全。 你可以试试将我这个仓库的图标放到 ~/.emacs.d/.cache/svg-lib 目录下,这里都是全了的。

我就是从你这下载的 :joy:

那不应该啊,一共是32个图标,只要名字对就行,对应这里设置的名字:

你是在什么mode下输入哪个关键字就会提示下载图标?

emacs-lisp-mode,

README.org
material_application-braces-outline.svg
material_application-brackets-outline.svg
material_application-parentheses-outline.svg
material_circle-half-full.svg
material_code-braces.svg
material_code-brackets.svg
material_cog.svg
material_crosshairs-question.svg
material_file-code-outline.svg
material_file-document-outline.svg
material_folder.svg
material_format-list-bulleted-square.svg
material_format-list-bulleted-type.svg
material_format-list-checks.svg
material_function-variant.svg
material_function.svg
material_key-variant.svg
material_lambda.svg
material_lightning-bolt-outline.svg
material_lock-remove-outline.svg
material_note-text-outline.svg
material_numeric.svg
material_palette.svg
material_plus-circle-outline.svg
material_plus-minus.svg
material_ruler-square.svg
material_script-text-outline.svg
material_sticker-text-outline.svg
material_table-column-plus-after.svg
material_variable-box.svg
material_variable.svg
material_view-grid-plus-outline.svg

是的,我已经去掉 kind-icon 了

发现这个问题后,我也暂时去掉了 kind-icon,他的功能也不是很要紧。

我确认过了,图标名字是没问题的,我用的跟你的一样。不会再去联网。

或者你可以设置 (setq kind-icon-use-icons nil) ,这样就会用基于文本的图标,不需要下载的。

可以给 kind-icon 提个 issue,建议加一个安装 icions 的命令,一次性下载完。就不会每次都自动去下了。

嗯,好的,谢谢。我下午再试试 kind-icon

也可以试试这个命令: M-x kind-icon-reset-cache,可以重置缓存。(切换主题也要执行一次,主题的图标才会刷新)