I'm in the process of yoinking some of your configuration (thank you for providing that, the plugins and blog posts) and noticed some small issues in the autopairs setup.
- It looks like you forgot to finish writing
disable-rule-for-filetypes so that it accepts and makes use of the arguments you provide when calling it. It instead always uses autopairs.get_rule for "'" and the lisps table (the latter doesn't really matter).
- Making that change myself I noticed that it doesn't work for
"`". Running :lua require(vim.inspect(require('nvim-autopairs').get_rule("`"))) reveals that because only a single rule exists, it can't be indexed.
- When debugging this, I noticed that there are two rules for
"'", the second one being exclusive to Rust and more importantly, the first one excluding Rust using not_filetypes = { "rust" } (these rules disable autopairs for "'" when used in lifetime annotation position).
Since your current code uses assoc-in, it overrides the existing table of excluded filetypes essentially disabling the rather useful rules for Rust.
Here is my (likely unidiomatic, this is my first LISP) code to address these issues:
(module dotfiles.plugin.autopairs
{autoload {a aniseed.core}})
(def- lisps [:scheme :lisp :clojure :fennel])
(defn- extend [tbl items]
(let [tbl (if (a.nil? tbl) [] tbl)]
(each [_ item (ipairs items)]
(table.insert tbl item))
tbl))
(defn- get-if-not-nil [tbl index]
(let [val (. tbl index)]
(if (a.nil? val)
tbl
val)))
(let [(ok? autopairs) (pcall require :nvim-autopairs)]
(when ok?
(defn- disable-rule-for-filetypes [rule filetypes]
(let [rule (autopairs.get_rule rule)]
(let [rule (get-if-not-nil rule 1)]
(a.assoc rule
:not_filetypes
(extend (. rule :not_filetypes) filetypes)))))
(autopairs.setup)
(disable-rule-for-filetypes "'" lisps)
(disable-rule-for-filetypes "`" lisps)))
I hope this is useful to you 🙂
I'm in the process of yoinking some of your configuration (thank you for providing that, the plugins and blog posts) and noticed some small issues in the autopairs setup.
disable-rule-for-filetypesso that it accepts and makes use of the arguments you provide when calling it. It instead always usesautopairs.get_rulefor"'"and thelispstable (the latter doesn't really matter)."`". Running:lua require(vim.inspect(require('nvim-autopairs').get_rule("`")))reveals that because only a single rule exists, it can't be indexed."'", the second one being exclusive to Rust and more importantly, the first one excluding Rust usingnot_filetypes = { "rust" }(these rules disable autopairs for"'"when used in lifetime annotation position).Since your current code uses
assoc-in, it overrides the existing table of excluded filetypes essentially disabling the rather useful rules for Rust.Here is my (likely unidiomatic, this is my first LISP) code to address these issues:
I hope this is useful to you 🙂