doomemacs / doomemacs

An Emacs framework for the stubborn martian hacker
MIT License
19.61k stars 3.07k forks source link

Can't center with ctrl-l when editing C code with LSP. #5713

Open verhovsky opened 3 years ago

verhovsky commented 3 years ago

What did you expect to happen?

When I press ctrl-l while editing a C file, it should move around the file so that the line my cursor is currently on is in the middle of the screen.

What actually happened?

I see this error:

Debugger entered--Lisp error: (error "method not found")
  signal(error ("method not found"))
  error("method not found")
  lsp-request("$ccls/navigate" (:textDocument (:uri "file:///Users/space/code/curl/src/tool_operate.c") :position (:line 733 :character 39) :direction "D"))
  lsp-find-custom("$ccls/navigate" (:direction "D"))
  ccls-navigate("D")
  (closure (t) (&rest _) (interactive) (ccls-navigate "D"))()
  #<subr funcall-interactively>((closure (t) (&rest _) (interactive) (ccls-navigate "D")))
  apply(#<subr funcall-interactively> (closure (t) (&rest _) (interactive) (ccls-navigate "D")))
  funcall-interactively((closure (t) (&rest _) (interactive) (ccls-navigate "D")))
  #<subr call-interactively>((closure (t) (&rest _) (interactive) (ccls-navigate "D")) nil nil)
  apply(#<subr call-interactively> ((closure (t) (&rest _) (interactive) (ccls-navigate "D")) nil nil))
  explain-pause--wrap-call-interactively(#<subr call-interactively> (closure (t) (&rest _) (interactive) (ccls-navigate "D")) nil nil)
  apply(explain-pause--wrap-call-interactively #<subr call-interactively> ((closure (t) (&rest _) (interactive) (ccls-navigate "D")) nil nil))
  call-interactively((closure (t) (&rest _) (interactive) (ccls-navigate "D")) nil nil)
  command-execute((closure (t) (&rest _) (interactive) (ccls-navigate "D")))

Steps to reproduce

  1. Put this in your init.el:
(doom! :input
       lsp
       (cc +lsp)                ; C/C++/Obj-C madness
  1. Create/open a C file like myfile.c and write some code in it (you can add a bunch of empty lines to make it longer)
int main(void) {
}

press Ctrl-l

System Information

https://pastebin.com/Pa0aFHCr

ccruquan commented 2 years ago

https://github.com/doomemacs/doomemacs/blob/9d4d5b756a8598c4b5c842e9f1f33148af2af8fd/modules/lang/cc/config.el#L250

Ctrl-l rebind in c/c++ mode after ccls load

dolmens commented 1 year ago

How to disable ccls, it rebinds "C-h", "C-k" in normal state, which is inconvenient.

huxinbang commented 1 year ago

I tried to rebind it back inside 'with-eval-after-load' but failed.

Finally I used this for my temporary local fix, might be a bad solution, but it works:

diff --git a/modules/lang/cc/config.el b/modules/lang/cc/config.el
index 788903f0..1cb0af57 100644
--- a/modules/lang/cc/config.el
+++ b/modules/lang/cc/config.el
@@ -247,7 +247,7 @@
         :n "C-h" (cmd! (ccls-navigate "U"))
         :n "C-j" (cmd! (ccls-navigate "R"))
         :n "C-k" (cmd! (ccls-navigate "L"))
-        :n "C-l" (cmd! (ccls-navigate "D"))
+        ;; :n "C-l" (cmd! (ccls-navigate "D"))
         (:localleader
          :desc "Preprocess file"        "lp" #'ccls-preprocess-file
          :desc "Reload cache & CCLS"    "lf" #'ccls-reload)