This is something that's vexed me for a quite a while, but has got a lot worse now that I'm using lsp-mode. In fact, I'm not sure if it is a bug in lsp-mode, Emacs or intended behavior:

Say that you're using Emacs in the terminal and using the Emacs daemon/client protocol, start the Emacs daemon with:

emacs --daemon=test -Q --load=test.el

Where test.el contains:

(require 'lsp-mode)
(add-hook 'c-mode-hook      #'lsp)
(add-hook 'c++-mode-hook    #'lsp)

Now, try to open a new C/C++ file somewhere:

emacsclient -s test main.cpp

Emacs will now refuse to open, due to the dialogue created lsp-mode will be created before the emacsclient frame has opened.

The only way that I've found to workaround this is is to forcefully close the frame with Ctrl-C and try again with: emacsclient -s test . and then navigate to the file inside the client instead.

So, is this intended behavior, or some kind of bug? And is there any kind of workaround one could use? Given that I still want to have lsp enabled automatically in C/C++ files.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.