1

I've been struggling for setting ccls in Neovim.

I've ever used clangd for a long time; after following TJ's video and instructions on nvim-lspconfig, it works well.

Now I would like to switch to ccls and the configuration seems doesn't make it work.

  1. I've installed ccls on the system.

    enter image description here

  2. Neovim is aware of ccls while it is running .c files. enter image description here

Note: The operating system is Windows 10 rather than Ubuntu.

But the problem is, as shown in 2., there is no client (i.e., ccls that I expect) attached to the buffer.

It seems that there are more tutorials for setting ccls on coc.nvim than on nvim-lspconfig. But I need the latter.

For now, my nvim-lspconfig configuration is as follows.

local capabilities = require('cmp_nvim_lsp').default_capabilities()
require('lspconfig').ccls.setup{
  capabilities = capabilities,
  on_attach = function()
                print("Hello! C/C++!")  -- To remind me that ccls is attached
                vim.keymap.set('n', 'K', vim.lsp.buf.hover, {buffer = 0})
                vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {buffer = 0})
                vim.keymap.set('n', 'gt', vim.lsp.buf.type_definition, {buffer = 0})
                vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, {buffer = 0})
                vim.keymap.set('n', '<leader>dj', vim.diagnostic.goto_next, {buffer = 0})
                vim.keymap.set('n', '<leader>dk', vim.diagnostic.goto_prev, {buffer = 0})
                vim.keymap.set('n', '<leader>dl', "<cmd>Telescope diagnostic<CR>", {buffer = 0})
                vim.keymap.set('n', '<leader>r', vim.lsp.buf.rename, {buffer = 0}) 
              end,
}

In addition, the environment info

OS: Windows 10

Neovim version:
  NVIM v0.9.1
  Build type: RelWithDebInfo
  LuaJIT 2.1.0-beta3

Plugin manager: Packer

Is there something I missed? Could any one help? Thanks.

1 Answer 1

0

Try adding a .ccls file in the file's directory. ccls looks for a .ccls file or a compile_commands.json file to identify the project root directory. I have just encountered the same problem, and making an empty .ccls file solved the problem for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.