From eb90d484c56a9f699310699eaebdeaa22b21f475 Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Tue, 1 Aug 2023 20:28:56 -0700 Subject: [PATCH] fix: allow brackets in prefixed strings --- lua/nvim-autopairs/rules/basic.lua | 2 +- lua/nvim-autopairs/utils.lua | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/lua/nvim-autopairs/rules/basic.lua b/lua/nvim-autopairs/rules/basic.lua index ca42b023..a3b94488 100644 --- a/lua/nvim-autopairs/rules/basic.lua +++ b/lua/nvim-autopairs/rules/basic.lua @@ -24,7 +24,7 @@ local function bracket_creator(opt) end if opt.enable_bracket_in_quote then -- still add bracket if text is quote "|" and next_char have " - rule:with_pair(cond.is_bracket_in_quote(), 1) + rule:with_pair(cond.is_bracket_in_quote(), 2) end return rule end diff --git a/lua/nvim-autopairs/utils.lua b/lua/nvim-autopairs/utils.lua index 5ffdc9d1..273e8c07 100644 --- a/lua/nvim-autopairs/utils.lua +++ b/lua/nvim-autopairs/utils.lua @@ -68,10 +68,8 @@ M.is_in_quotes = function (line, pos, quote_type) result == false and M.is_quote(char) and (not quote_type or char == quote_type) and - --a single quote with a word before is not count unless it is a - -- prefixed string in python (e.g. f'string {with_brackets}') - not (char == "'" and prev_char:match(vim.bo.filetype == "python" - and "[AC-EG-QS-TV-Zac-eg-qs-tv-z0-9]" or "%w")) + --a single quote with a word before is not count + not (char == "'" and prev_char:match("%w")) then last_char = quote_type or char result = true