feat(plugins): add autopairs
This commit is contained in:
parent
4ea6e5d4bf
commit
d5fa53ba29
1 changed files with 54 additions and 0 deletions
54
plugins/autopairs.nix
Normal file
54
plugins/autopairs.nix
Normal file
|
|
@ -0,0 +1,54 @@
|
||||||
|
# homepage: https://github.com/windwp/nvim-autopairs
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
extra = {
|
||||||
|
packages = [ pkgs.vimPlugins.nvim-autopairs ];
|
||||||
|
|
||||||
|
# Config (taken from AstroNvim)
|
||||||
|
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/autopairs.lua#L14-L25
|
||||||
|
# With cmp integration
|
||||||
|
# https://github.com/AstroNvim/AstroNvim/blob/v4.7.7/lua/astronvim/plugins/configs/nvim-autopairs.lua#L10
|
||||||
|
config = ''
|
||||||
|
require("nvim-autopairs").setup({
|
||||||
|
check_ts = true,
|
||||||
|
ts_config = { java = false },
|
||||||
|
fast_wrap = {
|
||||||
|
map = "<M-e>",
|
||||||
|
chars = { "{", "[", "(", '"', "'" },
|
||||||
|
pattern = ([[ [%'%"%)%>%]%)%}%,] ]]):gsub("%s+", ""),
|
||||||
|
offset = 0,
|
||||||
|
end_key = "$",
|
||||||
|
keys = "qwertyuiopzxcvbnmasdfghjkl",
|
||||||
|
check_comma = true,
|
||||||
|
highlight = "PmenuSel",
|
||||||
|
highlight_grey = "LineNr",
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
--- TODO: uncomment when cmp is setup
|
||||||
|
---require("cmp").event:on("confirm_done", require("nvim-autopairs.completion.cmp").on_confirm_done { tex = false })
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
rootOpts.keymaps = [
|
||||||
|
{
|
||||||
|
key = "<leader>ua";
|
||||||
|
|
||||||
|
# https://github.com/AstroNvim/astrocore/blob/v1.4.0/lua/astrocore/toggles.lua#L37-L50
|
||||||
|
action.__raw = ''
|
||||||
|
function()
|
||||||
|
local ok, autopairs = pcall(require, "nvim-autopairs")
|
||||||
|
if ok then
|
||||||
|
if autopairs.state.disabled then
|
||||||
|
autopairs.enable()
|
||||||
|
else
|
||||||
|
autopairs.disable()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
options.desc = "Toggle autopairs";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue