I am in the process of converting my init.vim over to lua files instead. One thing I have been getting hung up on is that I can’t seem to set the leader key. In my init.vim I have the leader key set to space using let mapleader = ' '. I have tried using the idiomatic vim.g.maplader = ' ' in my lua setup but it is not working.
I also tried setting the leader key by using my version from the init.vim wrapped in a Neovim cmd vim.cmd 'let mapleader = " "' and that has not worked either. I am sure I am probably just missing something here. Any ideas?
So I think I figured it out. A syntax error in another file seemed to be causing an issue? I won’t claim that I fully understand what happened here, cause I don’t , but my mapping of the leader key appears to be working as intended now with a simple vim.g.mapleader = ' '
In case someone finds this thread:
I made the mistake to set mapleader after setting the keymaps with vim.keymap.set. vim.g.mapleader = ' ' works for me if I put it before the calls to vim.keymap.set. If you configure vim with both lua and vimsript, I suppose you have to consider the order in which the files are loaded.
I’d like to create something that is conceptually really simple; I’ve used both stock vi and stock Emacs (Gosling and GNU) since the eighties, but with vi, I never changed more than 1 or 2 “vi” settings and I never ever modified either vim or neovim, so the config language is not yet familiar to me, nor is Lua, though a few tools I’ve used, including neovim, do use Lua.
Here’s what I’d like to add, nothing else:
I’d like to add something like space q to quit; could be bound to :q!
I’d like to add something similar like space w to write out the file/buffer, like :w or :w!
If it’s really easy, perhaps a third space key binding to do a force write-quit, similar to :wqa
Do I have to set up gobs of lines, or is there an easy way to do this without having to become an expert vim, neovim or Lua script writer?
I didn’t end up doing a space key binding; instead I did what I’ve done with Emacs instances many times: I defined a few function keys to perform Ctrl and Esc key sequences; so with vim and nvim, I used F6-F9 to add a few variations for writing, saving, and quitting. Not the space key, but it accomplishes a similar objective using different keys.