Skip to content

Commit

Permalink
fix: allow brackets in prefixed strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ribru17 committed Aug 2, 2023
1 parent a4f4ad1 commit eb90d48
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lua/nvim-autopairs/rules/basic.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions lua/nvim-autopairs/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit eb90d48

Please sign in to comment.