TabNine now works properly with the commit

This commit is contained in:
juan 2021-09-14 20:32:11 +08:00
parent bff6f5e613
commit 196f60f638
2 changed files with 31 additions and 23 deletions

View File

@ -1,3 +1,2 @@
vim.g.coq_settings = {auto_start = true, clients = {tabnine = {enabled = true}}} vim.g.coq_settings = {auto_start = true, clients = {tabnine = {enabled = true}}}
local coq = require('coq')
vim.cmd('COQnow') vim.cmd('COQnow')

View File

@ -1,22 +1,30 @@
local remap = vim.api.nvim_set_keymap local remap = vim.api.nvim_set_keymap
local npairs = require('nvim-autopairs') local npairs = require('nvim-autopairs')
npairs.setup({ map_bs = false }) npairs.setup({map_bs = false})
vim.g.coq_settings = { keymap = { recommended = false } } vim.g.coq_settings = {
auto_start = true,
clients = {tabnine = {enabled = true}},
keymap = {recommended = false}
}
-- these mappings are coq recommended mappings unrelated to nvim-autopairs -- these mappings are coq recommended mappings unrelated to nvim-autopairs
remap('i', '<esc>', [[pumvisible() ? "<c-e><esc>" : "<esc>"]], { expr = true, noremap = true }) remap('i', '<esc>', [[pumvisible() ? "<c-e><esc>" : "<esc>"]],
remap('i', '<c-c>', [[pumvisible() ? "<c-e><c-c>" : "<c-c>"]], { expr = true, noremap = true }) {expr = true, noremap = true})
remap('i', '<tab>', [[pumvisible() ? "<c-n>" : "<tab>"]], { expr = true, noremap = true }) remap('i', '<c-c>', [[pumvisible() ? "<c-e><c-c>" : "<c-c>"]],
remap('i', '<s-tab>', [[pumvisible() ? "<c-p>" : "<bs>"]], { expr = true, noremap = true }) {expr = true, noremap = true})
remap('i', '<tab>', [[pumvisible() ? "<c-n>" : "<tab>"]],
{expr = true, noremap = true})
remap('i', '<s-tab>', [[pumvisible() ? "<c-p>" : "<bs>"]],
{expr = true, noremap = true})
-- skip it, if you use another global object -- skip it, if you use another global object
_G.MUtils= {} _G.MUtils = {}
MUtils.CR = function() MUtils.CR = function()
if vim.fn.pumvisible() ~= 0 then if vim.fn.pumvisible() ~= 0 then
if vim.fn.complete_info({ 'selected' }).selected ~= -1 then if vim.fn.complete_info({'selected'}).selected ~= -1 then
return npairs.esc('<c-y>') return npairs.esc('<c-y>')
else else
-- you can change <c-g><c-g> to <c-e> if you don't use other i_CTRL-X modes -- you can change <c-g><c-g> to <c-e> if you don't use other i_CTRL-X modes
@ -26,13 +34,14 @@ MUtils.CR = function()
return npairs.autopairs_cr() return npairs.autopairs_cr()
end end
end end
remap('i', '<cr>', 'v:lua.MUtils.CR()', { expr = true, noremap = true }) remap('i', '<cr>', 'v:lua.MUtils.CR()', {expr = true, noremap = true})
MUtils.BS = function() MUtils.BS = function()
if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({ 'mode' }).mode == 'eval' then if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({'mode'}).mode ==
'eval' then
return npairs.esc('<c-e>') .. npairs.autopairs_bs() return npairs.esc('<c-e>') .. npairs.autopairs_bs()
else else
return npairs.autopairs_bs() return npairs.autopairs_bs()
end end
end end
remap('i', '<bs>', 'v:lua.MUtils.BS()', { expr = true, noremap = true }) remap('i', '<bs>', 'v:lua.MUtils.BS()', {expr = true, noremap = true})