Skip to content

Commit 1b39ac4

Browse files
committed
feat: support new ruby hash syntax
Refs: ecomba#52
1 parent 6447a4d commit 1b39ac4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

plugin/refactorings/general/extractmethod.vim

+11-1
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,24 @@ function! s:ruby_identify_tokens( tokenlist )
134134

135135
let ignore_to_eos = 0
136136

137+
let i = 1
137138
for token in a:tokenlist
139+
try
140+
let next_token = a:tokenlist[i+1]
141+
catch
142+
endtry
138143
if index(reserved,token) != -1
139144
let sym = "KEYWORD"
140145
elseif match(token, '\v^\s+$') != -1
141146
let sym = "WS"
142147
elseif match(token, '\v^\:\w+$') != -1
143148
let sym = "SYMBOL"
144149
elseif match(token, '\v^\I\i*$') != -1
145-
let sym = "VAR"
150+
if match(next_token, '\:' != -1)
151+
let sym = "SYMBOL"
152+
else
153+
let sym = "VAR"
154+
endif
146155
elseif match(token, '\v^\@\I\i*$') != -1
147156
let sym = "IVAR"
148157
elseif match(token, '\v^\d+(\.\d+)?$') != -1
@@ -189,6 +198,7 @@ function! s:ruby_identify_tokens( tokenlist )
189198
endif
190199

191200
return statements
201+
let i+=1
192202
endfunction
193203

194204
" Synopsis:

0 commit comments

Comments
 (0)