Skip to content

Commit

Permalink
Fix other plugins loading
Browse files Browse the repository at this point in the history
It was noticed that file_line plugin breaks the loading of
other plugins. For example, when having next line in ~/.vimrc:

    au BufNewFile main.c silent! 0r ~/.vim/skeleton/template.c

this line loads the content from template file when I'm creating new
main.c file. But when file-line plugin is installed this functionality
doesn't work (newly created main.c is blank). This patch fixes that.

Also, it was reported that file_line breaks vim-go plugin. I haven't
check if this patch fixes it though.

Fixes: bogado#62

Signed-off-by: Sam Protsenko <[email protected]>
  • Loading branch information
Sam Protsenko committed Jun 12, 2019
1 parent 559088a commit f1bf6c5
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions plugin/file_line.vim
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ function! s:reopenAndGotoLine(file_name, line_num, col_num)
exec "filetype detect"
endfunction

function! s:gotoline()
" Returns actual file name (without :* part)
" If is_goto parameter is 1, then file will be re-opened at the line parsed from
" :* part
function! s:get_file_name_and_goto(is_goto)
let file = bufname("%")

" :e command calls BufRead even though the file is a new one.
Expand All @@ -53,14 +56,27 @@ function! s:gotoline()
if ! empty(l:names)
let file_name = l:names[1]
let line_num = l:names[2] == ''? '0' : l:names[2]
let col_num = l:names[3] == ''? '0' : l:names[3]
call s:reopenAndGotoLine(file_name, line_num, col_num)
let col_num = l:names[3] == ''? '0' : l:names[3]
if (a:is_goto == 1)
call s:reopenAndGotoLine(file_name, line_num,
\ col_num)
endif
return file_name
endif
endfor
return file
endfunction

" Get the actual file name
function! s:file_name()
return s:get_file_name_and_goto(0)
endfunction

" Open file at the line after :* part
function! s:gotoline()
return s:get_file_name_and_goto(1)
endfunction

" Handle entry in the argument list.
" This is called via `:argdo` when entering Vim.
function! s:handle_arg()
Expand All @@ -87,6 +103,7 @@ function! s:startup()
endif
endfunction

if !isdirectory(expand("%:p"))
" Only use file_line upon files (not directory), and only if file already exists
if (!isdirectory(expand("%:p")) && filereadable(expand(s:file_name())))
autocmd VimEnter * call s:startup()
endif

0 comments on commit f1bf6c5

Please sign in to comment.