-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lspconfig default_capabilities not working #42
Comments
|
Oh sorry, that was a typo in github, not in my actual file. I still get the same error. |
--Tokyo Night setup
vim.cmd([[
set number
set tabstop=4
set shiftwidth=4
set expandtab
set clipboard=unnamedplus
call plug#begin()
Plug 'nvim-lua/plenary.nvim'
Plug 'https://github.com/vim-airline/vim-airline'
Plug 'preservim/nerdtree'
Plug 'dracula/vim',{'name':'dracula'}
Plug 'nvim-telescope/telescope.nvim'
Plug 'kyazdani42/nvim-web-devicons'
Plug 'morhetz/gruvbox'
Plug 'antoinemadec/FixCursorHold.nvim'
Plug 'neovim/nvim-lspconfig'
Plug 'nvim-treesitter/nvim-treesitter'
Plug 'iamcco/markdown-preview.nvim', { 'do': 'cd app && yarn install' }
Plug 'folke/tokyonight.nvim', { 'branch': 'main' }
Plug 'm4xshen/autoclose.nvim'
Plug 'https://www.github.com/hrsh7th/cmp-nvim-lsp'
Plug 'https://github.com/hrsh7th/cmp-nvim-lsp-signature-help'
Plug 'https://www.github.com/hrsh7th/cmp-buffer'
Plug 'https://www.github.com/hrsh7th/cmp-path'
Plug 'https://www.github.com/hrsh7th/cmp-cmdline'
Plug 'https://www.github.com/hrsh7th/nvim-cmp'
call plug#end()
nnoremap <leader>n :NERDTreeFocus<CR>
nnoremap <C-n> :NERDTree<CR>
nnoremap <C-t> :NERDTreeToggle<CR>
nnoremap <C-f> :NERDTreeFind<CR>
autocmd VimEnter * NERDTree
map <c-z> <nop>
function! RunCppFile(filename, filedir)
let compile = 'g++ ' . a:filename . ' -o ' . a:filedir . '/a.exe && ' . a:filedir . "/a.exe"
:terminal
:startinsert
call feedkeys(compile)
let key = nvim_replace_termcodes("<CR>", v:true, v:false, v:true)
call nvim_feedkeys(key, 'm', v:false)
endfunction
nnoremap <C-L> :call RunCppFile(expand("%:p"), expand("%:p:h"))<CR>
tnoremap <Esc> <C-\><C-n>:q <CR>
map <C-q> :terminal <CR>
]])
--Colorscheme setup
require("tokyonight").setup({
style="storm",
transparent=true,
terminal_colors = true
})
vim.cmd[[colorscheme tokyonight]]
--Telescope mappings
local opts = {noremap=true,silent=false}
vim.api.nvim_set_keymap('n','ff','<cmd>Telescope find_files<CR>',opts)
vim.api.nvim_set_keymap('n','fg','<cmd>Telescope live_grep<CR>',opts)
require'nvim-treesitter.configs'.setup{
highlight={
enable=true
}
}
require'lspconfig'.pyright.setup{}
require'lspconfig'.gdscript.setup{}
-- Mappings.
-- See `:help vim.diagnostic.*` for documentation on any of the below functions
local opts = { noremap=true, silent=true }
vim.api.nvim_set_keymap('n', '<space>e', '<cmd>lua vim.diagnostic.open_float()<CR>', opts)
vim.api.nvim_set_keymap('n', '[d', '<cmd>lua vim.diagnostic.goto_prev()<CR>', opts)
vim.api.nvim_set_keymap('n', ']d', '<cmd>lua vim.diagnostic.goto_next()<CR>', opts)
vim.api.nvim_set_keymap('n', '<space>q', '<cmd>lua vim.diagnostic.setloclist()<CR>', opts)
-- Use an on_attach function to only map the following keys
-- after the language server attaches to the current buffer
local on_attach = function(client, bufnr)
-- Enable completion triggered by <c-x><c-o>
vim.api.nvim_buf_set_option(bufnr, 'omnifunc', 'v:lua.vim.lsp.omnifunc')
-- Mappings.
-- See `:help vim.lsp.*` for documentation on any of the below functions
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gD', '<cmd>lua vim.lsp.buf.declaration()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gd', '<cmd>lua vim.lsp.buf.definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'K', '<cmd>lua vim.lsp.buf.hover()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gi', '<cmd>lua vim.lsp.buf.implementation()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<C-k>', '<cmd>lua vim.lsp.buf.signature_help()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wa', '<cmd>lua vim.lsp.buf.add_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wr', '<cmd>lua vim.lsp.buf.remove_workspace_folder()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>wl', '<cmd>lua print(vim.inspect(vim.lsp.buf.list_workspace_folders()))<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>D', '<cmd>lua vim.lsp.buf.type_definition()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>rn', '<cmd>lua vim.lsp.buf.rename()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>ca', '<cmd>lua vim.lsp.buf.code_action()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', 'gr', '<cmd>lua vim.lsp.buf.references()<CR>', opts)
vim.api.nvim_buf_set_keymap(bufnr, 'n', '<space>f', '<cmd>lua vim.lsp.buf.formatting()<CR>', opts)
end
-- Use a loop to conveniently call 'setup' on multiple servers and
-- map buffer local keybindings when the language server attaches
local servers = { 'pyright', 'rust_analyzer', 'clangd', 'gdscript' }
for _, lsp in pairs(servers) do
require('lspconfig')[lsp].setup {
on_attach = on_attach,
flags = {
-- This will be the default in neovim 0.7+
debounce_text_changes = 150,
}
}
end
local cmp = require'cmp'
cmp.setup({
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
vim.fn["vsnip#anonymous"](args.body) -- For `vsnip` users.
-- require('luasnip').lsp_expand(args.body) -- For `luasnip` users.
-- require('snippy').expand_snippet(args.body) -- For `snippy` users.
-- vim.fn["UltiSnips#Anon"](args.body) -- For `ultisnips` users.
end,
},
window = {
-- completion = cmp.config.window.bordered(),
-- documentation = cmp.config.window.bordered(),
},
mapping = cmp.mapping.preset.insert({
['<C-b>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.complete(),
['<C-e>'] = cmp.mapping.abort(),
['<CR>'] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
}),
sources = cmp.config.sources({
{ name = 'nvim_lsp' },
{ name = 'vsnip' }, -- For vsnip users.
-- { name = 'luasnip' }, -- For luasnip users.
-- { name = 'ultisnips' }, -- For ultisnips users.
-- { name = 'snippy' }, -- For snippy users.
}, {
{ name = 'buffer' },
})
})
-- Set configuration for specific filetype.
cmp.setup.filetype('gitcommit', {
sources = cmp.config.sources({
{ name = 'cmp_git' }, -- You can specify the `cmp_git` source if you were installed it.
}, {
{ name = 'buffer' },
})
})
-- Use buffer source for `/` and `?` (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline({ '/', '?' }, {
mapping = cmp.mapping.preset.cmdline(),
sources = {
{ name = 'buffer' }
}
})
-- Use cmdline & path source for ':' (if you enabled `native_menu`, this won't work anymore).
cmp.setup.cmdline(':', {
mapping = cmp.mapping.preset.cmdline(),
sources = cmp.config.sources({
{ name = 'path' }
}, {
{ name = 'cmdline' }
})
})
-- Set up lspconfig.
local capabilities = require('cmp_nvim_lsp').default_capabilities()
-- Replace <YOUR_LSP_SERVER> with each lsp server you've enabled.
require('lspconfig')['clangd'].setup {
capabilities = capabilities
}
require'cmp'.setup {
sources = {
{ name = 'nvim_lsp_signature_help' }
}
} I pasted my full |
This works for me: lsp_config.util.default_config =
vim.tbl_deep_extend('force', lsp_config.util.default_config, {
capabilities = capabilities,
}) |
jacobmischka
added a commit
to jacobmischka/dotfiles
that referenced
this issue
Dec 2, 2022
Might need to udpate default_capabilities to extend instead of overwrite hrsh7th/cmp-nvim-lsp#42 (comment)
wookayin
added a commit
to wookayin/cmp-nvim-lsp
that referenced
this issue
Nov 16, 2023
Using `require('cmp_nvim_lsp').default_capabilities()` alone will be not enough. We have to merge with the default LSP capabilities producced by `vim.lsp.protocol.make_client_capabilities()`. See hrsh7th#42 and hrsh7th#44.
deathmaz
added a commit
to deathmaz/dotfiles
that referenced
this issue
Nov 20, 2023
hrsh7th
pushed a commit
that referenced
this issue
Dec 10, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is the code used to setup clangd for c++, and when I open up neovim, I get
error loading chunk
message with that block of code, but without it I don't get any error.The text was updated successfully, but these errors were encountered: