Giter Club home page Giter Club logo

Comments (7)

altermo avatar altermo commented on June 30, 2024 1

Oh, I forgot that run_run returns the inputted key, so:

local core=require'ultimate-autopair.core'
vim.keymap.set('i','\r',function()
    local key=core.run_run(vim.api.nvim_replace_termcodes('<plug>ultimate-autopair-CR',true,true,true))
    if key==vim.api.nvim_replace_termcodes('<plug>ultimate-autopair-CR',true,true,true) then
        vim.api.nvim_feedkeys('\r','n',false)
    else
        vim.api.nvim_feedkeys(key,'n',false)
    end
end)

from ultimate-autopair.nvim.

altermo avatar altermo commented on June 30, 2024

The thing is that each key gets past through nvim_replace_termcodes, so it is \r and not <cr>.
Note that core.run returns an action and requires the mapping to be an <expr>, activating textlock, which you probably don't want.
So I would guess you want this:

local core=require'ultimate-autopair.core'
vim.keymap.set('i','\r',function()
    vim.api.nvim_feedkeys(core.run_run('\r'),'n',false)
end)

(I'm currently working on the next version of the plugin where this will be simplified)

from ultimate-autopair.nvim.

weilbith avatar weilbith commented on June 30, 2024

Nice, thank you!

How can I know disable the automatic mapping by the plugin? I have some issues with the loading order, so my mappings gets overwritten by the one of the plugin atm. But if I set in the plugin config the cr = { map = '' }, then the run_run function does not work anymore. Can I disable the plugin to create the mapping, but still have the function working?

(I'm currently working on the next version of the plugin where this will be simplified)

Cool! 👍

from ultimate-autopair.nvim.

altermo avatar altermo commented on June 30, 2024

It is not possible (yet).
But you could do cr = { map = '<plug>ultimate-autopair-CR' } and then use

local core=require'ultimate-autopair.core'
vim.keymap.set('i','\r',function()
    vim.api.nvim_feedkeys(core.run_run(vim.api.nvim_replace_termcodes('<plug>ultimate-autopair-CR',true,true,true)),'n',false)
end)

from ultimate-autopair.nvim.

weilbith avatar weilbith commented on June 30, 2024

Nice, that does the job. Good idea! 👍🏾
Thank you very much for your help!

from ultimate-autopair.nvim.

weilbith avatar weilbith commented on June 30, 2024

Damn. I get sometimes recursive mapping errors now. Don't know where they are coming from. 😑
It triggers when I hit enter and there is nothing happening by autopair. So if I type (<CR>, that is fine. But if I just type <CR> anywhere else to create a new line, it fails with the recursion error. 🤔
Surprised that also explicitly setting noremap = true doesn't help. 😖

from ultimate-autopair.nvim.

weilbith avatar weilbith commented on June 30, 2024

Alright, this finally works now. 👌🏾
Despite that part: I love how powerful this plugin is. 😊

from ultimate-autopair.nvim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.