Skip to content

a collection of compilers for ready use by Vim's built-in compiler feature (see :help :compiler)

Notifications You must be signed in to change notification settings

Konfekt/vim-compilers

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

57 Commits
 
 
 
 
 
 

Repository files navigation

The folder compiler/ contains compiler files that set up compilers (or linters, that is, syntax checkers) for easy use in Vim. Copy them into your Vim configuration folder (~/.vim on Linux and MacOS, %USERPROFILE%/vimfiles on Microsoft Windows). You may also use a plug-in manager such as vim-plug (in this case, add Plug 'konfekt/vim-compilers' to your vimrc to use them).

Usage and Setup

Switch to a compiler by :compiler ... and then start it by :make or :lmake. For example, first call :compiler flake8 to switch to flake8, and then lint the current (Python) file by :lmake %:S. In one go: :comp flake8 | lmake %:S.

Convenience Commands

This plug-in provides a command (L)Compiler to set the compiler and call it by (l)make in one go, for example:

LCompiler flake8 %:S

achieves the same as :comp flake8 | lmake %:S. Everything following its first argument is passed to (L)Make.

For faster access to this commands, install vim-alias and add aliases such as

Alias cm   Compiler
Alias cmm  Compiler\ %:S<c-b><c-right>
Alias lcm  LCompiler
Alias lcmm LCompiler\ %:S<c-b><c-right>

Alias m    Make
Alias mm   Make\ %:S
Alias lm   LMake
Alias lmm  LMake\ %:S

Calling a Linter

For convenience, define in ~/.vim/after/ftplugin/python.vim a command

command! -buffer -bang Lint compiler flake8 | lmake %:S<bang>

It can then be called to lint the main file by :Lint.

The location-list window that lists all compiler messages can then be opened by :lwindow; their locations can be jumped to by :ln respectively :lp (or use vim-unimpaired's mappings ]l and [l.)

To automatically open the location-list window after linting has finished, add autocmd QuickFixCmdPost lmake lwindow to your vimrc.

To automatically run :Lint after saving the modifications to a source code file, say Python, add to ~/.vim/after/ftplugin/python.vim:

    autocmd BufWrite <buffer=abuf> Lint

Calling a Compiler

For a compiler command, such as python, define in ~/.vim/after/ftplugin/python.vim a command

command! -buffer -bang Compile compiler python | make<bang>.

that can then be called to compile the main file. For example, if it is the one of the currently open buffer, then :Compile %:S suffices.

The (quickfix) window that lists all compiler messages can then be opened by :cwindow; their locations can be jumped to by :cn respectively :cp (or use vim-unimpaired's mappings ]q and [q.).

To automatically open the quickfix window after compilation has finished, add autocmd QuickFixCmdPost make cwindow to your vimrc.

Run as Jobs

To run a linter or compiler in the background, use an :(L)Make command (instead of :make or :lmake), such as

  • that of tasks.vim, or

  • that of vim-dispatch, or

  • that defined by

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

    with AsyncRun.vim installed. To avoid empty lines in the quickfix list, add let g:asyncrun_trim = 1 to your vimrc. Other options, such as g:asyncrun_save might be of interest.

Signpost Locations

The plug-in vim-markify marks all found locations by text signs at the side of the window.

Additional Compilers

Vim already comes with many compiler files, see :e $VIMRUNTIME/compiler.

Googling for GitHub Vim compilers yielded compiler files for

A search request on GitHub itself yields compiler files for

About

a collection of compilers for ready use by Vim's built-in compiler feature (see :help :compiler)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •