-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Milestone
Description
Thanks for the nice plugin!
So, I often get errors when using a in_string()
condition. In my case, I wanted to create a rule that pairs <>
in lua when inside a string (useful for writing keymaps such as "<CR>"
).
Following the example in the docs, I added this to my config:
{ "<", ">", ft = { "lua" }, cond = function(fn) return not fn.in_string() end }
Which works, but errors quite often. For instance, when typing "
here:
-- * = cursor
vim.api.nvim_create_user_command(*, command, opts)
I get this error:
...y/ultimate-autopair.nvim/lua/ultimate-autopair/utils.lua:161: Index out of bounds
stack traceback:
...y/ultimate-autopair.nvim/lua/ultimate-autopair/debug.lua:77: in function <...y/ultimate-autopair.nvim/lua/ultimate-autopair/debug.lua:74>
[C]: in function '_getlines'
...y/ultimate-autopair.nvim/lua/ultimate-autopair/utils.lua:161: in function 'gettsnode'
...autopair.nvim/lua/ultimate-autopair/extension/tsnode.lua:36: in function '_in_tsnode'
...autopair.nvim/lua/ultimate-autopair/extension/tsnode.lua:101: in function 'filter'
...autopair.nvim/lua/ultimate-autopair/extension/tsnode.lua:124: in function 'sfilter'
...ua/ultimate-autopair/profile/default/utils/open_pair.lua:85: in function 'count_end_pair'
...ua/ultimate-autopair/profile/default/utils/open_pair.lua:152: in function 'open_end_pair_after'
...air.nvim/lua/ultimate-autopair/profile/default/pairs.lua:12: in function 'can_check'
...air.nvim/lua/ultimate-autopair/profile/default/pairs.lua:26: in function <...air.nvim/lua/ultimate-autopair/profile/default/pairs.lua:25>
[C]: in function 'xpcall'
...y/ultimate-autopair.nvim/lua/ultimate-autopair/debug.lua:97: in function 'run'
...zy/ultimate-autopair.nvim/lua/ultimate-autopair/core.lua:96: in function <...zy/ultimate-autopair.nvim/lua/ultimate-autopair/core.lua:87>
I also check the in_string
function in the code itself, and taking a guess from the function's signature, I also tried this;
{
"<",
">",
ft = { "lua" },
cond = function(fn)
local row, col = unpack(vim.api.nvim_win_get_cursor(0))
return fn.in_string(fn.opt, row, col)
end,
},
which does not appear to well either.
Metadata
Metadata
Assignees
Labels
No labels