aboutsummaryrefslogtreecommitdiff
path: root/runtime/compiler
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
committerJosh Rahm <joshuarahm@gmail.com>2025-02-05 23:09:29 +0000
commitd5f194ce780c95821a855aca3c19426576d28ae0 (patch)
treed45f461b19f9118ad2bb1f440a7a08973ad18832 /runtime/compiler
parentc5d770d311841ea5230426cc4c868e8db27300a8 (diff)
parent44740e561fc93afe3ebecfd3618bda2d2abeafb0 (diff)
downloadrneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.gz
rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.tar.bz2
rneovim-d5f194ce780c95821a855aca3c19426576d28ae0.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309HEADrahm
Diffstat (limited to 'runtime/compiler')
-rw-r--r--runtime/compiler/bash.vim12
-rw-r--r--runtime/compiler/cppcheck.vim4
-rw-r--r--runtime/compiler/eslint.vim7
-rw-r--r--runtime/compiler/groff.vim4
-rw-r--r--runtime/compiler/javac.vim8
-rw-r--r--runtime/compiler/maven.vim2
-rw-r--r--runtime/compiler/mypy.vim4
-rw-r--r--runtime/compiler/pandoc.vim4
-rw-r--r--runtime/compiler/powershell.vim7
-rw-r--r--runtime/compiler/pylint.vim3
-rw-r--r--runtime/compiler/pytest.vim103
-rw-r--r--runtime/compiler/ruff.vim3
-rw-r--r--runtime/compiler/spotbugs.vim254
-rw-r--r--runtime/compiler/tex.vim7
-rw-r--r--runtime/compiler/typst.vim5
15 files changed, 398 insertions, 29 deletions
diff --git a/runtime/compiler/bash.vim b/runtime/compiler/bash.vim
new file mode 100644
index 0000000000..cbd76ae410
--- /dev/null
+++ b/runtime/compiler/bash.vim
@@ -0,0 +1,12 @@
+" Vim compiler file
+" Compiler: Bash Syntax Checker
+" Maintainer: @konfekt
+" Last Change: 2024 Dec 27
+
+if exists("current_compiler")
+ finish
+endif
+let current_compiler = "bash"
+
+CompilerSet makeprg=bash\ -n
+CompilerSet errorformat=%f:\ line\ %l:\ %m
diff --git a/runtime/compiler/cppcheck.vim b/runtime/compiler/cppcheck.vim
index 4df12d1714..033613c091 100644
--- a/runtime/compiler/cppcheck.vim
+++ b/runtime/compiler/cppcheck.vim
@@ -1,7 +1,7 @@
" vim compiler file
" Compiler: cppcheck (C++ static checker)
" Maintainer: Vincent B. (twinside@free.fr)
-" Last Change: 2024 Nov 08 by @Konfekt
+" Last Change: 2024 Nov 19 by @Konfekt
if exists("current_compiler") | finish | endif
let current_compiler = "cppcheck"
@@ -25,7 +25,7 @@ let &l:makeprg = 'cppcheck --quiet'
\ (filereadable('compile_commands.json') ? '--project=compile_commands.json' :
\ (!empty(glob('*'..s:slash..'compile_commands.json', 1, 1)) ? '--project='..glob('*'..s:slash..'compile_commands.json', 1, 1)[0] :
\ (empty(&path) ? '' : '-I')..join(map(filter(split(&path, ','), 'isdirectory(v:val)'),'shellescape(v:val)'), ' -I')))))
-exe 'CompilerSet makeprg='..escape(&l:makeprg, ' "')
+exe 'CompilerSet makeprg='..escape(&l:makeprg, ' \|"')
CompilerSet errorformat=
\%f:%l:%c:\ %tarning:\ %m,
diff --git a/runtime/compiler/eslint.vim b/runtime/compiler/eslint.vim
index db7a665991..0414817900 100644
--- a/runtime/compiler/eslint.vim
+++ b/runtime/compiler/eslint.vim
@@ -1,13 +1,12 @@
" Vim compiler file
" Compiler: ESLint for JavaScript
" Maintainer: Romain Lafourcade <romainlafourcade@gmail.com>
-" Last Change: 2020 August 20
-" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition)
+" Last Change: 2024 Nov 30
if exists("current_compiler")
finish
endif
let current_compiler = "eslint"
-CompilerSet makeprg=npx\ eslint\ --format\ compact
-CompilerSet errorformat=%f:\ line\ %l\\,\ col\ %c\\,\ %m,%-G%.%#
+CompilerSet makeprg=npx\ eslint\ --format\ stylish
+CompilerSet errorformat=%-P%f,\%\\s%#%l:%c\ %#\ %trror\ \ %m,\%\\s%#%l:%c\ %#\ %tarning\ \ %m,\%-Q,\%-G%.%#,
diff --git a/runtime/compiler/groff.vim b/runtime/compiler/groff.vim
index 640146d6a1..3e9ae0488f 100644
--- a/runtime/compiler/groff.vim
+++ b/runtime/compiler/groff.vim
@@ -1,7 +1,7 @@
" Vim compiler file
" Compiler: Groff
" Maintainer: Konfekt
-" Last Change: 2024 Sep 8
+" Last Change: 2024 Nov 19
"
" Expects output file extension, say `:make html` or `:make pdf`.
" Supported devices as of Sept 2024 are: (x)html, pdf, ps, dvi, lj4, lbp ...
@@ -30,7 +30,7 @@ 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.$*', ' ')
+ \ ' -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,
diff --git a/runtime/compiler/javac.vim b/runtime/compiler/javac.vim
index 9bd4cdf270..53cd772ed8 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 Jun 14
+" Last Change: 2024 Nov 19 (enable local javac_makeprg_params)
if exists("current_compiler")
finish
@@ -11,11 +11,7 @@ let current_compiler = "javac"
let s:cpo_save = &cpo
set cpo&vim
-if exists("g:javac_makeprg_params")
- execute $'CompilerSet makeprg=javac\ {escape(g:javac_makeprg_params, ' \|"')}'
-else
- CompilerSet makeprg=javac
-endif
+execute $'CompilerSet makeprg=javac\ {escape(get(b:, 'javac_makeprg_params', get(g:, 'javac_makeprg_params', '')), ' \|"')}'
CompilerSet errorformat=%E%f:%l:\ error:\ %m,
\%W%f:%l:\ warning:\ %m,
diff --git a/runtime/compiler/maven.vim b/runtime/compiler/maven.vim
index ef8d8a6fb2..72e74e301d 100644
--- a/runtime/compiler/maven.vim
+++ b/runtime/compiler/maven.vim
@@ -14,7 +14,7 @@ if exists("current_compiler")
endif
let current_compiler = "maven"
-CompilerSet makeprg=mvn\ --batch-mode
+execute $'CompilerSet makeprg=mvn\ --batch-mode\ {escape(get(b:, 'maven_makeprg_params', get(g:, 'maven_makeprg_params', '')), ' \|"')}'
" Error message for POM
CompilerSet errorformat=[FATAL]\ Non-parseable\ POM\ %f:\ %m%\\s%\\+@%.%#line\ %l\\,\ column\ %c%.%#,
diff --git a/runtime/compiler/mypy.vim b/runtime/compiler/mypy.vim
index 891488626a..907b98b777 100644
--- a/runtime/compiler/mypy.vim
+++ b/runtime/compiler/mypy.vim
@@ -1,7 +1,7 @@
" Vim compiler file
" Compiler: Mypy (Python static checker)
" Maintainer: @Konfekt
-" Last Change: 2024 Nov 07
+" Last Change: 2024 Nov 19
if exists("current_compiler") | finish | endif
let current_compiler = "mypy"
@@ -12,7 +12,7 @@ set cpo&vim
" CompilerSet makeprg=mypy
let &l:makeprg = 'mypy --show-column-numbers '
\ ..get(b:, 'mypy_makeprg_params', get(g:, 'mypy_makeprg_params', '--strict --ignore-missing-imports'))
-exe 'CompilerSet makeprg='..escape(&l:makeprg, ' "')
+exe 'CompilerSet makeprg='..escape(&l:makeprg, ' \|"')
CompilerSet errorformat=%f:%l:%c:\ %t%*[^:]:\ %m
let &cpo = s:cpo_save
diff --git a/runtime/compiler/pandoc.vim b/runtime/compiler/pandoc.vim
index 6c15e104c3..5d90a518c9 100644
--- a/runtime/compiler/pandoc.vim
+++ b/runtime/compiler/pandoc.vim
@@ -1,7 +1,7 @@
" Vim compiler file
" Compiler: Pandoc
" Maintainer: Konfekt
-" Last Change: 2024 Sep 8
+" Last Change: 2024 Nov 19
"
" Expects output file extension, say `:make html` or `:make pdf`.
" Passes additional arguments to pandoc, say `:make html --self-contained`.
@@ -56,7 +56,7 @@ execute 'CompilerSet makeprg=pandoc'..escape(
\ ' '..s:PandocLang()..
\ ' --from='..s:PandocFiletype(&filetype)..
\ ' '..get(b:, 'pandoc_compiler_args', get(g:, 'pandoc_compiler_args', ''))..
- \ ' --output %:r:S.$* -- %:S', ' ')
+ \ ' --output %:r:S.$* -- %:S', ' \|"')
CompilerSet errorformat=\"%f\",\ line\ %l:\ %m
let &cpo = s:keepcpo
diff --git a/runtime/compiler/powershell.vim b/runtime/compiler/powershell.vim
index 821fea4085..3d37d7c847 100644
--- a/runtime/compiler/powershell.vim
+++ b/runtime/compiler/powershell.vim
@@ -3,8 +3,9 @@
" URL: https://github.com/PProvost/vim-ps1
" Contributors: Enno Nagel
" Last Change: 2024 Mar 29
-" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition)
-" 2024 Apr 05 by The Vim Project (avoid leaving behind g:makeprg)
+" 2024 Apr 03 by the Vim Project (removed :CompilerSet definition)
+" 2024 Apr 05 by the Vim Project (avoid leaving behind g:makeprg)
+" 2024 Nov 19 by the Vim Project (properly escape makeprg setting)
if exists("current_compiler")
finish
@@ -49,7 +50,7 @@ let s:makeprg = g:ps1_makeprg_cmd .. ' %:p:S'
" + CategoryInfo : ObjectNotFound: (Write-Ouput:String) [], CommandNotFoundException
" + FullyQualifiedErrorId : CommandNotFoundException
-execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' ')
+execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' \|"')
" Showing error in context with underlining.
CompilerSet errorformat=%+G+%m
diff --git a/runtime/compiler/pylint.vim b/runtime/compiler/pylint.vim
index 4c9c23e125..96abf315ab 100644
--- a/runtime/compiler/pylint.vim
+++ b/runtime/compiler/pylint.vim
@@ -2,6 +2,7 @@
" Compiler: Pylint for Python
" Maintainer: Daniel Moch <daniel@danielmoch.com>
" Last Change: 2024 Nov 07 by The Vim Project (added params variable)
+" 2024 Nov 19 by the Vim Project (properly escape makeprg setting)
if exists("current_compiler") | finish | endif
let current_compiler = "pylint"
@@ -13,7 +14,7 @@ set cpo&vim
let &l:makeprg = 'pylint ' .
\ '--output-format=text --msg-template="{path}:{line}:{column}:{C}: [{symbol}] {msg}" --reports=no ' .
\ get(b:, "pylint_makeprg_params", get(g:, "pylint_makeprg_params", '--jobs=0'))
-exe 'CompilerSet makeprg='..escape(&l:makeprg, ' "')
+exe 'CompilerSet makeprg='..escape(&l:makeprg, ' \|"')
CompilerSet errorformat=%A%f:%l:%c:%t:\ %m,%A%f:%l:\ %m,%A%f:(%l):\ %m,%-Z%p^%.%#,%-G%.%#
let &cpo = s:cpo_save
diff --git a/runtime/compiler/pytest.vim b/runtime/compiler/pytest.vim
new file mode 100644
index 0000000000..7fc189932c
--- /dev/null
+++ b/runtime/compiler/pytest.vim
@@ -0,0 +1,103 @@
+" Vim compiler file
+" Compiler: Pytest (Python testing framework)
+" Maintainer: @Konfekt and @mgedmin
+" Last Change: 2024 Nov 28
+
+if exists("current_compiler") | finish | endif
+let current_compiler = "pytest"
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" CompilerSet makeprg=pytest
+if has('unix')
+ execute $'CompilerSet makeprg=/usr/bin/env\ PYTHONWARNINGS=ignore\ pytest\ {escape(get(b:, 'pytest_makeprg_params', get(g:, 'pytest_makeprg_params', '--tb=short --quiet')), ' \|"')}'
+elseif has('win32')
+ execute $'CompilerSet makeprg=set\ PYTHONWARNINGS=ignore\ &&\ pytest\ {escape(get(b:, 'pytest_makeprg_params', get(g:, 'pytest_makeprg_params', '--tb=short --quiet')), ' \|"')}'
+else
+ CompilerSet makeprg=pytest\ --tb=short\ --quiet
+ execute $'CompilerSet makeprg=pytest\ {escape(get(b:, 'pytest_makeprg_params', get(g:, 'pytest_makeprg_params', '--tb=short --quiet')), ' \|"')}'
+endif
+
+" Pytest syntax errors {{{2
+
+" Reset error format so that sourcing .vimrc again and again doesn't grow it
+" without bounds
+setlocal errorformat&
+
+" For the record, the default errorformat is this:
+"
+" %*[^"]"%f"%*\D%l: %m
+" "%f"%*\D%l: %m
+" %-G%f:%l: (Each undeclared identifier is reported only once
+" %-G%f:%l: for each function it appears in.)
+" %-GIn file included from %f:%l:%c:
+" %-GIn file included from %f:%l:%c\,
+" %-GIn file included from %f:%l:%c
+" %-GIn file included from %f:%l
+" %-G%*[ ]from %f:%l:%c
+" %-G%*[ ]from %f:%l:
+" %-G%*[ ]from %f:%l\,
+" %-G%*[ ]from %f:%l
+" %f:%l:%c:%m
+" %f(%l):%m
+" %f:%l:%m
+" "%f"\, line %l%*\D%c%*[^ ] %m
+" %D%*\a[%*\d]: Entering directory %*[`']%f'
+" %X%*\a[%*\d]: Leaving directory %*[`']%f'
+" %D%*\a: Entering directory %*[`']%f'
+" %X%*\a: Leaving directory %*[`']%f'
+" %DMaking %*\a in %f
+" %f|%l| %m
+"
+" and sometimes it misfires, so let's fix it up a bit
+" (TBH I don't even know what compiler produces filename(lineno) so why even
+" have it?)
+setlocal errorformat-=%f(%l):%m
+
+" Sometimes Vim gets confused about ISO-8601 timestamps and thinks they're
+" filenames; this is a big hammer that ignores anything filename-like on lines
+" that start with at least two spaces, possibly preceded by a number and
+" optional punctuation
+setlocal errorformat^=%+G%\\d%#%.%\\=\ \ %.%#
+
+" Similar, but when the entire line starts with a date
+setlocal errorformat^=%+G\\d\\d\\d\\d-\\d\\d-\\d\\d\ \\d\\d:\\d\\d%.%#
+
+" make: *** [Makefile:14: target] Error 1
+setlocal errorformat^=%+Gmake:\ ***\ %.%#
+
+" FAILED tests.py::test_with_params[YYYY-MM-DD:HH:MM:SS] - Exception: bla bla
+setlocal errorformat^=%+GFAILED\ %.%#
+
+" AssertionError: assert ...YYYY-MM-DD:HH:MM:SS...
+setlocal errorformat^=%+GAssertionError:\ %.%#
+
+" --- /path/to/file:before YYYY-MM-DD HH:MM:SS.ssssss
+setlocal errorformat^=---%f:%m
+
+" +++ /path/to/file:before YYYY-MM-DD HH:MM:SS.ssssss
+setlocal errorformat^=+++%f:%m
+
+" Sometimes pytest prepends an 'E' marker at the beginning of a traceback line
+setlocal errorformat+=E\ %#File\ \"%f\"\\,\ line\ %l%.%#
+
+" Python tracebacks (unittest + doctest output) {{{2
+
+" This collapses the entire traceback into just the last file+lineno,
+" which is convenient when you want to jump to the line that failed (and not
+" the top-level entry point), but it makes it impossible to see the full
+" traceback, which sucks.
+""setlocal errorformat+=
+"" \File\ \"%f\"\\,\ line\ %l%.%#,
+"" \%C\ %.%#,
+"" \%-A\ \ File\ \"unittest%.py\"\\,\ line\ %.%#,
+"" \%-A\ \ File\ \"%f\"\\,\ line\ 0%.%#,
+"" \%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,
+"" \%Z%[%^\ ]%\\@=%m
+setlocal errorformat+=File\ \"%f\"\\,\ line\ %l\\,%#%m
+
+exe 'CompilerSet errorformat='..escape(&l:errorformat, ' \|"')
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
diff --git a/runtime/compiler/ruff.vim b/runtime/compiler/ruff.vim
index 11a69740d8..318f4fe5cb 100644
--- a/runtime/compiler/ruff.vim
+++ b/runtime/compiler/ruff.vim
@@ -2,6 +2,7 @@
" Compiler: Ruff (Python linter)
" Maintainer: @pbnj-dragon
" Last Change: 2024 Nov 07
+" 2024 Nov 19 by the Vim Project (properly escape makeprg setting)
if exists("current_compiler") | finish | endif
let current_compiler = "ruff"
@@ -12,7 +13,7 @@ set cpo&vim
" CompilerSet makeprg=ruff
let &l:makeprg= 'ruff check --output-format=concise '
\ ..get(b:, 'ruff_makeprg_params', get(g:, 'ruff_makeprg_params', '--preview'))
-exe 'CompilerSet makeprg='..escape(&l:makeprg, ' "')
+exe 'CompilerSet makeprg='..escape(&l:makeprg, ' \|"')
CompilerSet errorformat=%f:%l:%c:\ %m,%f:%l:\ %m,%f:%l:%c\ -\ %m,%f:
let &cpo = s:cpo_save
diff --git a/runtime/compiler/spotbugs.vim b/runtime/compiler/spotbugs.vim
new file mode 100644
index 0000000000..8ed45f8ee0
--- /dev/null
+++ b/runtime/compiler/spotbugs.vim
@@ -0,0 +1,254 @@
+" Vim compiler file
+" Compiler: Spotbugs (Java static checker; needs javac compiled classes)
+" Maintainers: @konfekt and @zzzyxwvut
+" Last Change: 2024 Dec 20
+
+if exists('g:current_compiler') || bufname() !~# '\.java\=$' || wordcount().chars < 9
+ finish
+endif
+
+let s:cpo_save = &cpo
+set cpo&vim
+
+" Unfortunately Spotbugs does not output absolute paths, so you need to
+" pass the directory of the files being checked as `-sourcepath` parameter.
+" The regex, auxpath and glob try to include all dependent classes of the
+" current buffer. See https://github.com/spotbugs/spotbugs/issues/856
+
+" FIXME: When "search()" is used with the "e" flag, it makes no _further_
+" progress after claiming an EOL match (i.e. "\_" or "\n", but not "$").
+" XXX: Omit anonymous class declarations
+let s:keywords = '\C\<\%(\.\@1<!class\|@\=interface\|enum\|record\|package\)\%(\s\|$\)'
+let s:type_names = '\C\<\%(\.\@1<!class\|@\=interface\|enum\|record\)\s*\(\K\k*\)\>'
+" Capture ";" for counting a class file directory (see s:package_dir_heads below)
+let s:package_names = '\C\<package\s*\(\K\%(\k*\.\=\)\+;\)'
+let s:package = ''
+
+if has('syntax') && exists('g:syntax_on') &&
+ \ exists('b:current_syntax') && b:current_syntax == 'java' &&
+ \ hlexists('javaClassDecl') && hlexists('javaExternal')
+
+ function! s:GetDeclaredTypeNames() abort
+ if bufname() =~# '\<\%(module\|package\)-info\.java\=$'
+ return [expand('%:t:r')]
+ endif
+ defer execute('silent! normal! g``')
+ call cursor(1, 1)
+ let type_names = []
+ let lnum = search(s:keywords, 'eW')
+ while lnum > 0
+ let name_attr = synIDattr(synID(lnum, (col('.') - 1), 0), 'name')
+ if name_attr ==# 'javaClassDecl'
+ let tokens = matchlist(getline(lnum)..getline(lnum + 1), s:type_names)
+ if !empty(tokens) | call add(type_names, tokens[1]) | endif
+ elseif name_attr ==# 'javaExternal'
+ let tokens = matchlist(getline(lnum)..getline(lnum + 1), s:package_names)
+ if !empty(tokens) | let s:package = tokens[1] | endif
+ endif
+ let lnum = search(s:keywords, 'eW')
+ endwhile
+ return type_names
+ endfunction
+
+else
+ function! s:GetDeclaredTypeNames() abort
+ if bufname() =~# '\<\%(module\|package\)-info\.java\=$'
+ return [expand('%:t:r')]
+ endif
+ " Undo the unsetting of &hls, see below
+ if &hls
+ defer execute('set hls')
+ endif
+ " Possibly restore the current values for registers '"' and "y", see below
+ defer call('setreg', ['"', getreg('"'), getregtype('"')])
+ defer call('setreg', ['y', getreg('y'), getregtype('y')])
+ defer execute('silent bwipeout')
+ " Copy buffer contents for modification
+ silent %y y
+ new
+ " Apply ":help scratch-buffer" effects and match "$" in Java (generated)
+ " type names (see s:type_names)
+ setlocal iskeyword+=$ buftype=nofile bufhidden=hide noswapfile nohls
+ 0put y
+ " Discard text blocks and strings
+ silent keeppatterns %s/\\\@<!"""\_.\{-}\\\@<!"""\|\\"//ge
+ silent keeppatterns %s/".*"//ge
+ " Discard comments
+ silent keeppatterns %s/\/\/.\+$//ge
+ silent keeppatterns %s/\/\*\_.\{-}\*\///ge
+ call cursor(1, 1)
+ let type_names = []
+ let lnum = search(s:keywords, 'eW')
+ while lnum > 0
+ let line = getline(lnum)
+ if line =~# '\<package\>'
+ let tokens = matchlist(line..getline(lnum + 1), s:package_names)
+ if !empty(tokens) | let s:package = tokens[1] | endif
+ else
+ let tokens = matchlist(line..getline(lnum + 1), s:type_names)
+ if !empty(tokens) | call add(type_names, tokens[1]) | endif
+ endif
+ let lnum = search(s:keywords, 'eW')
+ endwhile
+ return type_names
+ endfunction
+endif
+
+if has('win32')
+
+ function! s:GlobClassFiles(src_type_name) abort
+ return glob(a:src_type_name..'$*.class', 1, 1)
+ endfunction
+
+else
+ function! s:GlobClassFiles(src_type_name) abort
+ return glob(a:src_type_name..'\$*.class', 1, 1)
+ endfunction
+endif
+
+if exists('b:spotbugs_properties')
+ " Let "ftplugin/java.vim" merge global entries, if any, in buffer-local
+ " entries
+
+ function! s:GetProperty(name, default) abort
+ return get(b:spotbugs_properties, a:name, a:default)
+ endfunction
+
+elseif exists('g:spotbugs_properties')
+
+ function! s:GetProperty(name, default) abort
+ return get(g:spotbugs_properties, a:name, a:default)
+ endfunction
+
+else
+ function! s:GetProperty(dummy, default) abort
+ return a:default
+ endfunction
+endif
+
+if (exists('g:spotbugs_properties') || exists('b:spotbugs_properties')) &&
+ \ ((!empty(s:GetProperty('sourceDirPath', [])) &&
+ \ !empty(s:GetProperty('classDirPath', []))) ||
+ \ (!empty(s:GetProperty('testSourceDirPath', [])) &&
+ \ !empty(s:GetProperty('testClassDirPath', []))))
+
+ function! s:CommonIdxsAndDirs() abort
+ let src_dir_path = s:GetProperty('sourceDirPath', [])
+ let bin_dir_path = s:GetProperty('classDirPath', [])
+ let test_src_dir_path = s:GetProperty('testSourceDirPath', [])
+ let test_bin_dir_path = s:GetProperty('testClassDirPath', [])
+ let dir_cnt = min([len(src_dir_path), len(bin_dir_path)])
+ let test_dir_cnt = min([len(test_src_dir_path), len(test_bin_dir_path)])
+ " Do not break up path pairs with filtering!
+ return [[range(dir_cnt),
+ \ src_dir_path[0 : dir_cnt - 1],
+ \ bin_dir_path[0 : dir_cnt - 1]],
+ \ [range(test_dir_cnt),
+ \ test_src_dir_path[0 : test_dir_cnt - 1],
+ \ test_bin_dir_path[0 : test_dir_cnt - 1]]]
+ endfunction
+
+ let s:common_idxs_and_dirs = s:CommonIdxsAndDirs()
+ delfunction s:CommonIdxsAndDirs
+
+ function! s:FindClassFiles(src_type_name) abort
+ let class_files = []
+ " Match pairwise the components of source and class pathnames
+ for [idxs, src_dirs, bin_dirs] in s:common_idxs_and_dirs
+ " Do not use "fnamemodify(a:src_type_name, ':p:s?src?bin?')" because
+ " only the rightmost "src" is looked for
+ for idx in idxs
+ let tail_idx = strridx(a:src_type_name, src_dirs[idx])
+ " No such directory or no such inner type (i.e. without "$")
+ if tail_idx < 0 | continue | endif
+ " Substitute "bin_dirs[idx]" for the rightmost "src_dirs[idx]"
+ let candidate_type_name = strpart(a:src_type_name, 0, tail_idx)..
+ \ bin_dirs[idx]..
+ \ strpart(a:src_type_name, (tail_idx + strlen(src_dirs[idx])))
+ for candidate in insert(s:GlobClassFiles(candidate_type_name),
+ \ candidate_type_name..'.class')
+ if filereadable(candidate) | call add(class_files, shellescape(candidate)) | endif
+ endfor
+ if !empty(class_files) | break | endif
+ endfor
+ if !empty(class_files) | break | endif
+ endfor
+ return class_files
+ endfunction
+
+else
+ function! s:FindClassFiles(src_type_name) abort
+ let class_files = []
+ for candidate in insert(s:GlobClassFiles(a:src_type_name),
+ \ a:src_type_name..'.class')
+ if filereadable(candidate) | call add(class_files, shellescape(candidate)) | endif
+ endfor
+ return class_files
+ endfunction
+endif
+
+if exists('g:spotbugs_alternative_path') &&
+ \ !empty(get(g:spotbugs_alternative_path, 'fromPath', '')) &&
+ \ !empty(get(g:spotbugs_alternative_path, 'toPath', ''))
+
+ " See https://github.com/spotbugs/spotbugs/issues/909
+ function! s:ResolveAbsolutePathname() abort
+ let pathname = expand('%:p')
+ let head_idx = stridx(pathname, g:spotbugs_alternative_path.toPath)
+ " No such file: a mismatched path request for a project
+ if head_idx < 0 | return pathname | endif
+ " Settle for failure with file readability tests _in s:FindClassFiles()_
+ return strpart(pathname, 0, head_idx)..
+ \ g:spotbugs_alternative_path.fromPath..
+ \ strpart(pathname, (head_idx + strlen(g:spotbugs_alternative_path.toPath)))
+ endfunction
+
+else
+ function! s:ResolveAbsolutePathname() abort
+ return expand('%:p')
+ endfunction
+endif
+
+function! s:CollectClassFiles() abort
+ " Possibly obtain a symlinked path for an unsupported directory name
+ let pathname = s:ResolveAbsolutePathname()
+ " Get a platform-independent pathname prefix, cf. "expand('%:p:h')..'/'"
+ let tail_idx = strridx(pathname, expand('%:t'))
+ let src_pathname = strpart(pathname, 0, tail_idx)
+ let all_class_files = []
+ " Get all type names in the current buffer and let the filename globbing
+ " discover inner type names from arbitrary type names
+ for type_name in s:GetDeclaredTypeNames()
+ call extend(all_class_files, s:FindClassFiles(src_pathname..type_name))
+ endfor
+ return all_class_files
+endfunction
+
+" Expose class files for removal etc.
+let b:spotbugs_class_files = s:CollectClassFiles()
+let s:package_dir_heads = repeat(':h', (1 + strlen(substitute(s:package, '[^.;]', '', 'g'))))
+let s:package_root_dir = fnamemodify(s:ResolveAbsolutePathname(), s:package_dir_heads..':S')
+let g:current_compiler = 'spotbugs'
+" CompilerSet makeprg=spotbugs
+let &l:makeprg = 'spotbugs'..(has('win32') ? '.bat' : '')..' '..
+ \ get(b:, 'spotbugs_makeprg_params', get(g:, 'spotbugs_makeprg_params', '-workHard -experimental'))..
+ \ ' -textui -emacs -auxclasspath '..s:package_root_dir..' -sourcepath '..s:package_root_dir..' '..
+ \ join(b:spotbugs_class_files, ' ')
+" Emacs expects doubled line numbers
+setlocal errorformat=%f:%l:%*[0-9]\ %m,%f:-%*[0-9]:-%*[0-9]\ %m
+
+" " This compiler is meant to be used for a single buffer only
+" exe 'CompilerSet makeprg='..escape(&l:makeprg, ' \|"')
+" exe 'CompilerSet errorformat='..escape(&l:errorformat, ' \|"')
+
+delfunction s:CollectClassFiles
+delfunction s:ResolveAbsolutePathname
+delfunction s:FindClassFiles
+delfunction s:GetProperty
+delfunction s:GlobClassFiles
+delfunction s:GetDeclaredTypeNames
+let &cpo = s:cpo_save
+unlet! s:package_root_dir s:package_dir_heads s:common_idxs_and_dirs s:package
+unlet! s:package_names s:type_names s:keywords s:cpo_save
+
+" vim: set foldmethod=syntax shiftwidth=2 expandtab:
diff --git a/runtime/compiler/tex.vim b/runtime/compiler/tex.vim
index 282b3a0588..bc1623729a 100644
--- a/runtime/compiler/tex.vim
+++ b/runtime/compiler/tex.vim
@@ -3,8 +3,9 @@
" Maintainer: Artem Chuprina <ran@ran.pp.ru>
" Contributors: Enno Nagel
" Last Change: 2024 Mar 29
-" 2024 Apr 03 by The Vim Project (removed :CompilerSet definition)
-" 2024 Apr 05 by The Vim Project (avoid leaving behind g:makeprg)
+" 2024 Apr 03 by the Vim Project (removed :CompilerSet definition)
+" 2024 Apr 05 by the Vim Project (avoid leaving behind g:makeprg)
+" 2024 Nov 19 by the Vim Project (properly escape makeprg setting)
if exists("current_compiler")
finish
@@ -27,7 +28,7 @@ if exists('b:tex_ignore_makefile') || exists('g:tex_ignore_makefile') ||
let current_compiler = "latex"
endif
let s:makeprg=current_compiler .. ' -interaction=nonstopmode'
- execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' ')
+ execute 'CompilerSet makeprg=' .. escape(s:makeprg, ' \|"')
else
let current_compiler = 'make'
endif
diff --git a/runtime/compiler/typst.vim b/runtime/compiler/typst.vim
index 33e55818e9..13699f4675 100644
--- a/runtime/compiler/typst.vim
+++ b/runtime/compiler/typst.vim
@@ -1,7 +1,8 @@
" Vim compiler file
" Language: Typst
-" Maintainer: Gregory Anders
-" Last Change: 2024-07-14
+" Previous Maintainer: Gregory Anders
+" Maintainer: Luca Saccarola <github.e41mv@aleeas.com>
+" Last Change: 2024 Dec 09
" Based on: https://github.com/kaarmu/typst.vim
if exists('current_compiler')