From 196f60f638de419c69360f5c75fef60de74230a5 Mon Sep 17 00:00:00 2001 From: juan Date: Tue, 14 Sep 2021 20:32:11 +0800 Subject: [PATCH] TabNine now works properly with the commit --- lua/plugins/coq.lua | 1 - lua/plugins/nvim-autopairs.lua | 53 ++++++++++++++++++++-------------- 2 files changed, 31 insertions(+), 23 deletions(-) diff --git a/lua/plugins/coq.lua b/lua/plugins/coq.lua index b4de7f2..80226cf 100644 --- a/lua/plugins/coq.lua +++ b/lua/plugins/coq.lua @@ -1,3 +1,2 @@ vim.g.coq_settings = {auto_start = true, clients = {tabnine = {enabled = true}}} -local coq = require('coq') vim.cmd('COQnow') diff --git a/lua/plugins/nvim-autopairs.lua b/lua/plugins/nvim-autopairs.lua index d449bf5..f74aeb5 100644 --- a/lua/plugins/nvim-autopairs.lua +++ b/lua/plugins/nvim-autopairs.lua @@ -1,38 +1,47 @@ local remap = vim.api.nvim_set_keymap 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 -remap('i', '', [[pumvisible() ? "" : ""]], { expr = true, noremap = true }) -remap('i', '', [[pumvisible() ? "" : ""]], { expr = true, noremap = true }) -remap('i', '', [[pumvisible() ? "" : ""]], { expr = true, noremap = true }) -remap('i', '', [[pumvisible() ? "" : ""]], { expr = true, noremap = true }) +remap('i', '', [[pumvisible() ? "" : ""]], + {expr = true, noremap = true}) +remap('i', '', [[pumvisible() ? "" : ""]], + {expr = true, noremap = true}) +remap('i', '', [[pumvisible() ? "" : ""]], + {expr = true, noremap = true}) +remap('i', '', [[pumvisible() ? "" : ""]], + {expr = true, noremap = true}) -- skip it, if you use another global object -_G.MUtils= {} +_G.MUtils = {} MUtils.CR = function() - if vim.fn.pumvisible() ~= 0 then - if vim.fn.complete_info({ 'selected' }).selected ~= -1 then - return npairs.esc('') + if vim.fn.pumvisible() ~= 0 then + if vim.fn.complete_info({'selected'}).selected ~= -1 then + return npairs.esc('') + else + -- you can change to if you don't use other i_CTRL-X modes + return npairs.esc('') .. npairs.autopairs_cr() + end else - -- you can change to if you don't use other i_CTRL-X modes - return npairs.esc('') .. npairs.autopairs_cr() + return npairs.autopairs_cr() end - else - return npairs.autopairs_cr() - end end -remap('i', '', 'v:lua.MUtils.CR()', { expr = true, noremap = true }) +remap('i', '', 'v:lua.MUtils.CR()', {expr = true, noremap = true}) MUtils.BS = function() - if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({ 'mode' }).mode == 'eval' then - return npairs.esc('') .. npairs.autopairs_bs() - else - return npairs.autopairs_bs() - end + if vim.fn.pumvisible() ~= 0 and vim.fn.complete_info({'mode'}).mode == + 'eval' then + return npairs.esc('') .. npairs.autopairs_bs() + else + return npairs.autopairs_bs() + end end -remap('i', '', 'v:lua.MUtils.BS()', { expr = true, noremap = true }) +remap('i', '', 'v:lua.MUtils.BS()', {expr = true, noremap = true})