nvim-autopairs icon indicating copy to clipboard operation
nvim-autopairs copied to clipboard

get_rule("'") returns nil: attempt to call method 'with_pair' (a nil value)

Open toan2406 opened this issue 5 years ago • 2 comments

Description

After update the plugin after this commit https://github.com/windwp/nvim-autopairs/commit/ff985c71417bceb168c5415813e40e656e3ea9ed, I got an error from get_rule("'"):with_pair.

E5113: Error while calling lua chunk: /Users/name/.config/nvim/lua/plugins/autopairs.lua:5: attempt to call method 'with_pair' (a nil value)

This is my usage

npairs.get_rule("'"):with_pair(function()
  if vim.bo.filetype == 'reason' then
    return false
  end
end)

Mapping bug

1.If you report a bug about indent. Please remember that plugin doesn't do anything about indent. It just trigger the indent of your vim config so if you have wrong indent config then it will do wrong indent. You can check by select a block of code and press == 2. provide result of command :verbose imap <cr>.

Steps to reproduce

No response

Minimal config

local npairs = require('nvim-autopairs')

npairs.setup()

npairs.get_rule("'"):with_pair(function()
  if vim.bo.filetype == 'reason' then
    return false
  end
end)

toan2406 avatar Oct 03 '21 07:10 toan2406

now there have 2 rules use single quote 1 rule specify for rust so that function is return to a table of rules

npairs.get_rule("'")[1]:with_pair(function()
  if vim.bo.filetype == 'reason' then
    return false
  end
end)

windwp avatar Oct 03 '21 11:10 windwp

Thank you, I will close this.

toan2406 avatar Oct 03 '21 13:10 toan2406