Issues with autopairs setup
Nobody has claimed this yet.
- Dominant language
- Fennel
- Stars
- 536
- Forks
- 47
- PR merge metrics
- No merged PRs in 30d
Description
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-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). - 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 usingnot_filetypes = { "rust" }(these rules disable autopairs for"'"when used in lifetime annotation position).
Since your current code usesassoc-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 🙂
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the dotfiles.plugin.autopairs module and inspect nvim-autopairs.get_rule for the apostrophe and backtick rules. Verify how disable-rule-for-filetypes receives its arguments, handles single and multiple rules, and preserves existing Rust exclusions; done means the listed Lisp filetypes are disabled without removing those exclusions.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- neovim
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100