I have created a mwe plugin to show my problem for fortran ft.

tree ftrial
├── autoload
│   └── makes.vim
└── ftplugin
    └── fortran_mk.vim


cat ftrial/autoload/makes.vim
" Variables {{{1
let s:Compiler = get(g:, "fortran_compiler", "gfortran")
let s:ObjExt    =   '.o'
let s:ModExt    =   '.mod'
let s:ExeExt    =   ''
let s:VimComp   =   'gfortran'
let s:FCFlags   =  get(g:, "fortran_fcflags",   '-Wall  -O0 -c')
let s:FLFlags   =   get(g:, "fortran_flflags",  '-Wall -O0')
let s:OutputGvim=   'vim'

" Compile current buffer {{{1
function! makes#Fcompile()

  let sou = expand("%:p")
  let obj = expand("%:p:r").s:ObjExt
  let s:fortran_comp_success = 0
  setlocal efm=%E%f:%l.%c:,%E%f:%l:,%C,%C%p%*[0123456789^],%ZError:\ %m,%C%.%#

  " Don't process any further if the compilation is up to date
  if filereadable(obj) && (getftime(obj)>getftime(sou))
    let &statusline = "'" . obj . "':is up to date"
    let s:fortran_comp_success=1

  let makeprg_saved = '"' . &makeprg . '"'
  execute "setlocal makeprg=" . s:Compiler
  let v:statusmsg = ''
  execute "make " . s:FCFlags . " " . sou . " -o " . obj

  " Don't process any further if the compilation was sucessful
  if empty(v:statusmsg)
    let &statusline = "'" . obj . "':Compiled successfully"
    let s:fortran_comp_success=1

  if v:shell_error !=0
    let &statusline = v:shell_error
  botright copen

and cat ftrial/ftplugin/fortran_mk.vim :

let s:Compiler = get(g:, "fortran_compiler", "gfortran")
let s:ObjExt    =   '.o'
let s:ModExt    =   '.mod'
let s:ExeExt    =   ''
let s:VimComp   =   'gfortran'
let s:FCFlags   =   '-Wall -g -O0 -c'
let s:FLFlags   =   '-Wall -g -O0'
let s:OutputGvim=   'vim'

function! Compile()
  :call makes#Fcompile()

with compiling with makeprg and efm set, I am expecting the error should be nicely formatted, but that is not hapenning. Rather I am getting the error as shown in the screenshots

What I am doing wrong here?

A sample hello.f90 with error is:

program hello
   implicit none
   write (*, *) "Hello"+i
   write(*,*) q
end program


This is what I am getting with :call Compile() with calling "call Compile()"

After I press Enter key after I got the last screen, this is what I get: After press Enter in first screen


I have tried to solve this with gvim --clean, dismiss effect of any other plugin, and it shows a new empty buffer. Kindly have a look at this screencast.

  • errorformat looks ok for me. You have another issue with other plugins
    – Maxim Kim
    Jul 29 '20 at 11:52
  • yes, I realised it. Now the problem is with efm, I am getting 2 extra buffer, and quickfix is at the 3rd buffer. I have checked that script no 28 is minifufexpl. with gvim --clean, this is I am not getting any quickfix at all.
    – BaRud
    Jul 29 '20 at 13:39

Try to change your errorformat to

setlocal efm=%E%f:%l:%c:,%E%f:%l:,%C,%C%p%*[0123456789^],%ZError:\ %m,%C%.%#

the difference is in separator between LINE and COLUMN. You have %l.%c, but looks like it should be %l:%c

  1. there are some problems with autocommands we cannot see from your example (but vim error clearly states it)

  2. if you do only set efm=..., set makeprg=..., :make you should have errors correctly put into quickfix window.

If you want to suppress output of :make command, use

:silent make

or install vim-dispatch plugin that can do make in background without noise.

  • I have added a screencast with gvim --clear. Hope that will clear what is going on.
    – BaRud
    Jul 29 '20 at 13:50
  • I am not sure I get it. I can see everything is OK in your screencast -- it is expected behaviour
    – Maxim Kim
    Jul 29 '20 at 14:13
  • you see that, at the end, there is no fortran code in the main buffer....its a new buffer and quickfix is at the bottom of an empty buffer
    – BaRud
    Jul 29 '20 at 14:15
  • as discussed in irc, efm doesn't parse out line number and it is "attached" to a filename, thus after make you jump to a first error and it is nonexistent filename for which a new buffer is created.
    – Maxim Kim
    Jul 29 '20 at 14:32
  • @D.BenKnoble: may I request you to stop judging? Also, may I expect some concrete answere from you in future, rather than comments?
    – BaRud
    Jul 29 '20 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.