Comments (7)
Okay, so I quickly updated the plugin to make this possible.
If you don't like the solution, then pleas give me feedback on how I could make it easier, as I don't know how to make it easier.
local ua_core=require'ultimate-autopair.core'
local ua=require'ultimate-autopair'
--For keycode:
---Make sure to pass them through `vim.api.nvim_replace_termcodes(key,true,true,true)` (or `vim.keycode(key)` if using neovim 0.10)
ua_core.dont_map={keycodes}
ua.setup(config)
vim.keymap.set('i',key,function()
return ua_core.run(keycode)
end,{expr=true,noremap=true,replace_keycodes=false})
Example
local ua_core=require'ultimate-autopair.core'
local ua=require'ultimate-autopair'
ua_core.dont_map={vim.api.nvim_replace_termcodes('<bs>',true,true,true)}
ua.setup({})
vim.keymap.set('i','<C-h>',function()
return ua_core.run(vim.api.nvim_replace_termcodes('<bs>',true,true,true))
end,{expr=true,noremap=true,replace_keycodes=false})
from ultimate-autopair.nvim.
Thank you for your reply! I'm going to try it.
from ultimate-autopair.nvim.
I have succeeded with your example. Moreover, I found the following code also works:
require('ultimate-autopair').setup({
cr = {
map = '<Plug>UltimateAutopairCR' -- or any other keys
}
})
function s:expand_ultimate_autopair_cr()
return luaeval("require('ultimate-autopair.core').run(vim.api.nvim_replace_termcodes('<CR>', true, true, true))")
endfunction
inoremap <silent> <expr> <CR> <SID>expand_ultimate_autopair_cr()
That seems a little bit simpler to me, because I have other vim plugins who provide mappings in VimL and should be added to the inoremap
line.
I think it is simpler if I can write something like:
require('ultimate-autopair').setup({
cr = {
map = nil -- disable the keymap but allows custom expansion with ua_core.run()
}
})
Thanks!
from ultimate-autopair.nvim.
Might I enquire why you reopened this issue?
from ultimate-autopair.nvim.
As I mentioned in the previous post, might I ask for a API like this?:
require('ultimate-autopair').setup({
cr = {
map = nil -- disable the keymap but allows custom expansion with ua_core.run()
}
})
Please feel free to close the issue if this is not your consideration. Thank you!
from ultimate-autopair.nvim.
Okay; added map=''
to just initialize modulo without any mappings and ''
which will activate all default mappings.
If you want to run for example newline, you can use:
local core=require'ultimate-autopair.core'
local default=require'ultimate-autopair.profile.default.utils'
vim.keymap.set('i','\r',function ()
local o=core.get_o_value('') --get information about the position; use key=='' which will activate all modules
for _,v in pairs(default.filter_for_opt({'newline'})) do --filter for specifically newline modules
local ret=v.check(vim.deepcopy(o))
if ret then return core.I.activate_iabbrev(ret) end
end
return '\x1d\r' --\x1d > :help i_CTRL-]
end,{expr=true,replace_keycodes=false})
from ultimate-autopair.nvim.
Thanks. That solves my problem.
from ultimate-autopair.nvim.
Related Issues (20)
- [Question] How to ignore a specific parser? HOT 1
- Builtin C-style block comment support HOT 2
- [Question] - JSX Support HOT 4
- alpha extension unexpected behavior HOT 2
- Support for lua `[=[...]=]` string? HOT 4
- [Performance] Holding on space in large markdown files freeze the editor HOT 3
- [Bug] Incorrect pair exiting behavior HOT 1
- [BUG] Wrong behavior when deleting asterisk in makdown files HOT 1
- Healthcheck fails saying parser is missing for 'lua' HOT 4
- [Feature Request] Specify pairs by regular expression HOT 3
- Way to prevent autocomplete if Esc is pressed? HOT 16
- Delete comma after pair HOT 6
- Undo mappings in insert mode don't work as expected HOT 3
- [BUG] Installing ultimate-autopair causes luasnip to malfunction HOT 2
- Parenths don't auto close in swift files with swift string interpolation HOT 5
- Feature request: fastwarp for left parenthesis
- Suround vs Surround HOT 2
- Bug: `in_string()` errors in `ftplugin/lua.lua` HOT 4
- [Bug] Pairing in Select mode doesn't work when LSP server loads HOT 3
- [Bug] Enter binding breaks when using `ray-x/lsp_signature.nvim` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ultimate-autopair.nvim.