0

I'd like to create a hotkey to insert the current branch name directly in insert mode with the hotkey <C-b>. I use the plugin gitsigns which has a variable vim.b.gitsigns_head containing the current branch but I can't seem to find a way to input it. I figured I need to add something like

vim.keymap.set('i', '<C-b>', vim.b.gitsigns_head) 

but I can't find any way to reference and print the variable.

1 Answer 1

1

I would do:

vim.keymap.set('i', '<C-b>', 'b:gitsigns_head', {expr = true}) 

Or if you prefer a "pure" lua version:

lua vim.keymap.set('i', '<C-b>', "luaeval('vim.b.gitsigns_head')", {expr = true}) 

The {expr = true} makes that the lhs is evaluated instead of used directly as input.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.