Skip to content

Commit d68d842

Browse files
author
lepoussin
committed
Don't remove comments in VHDL_map_put()
1 parent 4aa4ba9 commit d68d842

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

plugin/vhdl.vim

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ fun! VHDL_nice_align() range
5252

5353
" Reindent
5454
let equalprg_bak = &l:equalprg
55+
setlocal equalprg=
5556
silent exe 'norm '.(a:lastline-a:firstline+1).'=='
5657
let &l:equalprg = equalprg_bak
5758

@@ -273,16 +274,15 @@ fun! VHDL_map_put()
273274
endif
274275
exe "norm ma\<Esc>ap ("
275276

276-
call map(lines, 'substitute(v:val, "\\(--.*\\)\\@<!:[^;]*","=> ", "g")')
277-
call map(lines, 'substitute(v:val, "\\(--.*\\)\\@<!=> ;","=> ,", "g")')
277+
call map(lines, 'substitute(v:val, "\\(--.*\\)\\@<!:.\\{-}\\ze\\(;\\| \\?--\\|$\\)","=> ", "")')
278+
call map(lines, 'substitute(v:val, "\\(--.*\\)\\@<!=> ;","=> ,", "")')
278279
if lines[-1] !~ '--'
279280
let lines[-1] = substitute(lines[-1], '\(,\|);\)$', ')', '') "XXX
280281
endif
281282
silent! pu=lines
282283
norm o
283284
let cursor_bak2 = getpos('.')
284-
285-
exe '.-'.(len(lines)).',.call VHDL_nice_align()'
285+
"exe '.-'.(len(lines)).',.call VHDL_nice_align()'
286286
let end_move = 1
287287

288288
endif
@@ -320,19 +320,21 @@ fun! VHDL_map_put()
320320
else
321321
exe "norm ama\<Esc>ap ("
322322

323-
call map(lines, 'substitute(v:val, "\\(--.*\\)\\@<!:[^;]*","=> ", "g")')
324-
call map(lines, 'substitute(v:val, "\\(--.*\\)\\@<!=> ;","=> ,", "g")')
323+
call map(lines, 'substitute(v:val, "\\(--.*\\)\\@<!:.\\{-}\\ze\\(;\\| \\?--\\|$\\)","=> ", "")')
324+
call map(lines, 'substitute(v:val, "\\(--.*\\)\\@<!=> ;","=> ,", "")')
325325
if lines[-1] !~ '--'
326326
let lines[-1] = substitute(lines[-1], '\(,\|);\)$', ');', '') "XXX
327327
endif
328328
silent! pu=lines
329-
exe '.-'.(len(lines)).',.call VHDL_nice_align()'
329+
"exe '.-'.(len(lines)).',.call VHDL_nice_align()'
330330
let end_move = 1
331331

332332
endif
333333

334334
endif
335335

336+
exe cursor_bak[1].',.call VHDL_nice_align()'
337+
336338
" Go after first =>, if something has been added
337339
if exists('end_move')
338340
call setpos('.', cursor_bak)

0 commit comments

Comments
 (0)