ggandor / leap-spooky.nvim

👻 Actions at a distance
The Unlicense
277 stars 7 forks source link

fix: always assign string in lhs mapping ternary #23

Closed al-ce closed 9 months ago

al-ce commented 9 months ago

Hello! prefix = true in config results in the following error:

Failed to run `config` for leap-spooky.nvim

vim/keymap.lua:39: lhs: expected string, got boolean

# stacktrace:
  - vim/shared.lua:842 _in_ **validate**
  - vim/keymap.lua:39 _in_ **set**
  - /leap-spooky.nvim/lua/leap-spooky.lua:129 _in_ **setup**

Since 0ecd057 it appears that line the lhs assignment was being assigned to true if kwargs.prefix == true, due to the way the operands were distributed. This PR changes the lhs assignment to be closer to the previous expression. If this is correct and not an issue with my config, please make any preferred style changes. Thank you!

overview of changes previous 808bd88 ```lua lhs = (kwargs.prefix and key .. textobj or textobj:sub(1,1) .. key .. textobj:sub(2)), ``` current 0ecd057 ```lua lhs = (kwargs.prefix or not textobj:sub(1,1):match('[aiAI]') and key .. textobj or textobj:sub(1,1) .. key .. textobj:sub(2)), ``` proposed ```lua lhs = ( (kwargs.prefix or not textobj:sub(1,1):match('[aiAI]')) and key .. textobj or textobj:sub(1,1) .. key .. textobj:sub(2) ), ```
ggandor commented 9 months ago

Silly me. Thanks!