In lazy.nvim, the `build` parameter accept value in different format.
If the value is
1. a string and starts with `:`, it will be treated as vim command
2. a string and starts without `:`, it will be treated as shell command
3. a function. Lazy.nvim will run this function
I compared closely between case 1 and case 3. In case 1, when lazy.nvim
runs the viml command, the runtimepath is already populated with the
current plugin we are trying to build.
However in case 3, the runtimepath is not populated with the plugin
path, which means that any command you run by this plugin is not
available.
So I did it in a hacky way to add the plugin path to runtimepath
manually, and source it manually using `:runtime` command. The `:
runtime` command is needed because in the init process, adding the
plugin path to runtimepath does not ensure that the script under this
plugin is sourced immediately. So if we want to use the command/function
immediately, we need to source it manually, see also https://github.com/neovim/neovim/issues/29957.
1. fix a typo in gJ mapping when setting the mark, the correct syntax is
`mz` (set mark `z`), not `zm`
2. fix bug with `iB` text object: previously `viB` does not work as
expected, because it does not select the entire buffer as expected.
After much investigation, I found it is because the `<cmd>` mapping
argument. If we use `<cmd>` argument for mapping, the mode does not
change. So if we use `viB`, inititally we are still in visual mode.
Later in the implementation, when we use `` normal! `<V`> `` to
select the entire buffer, it interferes with original visual mode. As
a result, the entire buffer is not selected. In the text obj
implementation, we can use `exe "normal! \<Esc>"` to clear the visual
mode and make `viB`, but this is not ideal. I think it is eaiser to
just not use the `<cmd>` argument and use `:<C-U>` instead.
For TextYankPost event, it includes both yank and delete, we should only
restore cursor position for yank, not for delete. Otherwise, it messes
up with text deletion when you visually select multiple lines and delete
them. See also issue reported here: https://github.com/jdhao/nvim-config/pull/222#issuecomment-1698634645
The cache should be invalidated. This fix does not work 100%, because, e.g.,
there are other configs hiding deeper under lua/config/ directory.
A restart is the best way to reload the config.