-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrefactor.vim
31 lines (27 loc) · 887 Bytes
/
refactor.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
function refactor#menu() abort
let l:refactorCommandsMap = s:refactorCommands()
echo l:refactorCommandsMap
echo type(l:refactorCommandsMap)
let l:choice = inputlist(s:GetMainMenu())
let l:commandToExecute = "refactor#" .. &filetype .. "#" .. l:refactorCommandsMap[l:commands[l:choice]]
" echo l:commandToExecute
execute "call " .. l:commandToExecute .. "()"
endfunction
function! s:refactorCommands()
let l:refactorCommandsMap = {
\"Rename": "Rename",
\"Extract Variable": "ExtractVariable",
\"Extract Method": "ExtractMethod",
\"Inline": "Inline"
\}
return l:refactorCommandsMap
endfunction
function! s:GetMainMenu()
let l:result = []
let l:i = 0
for l:command in keys(s:refactorCommandsMap())
l:result[l:i] = l:i . " " . l:command
l:i+=1
endfor
return l:result
endfunction