diff options
| author | Kyren223 <Kyren223@proton.me> | 2025-05-04 17:49:41 +0300 |
|---|---|---|
| committer | Kyren223 <Kyren223@proton.me> | 2025-05-04 17:49:41 +0300 |
| commit | 2a210c153dcf801994be28c477e4860b394f33f0 (patch) | |
| tree | f0f9dfc130b92a768e9f183ad5435cf5c9127f5b | |
| parent | 8dbf1b96294ed9205dc858f71dedd368a9be1965 (diff) | |
Configured nvim-autopairs, it's not great but alternatives like
blink.pairs is not developed enough, maybe next year
| -rw-r--r-- | .config/nvim/lua/plugins/nvim-autopairs.lua | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/.config/nvim/lua/plugins/nvim-autopairs.lua b/.config/nvim/lua/plugins/nvim-autopairs.lua index 02553f0..68f2b68 100644 --- a/.config/nvim/lua/plugins/nvim-autopairs.lua +++ b/.config/nvim/lua/plugins/nvim-autopairs.lua @@ -3,8 +3,36 @@ return { event = 'InsertEnter', opts = { check_ts = true, + -- don't add pairs inside these treesitter nodes + -- THIS DOESN'T EVEN WORK IN LUA lol + -- I guess waiting on this to be fixed... ts_config = { - lua = { 'string' }, -- don't add pairs inside lua strings + lua = { 'string' }, + go = { 'string' }, + zig = { 'string' }, }, }, + config = function(_, opts) + require('nvim-autopairs').setup(opts) + + local Rule = require('nvim-autopairs.rule') + local npairs = require('nvim-autopairs') + local cond = require('nvim-autopairs.conds') + + npairs.add_rule(Rule('<', '>', { + -- if you use nvim-ts-autotag, you may want to exclude these filetypes from this rule + -- so that it doesn't conflict with nvim-ts-autotag + '-html', + '-javascriptreact', + '-typescriptreact', + }):with_pair( + -- regex will make it so that it will auto-pair on + -- `a<` but not `a <` + -- The `:?:?` part makes it also + -- work on Rust generics like `some_func::<T>()` + cond.before_regex('%a+:?:?$', 3) + ):with_move(function(opts) + return opts.char == '>' + end)) + end, } |
