mirror of
https://github.com/NotAShelf/nvf.git
synced 2024-11-26 23:16:46 +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;
|
formatting.format = cfg.format;
|
||||||
};
|
|
||||||
|
|
||||||
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
# `cmp` and `luasnip` are defined above, in the `nvim-cmp` section
|
||||||
setupOpts.mapping = {
|
mapping = {
|
||||||
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
${mappings.complete} = mkLuaInline "cmp.mapping.complete()";
|
||||||
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
${mappings.close} = mkLuaInline "cmp.mapping.abort()";
|
||||||
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
${mappings.scrollDocsUp} = mkLuaInline "cmp.mapping.scroll_docs(-4)";
|
||||||
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
|
${mappings.scrollDocsDown} = mkLuaInline "cmp.mapping.scroll_docs(4)";
|
||||||
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
|
${mappings.confirm} = mkLuaInline "cmp.mapping.confirm({ select = true })";
|
||||||
|
|
||||||
${mappings.next} = mkLuaInline ''
|
${mappings.next} = mkLuaInline ''
|
||||||
cmp.mapping(function(fallback)
|
cmp.mapping(function(fallback)
|
||||||
local has_words_before = function()
|
local has_words_before = function()
|
||||||
local line, col = unpack(vim.api.nvim_win_get_cursor(0))
|
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
|
return col ~= 0 and vim.api.nvim_buf_get_lines(0, line - 1, line, true)[1]:sub(col, col):match("%s") == nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_next_item()
|
cmp.select_next_item()
|
||||||
${optionalString luasnipEnable ''
|
${optionalString luasnipEnable ''
|
||||||
elseif luasnip.locally_jumpable(1) then
|
elseif luasnip.locally_jumpable(1) then
|
||||||
luasnip.jump(1)
|
luasnip.jump(1)
|
||||||
''}
|
''}
|
||||||
elseif has_words_before() then
|
elseif has_words_before() then
|
||||||
cmp.complete()
|
cmp.complete()
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
'';
|
'';
|
||||||
|
|
||||||
${mappings.previous} = mkLuaInline ''
|
${mappings.previous} = mkLuaInline ''
|
||||||
cmp.mapping(function(fallback)
|
cmp.mapping(function(fallback)
|
||||||
if cmp.visible() then
|
if cmp.visible() then
|
||||||
cmp.select_prev_item()
|
cmp.select_prev_item()
|
||||||
${optionalString luasnipEnable ''
|
${optionalString luasnipEnable ''
|
||||||
elseif luasnip.locally_jumpable(-1) then
|
elseif luasnip.locally_jumpable(-1) then
|
||||||
luasnip.jump(-1)
|
luasnip.jump(-1)
|
||||||
''}
|
''}
|
||||||
else
|
else
|
||||||
fallback()
|
fallback()
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue