abingham / emacs-ycmd

Emacs client for ycmd, the code completion system.
MIT License
384 stars 46 forks source link

ycmd does not work with C/C++ tramp files #482

Open Mafeuser opened 5 years ago

Mafeuser commented 5 years ago

I realize it is non-trivial task to provide support for tramp within ycmd, but the problem is emacs freezes and works very unstable when C/C++ remote buffer is opened, thus I request for ignoring ycmd activity on remote C/C++ files

regards

abingham commented 5 years ago

This is related to (but different from) #241.

abingham commented 5 years ago

I was seeing some similar problems a while back, and I added something like this to my emacs configuration:

(unless (tramp-tramp-file-p (buffer-file-name (current-buffer)))
    (ycmd-mode))

Basically, it says "don't go into ycmd-mode if the file appears to be accessed via tramp". I think this was in my python-mode-hook, but you could add it to c++-mode-hook or wherever is most appropriate.

Maybe try this and let me know if it works for you.

Mafeuser commented 5 years ago

I went this way, it works thanks

abingham commented 5 years ago

Can I close this?

Alexander-Shukaev commented 5 years ago

I believe the correct solution is to add

(unless (file-remote-p default-directory)
  (ycmd-mode)))

to ycmd--maybe-enable-mode until #241 is resolved in which case there would be a defcustom to toggle tramp support and avoid the above condition.

CDitzel commented 5 years ago

can you elaborate on this please? How would one use the above snippet to prevent ycmd to kick in when tramp is used?

Alexander-Shukaev commented 5 years ago

My point was that the snippet above should be added upstream, while if you want an immediate workaround with the same effect, you can do:

  (define-advice ycmd--maybe-enable-mode
      (:around (function &rest ...) ycmd--maybe-enable-mode/:around)
    (unless (file-remote-p default-directory)
      (apply function ...)))
Alexander-Shukaev commented 5 years ago

It will simply not turn on ycmd-mode in the current buffer by default if it detects that the buffer is visiting a remote file.