mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 15:06:45 +00:00
cmp: deduplicate attr key
This commit is contained in:
parent
834aee6cce
commit
347a04b62e
1 changed files with 40 additions and 40 deletions
|
@ -74,50 +74,50 @@ in {
|
|||
};
|
||||
|
||||
formatting.format = cfg.format;
|
||||
};
|
||||
|
||||
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
||||
setupOpts.mapping = {
|
||||
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
||||
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
||||
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
|
||||
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
|
||||
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
||||
mapping = {
|
||||
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
||||
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
||||
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
|
||||
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
|
||||
|
||||
${mappings.next} = mkLuaInline ''
|
||||
cmp.mapping(function(fallback)
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
${mappings.next} = mkLuaInline ''
|
||||
cmp.mapping(function(fallback)
|
||||
local has_words_before = function()
|
||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
||||
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||
end
|
||||
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
${optionalString luasnipEnable ''
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
''}
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
'';
|
||||
if cmp.visible() then
|
||||
cmp.select_next_item()
|
||||
${optionalString luasnipEnable ''
|
||||
elseif luasnip.locally_jumpable(1) then
|
||||
luasnip.jump(1)
|
||||
''}
|
||||
elseif has_words_before() then
|
||||
cmp.complete()
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
'';
|
||||
|
||||
${mappings.previous} = mkLuaInline ''
|
||||
cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
${optionalString luasnipEnable ''
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
''}
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
'';
|
||||
${mappings.previous} = mkLuaInline ''
|
||||
cmp.mapping(function(fallback)
|
||||
if cmp.visible() then
|
||||
cmp.select_prev_item()
|
||||
${optionalString luasnipEnable ''
|
||||
elseif luasnip.locally_jumpable(-1) then
|
||||
luasnip.jump(-1)
|
||||
''}
|
||||
else
|
||||
fallback()
|
||||
end
|
||||
end)
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue