replace compe with cmp
This commit is contained in:
parent
e46e48405e
commit
70ee28574e
5 changed files with 69 additions and 86 deletions
67
lua/config/cmp.lua
Normal file
67
lua/config/cmp.lua
Normal file
|
@ -0,0 +1,67 @@
|
|||
-- Completion plugin config
|
||||
|
||||
local utils = require('utils')
|
||||
|
||||
vim.cmd [[set shortmess+=c]]
|
||||
utils.opt('o', 'completeopt', 'menuone,noselect')
|
||||
|
||||
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 = 'git' }, -- You can specify the `git` source if [you were installed it](https://github.com/petertriho/cmp-git).
|
||||
}, {
|
||||
{ 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' }
|
||||
})
|
||||
})
|
|
@ -1,78 +0,0 @@
|
|||
-- Configuration for nvim-compe
|
||||
|
||||
local utils = require('utils')
|
||||
|
||||
vim.cmd [[set shortmess+=c]]
|
||||
utils.opt('o', 'completeopt', 'menuone,noselect')
|
||||
|
||||
require'compe'.setup {
|
||||
enabled = true;
|
||||
autocomplete = false;
|
||||
debug = false;
|
||||
min_length = 1;
|
||||
preselect = 'enable';
|
||||
throttle_time = 80;
|
||||
source_timeout = 200;
|
||||
incomplete_delay = 400;
|
||||
allow_prefix_unmatch = false;
|
||||
max_abbr_width = 1000;
|
||||
max_kind_width = 1000;
|
||||
max_menu_width = 1000000;
|
||||
documentation = false;
|
||||
|
||||
|
||||
source = {
|
||||
path = true;
|
||||
buffer = true;
|
||||
calc = true;
|
||||
vsnip = true;
|
||||
nvim_lsp = true;
|
||||
nvim_lua = true;
|
||||
spell = true;
|
||||
tags = true;
|
||||
snippets_nvim = true;
|
||||
treesitter = true;
|
||||
};
|
||||
}
|
||||
|
||||
local t = function(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
end
|
||||
|
||||
local check_back_space = function()
|
||||
local col = vim.fn.col('.') - 1
|
||||
if col == 0 or vim.fn.getline('.'):sub(col, col):match('%s') then
|
||||
return true
|
||||
else
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
-- Use (s-)tab to:
|
||||
--- move to prev/next item in completion menuone
|
||||
--- jump to prev/next snippet's placeholder
|
||||
-- _G.tab_complete = function()
|
||||
-- if vim.fn.pumvisible() == 1 then
|
||||
-- return t "<C-n>"
|
||||
-- elseif vim.fn.call("vsnip#available", {1}) == 1 then
|
||||
-- return t "<Plug>(vsnip-expand-or-jump)"
|
||||
-- elseif check_back_space() then
|
||||
-- return t "<Tab>"
|
||||
-- else
|
||||
-- return vim.fn['compe#complete']()
|
||||
-- end
|
||||
-- end
|
||||
-- _G.s_tab_complete = function()
|
||||
-- if vim.fn.pumvisible() == 1 then
|
||||
-- return t "<C-p>"
|
||||
-- elseif vim.fn.call("vsnip#jumpable", {-1}) == 1 then
|
||||
-- return t "<Plug>(vsnip-jump-prev)"
|
||||
-- else
|
||||
-- return t "<S-Tab>"
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- utils.map("i", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
-- utils.map("s", "<Tab>", "v:lua.tab_complete()", {expr = true})
|
||||
-- utils.map("i", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
||||
-- utils.map("s", "<S-Tab>", "v:lua.s_tab_complete()", {expr = true})
|
|
@ -1,4 +1,3 @@
|
|||
-- nvim-compe
|
||||
require('config.compe')
|
||||
require('config.cmp')
|
||||
require('config.treesitter')
|
||||
require('config.telescope')
|
||||
|
|
|
@ -112,7 +112,7 @@ return require('packer').startup(function()
|
|||
|
||||
use { 'cespare/vim-toml' }
|
||||
use { 'folke/trouble.nvim' }
|
||||
use { 'hrsh7th/nvim-compe' }
|
||||
use { 'hrsh7th/nvim-cmp' }
|
||||
use { 'jacoborus/tender.vim' }
|
||||
use { 'RRethy/vim-illuminate' }
|
||||
use { 'rust-lang/rust.vim' }
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
inoremap <silent><expr> <C-Space> compe#complete()
|
||||
inoremap <silent><expr> <CR> compe#confirm('<CR>')
|
||||
inoremap <silent><expr> <C-e> compe#close('<C-e>')
|
||||
inoremap <silent><expr> <C-f> compe#scroll({ 'delta': +4 })
|
||||
inoremap <silent><expr> <C-d> compe#scroll({ 'delta': -4 })
|
Loading…
Reference in a new issue