Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

floaty ux keymap hardcoded? #9

Open
rafcamlet opened this issue Aug 26, 2020 · 3 comments
Open

floaty ux keymap hardcoded? #9

rafcamlet opened this issue Aug 26, 2020 · 3 comments

Comments

@rafcamlet
Copy link

rafcamlet commented Aug 26, 2020

It seems to floaty ux has its keymaps hardcoded. It's quite unexpected, especally if you have mapped <c-j> as advence(1) and after expand it change into advence(-1).

https://github.com/norcalli/snippets.nvim/blob/663029663e0681c49e71f18ec81650c650e7c7aa/lua/snippets/inserters/floaty.lua#L316:L320

@rafcamlet rafcamlet reopened this Aug 27, 2020
@rafcamlet rafcamlet changed the title floaty ux keymap hardcodec? floaty ux keymap hardcoded? Aug 27, 2020
@salkin-mada
Copy link

salkin-mada commented Feb 9, 2021

Hi @rafcamlet . I use the floaty inserter. And the expand/advance triggers (both 1 and -1) is being remapped just fine.

function M.snippets()
    local opts = { noremap = true }
    api.nvim_set_keymap('i', '<A-k>', '<cmd>lua return require"snippets".expand_or_advance(1)<CR><ESC>gH', opts)
    api.nvim_set_keymap('i', '<A-j>', '<cmd>lua return require"snippets".advance_snippet(-1)<CR><ESC>gH', opts)
    api.nvim_set_keymap('n', '<A-k>', '<cmd>lua return require"snippets".expand_or_advance(1)<CR>gH', opts)
    api.nvim_set_keymap('n', '<A-j>', '<cmd>lua return require"snippets".advance_snippet(-1)<CR>gH', opts)
    api.nvim_set_keymap('s', '<A-k>', '<cmd>lua return require"snippets".expand_or_advance(1)<CR><ESC>gH', opts)
    api.nvim_set_keymap('s', '<A-j>', '<cmd>lua return require"snippets".advance_snippet(-1)<CR><ESC>gH', opts)
end

@rafcamlet
Copy link
Author

rafcamlet commented Feb 9, 2021

@salkin-mada There are hardcoded mappings in floaty ux buffer, which overwrites my custom mappings. https://github.com/norcalli/snippets.nvim/blob/663029663e0681c49e71f18ec81650c650e7c7aa/lua/snippets/inserters/floaty.lua#L316:L320

	api.nvim_buf_set_keymap(input_buf, 'i', '<c-k>', '<Cmd>lua SNIPPETS_FLOATY_HANDLER(1)<cr>', { noremap = true; silent = true })
	api.nvim_buf_set_keymap(input_buf, 'i', '<c-j>', '<Cmd>lua SNIPPETS_FLOATY_HANDLER(-1)<cr>', { noremap = true; silent = true })

I'm using inoremap <c-j> <cmd>lua return require'snippets'.expand_or_advance(1)<CR> but inside floaty buffer it is changed to lua SNIPPETS_FLOATY_HANDLER(-1) which is wrapper for require'snippets'.advance_snippet, but it has opposite sign.

@aoswalt
Copy link

aoswalt commented Feb 27, 2021

As a workaround, I was able to override the advance_snippet function to flip the sign.

local M = require'snippets'
local orig_advance = M.advance_snippet
local advance = function(offset)
  offset = offset or 1
  orig_advance(-offset)
end
M.advance_snippet = advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants