@@ -2,12 +2,9 @@ local M = {}
2
2
3
3
local debugprint = require (" debugprint" )
4
4
5
- local map_key = function (mode , lhs , buffer , opts )
6
- if
7
- lhs ~= nil
8
- and vim .api .nvim_get_option_value (" modifiable" , { buf = buffer })
9
- then
10
- vim .api .nvim_buf_set_keymap (buffer , mode , lhs , " " , opts )
5
+ local map_key = function (mode , lhs , opts )
6
+ if lhs ~= nil then
7
+ vim .api .nvim_set_keymap (mode , lhs , " " , opts )
11
8
end
12
9
end
13
10
@@ -18,130 +15,130 @@ local feedkeys = function(keys)
18
15
end
19
16
20
17
M .map_keys_and_commands = function (global_opts )
21
- vim .api .nvim_create_autocmd ({ " BufReadPost" , " BufNewFile" }, {
22
- group = vim .api .nvim_create_augroup (
23
- " debugprint_augroup" ,
24
- { clear = true }
25
- ),
26
- callback = function (opts )
27
- map_key (" n" , global_opts .keymaps .normal .plain_below , opts .buf , {
28
- callback = function ()
29
- feedkeys (debugprint .debugprint ({}))
30
- end ,
31
- desc = " Plain debug below current line" ,
32
- })
18
+ map_key (" n" , global_opts .keymaps .normal .plain_below , {
19
+ callback = function ()
20
+ feedkeys (debugprint .debugprint ({}))
21
+ end ,
22
+ desc = " Plain debug below current line" ,
23
+ })
33
24
34
- map_key (" n" , global_opts .keymaps .normal .plain_above , opts . buf , {
35
- callback = function ()
36
- feedkeys (debugprint .debugprint ({ above = true }))
37
- end ,
38
- desc = " Plain debug below current line" ,
39
- })
25
+ map_key (" n" , global_opts .keymaps .normal .plain_above , {
26
+ callback = function ()
27
+ feedkeys (debugprint .debugprint ({ above = true }))
28
+ end ,
29
+ desc = " Plain debug below current line" ,
30
+ })
40
31
41
- map_key (" n" , global_opts .keymaps .normal .variable_below , opts . buf , {
42
- callback = function ()
43
- feedkeys (debugprint .debugprint ({ variable = true }))
44
- end ,
45
- desc = " Variable debug below current line" ,
46
- })
32
+ map_key (" n" , global_opts .keymaps .normal .variable_below , {
33
+ callback = function ()
34
+ feedkeys (debugprint .debugprint ({ variable = true }))
35
+ end ,
36
+ desc = " Variable debug below current line" ,
37
+ })
47
38
48
- map_key (" n" , global_opts .keymaps .normal .variable_above , opts . buf , {
49
- callback = function ()
50
- feedkeys (debugprint .debugprint ({
51
- above = true ,
52
- variable = true ,
53
- }))
54
- end ,
55
- desc = " Variable debug above current line" ,
56
- })
39
+ map_key (" n" , global_opts .keymaps .normal .variable_above , {
40
+ callback = function ()
41
+ feedkeys (debugprint .debugprint ({
42
+ above = true ,
43
+ variable = true ,
44
+ }))
45
+ end ,
46
+ desc = " Variable debug above current line" ,
47
+ })
57
48
58
- map_key (
59
- " n" ,
60
- global_opts .keymaps .normal .variable_below_alwaysprompt ,
61
- opts .buf ,
62
- {
63
- callback = function ()
64
- feedkeys (debugprint .debugprint ({
65
- variable = true ,
66
- ignore_treesitter = true ,
67
- }))
68
- end ,
69
- desc = " Variable debug below current line (always prompt})" ,
70
- }
71
- )
72
-
73
- map_key (
74
- " n" ,
75
- global_opts .keymaps .normal .variable_above_alwaysprompt ,
76
- opts .buf ,
77
- {
78
- callback = function ()
79
- feedkeys (debugprint .debugprint ({
80
- above = true ,
81
- variable = true ,
82
- ignore_treesitter = true ,
83
- }))
84
- end ,
85
- desc = " Variable debug above current line (always prompt})" ,
86
- }
87
- )
88
-
89
- map_key (" n" , global_opts .keymaps .normal .textobj_below , opts .buf , {
90
- callback = function ()
91
- return debugprint .debugprint ({ motion = true })
92
- end ,
93
- expr = true ,
94
- desc = " Text-obj-selected variable debug below current line" ,
95
- })
49
+ map_key (" n" , global_opts .keymaps .normal .variable_below_alwaysprompt , {
50
+ callback = function ()
51
+ feedkeys (debugprint .debugprint ({
52
+ variable = true ,
53
+ ignore_treesitter = true ,
54
+ }))
55
+ end ,
56
+ desc = " Variable debug below current line (always prompt})" ,
57
+ })
96
58
97
- map_key (" n" , global_opts .keymaps .normal .textobj_above , opts . buf , {
98
- callback = function ()
99
- return debugprint .debugprint ({
100
- motion = true ,
101
- above = true ,
102
- })
103
- end ,
104
- expr = true ,
105
- desc = " Text-obj-selected variable debug above current line" ,
106
- })
59
+ map_key (" n" , global_opts .keymaps .normal .variable_above_alwaysprompt , {
60
+ callback = function ()
61
+ feedkeys ( debugprint .debugprint ({
62
+ above = true ,
63
+ variable = true ,
64
+ ignore_treesitter = true ,
65
+ }))
66
+ end ,
67
+ desc = " Variable debug above current line (always prompt}) " ,
68
+ })
107
69
108
- map_key (
109
- " n" ,
110
- global_opts .keymaps .normal .delete_debug_prints ,
111
- opts .buf ,
112
- {
113
- callback = debugprint .deleteprints ,
114
- desc = " Delete all debugprint statements in the current buffer" ,
115
- }
116
- )
117
-
118
- map_key (
119
- " n" ,
120
- global_opts .keymaps .normal .toggle_comment_debug_prints ,
121
- opts .buf ,
122
- {
123
- callback = debugprint .toggle_comment_debugprints ,
124
- desc = " Comment/uncomment all debugprint statements in the current buffer" ,
125
- }
126
- )
127
-
128
- map_key (" x" , global_opts .keymaps .visual .variable_below , opts .buf , {
129
- callback = function ()
130
- feedkeys (debugprint .debugprint ({ variable = true }))
131
- end ,
132
- desc = " Variable debug below current line" ,
70
+ map_key (" n" , global_opts .keymaps .normal .textobj_below , {
71
+ callback = function ()
72
+ return debugprint .debugprint ({ motion = true })
73
+ end ,
74
+ expr = true ,
75
+ desc = " Text-obj-selected variable debug below current line" ,
76
+ })
77
+
78
+ map_key (" n" , global_opts .keymaps .normal .textobj_above , {
79
+ callback = function ()
80
+ return debugprint .debugprint ({
81
+ motion = true ,
82
+ above = true ,
133
83
})
84
+ end ,
85
+ expr = true ,
86
+ desc = " Text-obj-selected variable debug above current line" ,
87
+ })
88
+
89
+ map_key (" x" , global_opts .keymaps .visual .variable_below , {
90
+ callback = function ()
91
+ feedkeys (debugprint .debugprint ({ variable = true }))
92
+ end ,
93
+ desc = " Variable debug below current line" ,
94
+ })
95
+
96
+ map_key (" x" , global_opts .keymaps .visual .variable_above , {
97
+ callback = function ()
98
+ feedkeys (debugprint .debugprint ({
99
+ above = true ,
100
+ variable = true ,
101
+ }))
102
+ end ,
103
+ desc = " Variable debug above current line" ,
104
+ })
105
+
106
+ map_key (" n" , global_opts .keymaps .normal .delete_debug_prints , {
107
+ callback = debugprint .deleteprints ,
108
+ desc = " Delete all debugprint statements in the current buffer" ,
109
+ })
110
+
111
+ map_key (" n" , global_opts .keymaps .normal .toggle_comment_debug_prints , {
112
+ callback = debugprint .toggle_comment_debugprints ,
113
+ desc = " Comment/uncomment all debugprint statements in the current buffer" ,
114
+ })
115
+
116
+ map_key (" x" , global_opts .keymaps .visual .variable_below , {
117
+ callback = function ()
118
+ feedkeys (debugprint .debugprint ({ variable = true }))
119
+ end ,
120
+ desc = " Variable debug below current line" ,
121
+ })
122
+
123
+ map_key (" x" , global_opts .keymaps .visual .variable_above , {
124
+ callback = function ()
125
+ feedkeys (debugprint .debugprint ({
126
+ above = true ,
127
+ variable = true ,
128
+ }))
129
+ end ,
130
+ desc = " Variable debug above current line" ,
131
+ })
134
132
135
- map_key (" x" , global_opts .keymaps .visual .variable_above , opts .buf , {
136
- callback = function ()
137
- feedkeys (debugprint .debugprint ({
138
- above = true ,
139
- variable = true ,
140
- }))
141
- end ,
142
- desc = " Variable debug above current line" ,
133
+ map_key (" n" , global_opts .keymaps .normal .variable_above_alwaysprompt , {
134
+ callback = function ()
135
+ return debugprint .debugprint ({
136
+ above = true ,
137
+ variable = true ,
138
+ ignore_treesitter = true ,
143
139
})
144
140
end ,
141
+ desc = " Variable debug above current line (always prompt})" ,
145
142
})
146
143
147
144
if global_opts .commands .delete_debug_prints then
0 commit comments