mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-22 21:30:51 +00:00
Merge pull request #316 from diniamo/fix-autopairs-cr
modules/nvim-cmp: add edge case for autopairs in cr mapping
This commit is contained in:
commit
688a457a3d
2 changed files with 13 additions and 10 deletions
|
@ -4,7 +4,6 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (lib.modules) mkIf;
|
inherit (lib.modules) mkIf;
|
||||||
inherit (lib.strings) optionalString;
|
|
||||||
inherit (lib.nvim.dag) entryAnywhere;
|
inherit (lib.nvim.dag) entryAnywhere;
|
||||||
inherit (lib.nvim.lua) toLuaObject;
|
inherit (lib.nvim.lua) toLuaObject;
|
||||||
|
|
||||||
|
@ -14,7 +13,7 @@ in {
|
||||||
vim.startPlugins = ["nvim-autopairs"];
|
vim.startPlugins = ["nvim-autopairs"];
|
||||||
|
|
||||||
vim.luaConfigRC.autopairs = entryAnywhere ''
|
vim.luaConfigRC.autopairs = entryAnywhere ''
|
||||||
require("nvim-autopairs").setup{}
|
require("nvim-autopairs").setup({ map_cr = ${toLuaObject (!config.vim.autocomplete.enable)} })
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,15 +61,19 @@ in {
|
||||||
(mkSetLuaBinding mappings.complete ''
|
(mkSetLuaBinding mappings.complete ''
|
||||||
require('cmp').complete
|
require('cmp').complete
|
||||||
'')
|
'')
|
||||||
(mkSetLuaBinding mappings.confirm ''
|
(let
|
||||||
function()
|
defaultKeys =
|
||||||
if not require('cmp').confirm({ select = true }) then
|
if config.vim.autopairs.enable
|
||||||
local termcode = vim.api.nvim_replace_termcodes(${toJSON mappings.confirm.value}, true, false, true)
|
then "require('nvim-autopairs').autopairs_cr()"
|
||||||
|
else "vim.api.nvim_replace_termcodes(${toJSON mappings.confirm.value}, true, false, true)";
|
||||||
vim.fn.feedkeys(termcode, 'n')
|
in
|
||||||
|
mkSetLuaBinding mappings.confirm ''
|
||||||
|
function()
|
||||||
|
if not require('cmp').confirm({ select = true }) then
|
||||||
|
vim.fn.feedkeys(${defaultKeys}, 'n')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
'')
|
||||||
'')
|
|
||||||
(mkSetLuaBinding mappings.next ''
|
(mkSetLuaBinding mappings.next ''
|
||||||
function()
|
function()
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
|
|
Loading…
Reference in a new issue