I’d like to only enable company mode for node completions when I type [[
or run completion-at-point
. Recently I got this working, but it’s trying to autocomplete whenever I type anything in Org buffers, which is very distracting. Feels like this should be simple to achieve, but I can’t think of a way of doing it OTOH.
(I’d like company mode to do completion as normal everywhere else, it’s only in Org buffers I don’t want it for anything except node title completions.)
I suggest to first check user option org-roam-complete-everywhere
. It’s probably non-nil for you.
I just set it to nil, but the same thing still occurs.
Then I am afraid I have no idea. My guess is something outside Org-roam is interfering in your Emacs. I’d have a look at user option org-roam-completion-functions
and see what functions are set there, and edebug them to see what’s happening in the runtime.
Just in case, you may have abbrev completion happening for your company, which has nothing to do with Org-roam…
It turns out I had org-roam-complete-everywhere
in my org-roam-completion-functions
, I had only set org-roam-completion-everywhere
to nil before. What is the difference between these 2 things?
Tried removing org-roam-complete-everywhere
from org-roam-completion-functions
but it’s still staying there for some reason.
I have company-dabbrev
in my company-backends
but not company-abbrev
, which is I think what you are referring to.
These are two different things; they happen to have the same name. One is a function and the other is a customizing variable. The docstring of the function org-roam-complete-everywhere
clarifies how they work together:
Complete symbol at point as a link completion to an Org-roam node.
This is a ‘completion-at-point’ function, and is active when
‘org-roam-completion-everywhere’ is non-nil.
In order to solve your problem, I suggest you read Company’s documentation a bit more. I don’t use Company but I think your configuration of company-backends
needs adjustment. And I suspect having company-dabbrev
or company-dabbrev-code
in company-backends
causes this “aggressive” completion in your Org mode buffers.
You should be able to test the idea by doing something like this from this part of the manual.
(setq company-backends '((company-capf company-dabbrev-code)))
Or even
(setq company-backends '((company-capf)))
Org-roam’s completion uses a completion-at-point
function (typically abbreviated as “capf”, completion at point function), as noted in the docstring of org-roam-complete-everywhere
quoted above.
Once you know what company-backends
set up works for your Org buffers with Org-roam, then it will be simply a matter of setting it locally for Org buffers via org-mode-hook
so as not to affect other major modes.
I hope this helps.
Thank you, (setq-local company-backends '((company-capf)))
upon org-mode-hook
completely solves my problem. I will look at the other things you’ve sent too.