summaryrefslogtreecommitdiff
path: root/lua/core/autopairs.lua
diff options
context:
space:
mode:
authordevtoi <[email protected]>2021-08-22 20:03:19 +0200
committerGitHub <[email protected]>2021-08-22 20:03:19 +0200
commitd85584d09f9028fa4202cea473f7f0ae3c531aef (patch)
tree956d7d9909ca8e37ec604d96965ae7f878262388 /lua/core/autopairs.lua
parentc5c9ae0fb68567c2a207c8c486b03bbafc650f98 (diff)
[Refactor/Bugfix] move on_config_done callbacks to relevant setup() (#1175)
* Make autopairs config consistent with others * Fix two typos for autopairs * Remove extranous autopairs code. Return on setup * Remove extranous else for autopairs completion confirmation * Move on_config_done callbacks to setup functions. * Add on_config_done completion for builtins lacking a config function * enables galaxyline callbacks to work properly * Add modules for more builtins * Finish streamline of config function in plugin setup * Fix double use of which_key/wk * Fix erroneous remove of functionality in autopairs completion * consistency fixes * Work around telescope not found at config time * Match plugin definition of project and lualine with others * fix: restore config callback syntax Co-authored-by: Johan Melin <[email protected]> Co-authored-by: rebuilt <[email protected]> Co-authored-by: Luc Sinet <[email protected]> Co-authored-by: kylo252 <[email protected]>
Diffstat (limited to 'lua/core/autopairs.lua')
-rw-r--r--lua/core/autopairs.lua17
1 files changed, 11 insertions, 6 deletions
diff --git a/lua/core/autopairs.lua b/lua/core/autopairs.lua
index 470f8335..24aa1875 100644
--- a/lua/core/autopairs.lua
+++ b/lua/core/autopairs.lua
@@ -3,6 +3,7 @@ local M = {}
function M.config()
lvim.builtin.autopairs = {
active = true,
+ on_config_done = nil,
---@usage map <CR> on insert mode
map_cr = true,
---@usage auto insert after select function or method item
@@ -21,19 +22,19 @@ end
M.setup = function()
-- skip it, if you use another global object
_G.MUtils = {}
- local npairs = require "nvim-autopairs"
+ local autopairs = require "nvim-autopairs"
local Rule = require "nvim-autopairs.rule"
vim.g.completion_confirm_key = ""
MUtils.completion_confirm = function()
if vim.fn.pumvisible() ~= 0 then
if vim.fn.complete_info()["selected"] ~= -1 then
- return vim.fn["compe#confirm"](npairs.esc "<cr>")
+ return vim.fn["compe#confirm"](autopairs.esc "<cr>")
else
- return npairs.esc "<cr>"
+ return autopairs.esc "<cr>"
end
else
- return npairs.autopairs_cr()
+ return autopairs.autopairs_cr()
end
end
@@ -44,7 +45,7 @@ M.setup = function()
}
end
- npairs.setup {
+ autopairs.setup {
check_ts = lvim.builtin.autopairs.check_ts,
ts_config = lvim.builtin.autopairs.ts_config,
}
@@ -55,10 +56,14 @@ M.setup = function()
-- TODO: can these rules be safely added from "config.lua" ?
-- press % => %% is only inside comment or string
- npairs.add_rules {
+ autopairs.add_rules {
Rule("%", "%", "lua"):with_pair(ts_conds.is_ts_node { "string", "comment" }),
Rule("$", "$", "lua"):with_pair(ts_conds.is_not_ts_node { "function" }),
}
+
+ if lvim.builtin.autopairs.on_config_done then
+ lvim.builtin.autopairs.on_config_done(autopairs)
+ end
end
return M