syl20bnr / spacemacs

A community-driven Emacs distribution - The best editor is neither Emacs nor Vim, it's Emacs *and* Vim!
http://spacemacs.org
GNU General Public License v3.0
23.64k stars 4.89k forks source link

[c-c++] There is no command under 'compile' leader key. #16504

Closed zongtaowang closed 2 days ago

zongtaowang commented 1 month ago

Description :octocat:

[c-c++] layer the compile command is not defined

Reproduction guide :beetle:

Observed behaviour: :eyes: :broken_heart: There is no command under "compile" leader key Expected behaviour: :heart: :smile: I think it should show a pop window that lists the candidate command for compile the test.c file, and then another pop up windows to run the compiled file.

System Info :computer:

Backtrace :paw_prints:

no
smile13241324 commented 1 month ago

Please confirm that your lsp environment is properly loaded and your lsp server is connected.

This is when you enter "," you should see the which key window.

If not there is an issue in loading your config and you have to check your message buffer for errors.

zongtaowang commented 1 month ago

Please confirm that your lsp environment is properly loaded and your lsp server is connected.

This is when you enter "," you should see the which key window.

If not there is an issue in loading your config and you have to check your message buffer for errors.

Thank you for your suggestion. I believe that the lsp environment has been properly loaded. I am able to utilize other lsp commands. For instance, by typing ,=b, I can successfully run lsp-format-buffer command. Additionally, I have inspected the message buffer and found no errors either. By the way, what is displayed when you type ,c? In my situation, it shows the key window, but there is no command under the 'compile' leader key.

smile13241324 commented 1 week ago

This seems to be working for me. When I do SPC c I am seeing cmake-ide-compile. Here is my config:

     (c-c++ :variables
            c-c++-default-mode-for-headers 'c++-mode
            c-c++-backend 'lsp-clangd
            c-c++-lsp-enable-semantic-highlight 'rainbow
            c++-enable-organize-includes-on-save t
            c-c++-enable-clang-format-on-save t
            c-c++-adopt-subprojects t)

I have used this simple c file for testing:

#include <stdio.h>
#include <stdlib.h>

int main(void) {
  char buffer[5];
  FILE *fp = fopen("myfile", "rb");

  if (fp == NULL) {
    perror("Failed to open file \"myfile\"");
    return EXIT_FAILURE;
  }

  if (fread(buffer, 1, 5, fp) < 5) {
    fputs("An error occurred while reading the file.\n", stderr);
    return EXIT_FAILURE;
  }

  fclose(fp);

  printf("The bytes read were: ");
  for (int i = 0; i < 5; ++i) {
    printf("%02X ", buffer[i]);
  }
  putchar('\n');

  return EXIT_SUCCESS;
}

I am also running clangd as lsp server.

Is there an error message in your message buffer?