Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Cursor is left in the command line while compiling #38

Open
rlipscombe opened this issue Dec 14, 2017 · 3 comments
Open

Cursor is left in the command line while compiling #38

rlipscombe opened this issue Dec 14, 2017 · 3 comments

Comments

@rlipscombe
Copy link

...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.

@sanmiguel
Copy link
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.

@sanmiguel
Copy link
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

@rlipscombe
Copy link
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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants