emacle
2019 年11 月 28 日 02:31
1
org-mode里开启了 yasnippet,company 模式, 以company-yasnippet 为后端,但是company的候选列表不能显示以 <, #, _ 等符号开头的 snippet,无法补全 , 大家是怎么解决的?
查了些 但是没找到解决办法
opened 07:56AM - 26 Nov 15 UTC
closed 11:10PM - 01 Dec 15 UTC
wishlist
I have some snippets which key is `%`, `%%`, `%link_to`, etc.
I use in web-mode … with `.yas-parents` has `rhtml-mode`.
I can expand those yasnippet snippets with `[Tab]`.
But company-yasnippet don’t show candidates after `%`.
Here is the result of command `company-diag`:
```
Emacs 24.5.1 (x86_64-unknown-linux-gnu) of 2015-09-10 on foutrelis
Company 0.9.0-cvs
company-backends: ((company-robe company-web-html company-tern company-css company-files company-keywords company-capf company-yasnippet)
(company-abbrev company-dabbrev))
Used backend: (company-robe company-web-html company-tern company-css company-files company-keywords company-capf company-yasnippet)
Prefix: #("link" 0 1
(block-side t face #1=(web-mode-block-face))
1 2
(block-side t face #1#)
2 3
(block-side t face #1#)
3 4
(block-side t block-end t face #1#))
Completions: none
```
If this is not a problem in company-yasnippet, then how to add this for completing?
company-yasnippet--candidates
just looks for snippets with name that starts with the symbol-at-point, which can’t include snippets with names starting with punctuation.
emacle
2019 年11 月 28 日 07:13
2
保证capf在dabbrev-code前面,比如我的company-backends是
(company-capf company-files company-css
(company-dabbrev-code company-gtags company-etags company-keywords)
company-dabbrev)
前面的组有任何结果则不会用后面的一个/一组。company-css company-clang之类可以放心地加,在应用时会判断当前major-mode。
company补全是以word为单位(而非symbol),这个由当前buffer的major-mode的syntax-table决定,所以:(modify-syntax-entry ?% "w" ahk-mode-syntax-table)
(modify-syntax-entry ?< "w" org-mode-syntax-table)
(modify-syntax-entry ?@ "w" org-mode-syntax-table)
(modify-syntax-entry ?- "w" org-mode-syntax-table)
使用此方式解决 不知道这样做 有没有什么副作用?
会改变forward-word
等的行为,在org这种非programming mode里面应该影响不大。另一个办法是换用ivy/helm来补全。
1 个赞
emacle
2019 年11 月 29 日 07:14
4
ivy/helm 不是侧重于minibuffer里补全命令路径之类的?也能补全这些程序语言的东西吗?不是太懂
这种补全我还是感觉overlay这种方式比较习惯一点
是啊,更好的办法是改/advise company的代码,让它不只补全word这种syntax元素,不过我没试过。我倒是挺想让它改成补全symbol的。