1- local buffer = require (" nvim-surround.buffer" )
2- local cache = require (" nvim-surround.cache" )
3- local config = require (" nvim-surround.config" )
4- local input = require (" nvim-surround.input" )
5- local utils = require (" nvim-surround.utils" )
6-
71local M = {}
82
93-- Setup the plugin with user-defined options.
104--- @param user_opts user_options | nil The user options.
115M .setup = function (user_opts )
12- config .setup (user_opts )
6+ require ( " nvim-surround. config" ) .setup (user_opts )
137end
148
159-- Configure the plugin on a per-buffer basis.
1610--- @param buffer_opts user_options | nil The buffer-local options.
1711M .buffer_setup = function (buffer_opts )
18- config .buffer_setup (buffer_opts )
12+ require ( " nvim-surround. config" ) .buffer_setup (buffer_opts )
1913end
2014
2115-- Add delimiters around the cursor, in insert mode.
2216--- @param args { line_mode : boolean } Whether or not the delimiters should get put on new lines.
2317M .insert_surround = function (args )
18+ local config = require (" nvim-surround.config" )
19+ local buffer = require (" nvim-surround.buffer" )
20+ local input = require (" nvim-surround.input" )
2421 local char = input .get_char ()
2522 local curpos = buffer .get_curpos ()
2623 local delimiters = config .get_delimiters (char , args .line_mode )
@@ -50,6 +47,9 @@ M.pending_surround = false
5047--- @param args { selection : selection , delimiters : delimiter_pair , line_mode : boolean }
5148--- @return " g@" | nil
5249M .normal_surround = function (args )
50+ local config = require (" nvim-surround.config" )
51+ local buffer = require (" nvim-surround.buffer" )
52+ local cache = require (" nvim-surround.cache" )
5353 -- Call the operatorfunc if it has not been called yet
5454 if not args .selection then
5555 -- Clear the normal cache (since it was user-called)
8383-- Add delimiters around a visual selection.
8484--- @param args { line_mode : boolean , curpos : position , curswant : number }
8585M .visual_surround = function (args )
86+ local config = require (" nvim-surround.config" )
87+ local buffer = require (" nvim-surround.buffer" )
88+ local input = require (" nvim-surround.input" )
8689 local ins_char = input .get_char ()
8790
8891 if vim .fn .visualmode () == " V" then
153156--- @param args { del_char : string , curpos : position }| nil
154157--- @return " g@l" | nil
155158M .delete_surround = function (args )
159+ local config = require (" nvim-surround.config" )
160+ local buffer = require (" nvim-surround.buffer" )
161+ local cache = require (" nvim-surround.cache" )
162+ local utils = require (" nvim-surround.utils" )
156163 -- Call the operatorfunc if it has not been called yet
157164 if not args then
158165 -- Clear the delete cache (since it was user-called)
186193--- @param args { curpos : position , del_char : string , add_delimiters : add_func , line_mode : boolean }
187194--- @return " g@l" | nil
188195M .change_surround = function (args )
196+ local config = require (" nvim-surround.config" )
197+ local buffer = require (" nvim-surround.buffer" )
198+ local cache = require (" nvim-surround.cache" )
199+ local utils = require (" nvim-surround.utils" )
189200 -- Call the operatorfunc if it has not been called yet
190201 if not args .del_char or not args .add_delimiters then
191202 -- Clear the change cache (since it was user-called)
248259
249260--- @param mode " char" | " line" | " block"
250261M .normal_callback = function (mode )
262+ local config = require (" nvim-surround.config" )
263+ local buffer = require (" nvim-surround.buffer" )
264+ local cache = require (" nvim-surround.cache" )
265+ local input = require (" nvim-surround.input" )
251266 buffer .restore_curpos ({ old_pos = M .normal_curpos })
252267 -- Adjust the ] mark if the operator was in line-mode, e.g. `ip` or `3j`
253268 if mode == " line" then
@@ -307,6 +322,9 @@ M.normal_callback = function(mode)
307322end
308323
309324M .delete_callback = function ()
325+ local buffer = require (" nvim-surround.buffer" )
326+ local cache = require (" nvim-surround.cache" )
327+ local input = require (" nvim-surround.input" )
310328 -- Save the current position of the cursor
311329 local curpos = buffer .get_curpos ()
312330 -- Get a character input if not cached
@@ -322,6 +340,11 @@ M.delete_callback = function()
322340end
323341
324342M .change_callback = function ()
343+ local config = require (" nvim-surround.config" )
344+ local buffer = require (" nvim-surround.buffer" )
345+ local cache = require (" nvim-surround.cache" )
346+ local input = require (" nvim-surround.input" )
347+ local utils = require (" nvim-surround.utils" )
325348 -- Save the current position of the cursor
326349 local curpos = buffer .get_curpos ()
327350 if not cache .change .del_char or not cache .change .add_delimiters then
0 commit comments