[英]Is there a way to automatically add a whitespace upon completion in company-mode?
I use company-mode a lot on natural language completion with the local dictionary. 在本地字典的自然语言完成方面,我经常使用公司模式。 I am wondering if there is a way to automatically add a whitespace upon completion.
我想知道是否有一种方法可以在完成时自动添加空格。
For example, currently when I type abili
and select the first candidate ability
, my insert point is right after y|
例如,当前当我键入
abili
并选择第一个候选ability
,我的插入点就在y|
之后y|
. 。 Is there a way that the company-mode can add a space so my insert point is after
y |
有没有一种方式,公司模式可以添加一个空格,以便我的插入点在
y |
之后y |
? ?
I could not find any related information on this but this issue mentioned a space is added after completion in the Eshell mode. 我找不到与此相关的任何信息,但是此问题提到在Eshell模式下完成后会添加一个空格。 Apparently this is exactly what I want.
显然这正是我想要的。
The issue mentioned the function completion-at-point
. 问题提到了功能
completion-at-point
。 Is there a way that I can change or have a function that I can override the current completion mechanism? 有没有一种方法可以更改或具有可以覆盖当前完成机制的功能?
Thanks! 谢谢! I'd really appreciate any suggestions.
我真的很感谢任何建议。
You could add a hook to company-after-completion-hook
that would be called after completion with any of your company backends, eg. 您可以
company-after-completion-hook
挂钩中添加一个挂钩, company-after-completion-hook
将在您的任何公司后端完成后被调用,例如。
(defun my-company-after-completion-hook (&rest _ignored)
;; this would be called with the completion candidate, so you could
;; modify it to insert spaces based on the candidate
(just-one-space))
;; or setq-local in a mode hook, eg. for text-mode/org-mode or wherever you are
;; completing with dictionary words
(setq company-after-completion-hook #'my-company-after-completion-hook)
If you only wanted to add space after completing with a specific backend you could see if the backend already implements a post-completion
action, otherwise you could probably advise it. 如果您只想在完成特定的后端操作后增加空间,则可以查看后端是否已经实现了
post-completion
操作,否则您可能会建议这样做。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.