In order to know that a buffer represents a remote connection, you can use file-remote-p.
You can read about this function Here
For example, in a shell buffer, (file-remote-p default-directory) will allow you to differentiate between a local shell and a remote shell.
In order to toggle company-mode, you can call the company-mode function with a parameter ...
Doom has its own function set-company-backend! to set the backends:
(defun set-company-backend! (modes &rest backends)
"Prepends BACKENDS (in order) to `company-backends' in MODES.
MODES should be one symbol or a list of them, representing major or minor modes.
This will overwrite backends for MODES on consecutive uses.
If the car of BACKENDS is nil,...
This is a modified version of @chen-bin's answer which uses a wrapper function instead of using advice (avoids interfering with other uses). It also generalizes the syntax checking to allow checking for other kinds of syntax.
(defun company-complete-common-use-context ()
(faces-found (face-at-point nil t))
It turns out the word list needs to be sorted (case insensitive), at least sorting it makes it work for me.
Assuming you use company mode and have a shortcut to activate it.
(global-set-key (kbd "C-SPC") 'company-complete-common)
;; Dictionary for completion.
You can use hippie-expand:
(setq hippie-expand-try-functions-list '(try-expand-line))
(global-set-key (kbd "C-;") 'hippie-expand)
Now C-; should expand to the closest matching line. Repeating the command will get you all the matches.
Finally, if you want a popup menu with the choices listed there are some hacky ways of plugging hippie-expand into company-...
I had the same problem and found out that company-begin-commands was screwed by some configuration I copied from sombody else. The value defines when company completion should be triggered. The default for the value is:
abbrev can abbreviate text. Use a numeric argument to say how many words before point should be taken as the expansion. For example, to abbreviate the sentence "The cat and the mooon." as x, put the point at the end and do
C-u 5 C-x a g x <RET>
The emacs manual (info) for Abbrevs gives the details.