Skip to content

Instantly share code, notes, and snippets.

@muniter
Created August 2, 2021 15:55
Show Gist options
  • Save muniter/5f304b4e4dbb81465b58e3a0d6135978 to your computer and use it in GitHub Desktop.
Save muniter/5f304b4e4dbb81465b58e3a0d6135978 to your computer and use it in GitHub Desktop.
Completion su mode in lua
------ Completion ^X submode mappings
M._my_completion_mappings = function ()
--@note: Function that sets mappings to workaround completeopt="noselect"
--this allows for actually selecting the first entry when using <C-x>
--submodes, and therefore easier chaining <C-x><C-n> brcomes
--<C-x><C-n><C-n>
if string.match(vim.o.completeopt, "noselect") == nil then return end
local modes= {"l", "n", "k", "t", "i", "]", "f", "d", "v", "u", "o", "s", "p"}
for _, mode in pairs(modes) do
local map = string.format("<C-x><C-%s>", mode)
local remap = string.format("<C-x><C-%s><C-%s>", mode, mode)
gmap('i', map, remap, opts)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment