0

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

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

with

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'
"}}}1

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

  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
    return
  endif

  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
    return
  endif

  if v:shell_error !=0
    let &statusline = v:shell_error
  endif
  botright copen
endfunction
"}}}1

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()
endfunction

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

Screenshots:

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

Update

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.

2
  • errorformat looks ok for me. You have another issue with other plugins
    – Maxim Kim
    Commented Jul 29, 2020 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
    Commented Jul 29, 2020 at 13:39

1 Answer 1

1

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.

9
  • I have added a screencast with gvim --clear. Hope that will clear what is going on.
    – BaRud
    Commented Jul 29, 2020 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
    Commented Jul 29, 2020 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
    Commented Jul 29, 2020 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
    Commented Jul 29, 2020 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
    Commented Jul 29, 2020 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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