Skip to content

Commit

Permalink
fix cr mapping change mode with <c-c> (#393)
Browse files Browse the repository at this point in the history
* made the plugin move the cursor less

---------

Co-authored-by: Sam-programs <None>
  • Loading branch information
Sam-programs committed Sep 19, 2023
1 parent 3b664e8 commit f611dc2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
6 changes: 2 additions & 4 deletions lua/nvim-autopairs.lua
Expand Up @@ -567,12 +567,10 @@ M.autopairs_cr = function(bufnr)
and rule:can_cr(cond_opt)
then
local end_pair = rule:get_end_pair(cond_opt)
local end_pair_length = rule:get_end_pair_length(end_pair)
return utils.esc(
end_pair
.. utils.repeat_key(utils.key.join_left, end_pair_length)
'<CR>' .. end_pair
-- FIXME do i need to re indent twice #118
.. '<cr><esc>====O'
.. '<CMD>normal ====k$<CR><right><CR>'
)
end

Expand Down
11 changes: 5 additions & 6 deletions lua/nvim-autopairs/rule.lua
Expand Up @@ -15,9 +15,9 @@ local Cond = require('nvim-autopairs.conds')
--- @field is_undo boolean add break undo sequence

local Rule = setmetatable({}, {
__call = function(self, ...)
return self.new(...)
end,
__call = function(self, ...)
return self.new(...)
end,
})

---@return Rule
Expand Down Expand Up @@ -114,9 +114,8 @@ function Rule:get_map_cr(opts)
if self.map_cr_func then
return self.map_cr_func(opts)
end
return '<c-g>u<cr><c-c>==O'
return '<c-g>u<CR><CMD>normal ==k$<CR><right><CR>'
end

function Rule:replace_map_cr(value)
self.map_cr_func = value
return self
Expand Down Expand Up @@ -173,7 +172,7 @@ 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
self.pair_cond[pos or (#self.pair_cond + 1)] = cond
return self
end

Expand Down

0 comments on commit f611dc2

Please sign in to comment.