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
-
7
1
local M = {}
8
2
9
3
-- Setup the plugin with user-defined options.
10
4
--- @param user_opts user_options | nil The user options.
11
5
M .setup = function (user_opts )
12
- config .setup (user_opts )
6
+ require ( " nvim-surround. config" ) .setup (user_opts )
13
7
end
14
8
15
9
-- Configure the plugin on a per-buffer basis.
16
10
--- @param buffer_opts user_options | nil The buffer-local options.
17
11
M .buffer_setup = function (buffer_opts )
18
- config .buffer_setup (buffer_opts )
12
+ require ( " nvim-surround. config" ) .buffer_setup (buffer_opts )
19
13
end
20
14
21
15
-- Add delimiters around the cursor, in insert mode.
22
16
--- @param args { line_mode : boolean } Whether or not the delimiters should get put on new lines.
23
17
M .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" )
24
21
local char = input .get_char ()
25
22
local curpos = buffer .get_curpos ()
26
23
local delimiters = config .get_delimiters (char , args .line_mode )
@@ -50,6 +47,9 @@ M.pending_surround = false
50
47
--- @param args { selection : selection , delimiters : delimiter_pair , line_mode : boolean }
51
48
--- @return " g@" | nil
52
49
M .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" )
53
53
-- Call the operatorfunc if it has not been called yet
54
54
if not args .selection then
55
55
-- Clear the normal cache (since it was user-called)
83
83
-- Add delimiters around a visual selection.
84
84
--- @param args { line_mode : boolean , curpos : position , curswant : number }
85
85
M .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" )
86
89
local ins_char = input .get_char ()
87
90
88
91
if vim .fn .visualmode () == " V" then
153
156
--- @param args { del_char : string , curpos : position }| nil
154
157
--- @return " g@l" | nil
155
158
M .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" )
156
163
-- Call the operatorfunc if it has not been called yet
157
164
if not args then
158
165
-- Clear the delete cache (since it was user-called)
186
193
--- @param args { curpos : position , del_char : string , add_delimiters : add_func , line_mode : boolean }
187
194
--- @return " g@l" | nil
188
195
M .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" )
189
200
-- Call the operatorfunc if it has not been called yet
190
201
if not args .del_char or not args .add_delimiters then
191
202
-- Clear the change cache (since it was user-called)
248
259
249
260
--- @param mode " char" | " line" | " block"
250
261
M .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" )
251
266
buffer .restore_curpos ({ old_pos = M .normal_curpos })
252
267
-- Adjust the ] mark if the operator was in line-mode, e.g. `ip` or `3j`
253
268
if mode == " line" then
@@ -307,6 +322,9 @@ M.normal_callback = function(mode)
307
322
end
308
323
309
324
M .delete_callback = function ()
325
+ local buffer = require (" nvim-surround.buffer" )
326
+ local cache = require (" nvim-surround.cache" )
327
+ local input = require (" nvim-surround.input" )
310
328
-- Save the current position of the cursor
311
329
local curpos = buffer .get_curpos ()
312
330
-- Get a character input if not cached
@@ -322,6 +340,11 @@ M.delete_callback = function()
322
340
end
323
341
324
342
M .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" )
325
348
-- Save the current position of the cursor
326
349
local curpos = buffer .get_curpos ()
327
350
if not cache .change .del_char or not cache .change .add_delimiters then
0 commit comments