Skip to content

Cursor is left in the command line while compiling #38

Open

Description

@rlipscombe

...and because compiling takes a while, it prevents me from navigating around in my source file for a fraction of a second after I save, and leaves unsightly escape codes sitting there.

Activity

  1. sanmiguel commented on Dec 14, 2017

    @sanmiguel
    Member

    This was traditionally a shortcoming of just how vim plugins work. There was no facility for running tasks in the background, so everything was synchronous.

    That's all changed in the last year or so, but to my shame I haven't taken the time to make any contributions to this plugin to bring it up to the state of the art.

    I use a plugin called neomake to run background jobs like this, although I believe there are other options out there.

    I have some configuration in my dotfiles (which I'll provide the relevant snippet from shortly) that uses the guts of this script via neomake to achieve what I think you're after: compilation in the background, and population of the loc-list with any warnings/errors.

  2. sanmiguel commented on Dec 14, 2017

    @sanmiguel
    Member

    There are a few ways to set this up but the bottom line is you need the erlang_check.erl script somewhere accessible on disk, have this plugin disabled, and to have the neomake plugin installed.

    Then you'll want to have something like the following in your .vimrc/init.vim:

    function! s:flycheck_postprocess(entry)
        if a:entry.text =~ 'Warning: '
            let a:entry.type = 'W'
            let a:entry.text = substitute(a:entry.text, 'Warning: ', '', "g")
        else
            let a:entry.type = 'E'
        endif
    endfunction
    
    let g:neomake_erlang_flycheck_maker = {
            \ 'exe': '/YOUR/PATH/TO/vim-erlang-compiler/compiler/erlang_check.erl',
            \ 'args': ['--nooutdir'],
            \ 'errorformat': '%f:%l: %m,%f: %m',
            \ 'postprocess': function('s:flycheck_postprocess')
            \ }

    With this all in place, you should be able to run :Neomake flycheck in an erlang file and it should compile it in the background and put warnings/errors in the location-list sensibly.

    LMK how it works out, and I'll help where I can. I'm normally in #vim-erlang on freenode so if IRC is your thing feel free to ask in there and I will answer when I can. Otherwise, feel free to reply here and we'll get you up and running.

    Cheers!
    Michael

  3. rlipscombe commented on Dec 14, 2017

    @rlipscombe
    Author

    Thanks. If I've gotta do that, I might just go back to my syntastic + syntaxerl setup that I had until recently. Though using erlang_check might be better than syntaxerl. I'll have a play with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions