Skip to content

Commit

Permalink
Replace nvim-compe with nvim-cmp
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Sep 2, 2021
1 parent 7853657 commit 7e90b42
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 58 deletions.
20 changes: 16 additions & 4 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@
path = pack/plugins/opt/nvim-tree.lua
url = git@github.com:kyazdani42/nvim-tree.lua.git
ignore = dirty
[submodule "pack/plugins/start/nvim-compe"]
path = pack/plugins/start/nvim-compe
url = git@github.com:hrsh7th/nvim-compe.git
ignore = dirty
[submodule "pack/plugins/opt/neogit"]
path = pack/plugins/opt/neogit
url = git@github.com:TimUntersberger/neogit.git
Expand Down Expand Up @@ -234,3 +230,19 @@
path = pack/plugins/opt/nvim-notify
url = git@github.com:rcarriga/nvim-notify.git
ignore = dirty
[submodule "pack/plugins/start/nvim-cmp"]
path = pack/plugins/start/nvim-cmp
url = git@github.com:hrsh7th/nvim-cmp.git
ignore = dirty
[submodule "pack/plugins/start/cmp-buffer"]
path = pack/plugins/start/cmp-buffer
url = git@github.com:hrsh7th/cmp-buffer.git
ignore = dirty
[submodule "pack/plugins/opt/cmp_luasnip"]
path = pack/plugins/opt/cmp_luasnip
url = git@github.com:saadparwaiz1/cmp_luasnip.git
ignore = dirty
[submodule "pack/plugins/opt/cmp-nvim-lsp"]
path = pack/plugins/opt/cmp-nvim-lsp
url = git@github.com:hrsh7th/cmp-nvim-lsp.git
ignore = dirty
4 changes: 3 additions & 1 deletion init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ else
vim.cmd('packadd! asynctasks.vim')
vim.cmd('packadd! bufferline.nvim')
vim.cmd('packadd! cfilter')
vim.cmd('packadd! cmp-nvim-lsp')
vim.cmd('packadd! cmp_luasnip')
vim.cmd('packadd! diffview.nvim')
vim.cmd('packadd! gitlinker.nvim')
vim.cmd('packadd! gitsigns.nvim')
Expand All @@ -193,7 +195,6 @@ else
vim.cmd('packadd! nvim-lspconfig')
vim.cmd('packadd! nvim-luaref')
vim.cmd('packadd! nvim-notify')
vim.cmd('packadd! toggleterm.nvim')
vim.cmd('packadd! nvim-tree.lua')
vim.cmd('packadd! nvim-treesitter')
vim.cmd('packadd! nvim-treesitter-textobjects')
Expand All @@ -204,6 +205,7 @@ else
vim.cmd('packadd! stickybuf.nvim')
vim.cmd('packadd! telescope-asynctasks.nvim')
vim.cmd('packadd! telescope-dap.nvim')
vim.cmd('packadd! toggleterm.nvim')
vim.cmd('packadd! vim-eunuch')
vim.cmd('packadd! vim-scriptease')
vim.cmd('packadd! vim-sleuth')
Expand Down
8 changes: 0 additions & 8 deletions lua/config_utils/completion.lua
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
local completion = {}

function completion.trigger_completion()
if vim.fn.pumvisible() ~= 0 then
return vim.fn['compe#confirm']({ keys = '<C-Space>', select = true })
else
return vim.fn['compe#complete']()
end
end

function completion.tab_snippet()
if require('luasnip').expand_or_jumpable() then
return vim.api.nvim_replace_termcodes('<Plug>luasnip-expand-or-jump', true, true, true)
Expand Down
1 change: 1 addition & 0 deletions pack/plugins/opt/cmp-nvim-lsp
Submodule cmp-nvim-lsp added at 9af212
1 change: 1 addition & 0 deletions pack/plugins/opt/cmp_luasnip
Submodule cmp_luasnip added at 438632
1 change: 1 addition & 0 deletions pack/plugins/start/cmp-buffer
Submodule cmp-buffer added at 5dde54
1 change: 1 addition & 0 deletions pack/plugins/start/nvim-cmp
Submodule nvim-cmp added at 1ae7b5
1 change: 0 additions & 1 deletion pack/plugins/start/nvim-compe
Submodule nvim-compe deleted from dc39f9
2 changes: 1 addition & 1 deletion plugin/autopairs.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
require('nvim-autopairs').setup()
require('nvim-autopairs.completion.compe').setup({ map_cr = true })
require('nvim-autopairs.completion.cmp').setup({ map_cr = true })
58 changes: 58 additions & 0 deletions plugin/cmp.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
local kinds = {
Text = ' Text',
Method = ' Method',
Function = ' Function',
Constructor = ' Constructor',
Field = 'ﰠ Field',
Variable = ' Variable',
Class = ' Class',
Interface = ' Interface',
Module = ' Module',
Property = ' Property',
Unit = ' Unit',
Value = ' Value',
Enum = ' Enum',
Keyword = ' Keyword',
Snippet = '﬌ Snippet',
Color = ' Color',
File = ' File',
Reference = ' Reference',
Folder = ' Folder',
EnumMember = ' EnumMember',
Constant = ' Constant',
Struct = ' Struct',
Event = 'ﯓ Event',
Operator = ' Operator',
TypeParameter = ' TypeParameter',
}

local sources = {
{ name = 'buffer' },
}
if not vim.g.started_by_firenvim then
table.insert(sources, { name = 'nvim_lsp' })
table.insert(sources, { name = 'luasnip' })
end

local luasnip = require('luasnip')
local cmp = require('cmp')
cmp.setup({
sources = sources,
mapping = {
['<C-d>'] = cmp.mapping.scroll_docs(-4),
['<C-f>'] = cmp.mapping.scroll_docs(4),
['<C-Space>'] = cmp.mapping.confirm({ select = true }),
['<C-e>'] = cmp.mapping.close(),
},
snippet = {
expand = function(args)
luasnip.lsp_expand(args.body)
end,
},
formatting = {
format = function(_, vim_item)
vim_item.kind = kinds[vim_item.kind]
return vim_item
end,
},
})
14 changes: 0 additions & 14 deletions plugin/compe.lua

This file was deleted.

30 changes: 1 addition & 29 deletions plugin/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ lsp_status.config({
current_function = false,
diagnostics = false, -- Will be displayed via lualine
})
lsp_status.capabilities.textDocument.completion.completionItem.snippetSupport = true
lsp_status.capabilities = require('cmp_nvim_lsp').update_capabilities(lsp_status.capabilities)
lsp_status.register_progress()

-- Buffer with LSP settings
Expand Down Expand Up @@ -95,34 +95,6 @@ lspconfig.cmake.setup({
on_attach = on_attach,
})

-- Icons
local kinds = require('vim.lsp.protocol').CompletionItemKind
kinds[kinds.Text] = ' Text'
kinds[kinds.Method] = ' Method'
kinds[kinds.Function] = ' Function'
kinds[kinds.Constructor] = ' Constructor'
kinds[kinds.Field] = 'ﰠ Field'
kinds[kinds.Variable] = ' Variable'
kinds[kinds.Class] = ' Class'
kinds[kinds.Interface] = ' Interface'
kinds[kinds.Module] = ' Module'
kinds[kinds.Property] = ' Property'
kinds[kinds.Unit] = ' Unit'
kinds[kinds.Value] = ' Value'
kinds[kinds.Enum] = ' Enum'
kinds[kinds.Keyword] = ' Keyword'
kinds[kinds.Snippet] = '﬌ Snippet'
kinds[kinds.Color] = ' Color'
kinds[kinds.File] = ' File'
kinds[kinds.Reference] = ' Reference'
kinds[kinds.Folder] = ' Folder'
kinds[kinds.EnumMember] = ' EnumMember'
kinds[kinds.Constant] = ' Constant'
kinds[kinds.Struct] = ' Struct'
kinds[kinds.Event] = 'ﯓ Event'
kinds[kinds.Operator] = ' Operator'
kinds[kinds.TypeParameter] = ' TypeParameter'

-- Diagnistic signs
vim.fn.sign_define('LspDiagnosticsSignError', { text = '' })
vim.fn.sign_define('LspDiagnosticsSignWarning', { text = '' })
Expand Down

0 comments on commit 7e90b42

Please sign in to comment.