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

How to enter a new keymap #110

Open
ammukuttu opened this issue Nov 16, 2023 · 5 comments
Open

How to enter a new keymap #110

ammukuttu opened this issue Nov 16, 2023 · 5 comments

Comments

@ammukuttu
Copy link

In the previous version of configuration (pre-lua), the keymapping was in mappings.vim. Neovim has a different construct and need some guidance.

I need to change my keymap to IAST to enter Sanskrit diacritical marks. For this I had established this map in mappings.vim. Essentially I need a toggle. How would I unset this keymap once established in a session?

map <C-%> :set keymap=iast<CR>

what will be the equivalent entry in keymaps.lua. I tried several format of this without success

keymap("n", "C-%", ":set keymap=iast<CR>",term_opts)

@benbrastmckie
Copy link
Owner

How about this one:

  vim.keymap.set('n', '<C-%>', ':set keymap=iast<CR>', term_ops)

@ammukuttu
Copy link
Author

doesn't work

@benbrastmckie
Copy link
Owner

Ok that was just a shot in the dark. I'm not too sure what IAST is or does, but if you can find the commands you need then binding those commands shouldn't be too hard. You will probably need two, one to turn it on, the other to turn it off (whatever it is in this case). Alternatively, given your two commands, there is probably a way to create a toggle by defining a function.

Feel free to elaborate what you have already and what you are looking for since I don't know much about this already.

@ammukuttu
Copy link
Author

IAST is just a way to tell the keyboard to start typing character in a certain manner. For example when asked it will put a - above i when you type -i. It is no different from other keymapping that you see in /opt/homebrew/Cellar/neovim/0.9.4/share/nvim/runtime/keymap. There is an iast.vim file that looks like
" Vim Keymap file for translitteration of pāli and sanskrit with IAST mapping
" Author: t-om miu iki.fi
" Last Change: 2007-08-21
" Version: 0.1

scriptencoding utf-8
let b:keymap_name = "tl"
loadkeymap
-a ā
-A Ā
.h ḥ
.H Ḥ

@benbrastmckie
Copy link
Owner

How about this one:

vim.api.nvim_set_keymap('n', '<C-%>', ':set keymap=iast<CR>', { noremap = true, silent = true })

Or, using the local definitions, add the following to keymaps.lua:

keymap("n", "<C-%>", ":set keymap=iast<CR>", opts)

Sorry for the long delay.

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

2 participants