Skip to content

Commit

Permalink
fix: priority pair
Browse files Browse the repository at this point in the history
  • Loading branch information
windwp committed Aug 17, 2024
1 parent 48ca9aa commit 4fea246
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lua/nvim-autopairs/rule.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ local Cond = require('nvim-autopairs.conds')
--- @field is_multibyte boolean
--- @field is_endwise boolean only use on end_wise
--- @field is_undo boolean add break undo sequence

local Rule = setmetatable({}, {
__call = function(self, ...)
return self.new(...)
Expand Down Expand Up @@ -172,7 +171,11 @@ end
---@return Rule
function Rule:with_pair(cond, pos)
if self.pair_cond == nil then self.pair_cond = {} end
self.pair_cond[pos or (#self.pair_cond + 1)] = cond
if pos then
table.insert(self.pair_cond, pos, cond)
else
table.insert(self.pair_cond, cond)
end
return self
end

Expand Down
1 change: 1 addition & 0 deletions lua/nvim-autopairs/rules/basic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ local utils = require('nvim-autopairs.utils')
local function quote_creator(opt)
local quote = function(...)
local move_func = opt.enable_moveright and cond.move_right or cond.none
---@type Rule
local rule = Rule(...)
:with_move(move_func())
:with_pair(cond.not_add_quote_inside_quote())
Expand Down

0 comments on commit 4fea246

Please sign in to comment.