Skip to content

Commit 283e614

Browse files
committed
Merge pull request #21 from bendk/buffer-management
Better buffer/window management for showing FML output
2 parents 924949c + 59f4f35 commit 283e614

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

plugin/follow-my-lead.vim

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,17 +91,11 @@ function! FMLCalcMappingWidth(mappings)
9191
return mapping_width
9292
endfunction
9393

94-
function! FMLClose()
95-
unlet s:fml_bufnr
96-
bdelete
97-
endfunction
98-
9994
function! FMLShow()
10095
let formattedMappings = join(map(FMLGetLeaderMappingsBySource(), 'FMLFormatMappings(v:val.source, v:val.mappings)'), "\n\n")
10196

102-
if(exists('s:fml_bufnr'))
97+
if(exists('s:fml_bufnr') && bufwinnr(s:fml_bufnr) != -1)
10398
execute bufwinnr(s:fml_bufnr) . 'wincmd w'
104-
execute 'normal ggdG'
10599
else
106100
new
107101
" Make it an unlisted scratch buffer
@@ -110,10 +104,12 @@ function! FMLShow()
110104
setlocal noswapfile
111105
setlocal nobuflisted
112106

113-
nnoremap <buffer> <silent> q :call FMLClose()<cr>
107+
nnoremap <buffer> <silent> q :bdelete<cr>
108+
silent file [Follow My Lead]
114109
let s:fml_bufnr = bufnr('%')
115110
endif
116111

112+
normal! ggdG
117113
put =formattedMappings
118114
normal! gg
119115

0 commit comments

Comments
 (0)