File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed
Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,8 @@ function M.open()
1919
2020 -- Receiver
2121 local current_struct_name = helper .get_struct_at_cursor ()
22- local default_value = current_struct_name and helper .predict_abbreviation (current_struct_name ) or " "
22+ local default_value = current_struct_name and config .options .receiver .predict_abbreviation (current_struct_name )
23+ or " "
2324 ui .get_receiver (default_value , function (recevier )
2425 coroutine.resume (co , recevier )
2526 end )
Original file line number Diff line number Diff line change @@ -7,6 +7,26 @@ M.options = {
77 --- @usage "snacks" - Use folke/snacks picker
88 --- @usage "fzf_lua" - Use ibhagwan/fzf-lua
99 picker = nil ,
10+ receiver = {
11+ --- Predict the abbreviation for the current struct
12+ --- @param struct_name ? string The Go struct name
13+ --- @return string abbreviation The predicted abbreviation
14+ predict_abbreviation = function (struct_name )
15+ if not struct_name then
16+ return " "
17+ end
18+
19+ local abbreviation = " "
20+ abbreviation = abbreviation .. string.sub (struct_name , 1 , 1 )
21+ for i = 2 , # struct_name do
22+ local char = string.sub (struct_name , i , i )
23+ if char == string.upper (char ) and char ~= string.lower (char ) then
24+ abbreviation = abbreviation .. char
25+ end
26+ end
27+ return string.lower (abbreviation ) .. " *" .. struct_name
28+ end ,
29+ },
1030 insert = {
1131 --- @type " after" | " before" | " end"
1232 --- @usage "after" - insert after the receiver's struct declaration
You can’t perform that action at this time.
0 commit comments