p00f / clangd_extensions.nvim

Clangd's off-spec features for neovim's LSP client. Use https://sr.ht/~p00f/clangd_extensions.nvim instead
MIT License
448 stars 16 forks source link

Installation with plug? #21

Closed at8i closed 2 years ago

at8i commented 2 years ago

I have installed your plugin using plug manger in both Mac and arch but it is not working. The only problem would be plug installation. Do i need to install it with packer?

p00f commented 2 years ago

no, just ensure you are setting up clangd_extensions after Plug#end just like any other plugin

at8i commented 2 years ago
"lspconfig
Plug 'neovim/nvim-lspconfig'
Plug 'p00f/clangd_extensions.nvim'

function! DoRemote(arg)
  UpdateRemotePlugs
endfunction
call plug#end()

luafile ~/.config/nvim/lsp.lua

Lsp.lua:

-- Mappings.
local opts = { noremap=true, silent=true }
vim.keymap.set('n', '<space>e', vim.diagnostic.open_float, opts)
vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, opts)
vim.keymap.set('n', ']d', vim.diagnostic.goto_next, opts)
vim.keymap.set('n', '<space>q', vim.diagnostic.setloclist, opts)

local on_attach = function(client, bufnr)
  vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
  -- Mappings.
  local bufopts = { noremap=true, silent=true, buffer=bufnr }
  vim.keymap.set('n', 'gD', vim.lsp.buf.declaration, bufopts)
  vim.keymap.set('n', 'gd', vim.lsp.buf.definition, bufopts)
  vim.keymap.set('n', 'K', vim.lsp.buf.hover, bufopts)
  vim.keymap.set('n', 'gi', vim.lsp.buf.implementation, bufopts)
  vim.keymap.set('n', '<C-k>', vim.lsp.buf.signature_help, bufopts)
  vim.keymap.set('n', '<space>wa', vim.lsp.buf.add_workspace_folder, bufopts)
  vim.keymap.set('n', '<space>wr', vim.lsp.buf.remove_workspace_folder, bufopts)
  vim.keymap.set('n', '<space>wl', function()
    print(vim.inspect(vim.lsp.buf.list_workspace_folders()))
  end, bufopts)
  vim.keymap.set('n', '<space>D', vim.lsp.buf.type_definition, bufopts)
  vim.keymap.set('n', '<space>rn', vim.lsp.buf.rename, bufopts)
  vim.keymap.set('n', '<space>ca', vim.lsp.buf.code_action, bufopts)
  vim.keymap.set('n', 'gr', vim.lsp.buf.references, bufopts)
  vim.keymap.set('n', '<space>f', vim.lsp.buf.formatting, bufopts)
end

local lsp_flags = {
  debounce_text_changes = 150,
}

require("clangd_extensions").setup {
    server = {
    on_attach = on_attach,
    flags = lsp_flags,
    },
}

At the top you can see the end of my Plug and as you can see I configure the plugin afterwards. But the problem is after installing the plugin I don't have access to your plugin's commands in my Command-line. for example when I enter ':Clangd' the only command available is 'ClandSwtitchSourceHeader' which comes from Lsp. Am I doing something wrong? I have many plugins working without any problems. I have looked everywhere for reasons why a plugin commands cannot be recognised before coming here because this is really weird.

p00f commented 2 years ago

the config looks correct

p00f commented 2 years ago

Do you get inlay hints?

at8i commented 2 years ago

No inlay hints. But I am pretty sure it is something from my side because it happens in MacOS and Arch. Clangd attaches to the buffer in LspInfo. My only guess is that I don't have standard Lua file system.

I am just trying Lua plugins to see how they work so I just used luafile from init.vim Can it be the cause?

Should I create Lua folder and namespace and etc or is it something else?

at8i commented 2 years ago

I installed support for node.js and it fixed everything. npm install -g neovim and it worked.

p00f commented 2 years ago

That's not relevant, I don't even have nodejs...

image

Anyway, closing since the issue is fixed