Skip to content

Can't use ccls with ESP32 related projects #961

Open
@Aaron-Uriel-Guzman-Cardoso

Description

Hi, I'm working with on a project, this project uses PlatformIO and is targeted to an ESP32, as a recomendation from this website I installed and compiled ccls version "0.20230717" with the LLVM that Espessif provides in version "16.0.4-20231113". I noticed it worked on simple projects that do not have anything related to PlatformIO or the ESP-IDF but on projects that do have something related to the ESP32, it throws a bunch of errors on the Neovim side.
This is the command that I used to make the compilation:

cmake -H. -Brelease-xtensa -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=rest/of/the/path/llvm-esp-16.0.4-20231113-linux-amd64/esp-clang/

Indexing a project like the hello_world example of the ESP-IDF does not show any problem:

❯ ~/path/to/ccls/release-xtensa/ccls --index=. --init="{\"compilationDatabaseDirectory\": \"build\"}"
13:27:08 ccls           initialize.cc:276 I initialize in directory /home/auriel/Documentos/esp-idf-v5.2/examples/get-started/hello_world with uri file:///home/auriel/Documentos/esp-idf-v5.2/examples/get-started/hello_world/.
13:27:08 ccls           initialize.cc:299 I initializationOptions: {"compilationDatabaseCommand":"","compilationDatabaseDirectory":"build","cache":{"directory":".ccls-cache","format":"binary","hierarchicalPath":false,"retainInMemory":2},"capabilities":{"documentOnTypeFormattingProvider":{"firstTriggerCharacter":"}","moreTriggerCharacter":[]},"foldingRangeProvider":true,"workspace":{"workspaceFolders":{"supported":true,"changeNotifications":true}}},"clang":{"excludeArgs":[],"extraArgs":[],"pathMappings":[],"resourceDir":""},"client":{"diagnosticsRelatedInformation":true,"hierarchicalDocumentSymbolSupport":true,"linkSupport":true,"snippetSupport":true},"codeLens":{"localVariables":true},"completion":{"caseSensitivity":2,"detailedLabel":true,"dropOldRequests":true,"duplicateOptional":true,"filterAndSort":true,"include":{"blacklist":[],"maxPathSize":30,"suffixWhitelist":[".h",".hpp",".hh",".inc"],"whitelist":[]},"maxNum":100,"placeholder":true},"diagnostics":{"blacklist":[],"onChange":1000,"onOpen":0,"onSave":0,"spellChecking":true,"whitelist":[]},"highlight":{"largeFileSize":2097152,"lsRanges":false,"blacklist":[],"whitelist":[]},"index":{"blacklist":[],"comments":2,"initialNoLinkage":false,"initialBlacklist":[],"initialWhitelist":[],"maxInitializerLines":5,"multiVersion":0,"multiVersionBlacklist":[],"multiVersionWhitelist":[],"name":{"suppressUnwrittenScope":false},"onChange":false,"parametersInDeclarations":true,"threads":0,"trackDependency":2,"whitelist":[]},"request":{"timeout":5000},"session":{"maxNum":10},"workspaceSymbol":{"caseSensitivity":1,"maxNum":1000,"sort":true},"xref":{"maxNum":2000}}
13:27:08 ccls           initialize.cc:331 I use -resource-dir=/home/auriel/Documentos/Códigos/llvm-esp-16.0.4-20231113-linux-amd64/esp-clang/lib/clang/16
13:27:08 ccls           initialize.cc:363 I workspace folder: /home/auriel/Documentos/esp-idf-v5.2/examples/get-started/hello_world/
13:27:08 ccls              project.cc:429 I loaded /home/auriel/Documentos/esp-idf-v5.2/examples/get-started/hello_world/build/compile_commands.json
13:27:08 ccls              project.cc:284 I use /home/auriel/Documentos/esp-idf-v5.2/examples/get-started/hello_world/.ccls: %compile_commands.json --target=xtensa-esp32 --gcc-toolchain=/home/auriel/.espressif/tools/xtensa-esp-elf/esp-13.2.0_20230928/xtensa-esp-elf/
13:27:08 ccls           initialize.cc:388 I start 2 indexers
13:27:08 ccls           initialize.cc:396 I dispatch initial index requests
entries:    832
completed:    0/83213:27:08 indexer0         pipeline.cc:386 I delete /home/auriel/Documentos/esp-idf-v5.2/examples/get-started/hello_world/build/project_elf_src_esp32.c
completed:   77/83213:27:09 indexer0         pipeline.cc:386 I delete /home/auriel/Documentos/esp-idf-v5.2/examples/get-started/hello_world/build/x509_crt_bundle.S
completed:  832/832

However the cache directory is empty:

du -hs .ccls-cache/

Neovim

When I open neovim I get a bunch of errors like this:

LSP[ccls]: Error NO_RESULT_CALLBACK_FOUND: {                                                                                                                                              
  error = {
    code = -32603,
    message = "failed to index /home/auriel/Documentos/esp-idf-v5.2/components/xtensa/eri.c"
  },
  id = 1,
  jsonrpc = "2.0"
}

I added the last lines of the log file "/home/user/.local/state/nvim/lsp.log" in this report:
lsp_log.txt

This is the setting that I have on nvim-lspconfig:

    lspconfig["ccls"].setup {
      cmd = { "/home/user/path/ccls/release-xtensa/ccls" },
      init_options = {
        compilationDatabaseDirectory = "build",
        index = {
          threads = 0,
        },
        clang = {
          excludeArgs = { "-frounding-math"}
        },
      },
      capabilities = capabilities,
    }

I noticed that the error "No callback found for server response id 1" is repeated a lot and searching I found this Issue that suggest this is a specific ccls problem.

As a result I don't get any autocompletion, so I thought reporting this could be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions