aboutsummaryrefslogtreecommitdiff
path: root/runtime/compiler
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-11-19 22:57:13 +0000
commit9be89f131f87608f224f0ee06d199fcd09d32176 (patch)
tree11022dcfa9e08cb4ac5581b16734196128688d48 /runtime/compiler
parentff7ed8f586589d620a806c3758fac4a47a8e7e15 (diff)
parent88085c2e80a7e3ac29aabb6b5420377eed99b8b6 (diff)
downloadrneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.gz
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.tar.bz2
rneovim-9be89f131f87608f224f0ee06d199fcd09d32176.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'runtime/compiler')
-rw-r--r--runtime/compiler/README.txt2
-rw-r--r--runtime/compiler/cppcheck.vim40
-rw-r--r--runtime/compiler/groff.vim45
-rw-r--r--runtime/compiler/hare.vim23
-rw-r--r--runtime/compiler/javac.vim9
-rw-r--r--runtime/compiler/make.vim13
-rw-r--r--runtime/compiler/pandoc.vim50
-rw-r--r--runtime/compiler/typst.vim15
8 files changed, 163 insertions, 34 deletions
diff --git a/runtime/compiler/README.txt b/runtime/compiler/README.txt
index dccf4a9762..327d0a7fde 100644
--- a/runtime/compiler/README.txt
+++ b/runtime/compiler/README.txt
@@ -4,6 +4,8 @@ They are used with the ":compiler" command.
These scripts usually set options, for example 'errorformat'.
See ":help write-compiler-plugin".
+To undo the effect of a compiler plugin, use the make compiler plugin.
+
If you want to write your own compiler plugin, have a look at the other files
for how to do it, the format is simple.
diff --git a/runtime/compiler/cppcheck.vim b/runtime/compiler/cppcheck.vim
new file mode 100644
index 0000000000..ed7c46e90f
--- /dev/null
+++ b/runtime/compiler/cppcheck.vim
@@ -0,0 +1,40 @@
+" vim compiler file
+" Compiler: cppcheck (C++ static checker)
+" Maintainer: Vincent B. (twinside@free.fr)
+" Last Change: 2024 Oct 4 by @Konfekt
+
+if exists("cppcheck")
+ finish
+endif
+let current_compiler = "cppcheck"
+
+let s:cpo_save = &cpo
+set cpo-=C
+
+if !exists('g:c_cppcheck_params')
+ let g:c_cppcheck_params = '--verbose --force --inline-suppr'
+ \ ..' '..'--enable=warning,style,performance,portability,information,missingInclude'
+ \ ..' '..(executable('getconf') ? '-j' .. systemlist('getconf _NPROCESSORS_ONLN')[0] : '')
+ let s:undo_compiler = 'unlet! g:c_cppcheck_params'
+endif
+
+let &l:makeprg = 'cppcheck --quiet'
+ \ ..' --template="{file}:{line}:{column}: {severity}: [{id}] {message} {callstack}"'
+ \ ..' '..get(b:, 'c_cppcheck_params',
+ \ g:c_cppcheck_params..' '..(&filetype ==# 'cpp' ? ' --language=c++' : ''))
+ \ ..' '..get(b:, 'c_cppcheck_includes', get(g:, 'c_cppcheck_includes',
+ \ (filereadable('compile_commands.json') ? '--project=compile_commands.json' :
+ \ (empty(&path) ? '' : '-I')..join(map(filter(split(&path, ','), 'isdirectory(v:val)'),'shellescape(v:val)'), ' -I'))))
+silent CompilerSet makeprg
+
+CompilerSet errorformat=
+ \%f:%l:%c:\ %tarning:\ %m,
+ \%f:%l:%c:\ %trror:\ %m,
+ \%f:%l:%c:\ %tnformation:\ %m,
+ \%f:%l:%c:\ %m,
+ \%.%#\ :\ [%f:%l]\ %m
+
+exe get(s:, 'undo_compiler', '')
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
diff --git a/runtime/compiler/groff.vim b/runtime/compiler/groff.vim
new file mode 100644
index 0000000000..640146d6a1
--- /dev/null
+++ b/runtime/compiler/groff.vim
@@ -0,0 +1,45 @@
+" Vim compiler file
+" Compiler: Groff
+" Maintainer: Konfekt
+" Last Change: 2024 Sep 8
+"
+" Expects output file extension, say `:make html` or `:make pdf`.
+" Supported devices as of Sept 2024 are: (x)html, pdf, ps, dvi, lj4, lbp ...
+" Adjust command-line flags, language, encoding by buffer-local/global variables
+" groff_compiler_args, groff_compiler_lang, and groff_compiler_encoding,
+" which default to '', &spelllang and 'utf8'.
+
+if exists("current_compiler")
+ finish
+endif
+
+let s:keepcpo = &cpo
+set cpo&vim
+
+let current_compiler = 'groff'
+
+silent! function s:groff_compiler_lang()
+ let lang = get(b:, 'groff_compiler_lang',
+ \ &spell ? matchstr(&spelllang, '^\a\a') : '')
+ if lang ==# 'en' | let lang = '' | endif
+ return empty(lang) ? '' : '-m'..lang
+endfunction
+
+" Requires output format (= device) to be set by user after :make.
+execute 'CompilerSet makeprg=groff'..escape(
+ \ ' '..s:groff_compiler_lang()..
+ \ ' -K'..get(b:, 'groff_compiler_encoding', get(g:, 'groff_compiler_encoding', 'utf8'))..
+ \ ' '..get(b:, 'groff_compiler_args', get(g:, 'groff_compiler_args', ''))..
+ \ ' -mom -T$* -- %:S > %:r:S.$*', ' ')
+" From Gavin Freeborn's https://github.com/Gavinok/vim-troff under Vim License
+" https://github.com/Gavinok/vim-troff/blob/91017b1423caa80aba541c997909a4f810edd275/compiler/troff.vim#L39
+CompilerSet errorformat=%o:<standard\ input>\ (%f):%l:%m,
+ \%o:\ <standard\ input>\ (%f):%l:%m,
+ \%o:%f:%l:%m,
+ \%o:\ %f:%l:%m,
+ \%f:%l:\ macro\ %trror:%m,
+ \%f:%l:%m,
+ \%W%tarning:\ file\ '%f'\\,\ around\ line\ %l:,%Z%m
+
+let &cpo = s:keepcpo
+unlet s:keepcpo
diff --git a/runtime/compiler/hare.vim b/runtime/compiler/hare.vim
index c98bbb9c63..33edb3a281 100644
--- a/runtime/compiler/hare.vim
+++ b/runtime/compiler/hare.vim
@@ -1,28 +1,29 @@
-" Vim compiler file
-" Compiler: Hare Compiler
-" Maintainer: Amelia Clarke <me@rsaihe.dev>
-" Last Change: 2022-09-21
-" 2024 Apr 05 by The Vim Project (removed :CompilerSet definition)
+" Vim compiler file.
+" Compiler: Hare
+" Maintainer: Amelia Clarke <selene@perilune.dev>
+" Last Change: 2024-05-23
+" Upstream: https://git.sr.ht/~sircmpwn/hare.vim
-if exists("g:current_compiler")
+if exists('current_compiler')
finish
endif
-let g:current_compiler = "hare"
+let current_compiler = 'hare'
let s:cpo_save = &cpo
set cpo&vim
-if filereadable("Makefile") || filereadable("makefile")
+if filereadable('Makefile') || filereadable('makefile')
CompilerSet makeprg=make
else
CompilerSet makeprg=hare\ build
endif
CompilerSet errorformat=
- \Error\ %f:%l:%c:\ %m,
- \Syntax\ error:\ %.%#\ at\ %f:%l:%c\\,\ %m,
+ \%f:%l:%c:\ syntax\ error:\ %m,
+ \%f:%l:%c:\ error:\ %m,
\%-G%.%#
let &cpo = s:cpo_save
unlet s:cpo_save
-" vim: tabstop=2 shiftwidth=2 expandtab
+
+" vim: et sts=2 sw=2 ts=8
diff --git a/runtime/compiler/javac.vim b/runtime/compiler/javac.vim
index f5fe84124f..9bd4cdf270 100644
--- a/runtime/compiler/javac.vim
+++ b/runtime/compiler/javac.vim
@@ -1,7 +1,7 @@
" Vim compiler file
" Compiler: Java Development Kit Compiler
" Maintainer: Doug Kearns <dougkearns@gmail.com>
-" Last Change: 2024 Apr 03
+" Last Change: 2024 Jun 14
if exists("current_compiler")
finish
@@ -11,7 +11,12 @@ let current_compiler = "javac"
let s:cpo_save = &cpo
set cpo&vim
-CompilerSet makeprg=javac
+if exists("g:javac_makeprg_params")
+ execute $'CompilerSet makeprg=javac\ {escape(g:javac_makeprg_params, ' \|"')}'
+else
+ CompilerSet makeprg=javac
+endif
+
CompilerSet errorformat=%E%f:%l:\ error:\ %m,
\%W%f:%l:\ warning:\ %m,
\%-Z%p^,
diff --git a/runtime/compiler/make.vim b/runtime/compiler/make.vim
new file mode 100644
index 0000000000..748251bf8e
--- /dev/null
+++ b/runtime/compiler/make.vim
@@ -0,0 +1,13 @@
+" Vim compiler plugin
+"
+" Maintainer: The Vim Project <https://github.com/vim/vim>
+" Last Change: 2024 Sep 10
+" Original Author: Konfekt
+"
+" This compiler plugin is used to reset previously set compiler options.
+
+if exists("g:current_compiler") | unlet g:current_compiler | endif
+if exists("b:current_compiler") | unlet b:current_compiler | endif
+
+CompilerSet makeprg&
+CompilerSet errorformat&
diff --git a/runtime/compiler/pandoc.vim b/runtime/compiler/pandoc.vim
index 6c151930c5..6c15e104c3 100644
--- a/runtime/compiler/pandoc.vim
+++ b/runtime/compiler/pandoc.vim
@@ -1,9 +1,12 @@
" Vim compiler file
" Compiler: Pandoc
" Maintainer: Konfekt
+" Last Change: 2024 Sep 8
"
" Expects output file extension, say `:make html` or `:make pdf`.
" Passes additional arguments to pandoc, say `:make html --self-contained`.
+" Adjust command-line flags by buffer-local/global variable
+" b/g:pandoc_compiler_args which defaults to empty.
if exists("current_compiler")
finish
@@ -25,31 +28,36 @@ let s:supported_filetypes =
silent! function s:PandocFiletype(filetype) abort
let ft = a:filetype
- if ft ==# 'pandoc'
- return 'markdown'
- elseif ft ==# 'tex'
- return 'latex'
- elseif ft ==# 'xml'
- " Pandoc does not support XML as a generic input format, but it does support
- " EndNote XML and Jats XML out of which the latter seems more universal.
- return 'jats'
- elseif ft ==# 'text' || empty(ft)
- return 'markdown'
- elseif index(s:supported_filetypes, &ft) >= 0
- return ft
+
+ if ft ==# 'pandoc' | return 'markdown'
+ elseif ft ==# 'tex' | return 'latex'
+ " Pandoc does not support XML as a generic input format, but it does support
+ " EndNote XML and Jats XML out of which the latter seems more universal.
+ elseif ft ==# 'xml' | return 'jats'
+ elseif ft ==# 'text' || empty(ft) | return 'markdown'
+ elseif index(s:supported_filetypes, &ft) >= 0 | return ft
else
- echomsg 'Unsupported filetype: ' . ft . ', falling back to Markdown as input format!'
+ echomsg 'Unsupported filetype: '..ft..', falling back to Markdown as input format!'
return 'markdown'
endif
endfunction
-execute 'CompilerSet makeprg=pandoc\ --standalone' .
- \ '\ --metadata\ title=%:t:r:S' .
- \ '\ --metadata\ lang=' . matchstr(&spelllang, '^\a\a') .
- \ '\ --from=' . s:PandocFiletype(&filetype) .
- \ '\ ' . escape(get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', '')), ' ') .
- \ '\ --output\ %:r:S.$*\ %:S'
-
-CompilerSet errorformat="%f",\ line\ %l:\ %m
+
+silent! function s:PandocLang()
+ let lang = get(b:, 'pandoc_compiler_lang',
+ \ &spell ? matchstr(&spelllang, '^\a\a') : '')
+ if lang ==# 'en' | let lang = '' | endif
+ return empty(lang) ? '' : '--metadata lang='..lang
+endfunction
+
+execute 'CompilerSet makeprg=pandoc'..escape(
+ \ ' --standalone'..
+ \ (s:PandocFiletype(&filetype) ==# 'markdown' && (getline(1) =~# '^%\s\+\S\+' || (search('^title:\s+\S+', 'cnw') > 0)) ?
+ \ '' : ' --metadata title=%:t:r:S')..
+ \ ' '..s:PandocLang()..
+ \ ' --from='..s:PandocFiletype(&filetype)..
+ \ ' '..get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', ''))..
+ \ ' --output %:r:S.$* -- %:S', ' ')
+CompilerSet errorformat=\"%f\",\ line\ %l:\ %m
let &cpo = s:keepcpo
unlet s:keepcpo
diff --git a/runtime/compiler/typst.vim b/runtime/compiler/typst.vim
new file mode 100644
index 0000000000..33e55818e9
--- /dev/null
+++ b/runtime/compiler/typst.vim
@@ -0,0 +1,15 @@
+" Vim compiler file
+" Language: Typst
+" Maintainer: Gregory Anders
+" Last Change: 2024-07-14
+" Based on: https://github.com/kaarmu/typst.vim
+
+if exists('current_compiler')
+ finish
+endif
+let current_compiler = get(g:, 'typst_cmd', 'typst')
+
+" With `--diagnostic-format` we can use the default errorformat
+let s:makeprg = [current_compiler, 'compile', '--diagnostic-format', 'short', '%:S']
+
+execute 'CompilerSet makeprg=' . join(s:makeprg, '\ ')