2

I am trying to configure a RPi4-based programming environment for embedded systems programming.

I chose neovim as a primary editor due to ability to work with both "desktop" (with monitor and keyboard attached) and headless (remote, with ssh connection only) modes + availability of many modern IDE features, but I still learning how to configure it and how to be productive with it.

I am trying to use packer.nvim as nvim's plugin manager and lsp-zero.nvim as some sort of meta-plugin which brings together few other autocomplete-related plugins, such as (nvim-cmp, nvim-lspconfig, mason.nvim) and enables autocompletion.

This bundle allows to manage language servers easily, for example, in order to install C++ autocomplete engine one just needs to run :LspInstall clangd command.

The problem is that clangd seems to be unavailable for aarch64 in this setup (the error message is "The current platform is unsupported"), however I can install clangd into the system using snap package manager, so I am sure there must be some way to make externally installed clangd server working with neovim (perhaps in a bit more hands on way), but everything I tried so far didn't work.

I configured clangd in .lua files:

local cfg = require('lspconfig')
cfg.clangd.setup({})

Here is output of :LspLog when trying editing C++ source code:

[START][2023-07-09 18:19:09] LSP logging initiated
[INFO][2023-07-09 18:19:09] .../vim/lsp/rpc.lua:662 "Starting RPC client"   {  args = {},  cmd = "/snap/bin/clangd",  extra = {    cwd = "/home/alexsavo/t/cproj"  }}
[DEBUG][2023-07-09 18:19:09] .../vim/lsp/rpc.lua:284    "rpc.send"  {  id = 1,  jsonrpc = "2.0",  method = "initialize",  params = {    capabilities = {      offsetEncoding = { "utf-8", "utf-16" },      textDocument = {        callHierarchy = {          dynamicRegistration = false        },        codeAction = {          codeActionLiteralSupport = {            codeActionKind = {              valueSet = { "", "quickfix", "refactor", "refactor.extract", "refactor.inline", "refactor.rewrite", "source", "source.organizeImports" }            }          },          dataSupport = true,          dynamicRegistration = false,          isPreferredSupport = true,          resolveSupport = {            properties = { "edit" }          }        },        completion = {          completionItem = {            commitCharactersSupport = true,            deprecatedSupport = true,            documentationFormat = { "markdown", "plaintext" },            insertReplaceSupport = true,            insertTextModeSupport = {              valueSet = { 1, 2 }            },            labelDetailsSupport = true,            preselectSupport = true,            resolveSupport = {              properties = { "documentation", "detail", "additionalTextEdits", "sortText", "filterText", "insertText", "textEdit", "insertTextFormat", "insertTextMode" }            },            snippetSupport = true,            tagSupport = {              valueSet = { 1 }            }          },          completionItemKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 }          },          completionList = {            itemDefaults = { "commitCharacters", "editRange", "insertTextFormat", "insertTextMode", "data" }          },          contextSupport = true,          dynamicRegistration = false,          editsNearCursor = true,          insertTextMode = 1        },        declaration = {          linkSupport = true        },        definition = {          linkSupport = true        },        documentHighlight = {          dynamicRegistration = false        },        documentSymbol = {          dynamicRegistration = false,          hierarchicalDocumentSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }          }        },        hover = {          contentFormat = { "markdown", "plaintext" },          dynamicRegistration = false        },        implementation = {          linkSupport = true        },        publishDiagnostics = {          relatedInformation = true,          tagSupport = {            valueSet = { 1, 2 }          }        },        references = {          dynamicRegistration = false        },        rename = {          dynamicRegistration = false,          prepareSupport = true        },        semanticTokens = {          augmentsSyntaxTokens = true,          dynamicRegistration = false,          formats = { "relative" },          multilineTokenSupport = false,          overlappingTokenSupport = true,          requests = {            full = {              delta = true            },            range = false          },          serverCancelSupport = false,          tokenModifiers = { "declaration", "definition", "readonly", "static", "deprecated", "abstract", "async", "modification", "documentation", "defaultLibrary" },          tokenTypes = { "namespace", "type", "class", "enum", "interface", "struct", "typeParameter", "parameter", "variable", "property", "enumMember", "event", "function", "method", "macro", "keyword", "modifier", "comment", "string", "number", "regexp", "operator", "decorator" }        },        signatureHelp = {          dynamicRegistration = false,          signatureInformation = {            activeParameterSupport = true,            documentationFormat = { "markdown", "plaintext" },            parameterInformation = {              labelOffsetSupport = true            }          }        },        synchronization = {          didSave = true,          dynamicRegistration = false,          willSave = true,          willSaveWaitUntil = true        },        typeDefinition = {          linkSupport = true        }      },      window = {        showDocument = {          support = true        },        showMessage = {          messageActionItem = {            additionalPropertiesSupport = false          }        },        workDoneProgress = true      },      workspace = {        applyEdit = true,        configuration = true,        didChangeWatchedFiles = {          dynamicRegistration = false,          relativePatternSupport = true        },        semanticTokens = {          refreshSupport = true        },        symbol = {          dynamicRegistration = false,          hierarchicalWorkspaceSymbolSupport = true,          symbolKind = {            valueSet = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26 }          }        },        workspaceEdit = {          resourceOperations = { "rename", "create", "delete" }        },        workspaceFolders = true      }    },    clientInfo = {      name = "Neovim",      version = "0.9.1"    },    initializationOptions = vim.empty_dict(),    processId = 2218712,    rootPath = "/home/alexsavo/t/cproj",    rootUri = "file:///home/alexsavo/t/cproj",    trace = "off",    workspaceFolders = { {        name = "/home/alexsavo/t/cproj",        uri = "file:///home/alexsavo/t/cproj"      } }  }}

but no further attempts to call the autosuggestions server.

Here is :LspInfo output:

enter image description here

  • 1
    What does `clangd -version` say? – svlasov Jul 10 '23 at 12:15
  • I think it is 10.0.0. Is it too old? `clangd --version` hangs: clangd starts without producing any output. I tried `snap info clangd` and got the following output `name: clangd summary: Language Server Protocol implementation for C/C++ IDEs ... store-url: https://snapcraft.io/clangd ... Clangd is an implementation of the Language Server Protocol leveraging Clang. ... commands: - clangd snap-id: Nw2SyqKbD2SvyuOu5fFAxXJ1sjeOw8zx ... latest/edge: 10.0.0+git2c4ca68 2020-03-31 (2520) 8MB classic installed: 10.0.0+git2c4ca68 (2520) 8MB classic` – Alexandr Savochkin Jul 10 '23 at 18:46
  • 1
    `clangd -version` should report which platform it is built for. If it just silently hangs, probably that's why neovim doesn't report any errors. – svlasov Jul 10 '23 at 22:12
  • Thanks! This seems to be a reason why it didn't work. The clangd binary available via snap seems to be incompatible and/or buggy. I rebuilt clangd from the source code and made it seacheable via PATH and now autocompletion works. – Alexandr Savochkin Jul 12 '23 at 06:35

0 Answers0