Skip to main content
deleted 36 characters in body; edited title
Source Link
D. Ben Knoble
  • 27.7k
  • 3
  • 31
  • 68

A buffer is openning Buffer opened when compilation successfullcompiling succeeds

I am writing a vim plugin for fortran ft the fortran filetype. In my

In an autoload script, I have done:

" File Name: autoload/makes.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! makes#Fcompile()
  exe ":cclose"
  exe ":update"

  let sou = expand("%:p")
  let obj = expand("%:p:r").s:ObjExt

  if !filereadable(obj) || (filereadable(obj) && (getftime(obj)<getftime(sou)))
    let makeprg_saved = '"'.&makeprg.'"'
    exe "setlocal makeprg=".s:Compiler
    let v:statusmsg = ''
    exe "make ".s:FCFlags. " " .sou. " -o " .obj
    if empty(v:statusmsg)
      :let &statusline = "'".obj."':Compiled successfully"
    endif
    if v:shell_error !=0
      :let &statusline = v:shell_error
    endif
    ":redraw!
    exe ":botright copen"
  else
    :let &statusline = "'".obj."':is up to date"
  endif
endfunction

andI use it from ftplugin/fortran_mk.vim aslike this:

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

Now, I compile a program, say, foo.f90 as:

Program foo
   Implicit None
   write (*, *) "Hello"+i
End Program foo

The problem is, that when compilation is successfulsucceeds (called using :exe Compile()), it opens a buffer opens named ": -- NO NAME --""<Integer>: -- NO NAME --". If there is an error the buffer does not open and shows the error in quickfix.

I want no buffer to open when executation is successful,compilation succeeds and a oneline error when it failed.

How I can do that? Kindly help.

A buffer is openning when compilation successfull

I am writing a vim plugin for fortran ft. In my autoload, I have done:

" File Name: autoload/makes.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! makes#Fcompile()
  exe ":cclose"
  exe ":update"

  let sou = expand("%:p")
  let obj = expand("%:p:r").s:ObjExt

  if !filereadable(obj) || (filereadable(obj) && (getftime(obj)<getftime(sou)))
    let makeprg_saved = '"'.&makeprg.'"'
    exe "setlocal makeprg=".s:Compiler
    let v:statusmsg = ''
    exe "make ".s:FCFlags. " " .sou. " -o " .obj
    if empty(v:statusmsg)
      :let &statusline = "'".obj."':Compiled successfully"
    endif
    if v:shell_error !=0
      :let &statusline = v:shell_error
    endif
    ":redraw!
    exe ":botright copen"
  else
    :let &statusline = "'".obj."':is up to date"
  endif
endfunction

and use it from ftplugin/fortran_mk.vim as:

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

Now, I compile a program, say, foo.f90 as:

Program foo
   Implicit None
   write (*, *) "Hello"+i
End Program foo

The problem is, when compilation is successful (called using :exe Compile()), it opens a buffer named ": -- NO NAME --". If there is error the buffer does not open and shows the error in quickfix.

I want no buffer to open when executation is successful, and a oneline error when it failed.

How I can do that? Kindly help.

Buffer opened when compiling succeeds

I am writing a vim plugin for the fortran filetype.

In an autoload script, I have done:

" File Name: autoload/makes.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! makes#Fcompile()
  exe ":cclose"
  exe ":update"

  let sou = expand("%:p")
  let obj = expand("%:p:r").s:ObjExt

  if !filereadable(obj) || (filereadable(obj) && (getftime(obj)<getftime(sou)))
    let makeprg_saved = '"'.&makeprg.'"'
    exe "setlocal makeprg=".s:Compiler
    let v:statusmsg = ''
    exe "make ".s:FCFlags. " " .sou. " -o " .obj
    if empty(v:statusmsg)
      :let &statusline = "'".obj."':Compiled successfully"
    endif
    if v:shell_error !=0
      :let &statusline = v:shell_error
    endif
    ":redraw!
    exe ":botright copen"
  else
    :let &statusline = "'".obj."':is up to date"
  endif
endfunction

I use it from ftplugin/fortran_mk.vim like this:

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

Now, I compile a program, say, foo.f90 as:

Program foo
   Implicit None
   write (*, *) "Hello"+i
End Program foo

The problem is that when compilation succeeds (:exe Compile()), a buffer opens named "<Integer>: -- NO NAME --". If there is an error the buffer does not open and shows the error in quickfix.

I want no buffer to open when compilation succeeds and a oneline error when it failed.

Source Link
BaRud
  • 491
  • 3
  • 10

A buffer is openning when compilation successfull

I am writing a vim plugin for fortran ft. In my autoload, I have done:

" File Name: autoload/makes.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! makes#Fcompile()
  exe ":cclose"
  exe ":update"

  let sou = expand("%:p")
  let obj = expand("%:p:r").s:ObjExt

  if !filereadable(obj) || (filereadable(obj) && (getftime(obj)<getftime(sou)))
    let makeprg_saved = '"'.&makeprg.'"'
    exe "setlocal makeprg=".s:Compiler
    let v:statusmsg = ''
    exe "make ".s:FCFlags. " " .sou. " -o " .obj
    if empty(v:statusmsg)
      :let &statusline = "'".obj."':Compiled successfully"
    endif
    if v:shell_error !=0
      :let &statusline = v:shell_error
    endif
    ":redraw!
    exe ":botright copen"
  else
    :let &statusline = "'".obj."':is up to date"
  endif
endfunction

and use it from ftplugin/fortran_mk.vim as:

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

Now, I compile a program, say, foo.f90 as:

Program foo
   Implicit None
   write (*, *) "Hello"+i
End Program foo

The problem is, when compilation is successful (called using :exe Compile()), it opens a buffer named ": -- NO NAME --". If there is error the buffer does not open and shows the error in quickfix.

I want no buffer to open when executation is successful, and a oneline error when it failed.

How I can do that? Kindly help.