Git Product home page Git Product logo

asyncrun.vim's Introduction

Preface

This plugin takes the advantage of new APIs in Vim 8 (and NeoVim) to enable you to run shell commands in the background and read the output in the quickfix window in realtime:

  • Easy to use, start your background command by :AsyncRun (just like old ! cmd).
  • The command is running in the background, no need to wait for the entire process to finish.
  • Output is displayed in the quickfix window, errors are matched with errorformat.
  • You can explore the error output immediately or keep working in vim while executing.
  • Ring the bell or play a sound to notify your job is finished while you're focusing on editing.
  • Customizable runners and command modifiers bring you the dark power of asyncrun.
  • Fast and lightweight, just a single self-contained asyncrun.vim source file.
  • Provide corresponding user experience in vim, neovim, gvim, and macvim.

If that doesn't excite you, then perhaps this GIF screen capture below will change your mind.

README in Chinese | 中文文档

News

  • 2021/12/15 new extra runners to run command in a tmux, or floaterm window.
  • 2020/02/18 asynctasks uses asyncrun to introduce vscode's task system to vim.
  • 2020/01/21 run command in internal terminal with -mode=term see here.
  • 2020/04/17 AsyncRun now supports command range, try: :%AsyncRun cat.

Install

Install with vim-plug:

Plug 'skywind3000/asyncrun.vim'

Example

Remember to open vim's quickfix window by :copen (or setting g:asyncrun_open) before invoking AsyncRun, otherwise, you will not see any output.

Contents

Tutorials

Async run gcc to compile current file

:AsyncRun gcc "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)"
:AsyncRun g++ -O3 "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENOEXT)" -lpthread 

This command will run gcc in the background and output to the quickfix window in real time. Macro '$(VIM_FILEPATH)' stands for filename with full path and '$(VIM_FILENOEXT)' represents filename without extension.

Async run make

:AsyncRun make
:AsyncRun make -f makefile

Remember to open the quickfix window by :copen before using the AsyncRun command, if you don't open it, you will not see any output.

Grep key word

:AsyncRun! grep -R -n word . 
:AsyncRun! grep -R -n <cword> . 

when ! is included, auto-scroll in quickfix will be disabled. <cword> represents current word under cursor.

Compile go project

:AsyncRun go build "$(VIM_FILEDIR)"

Macro '$(VIM_FILEDIR)' stands for the current file dir.

Lookup man page

:AsyncRun! man -S 3:2:1 <cword>

Git push

:AsyncRun git push origin master

Git push from project root

:AsyncRun -cwd=<root> git push origin master

Use -cwd=? to specify the working directory, macro <root> or $(VIM_ROOT) represents current Project Root.

Setup <F7> to compile file

:noremap <F7> :AsyncRun gcc "$(VIM_FILEPATH)" -o "$(VIM_FILEDIR)/$(VIM_FILENAME)" <cr> 

File name may contain spaces, therefore, it's safe to quote them.

Run a python script

:AsyncRun -cwd=$(VIM_FILEDIR) python "$(VIM_FILEPATH)"

New option -raw will display the raw output (without matching to errorformat). Remember to put let $PYTHONUNBUFFERED=1 in your .vimrc to disable python stdout buffering, see here.

Run a python script in a new terminal

:AsyncRun -cwd=$(VIM_FILEDIR) -mode=term -pos=TAB  python "$(VIM_FILEPATH)"

This will run python in the internal-terminal (vim 8.2 or nvim-0.4.0 is required) in a new tabpage.

A good assistant to asyncrun

asynctasks.vim a plugin built upon asyncrun, an easy way to use asyncrun. It allows you to manage your building, testing, and deploying tasks in a global or project local configuration, and run them by their names.

Manual

There are two vim commands: :AsyncRun and :AsyncStop to control async jobs.

AsyncRun - Run shell command

:AsyncRun[!] [options] {cmd} ...

Run shell command in the background and output to quickfix. when ! is included, auto-scroll in quickfix will be disabled. Parameters are split by space, if a parameter contains space, it should be quoted or escaped as backslash + space (Unix only).

Macro variables in the parameters will be expanded before executing:

$(VIM_FILEPATH)  - File name of current buffer with full path
$(VIM_FILENAME)  - File name of current buffer without path
$(VIM_FILEDIR)   - Full path of current buffer without the file name
$(VIM_FILEEXT)   - File extension of current buffer
$(VIM_FILENOEXT) - File name of current buffer without path and extension
$(VIM_PATHNOEXT) - Current file name with full path but without extension
$(VIM_CWD)       - Current directory
$(VIM_RELDIR)    - File path relativize to current directory
$(VIM_RELNAME)   - File name relativize to current directory 
$(VIM_ROOT)      - Project root directory
$(VIM_CWORD)     - Current word under cursor
$(VIM_CFILE)     - Current filename under cursor
$(VIM_GUI)       - Is running under gui ?
$(VIM_VERSION)   - Value of v:version
$(VIM_COLUMNS)   - How many columns in vim's screen
$(VIM_LINES)     - How many lines in vim's screen
$(VIM_SVRNAME)   - Value of v:servername for +clientserver usage
$(VIM_PRONAME)   - Name of current project root directory
$(VIM_DIRNAME)   - Name of current directory

Environment variables with same name, like $VIM_FILENAME, are also initialized. Thus your child process can access them with getenv(xxx) at any time.

Some macros variables have their short names starting with '<' :

<cwd>   - Current directory
<cword> - Current word under cursor
<cfile> - Current file name under cursor
<root>  - Project root directory

They are also acceptable. So, you can use both $(VIM_ROOT) or its alias <root> to represent Project Root of the current file. Macro variables can be quoted with "..." in the command string when file name contains spaces (like normal shell command escaping), but they should not be quoted in the -cwd=? option.

There can be some options before your [cmd]:

Option Default Description
-mode=? "async" specify how to run the command as -mode=?, available modes are "async" (default), "bang" (with ! command) and "terminal" (in internal terminal), see running modes for details.
-cwd=? unset initial directory (use current directory if unset), for example use -cwd=<root> to run commands in project root directory, or -cwd=$(VIM_FILEDIR) to run commands in current buffer's parent directory.
-save=? 0 use -save=1 to save current file, -save=2 to save all modified files before executing.
-program=? unset set to make to use &makeprg, grep to use &grepprt and wsl to execute commands in WSL (windows 10), see command modifiers.
-post=? unset vimscript to exec after job finished, spaces must be escaped to '\ '
-auto=? unset event name to trigger QuickFixCmdPre/QuickFixCmdPost [name] autocmd.
-raw unset use raw output if present, and &errorformat will be ignored.
-strip unset remove the heading/trailing messages if it is present (omit command and "[Finished in ...]" message).
-errorformat=? unset errorformat for error matching, if it is unprovided, use current &errorformat value. Beware that % needs to be escaped into \%.
-silent unset provide -silent to prevent open quickfix window (will override g:asyncrun_open temporarily)
-scroll=? unset set to 0 to prevent quickfix auto-scrolling
-once unset provide to buffer all output and flush when job is finished, useful when there are multi-line patterns in your errorformat
-encoding=? unset specify command encoding independently (overshadow g:asyncrun_encs)
-pos=? "bottom" When using internal terminal with -mode=term, -pos is used to specify where to split the terminal window, it can be one of "tab", "curwin", "top", "bottom", "left", "right" and "external". And you can customize new runners and pass runner's name to -pos option.
-rows=num 0 When using a horizontal split terminal, this value represents the height of terminal window.
-cols=num 0 When using a vertical split terminal, this value represents the width of terminal window.
-focus=? 1 set to 0 to prevent focus changing when -mode=term
-hidden=? 0 set to 1 to init bufhidden to hide for internal terminal, set to 0 to init bufhidden to wipe
-listed=? 1 when using -mode=term, set to 0 to hide the terminal in the buffer list
-close unset when using -mode=term, close the terminal automatically when terminal process is finished

For the full list of the options, please see the Command Specification.

All options must start with a minus and position before [cmd]. Since no shell command string starting with a minus. So they can be distinguished from shell command easily without any ambiguity.

Don't worry if you do have a shell command starting with '-', Just put a placeholder @ before your command to tell asyncrun explicitly: "stop parsing options now, the following string is all my command".

AsyncStop - Stop the running job

:AsyncStop[!]

stop the running job, when "!" is included, job will be stopped by signal KILL.

Function (API)

Function form is convenient for vimscript:

:call asyncrun#run(bang, opts, command)

parameters:

  • bang: an empty string or a single bang character "!", same as bang sign in AsyncRun!.
  • opts: a dictionary contains: mode, cwd, raw and errorformat etc.
  • command: the shell command you want to execute.

Settings

  • g:asyncrun_exit - script will be executed after finished.
  • g:asyncrun_bell - non-zero to ring a bell after finished.
  • g:asyncrun_mode - specify how to run your command, see here.
  • g:asyncrun_encs - set shell encoding if it's different from &encoding, see encoding.
  • g:asyncrun_trim - non-zero to trim the empty lines in the quickfix window.
  • g:asyncrun_auto - event name to trigger QuickFixCmdPre/QuickFixCmdPost, see FAQ.
  • g:asyncrun_open - above zero to open quickfix window at given height after command starts.
  • g:asyncrun_save - non-zero to save current(1) or all(2) modified buffer(s) before executing.
  • g:asyncrun_timer - how many messages should be inserted into quickfix every 100ms interval.
  • g:asyncrun_wrapper - enable to setup a command prefix.
  • g:asyncrun_stdin - non-zero to enable stdin (useful for cmake on windows).
  • g:asyncrun_qfid - use quickfix id to prevent interleaving output of concurrent plugins appending to the quickfix list.

For more information of above options, please visit option details.

Variables

  • g:asyncrun_code - exit code
  • g:asyncrun_status - 'running', 'success' or 'failure'

Autocmd

autocmd User AsyncRunPre   - triggered before executing
autocmd User AsyncRunStart - triggered after starting successfully
autocmd User AsyncRunStop  - triggered when job finished

Note, AsyncRunPre is always likely to be invoked, but AsyncRunStart and AsyncRunStop will only be invoked if the job starts successfully.

When the previous job is still running or vim job slot is full, AsyncRun may fail. In this circumstance, AsyncRunPre will be invoked but AsyncRunStart and AsyncRunStop will have no chance to trigger.

Project Root

Vim is lack of project management, as files usually belong to projects, you can do nothing to the project if you don't have any information about where the project locates. Inspired by CtrlP, this feature (new in version 1.3.12) is very useful when you've something to do with the whole project.

Macro <root> or $(VIM_ROOT) in the command line or in the -cwd option will be expanded as the Project Root Directory of the current file:

:AsyncRun make
:AsyncRun -cwd=<root> make

The first make will run in the vim's current directory (which :pwd returns), while the second one will run in the project root directory of current file. This feature is very useful when you have something (make / grep) to do with the whole project.

The project root is the nearest ancestor directory of the current file which contains one of these directories or files: .svn, .git, .hg, .root or .project. If none of the parent directories contains these root markers, the directory of the current file is used as the project root. The root markers can also be configurated, see Project Root.

Running Modes

The default behavior is to run async command and output to quickfix window. However there is a -mode=? option can allow you specify how to run your command:

mode description
async default behavior, run async command and output to quickfix window
bang same as !
term open a reusable internal terminal window and run your command

For more information, please see here.

Internal Terminal

AsyncRun is capable to run commands in Vim/NeoVim's internal terminal with the -mode=term option. You can specify how to open the terminal window by -pos=?, available positions are:

  • -pos=tab: open the terminal in a new tab.
  • -pos=TAB: open the terminal in a new tab on the left side.
  • -pos=curwin: open the terminal in the current window.
  • -pos=top: open the terminal above the current window.
  • -pos=bottom: open the terminal below the current window.
  • -pos=left: open the terminal on the left side.
  • -pos=right: open the terminal on the right side.
  • -pos=hide: don't open a window, run in background.
  • -pos=external: use an external terminal (Windows & Gnome only).

Examples:

:AsyncRun -mode=term -pos=tab python "$(VIM_FILEPATH)"
:AsyncRun -mode=term -pos=TAB -close -cwd=<root> lazygit
:AsyncRun -mode=term -pos=bottom -rows=10 python "$(VIM_FILEPATH)"
:AsyncRun -mode=term -pos=right -cols=80 python "$(VIM_FILEPATH)"
:AsyncRun -mode=term -pos=curwin python "$(VIM_FILEPATH)"
:AsyncRun -mode=term -pos=curwin -hidden python "$(VIM_FILEPATH)"

Internal terminal related options:

Option Default Description
-pos=? "bottom" When using internal terminal with -mode=term, -pos is used to specify where to split the terminal window, it can be one of "tab", "curwin", "top", "bottom", "left", "right" and "external".
-rows=num 0 When using a horizontal split terminal, this value represents the height of terminal window.
-cols=num 0 When using a vertical split terminal, this value represents the width of terminal window.
-focus=? 1 set to 0 to prevent focus changing when -mode=term
-close unset when using -mode=term, close the terminal automatically when terminal process is finished
-hidden=? 0 set to 1 to setup bufhidden to hide for internal terminal
-listed=? 1 when using -mode=term, set to 0 to hide the terminal in the buffer list

The -pos field accepts an uppercase TAB, to create a tab on the left of the current tab. When using internal terminal in a split window, AsyncRun will firstly reuse a finished previous terminal window if it exists, if not, a new terminal window will be created in given position. Tab based terminal can also be reusable if -reuse is provided.

Terminal Name

There can be many commands running in the internal terminal, you can specify a name for each of them and receive it in g:asyncrun_name:

:AsyncRun -mode=term -pos=hide -name=123 -post=echo\ g:asyncrun_name  ls -la

When this process finished, script defined in -post will be executed and your command name will display by echo. Another variable g:asyncrun_code stores exit code.

Quickfix window

AsyncRun displays its output in quickfix window, so if you don't use :copen {height} to open quickfix window, you won't see any output. For convenience there is an option g:asyncrun_open for you:

:let g:asyncrun_open = 8

Setting g:asyncrun_open to 8 will open quickfix window automatically at 8 lines height after command starts.

Range support

AsyncRun can take a range of lines in the current buffer as command's stdin after version 1.3.27. You can try:

:%AsyncRun cat

the whole buffer will be the input of command cat. you will see the content of your current buffer will be output to the quickfix window.

:10,20AsyncRun python

text between line 10-20 will be taken as the stdin of python. code in that range will be executed by python and the output will display in the quickfix window.

:'<,'>AsyncRun -raw perl

The visual selection (line-wise) will be taken as stdin.

Advanced Topics

AsyncRun provides enough flexibility and possibility to customize various details of how to run a command.

Extra Runners

Besides the default quickfix and internal terminal mechanism, the user-defined runners allow you to run commands in any way you want. eg. in a new gnome-terminal window/tab, a floaterm window, or a side-by-side tmux split.

By default, AsyncRun is shipped with some popular runners:

Runner Description Requirement Link
gnome run in a new gnome terminal GNOME gnome.vim
gnome_tab run in a new gnome terminal tab GNOME gnome_tab.vim
xterm run in a xterm window xterm xterm.vim
tmux run in a separated tmux split Vimux tmux.vim
floaterm run in a new floaterm window floaterm floaterm.vim
floaterm_reuse run in a reusable floaterm window floaterm floaterm_reuse.vim
quickui run in a quickui window vim-quickui quickui.vim
termhelp run in terminal help vim-terminal-help termhelp.vim
toggleterm run in a toggleterm window toggleterm.nvim toggleterm.vim
xfce run in a new xfce terminal xfce4-terminal xfce.vim
konsole run in a new konsole terminal KDE konsole.vim
macos run in a macOS system terminal macOS macos.vim
iterm run in a new iTerm2 tab macOS + iTerm2 iterm.vim

e.g.

:AsyncRun -mode=term -pos=gnome      ls -la
:AsyncRun -mode=term -pos=floaterm   ls -la
:AsyncRun -mode=term -pos=tmux       ls -la

Screenshot for gnome runner:

When using gnome, konsole, or xfce runner in GVim, you get exactly the same experience like starting a command-line program from IDEs.

When you use toggleterm2 and use the packer.nvim management plugin, you can set shortcut keys to specify the open window, such as:

	use({
		"skywind3000/asyncrun.vim",
		as = "asyncrun",
		config = function()
			require("asyncrun_toggleterm").setup({
				mapping = "<leader>tt",
				start_in_insert = false,
			})
		end,
	})

All runners are customizable, you can modify or define your own runners, see the next section "customize runner".

Customize Runner

User-defined runners allow you to specify how the command will run by creating a new runner. It can be useful when you want your commands run in a tmux split or a new gnome-terminal window:

function! MyRunner(opts)
    echo "command to run is: " . a:opts.cmd
endfunction

let g:asyncrun_runner = get(g:, 'asyncrun_runner', {})
let g:asyncrun_runner.test = function('MyRunner')

Then try:

:AsyncRun -mode=term -pos=test ls -la $(VIM_FILEDIR)

When -mode is term and -pos can used to represent runner name.

Runner function has only one argument: opts, it contains the options extracted from :AsyncRun command line, and opts.cmd stores current command.

Another way to create a runner is to simply create a .vim file in the autoload/asyncrun/runner/ folder of your run-time-path (see the examples).

For more information, please visit project wiki: customize runner.

Command Modifier

Command modifiers can be used to change your command before running:

let g:asyncrun_program = get(g:, 'asyncrun_program', {})
let g:asyncrun_program.nice = { opts -> 'nice -5' . opts.cmd }

When you are using:

:AsyncRun -program=nice ls -la

The command ls -la will be changed into nice -5 ls -la.

The -program=msys, -program=wsl are both implemented as a new command modifier it changes command ls into:

c:\windows\sysnative\wsl.exe ls

And replace any thing like $(WSL_FILENAME) and $(WSL_FILEPATH) in your command.

Requirements

Vim 7.4.1829 is minimal version to support async mode. If you are use older versions, g:asyncrun_mode will fall back from 0/async to 1/sync. NeoVim 0.1.4 or later is also supported.

Recommend to use Vim 8.0 or later.

Cooperate with vim-fugitive:

asyncrun.vim can cooperate with vim-fugitive, see here.

Language Tips

More Topics

Don't forget to read the Frequently Asked Questions.

Cooperate with other Plugins

Name Description
asynctasks Introduce vscode's task system to vim (powered by AsyncRun).
vim-fugitive perfect cooperation, asyncrun gets Gfetch/Gpush running in background
errormarker perfect cooperation, errormarker will display the signs on the error or warning lines
airline very well, airline will display status of background jobs
sprint nice plugin who uses asyncrun to provide an IDE's run button to runs your code

See: Cooperate with famous plugins

History

  • 2.9.1 (2021-12-15): extra runners to run command in a tmux, or floaterm window.
  • 2.6.2 (2020-03-08): change runner's argument from string to dict.
  • 2.6.0 (2020-03-07): -post can be used in terminal mode.
  • 2.5.5 (2020-03-07): "-mode=term -pos=tab" obeys "-focus=0" now.
  • 2.5.3 (2020-03-02): new -silent option to prevent open quickfix, add command modifier.
  • 2.5.0 (2020-02-29): refactor, remove useless codes, new command modifier g:asyncrun_program.
  • 2.4.8 (2020-02-21): run with :execute if command is starting with colon.
  • 2.4.7 (2020-02-21): new customizable runners by g:asyncrun_runner, see customize runner.
  • 2.4.0 (2020-02-10): fixed internal terminal issue in msys.
  • 2.3.0 (2020-02-10): new mode aliases, minor issue fix.
  • 2.2.9 (2020-02-10): new terminal mode options: -safe=1, -listed=0 and -reuse.
  • 2.2.6 (2020-02-06): new: parameter -hidden when using -mode=term to set bufhidden to hidden.
  • 2.2.5 (2020-02-05): more safe to start a terminal.
  • 2.2.4 (2020-02-05): exit when starting terminal failed in current window with -pos=curwin.
  • 2.2.3 (2020-02-05): new -program=wsl to run command in wsl (windows 10 only).
  • 2.2.2 (2020-02-05): new -pos=curwin to open terminal in current window.
  • 2.2.1 (2020-01-20): set noreletivenumber for terminal window.
  • 2.2.0 (2020-01-18): new -focus=0 option for -mode=term to prevent focus change.
  • 2.1.9 (2020-01-12): polish -mode=term, omit number and signcolunm in terminal.
  • 2.1.8 (2020-01-11): new options errorformat in asyncrun#run(...).
  • 2.1.4 (2020-01-09): correct command encoding on windows and fixed minor issues.
  • 2.1.0 (2020-01-09): new mode -mode=term to run command in a reusable terminal window.
  • 2.0.8 (2019-04-28): handle tcd (introduced in 8.1.1218). use grepformat when -program=grep.
  • 2.0.7 (2019-01-27): restore g:asyncrun_stdin because rg will break if stdin is pipe.
  • 2.0.6 (2019-01-26): more adaptive to handle stdin and remove 'g:asyncrun_stdin'
  • 2.0.5 (2019-01-14): enable stdin by default on windows (fix cmake stdin warning on windows).
  • 2.0.4 (2019-01-13): new option g:asyncrun_stdin, set to 1 to enable stdin .
  • 2.0.3 (2019-01-04): new macro $VIM_PATHNOEXT (by @PietroPate)
  • 2.0.2 (2018-12-25): new -strip and -append option to control quickfix (by @bennyyip)
  • 2.0.1 (2018-04-29): new option g:asyncrun_save to save files.
  • 2.0.0 (2018-04-27): improve neovim compatability, handle tcd command in neovim.
  • 1.3.27 (2018-04-17): AsyncRun now supports range, try: :%AsyncRun cat
  • 1.3.26 (2018-04-16): new option g:asyncrun_wrapper to enable setup a command prefix
  • 1.3.25 (2018-04-16): handle makeprg/grepprg correctly, accept % and $* macros. close #96 #84 and #35
  • 1.3.24 (2018-04-13): remove trailing ^M on windows.
  • 1.3.23 (2018-04-03): back compatible to vim 7.3, can fall back to mode 1 in old vim.
  • 1.3.22 (2018-03-11): new option g:asyncrun_open to open quickfix window automatically at given height.
  • 1.3.21 (2018-03-02): fixed: float point reltime issues
  • 1.3.20 (2018-02-08): fixed: Incorrect background job status (@antoinemadec)
  • 1.3.19 (2017-12-13): new option g:asyncrun_skip to skip specific autocmd.
  • 1.3.18 (2017-12-12): fixed: windo breaks commands (especially in neovim).
  • 1.3.17 (2017-08-06): fixed: process hang when mode is 5.
  • 1.3.16 (2017-08-05): fixed: g:asyncrun_mode issue (Joel Taylor)
  • 1.3.15 (2017-07-30): fixed: remove trailing new line in neovim.
  • 1.3.14 (2017-07-27): improve asyncrun#get_root(), allow user indicate the rootmarkers
  • 1.3.13 (2017-07-12): new option (-raw) to use raw output (not match with the errorformat).
  • 1.3.12 (2017-06-25): new macro <root> or $(VIM_ROOT) to indicate project root directory.
  • 1.3.11 (2017-05-19): new option (-save=2) to save all modified files.
  • 1.3.10 (2017-05-04): remove trailing ^M in NeoVim 2.0 on windows
  • 1.3.9 (2016-12-23): minor bugs fixed, improve performance and compatibility.
  • 1.3.8 (2016-11-17): new autocmd AsyncRunPre/AsyncRunStart/AsyncRunStop, fixed cmd line window conflict.
  • 1.3.7 (2016-11-13): new option 'g:asyncrun_timer' to prevent gui freeze by massive output.
  • 1.3.6 (2016-11-08): improve performance in quickfix_toggle, fixed small issue in bell ringing.
  • 1.3.5 (2016-11-02): new option "g:asyncrun_auto" to trigger QuickFixCmdPre/QuickFixCmdPost.
  • 1.3.4 (2016-10-28): new option "g:asyncrun_local" to use local value of errorformat rather the global value.
  • 1.3.3 (2016-10-21): prevent job who reads stdin from getting hanging, fixed an issue in fast exiting jobs.
  • 1.3.2 (2016-10-19): new "-post" option to run a vimscript after the job finished
  • 1.3.1 (2016-10-18): fixed few issues of arguments passing in different modes
  • 1.3.0 (2016-10-17): add support to neovim, better CJK characters handling.
  • 1.2.0 (2016-10-16): refactor, correct arguments parsing, cmd options and &makeprg supports
  • 1.1.1 (2016-10-13): use the vim native &shell and &shellcmdflag config to execute commands.
  • 1.1.0 (2016-10-12): quickfix window scroll only if cursor is on the last line
  • 1.0.3 (2016-10-10): reduce quickfix output latency.
  • 1.0.2 (2016-10-09): fixed an issue in replacing macros in parameters.
  • 1.0.1 (2016-10-07): Add a convenient way to toggle quickfix window (asyncrun#quickfix_toggle)
  • 1.0.0 (2016-09-21): can fall back to sync mode to compatible older vim versions.
  • 0.0.3 (2016-09-15): new arguments now accept environment variables wrapped by $(...)
  • 0.0.2 (2016-09-12): some improvements and more documents for a tiny tutorial.
  • 0.0.1 (2016-09-08): improve arguments parsing
  • 0.0.0 (2016-08-24): initial version

Credits

Trying best to provide the most simply and convenience experience in the asynchronous-jobs.

Author: skywind3000 Please vote it if you like it: http://www.vim.org/scripts/script.php?script_id=5431

asyncrun.vim's People

Contributors

bennyyip avatar eliasdaler avatar etrnal70 avatar fievel avatar grodzik avatar idbrii avatar js-zheng avatar kaihowl avatar lu5je0 avatar meijieru avatar n0bra1n3r avatar pietropate avatar qujihan avatar skyblueee avatar skywind3000 avatar tankorsmash avatar tomtomjhj avatar wookayin avatar yungen-lu avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

asyncrun.vim's Issues

save only saves current file

I've just switched to this from using :make and waiting. I used to have the autowrite option, so when I invoked make it would save any changed buffers. Using AsyncRun -save only saves the current buffer.
This seems easy enough to fix - I've changed the 'silent update' to 'silent wall' locally.

run exe with printf error

include <stdio.h>

int main(int argc, const char *argv[])
{
printf("a");
printf("b");
return 0;
}
Async gcc % -o a.exe
Async a.exe

Error detected while processing function 12_AsyncRun_Job_OnClose:
line 10:
E117:Unknown function: AsyncRun_Job_OnCallback
...
...
...

g:asyncrun_status with airline always shows success

Hi @skywind3000
I added g:asyncrun_status to airline to make it show the status of asyncrun
let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}'])

But it always shows success even when the result of command execution is error
I recorded the issue with asciinema https://asciinema.org/a/a4ksqp8enp5tx29uyoczy7f7q

So first I run two commands with :AsyncRun that return errors
After that I run the same two commands in NeoVim terminal just to show the actual output.

I'm using NVIM v0.1.6-175-g7246750

Thank you!

Usage with a debugger

Is it possible to add a debugger, run a test async, and then pop into a debug session when the debugger is reached?

Right now, the only way I can get this to work is to set the mode to either make or :!. When I run with async mode, it'll act like it wants to pop into a debug session, but will continue past it.

Avoiding too many jobs at once

I'm working on this plugin where it calls another program asynchronously on every hit of a keyboard key. However, for obvious reasons, I'm getting ERROR: background job is still running.

I see two solutions

  1. Not asyncrun.vim related: how to add a delay between key hit (still ongoing research, probably I'll have to check timestamps etc)
  2. asyncrun.vim related: trying to do an AsyncStop! before every AsyncStart!, that way when the keys stop being pressed quickly, the last AsyncStart! will continue just fine (drawback is that the external program will probably be executed many times afaik).

On the solution 2, I'm trying this:

function! StopCommunications()
  exec ":AsyncStop!"
endfunction

function! StartCommunications()
  exec ":AsyncStop!"
  exec ":AsyncRun! my_program"
  " ...
endfunction

augroup MyPlugin
  autocmd!

  autocmd User AsyncRunPre :call StopCommunications()
  autocmd CursorMoved  * :call StartCommunications()
augroup END

Even with the AsyncStop! being called, I still get ERROR: background job is still running, which leads me to believe that I don't know how AsyncStop! works.

Opening error file in Clist not works in neovim

In neovim, when we use AsyncRun to GNU make, errors in the clist are not using the full path from the project root. The same works in vim 8.0

Steps to repro:

  • Clone the repo

https://github.com/Mariappan/testrepo

When using vim 8.0 and open the file l1/src/main.c and giving this command: ":AsyncRun make"

|| gcc main.c -O0 -g -Wall -Werror -o test∙
|| main.c: In function ‘main’:∙
l1/src/main.c|7 col 5| error: expected ‘;’ before ‘return’∙
|| return 0;∙
|| ^∙
l1/src/main.c|8 col 1| error: control reaches end of non-void function [-Werror=return-type]∙
|| }∙
|| ^∙
|| cc1: all warnings being treated as errors∙

When using neovim 0.1.7 and open the file l1/src/main.c and giving this command: ":AsyncRun make"
|| gcc main.c -O0 -g -Wall -Werror -o test∙
||
|| main.c: In function ‘main’:∙
||
main.c|7 col 5| error: expected ‘;’ before ‘return’∙
|| return 0;∙
|| ^∙
||∙
main.c|8 col 1| error: control reaches end of non-void function [-Werror=return-type]∙
|| }∙

Missing expansions for makeprg and grepprg

Summary: I have some makeprg's that use vim % expansions. I want both :make and :AsyncRun to work consistently. As such I want to continue to use the % style macros. I would like for asyncrun.vim to support makeprg and grepprg that contain % expansions.

When I use :AsyncRun -program=make, I expect the same output as :make, but instead I get, for example package not found %:h. This is because asyncrun#run does not expand % macros.

I have found a partial solution to the same general problem in timbertson/vim-background-make@404905f

I have also locally applied a less complete patch as follows, which covers only my use case (no escaped expansions in my makeprgs), that could also be used as a possible approach:
https://gist.github.com/raggi/3bcbb18183be138f3b24718891921d9b

An example of a makeprg I would like to work:

setlocal makeprg=go\ build\ ./%:h;echo\ package\ %:h;echo;go\ test\ ./%:h

And the corresponding errorformat, demonstrating usage:

setlocal errorformat=
      \%E%f:%l::%tarning:\ %m,
      \%E%f:%l:%c:%tarning:\ %m,
      \%E%f:%l::%trror:\ %m,
      \%E%f:%l:%c:%trror:\ %m,
      \%E%f:%l:\ %m,
      \%Dpackage\ %f,
      \%E---\ FAIL:\ %m,
      \%C%f:%l:\ %m

If you would like me to prepare a patch, let me know what your preferred approach will be, and I will add this to my TODO list.

Thanks!

[Question] Run multiple commands

Hi @skywind3000
With vim-dispatch i can run multiple processes which will be started in separate tmux panes
Is it possible to implement such behaviour with asyncrun?
So for example i want to start http-server, start js/sass/less etc. preprocessor, run tests

Also it would be very great to see which processes are currently running in split window and to make some actions with those processes. For example we have 3 processes:

1 http-server
2 gulp
3 tests

Each one of them you can stop, restart, open quickfix window etc.

Feel free to close this issue if it doesn't fit the purpose of your plugin
Thank you for your work!

Keeps the logs of multiple asyncrun command output

Every time a new command is run, the quickfix window is flushed and the output from the previous command will gone. Is there a way to keep all the logs? User can use some explicit command to clear it when he really want to do that.

ANSI colors not currently supported

If I do:

 :Asyncrun! echo "\e[32mHello World\e[0m"

I get this:

 || ["echo", ""\e[32mHello", "World\e[0m""]
 || "\e[32mHello World\e[0m"
 || [Finished in 0 seconds]

Where "Hello World" is not colored.

与 airline 协同时,报 Invalid expression 错误

####问题
在 airline 中加入 let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}']) 后,就立马报错,不知原因

####相关代码

  • airline配置
let g:airline#extensions#syntastic#enabled = 1
 let g:airline#extensions#tabline#enabled = 1
let g:airline#extensions#tabline#left_sep = ' '
let g:airline#extensions#tabline#left_alt_sep = '|'

" for asyncrun.vim
let g:airline_section_error = airline#section#create_right(['%{g:asyncrun_status}']) 
  • 插件配置
call plug#begin('~/.vim/plugged')
  2 
  3 Plug 'https://github.com/kien/ctrlp.vim'
  4 
  5 Plug 'scrooloose/nerdtree', { 'on':  'NERDTreeToggle' }
  6 
  7 Plug 'https://github.com/vim-airline/vim-airline'
  8 
  9 Plug 'https://github.com/vim-syntastic/syntastic'
 10 
 11 Plug 'https://github.com/skywind3000/asyncrun.vim'
 12 
 13 for f in split(glob('~/.vim/confs/_plugins/*.vim'), '\n')
 14     exe 'source' f                                                                                      
 15 endfor
 16 
 17 call plug#end()

####报错信息

vi plugins.vim 
Error detected while processing /home/ubuntu/.vim/confs/_plugins/vim-airline.vim:
line    7:
E117: Unknown function: airline#section#create_right
E15: Invalid expression: airline#section#create_right(['%{g:asyncrun_status}'])
Press ENTER or type command to continue

####环境

  • vim
vim --version
VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Jan  2 2014 19:39:32)
Included patches: 1-52
Modified by [email protected]
Compiled by buildd@
Huge version without GUI.  Features included (+) or not (-):
+acl             +farsi           +mouse_netterm   +syntax
+arabic          +file_in_path    +mouse_sgr       +tag_binary
+autocmd         +find_in_path    -mouse_sysmouse  +tag_old_static
-balloon_eval    +float           +mouse_urxvt     -tag_any_white
-browse          +folding         +mouse_xterm     -tcl
++builtin_terms  -footer          +multi_byte      +terminfo
+byte_offset     +fork()          +multi_lang      +termresponse
+cindent         +gettext         -mzscheme        +textobjects
-clientserver    -hangul_input    +netbeans_intg   +title
-clipboard       +iconv           +path_extra      -toolbar
+cmdline_compl   +insert_expand   -perl            +user_commands
+cmdline_hist    +jumplist        +persistent_undo +vertsplit
+cmdline_info    +keymap          +postscript      +virtualedit
+comments        +langmap         +printer         +visual
+conceal         +libcall         +profile         +visualextra
+cryptv          +linebreak       +python          +viminfo
+cscope          +lispindent      -python3         +vreplace
+cursorbind      +listcmds        +quickfix        +wildignore
+cursorshape     +localmap        +reltime         +wildmenu
+dialog_con      -lua             +rightleft       +windows
+diff            +menu            -ruby            +writebackup
+digraphs        +mksession       +scrollbind      -X11
-dnd             +modify_fname    +signs           -xfontset
-ebcdic          +mouse           +smartindent     -xim
+emacs_tags      -mouseshape      -sniff           -xsmp
+eval            +mouse_dec       +startuptime     -xterm_clipboard
+ex_extra        +mouse_gpm       +statusline      -xterm_save
+extra_search    -mouse_jsbterm   -sun_workshop    -xpm
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H     -g -O2 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1      
Linking: gcc   -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -o vim        -lm -ltinfo -lnsl  -lselinux  -lacl -lattr -lgpm -ldl    -L/usr/lib/python2.7/config-x86_64-linux-gnu -lpython2.7 -lpthread -ldl -lutil -lm -Xlinker -export-dynamic -Wl,-O1 -Wl,-Bsymbolic-functions 
  • 系统环境
uname -a
Linux VM-54-125-ubuntu 3.13.0-86-generic #131-Ubuntu SMP Thu May 12 23:33:13 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux

Running commands in the right environment

Hi!

First off, thanks for this plugin, it's fun to play with.

I'm trying to use it to run my Xcode builds from Xcode's command line tool and it works for the simplest case but starts to fail when I try to set environment variables and such before the command. Get errors saying "command not found" or even sometimes it will just hang until I interrupt it in vim.

My best guess is that commands aren't being run in the same user/shell/environment I'm operating in. Is that true? It's a bit hard to tell from reading the code (I'm new to vimscript)

For reference, I'm trying to run commands like these:

set -o pipefail;NSUnbufferedIO=YESxcrun xcodebuild build -project './TheoryDrills.xcodeproj' -scheme 'TheoryDrills' -destination "platform=iOS Simulator,name=iPhone 6s" | xcpretty --color

Where the simpler case does work:

xcodebuild -project './TheoryDrills.xcodeproj' -scheme 'TheoryDrills' -destination "platform=iOS Simulator,name=iPhone 6s" | xcpretty --color

Any tips/clues/help you could give would be awesome.

Also, in case it's helpful, this is the plugin which generates the command: https://github.com/gfontenot/vim-xcode/blob/master/plugin/xcode.vim#L132-L135. I'm trying to use AsyncRun as the runner.

Multiple processes

Is it possible/planned to be able to run multiple commands/processes simultaneously?

Incorrect background job status

Sometimes AsyncRun gets stuck thinking the background job is still running and won't allow further runs of the job.

ERROR: background job is still running

Verified that the process ran isn't running. AsyncStop doesn't seem to help.

MacVim 8.0.134

asyncrun not playing well with command buffer

Hi,
asyncrun doesn't work well when invoked from the command window (I use nnoremap : q:i).
If I try to open the command window again after invoking a longer AsynRun I get lots of error messages, rendering the command window unusable until the run is finished.

Mistake in readme.

'%>' should be '%<' in "Macro '%' stands for filename and '%>' represents filename without extension."

I forked and was about to submit a pull request, but changing one line seems to have resulted in 188 lines of whitespace changes.

Option to turn off displaying the command that is executed

Hi,

Currently when :AsyncRun command, it will show

[command]
...output...
[Finished in # seconds]

Because my use case involves username and password in the command, obviously having them displayed in plain text isn't good.

Is there a way to turn off displaying [command] and [Finished in #seconds] in quickfix window to only show the output?

Thanks

Problem getting asyncrun to use same $PATH as vim

The asyncrun command does not use the same $PATH as vim. In my shell:

$ echo $PATH
/Users/bsweeney/ebi/rnacentral-web/.direnv/python-2.7.10/bin:...

Then in vim:

:echo $PATH

produces:

/Users/bsweeney/ebi/rnacentral-web/.direnv/python-2.7.10/bin:..

but:

:AsyncRun echo "$PATH"

produces

/usr/local/opt/coreutils/libexec/gnubin:..

I suspect this is because I use direnv to set my path depending upon what directory I am in. I'm not sure how to either get the shell asyncrun uses to respect this, or how to pass PATH to the command. Is it possible?

程序结果没有输出到 quickfix?

我好像并没有什么 vim 配置上的调整,之前还是没问题的,但是 AsyncRun 突然不能将结果输出到 quickfix 中。

terminal 中运行,应当 print 一些信息:

user number: 943
item number: 1650
density:  0.05141489122401106
rating records: 79999
rating scale:  [1, 2, 3, 4, 5]
global average rating:  3.52833160415
MAE: 0.8502
RMSE: 1.0630

实际 vim 中 AsyncRun 运行:

|| [python 'average_filling.py']
|| [Finished in 10 seconds]

不知道是否有些排查的方法?

(Question) Format asyncrun's output

When I'm running a python script, all output lines in the quickfix window are prefaced with ||, i.e.

|| line 1
|| line 2

Can I somehow get rid of these lines? I searched the FAQ but could not find a solution.
Thanks in advance!

Document g:asyncrun_timer or default to -1

I found the delay in updating the quickfix list annoying so in my .vimrc I do

" Update :AsyncRun output as it is ready rather than waiting on timer.
let g:asyncrun_timer = -1

The code makes it look like this is supposed to work, so I'm wondering why it isn't the default or at least documented. It seems to work for me... (famous last words, I know)

ZSH shell

Hi, Is this plugin able to run command in my zsh shell with aliases I have in zshrc?

Wishlist: g:asynrun_start callback

I would like to change my status line color to indicate the status of the async job:

  • green when it's successful
  • red when it failed
  • purple when it's still running

I can do the first two from the g:asyncrun_exit callback. To do the third, I have to overwrite the :AsyncRun command, which is cumbersome to do, since plugins are sourced after my .vimrc.

What do you think about adding a g:asyncrun_start setting, with a script to be executed right before a job is started?

How to make asyncrun use Elixir `exunit` compiler to display failures like in Dispatch?

First, I wanted to say thank you for work. I have the feeling asyncrun will be a plugin I will use a lot. Kudos for neovim support 😄 .

I have read your FAQ about how to process the content in quickfix but I am not sure how to tell asyncrun to use the exunit compiler.

Screenshot:
image

See elixir-editors/vim-elixir#76 explains how it was fixed with vim-test + Dispatch.

a screenshot with Dispatch:
image

I am also wondering how Tim Pope does to have some syntax highlighting in color here but that's for another issue

关于使用%<加文件扩展名出错

你好!AsyncRun非常好用!!点赞!之前我一直都是用VimShell,感觉速度上还是不够快,虽然也可以异步进行。
我主要用Vim来写Markdown,然后用Pandoc来转换成为Tex或直接输出PDF。我在_vimrc中加入了

nnoremap <silent> <Leader>ppd :AsyncRun pandoc --output %<.pdf %:p <CR>

但是由于在%<后面出现了.pdf,AsyncRun就会直接认为是%<.pdf这一个文本。请问如何才能解决这个问题?谢谢

Every job fails with 'No such file or directory'

Hi,

I'm running the plugin in the latest vim (built from the git repository with all the necessary features). Yet, all calls to AsyncRun return immediately, and the quickfix list looks like this:

|| ["grep", "-R", "unsigned", "."]
|| executing job failed: No such file or directory
|| [Finished in 0 seconds with code 122]

Not sure what's going on.

Trigger autocommand QuickFixCmdPost

Hi,

thanks for the great plugin. Works really fine for me. Except one things: I run make through asyncrun and I additionally use the plugin errormarker (https://github.com/vim-scripts/errormarker.vim) that highlights compiler errors and warnings after a make using the QuickFixCmdPost. This does not work for asyncrun. Is it possible to add a doautocmd after asyncrun detects the exit of the called program? For now I added the following line as last command in AsyncRun_Job_OnFinish:

silent doautocmd QuickFixCmdPost make

The hard coding of make is really silly but I don't know how it could be implemented in a intelligent way. Any Ideas?

Automatically manipulate the quickfix window?

First of all, this is a nice plugin. But how about opening the quickfix window automatically when AsyncRun? I mean, instead of explicitly opening the quickfix by ourselves, the plugin could do this when necessary.

Can this plugin run functions defined in .vimrc execute asynchronously?

For example, I have this function:

func! CompileCppAndRun()
"silent w
"silent make
execute "copen"
if (line('$') == 1 && getline(1) == '')
silent execute ":cclose"
let cexec = "". "%:p:r "
silent execute "!clear"
silent execute "!" . "xterm " . "-e " . "cb_console_runner " . cexec
endif

endfunc

This is a function that compiles c++ program, executes if compiled or opens quickfix if there are compile errors.

So, can AsyncRun call this function?

E118 and cxpr [] by default

Hello,
First of all, great plugin!

Two quick question:

  1. When I run a command via AsyncRun, I get this error:

E118: Too many arguments for function: setqflist

Everything works correctly though. So I am not sure why I get this error.

  1. Would it be possible to clear out the quick fix list by default the next time I run an AsyncRun command? Right now, I have to do this manually via typing:

:cexpr []

If this can happen, everytime I run a command, that would be convenient.

How to stay in current window after asyncrun finishes?

I remember there was this function to customize whether to jump to the quickfix window when asyncrun finishes, but I can't find it in the document now, wonder if there is still some way to customize this behavior?

Put it simple, I just want the quickfix to be open but remain my current editing window instead of jumping to the quickfix window.

quick fix问题

插件安装成功,使用gcc可以生成二进制文件,但是没有quick fix窗口展示,请问这是什么问题?

Problem with grep

I haven't managed to find some time to track down the problem myself but sometimes the results get added to the quickfix list as unstructured entries, as if efm isn't set. I've attached a minimal vimrc, here's the steps to (hopefully) reproduce the issue:

  • Grep <TERM>
  • :copen
  • The entries are correctly formatted
  • Open the first result
  • Grep <TERM>
  • The entries are not formatted anymore
set nocompatible
call plug#begin('~/.vim/bundle')
Plug 'skywind3000/asyncrun.vim'
call plug#end()
let &grepprg='ag --vimgrep -- $*'
let grepformat='%f:%l:%c:%m'
command! -nargs=* Grep execute 'AsyncRun! -program=grep "'.escape(<q-args>, "|\%#'\ \"").'" .'

Does not work with Powershell in Windows

When a different shell is configured on Windows (for example, Powershell), some of the shell power is lost using the .cmd approach.

https://github.com/skywind3000/asyncrun.vim/blob/master/plugin/asyncrun.vim#L582

let l:tmp = fnamemodify(tempname(), ':h') . '\asyncrun.cmd'
let l:run = ['@echo off', a:cmd]
call writefile(l:run, l:tmp)
let l:args += [l:tmp]

for example:

:! 1+1

works with Powershell configured, but

:AsyncRun 1+1

does not work, because it is not a valid .cmd syntax.
I have made a simple change in my asyncrun.vim that enables me to work with any powershell expression:

let l:run = [&shell . " " . a:cmd]

Please let me know if you have any other suggestion to makes this work, or need help to implement this.

能否增加对 ex command ranges 的支持

如果可以直接使用 :%AsyncRun 来运行当前 buffer 区里的命令,这样对于需要修改重复运行的命令的方便多了,毕竟在 vim 里比在 shell 里容易编辑命令 :)

Output not captured in Quickfix for python scripts

Output of python scripts is not displayed in the Quickfix window.

I have the following in a test.py file:

# File: test.py
print('Hello world!')

If I run :AsyncRun python test.py the Quickfix window does not display the message. It simply shows:

|| [python test.py]
|| 
|| [Finished in 0 seconds]

But if I execute :AsyncRun python -c 'print("Hello world!")' I correctly get:

|| [python -c 'print("Hello world!")']
|| Hello world!
|| 
|| [Finished in 0 seconds]

In bash, for example, it works fine. If I have a file test.sh with:

# File: test.sh
echo 'Hello world!'

and execute :AsyncRun bash test.sh I get:

|| [bash test.sh]
|| Hello world!
|| 
|| [Finished in 0 seconds]

What am I missing here? Is there a problem with python output?

[suggestion] more friendly readme about copen

new to this plugin, nowhere to find why i have no quickfix popup after running the command, after a long search, finally found that i should call copen manually to see the result (usually i prefer quickfix window to be closed)

suggestion:

  • add an option to open quickfix automatically after command finish, and, make it default to true

  • add description about copen manually, in plugin's readme

  • or, have this setting as default:

    let g:asyncrun_exit='echo "AsyncRun " . g:asyncrun_status . "(" . g:asyncrun_code'
        \ . ' . "), use `:copen` to see the result"'
    

Provide example setup to get async netrw-write for remotes even when using `:w`

When editing a remote file, saving the file with :w is blocking the editor until the file is saved to the remote. This can vary dependent on file size and remote connection.

Would it be possible to offer a setup in the wiki similar to the fugitive setting of :Gpush to make this non-blocking?

netrw-write acts on the builtin write command :write via the autocommand events BufWriteCmd and FileWriteCmd as can be seen in $VIMRUNTIME/plugin/netrwPlugin.vim:

 au BufWriteCmd  ftp://*,rcp://*,scp://*,http://*,file://*,dav://*,davs://*,rsync://*,sftp://*          exe "sil doau BufWritePre ".fnameescape(expand("<amatch>"))|exe 'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau BufWritePost ".fnameescape(expand("<amatch>"))
 au FileWriteCmd ftp://*,rcp://*,scp://*,http://*,file://*,dav://*,davs://*,rsync://*,sftp://*          exe "sil doau FileWritePre ".fnameescape(expand("<amatch>"))|exe "'[,']".'Nwrite '.fnameescape(expand("<amatch>"))|exe "sil doau FileWritePost ".fnameescape(expand("<amatch>"))

errorformat is ignored

I read #16 and #19 about the output is not matched by errorformat, which is defined with a CompilerSet command. I open a new issue because I didn't find a solution and those issues are old.

In ftplugin/javascript.vim: autocmd BufWritePost <buffer> compiler javascript | Make %
In compiler/javascript.vim:

let &l:makeprg=substitute(system('npm bin'), '^\n*\s*\(.\{-}\)\n*\s*$', '\1', '') . '/eslint' . " -f compact"
CompilerSet errorformat=%E%f:\ line\ %l\\,\ col\ %c\\,\ %m,%C%.%#

In pack/my/start/z/plugin/asyncrun.vim:

command! -bang -nargs=* -complete=file Make AsyncRun -program=make @ <args>

And the result is the following one:

|| [C:\my\Dev\snippets\argo\node_modules\.bin/eslint -f compact accounts.service.js]
accounts.service.js|38 col 67 error| Error - Missing semicolon. (semi)
|| 
|| [Finished in 1 seconds with code 1]

Instead of (using standard make)

accounts.service.js|38 col 67 error| Error - Missing semicolon. (semi)

I tried

:compiler javascript
:set errorformat=%E%f:\ line\ %l\\,\ col\ %c\\,\ %m,%C%.%#
:Make %

With the same undesired results.

Any hint or is it the expected result?

Reference: https://github.com/albertosantini/vimfiles

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.