diff options
-rw-r--r-- | .config/nvim/init.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/.config/nvim/init.lua b/.config/nvim/init.lua index 33cfe4d..0ae24da 100644 --- a/.config/nvim/init.lua +++ b/.config/nvim/init.lua @@ -346,6 +346,7 @@ require('nvim-treesitter.configs').setup { } -- nvim-surround +local surround_conf = require('nvim-surround.config') require('nvim-surround').setup { surrounds = { ['’'] = { @@ -371,6 +372,30 @@ require('nvim-surround').setup { find = '“[^“”]*”', delete = '^(“ *)().-( *”)()$', }, + + ['l'] = { + add = function() + local result = surround_conf.get_input('Array name: ') + if result then + return { { result .. '[' }, { ']' } } + end + end, + find = function() + return surround_conf.get_selection({ + pattern = '[^=%s%(%){}]+%b[]' + }) + end, + delete = '^(.-%[)().-(%])()$', + change = { + target = '^.-([%w_]+)()%[.-%]()()$', + replacement = function() + local result = surround_conf.get_input('Array name: ') + if result then + return { { result }, { '' } } + end + end, + }, + }, } } |