]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
runtime(compiler): add mypy and ruff compiler; update pylint linter
authorKonfekt <Konfekt@users.noreply.github.com>
Thu, 7 Nov 2024 20:40:22 +0000 (21:40 +0100)
committerChristian Brabandt <cb@256bit.org>
Thu, 7 Nov 2024 20:40:22 +0000 (21:40 +0100)
mypy and ruff come from
https://github.com/Konfekt/vim-compilers/tree/master/compiler and the
former was added by @pbnj-dragon

closes: #16007

Signed-off-by: Konfekt <Konfekt@users.noreply.github.com>
Signed-off-by: Christian Brabandt <cb@256bit.org>
runtime/compiler/mypy.vim [new file with mode: 0644]
runtime/compiler/pylint.vim
runtime/compiler/ruff.vim [new file with mode: 0644]
runtime/doc/quickfix.txt
runtime/doc/tags

diff --git a/runtime/compiler/mypy.vim b/runtime/compiler/mypy.vim
new file mode 100644 (file)
index 0000000..8914886
--- /dev/null
@@ -0,0 +1,19 @@
+" Vim compiler file
+" Compiler:    Mypy (Python static checker)
+" Maintainer:   @Konfekt
+" Last Change: 2024 Nov 07
+
+if exists("current_compiler") | finish | endif
+let current_compiler = "mypy"
+
+let s:cpo_save = &cpo
+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, ' "')
+CompilerSet errorformat=%f:%l:%c:\ %t%*[^:]:\ %m
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
index 14e9696dbb4c5dbf7e7d4a564b085d3029b940b2..59408b475083d6d100f9206c38945b17333395d6 100644 (file)
@@ -1,13 +1,21 @@
 " Vim compiler file
-" Compiler:    Pylint for Python
-" Maintainer: Daniel Moch <daniel@danielmoch.com>
-" Last Change: 2016 May 20
-"              2024 Apr 03 by The Vim Project (removed :CompilerSet definition)
-
-if exists("current_compiler")
-  finish
-endif
+" Compiler:     Pylint for Python
+" Maintainer:   Daniel Moch <daniel@danielmoch.com>
+" Last Change:  2024 Nov 07 by The Vim Project (added params variable)
+
+if exists("current_compiler") | finish | endif
 let current_compiler = "pylint"
 
-CompilerSet makeprg=pylint\ --output-format=text\ --msg-template=\"{path}:{line}:{column}:{C}:\ [{symbol}]\ {msg}\"\ --reports=no
+let s:cpo_save = &cpo
+set cpo&vim
+
+" CompilerSet makeprg=ruff
+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",
+      \   (executable('getconf') ? '--jobs='..systemlist('getconf _NPROCESSORS_ONLN')[0] : '')))
+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
+unlet s:cpo_save
diff --git a/runtime/compiler/ruff.vim b/runtime/compiler/ruff.vim
new file mode 100644 (file)
index 0000000..11a6974
--- /dev/null
@@ -0,0 +1,19 @@
+" Vim compiler file
+" Compiler:     Ruff (Python linter)
+" Maintainer:   @pbnj-dragon
+" Last Change:  2024 Nov 07
+
+if exists("current_compiler") | finish | endif
+let current_compiler = "ruff"
+
+let s:cpo_save = &cpo
+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, ' "')
+CompilerSet errorformat=%f:%l:%c:\ %m,%f:%l:\ %m,%f:%l:%c\ -\ %m,%f:
+
+let &cpo = s:cpo_save
+unlet s:cpo_save
index e7536446b27cc047eb9f67cfd12f4b73353634fb..37f0a181d12179e09ea4474d2ff66c0df7bd37d3 100644 (file)
@@ -1,4 +1,4 @@
-*quickfix.txt*  For Vim version 9.1.  Last change: 2024 Oct 05
+*quickfix.txt*  For Vim version 9.1.  Last change: 2024 Nov 07
 
 
                  VIM REFERENCE MANUAL    by Bram Moolenaar
@@ -1405,6 +1405,33 @@ being checked.  To disable this set g:perl_compiler_force_warnings to a zero
 value.  For example: >
        let g:perl_compiler_force_warnings = 0
 
+MYPY TYPE CHECKER                                      *compiler-mypy*
+
+Commonly used compiler options can be added to 'makeprg' by setting the
+b/g:mypy_makeprg_params variable.  For example: >
+
+       let b:mypy_makeprg_params = "--warn-unused-ignores"
+
+The global default is "--strict --ignore-missing-imports".
+
+RUFF LINTER                                            *compiler-ruff*
+
+Commonly used compiler options can be added to 'makeprg' by setting the
+b/g:ruff_makeprg_params variable.  For example: >
+
+       let b:ruff_makeprg_params = "--max-line-length"..&textwidth
+
+The global default is "--preview".
+
+PYLINT LINTER                                          *compiler-pylint*
+
+Commonly used compiler options can be added to 'makeprg' by setting the
+b/g:pylint_makeprg_params variable.  For example: >
+
+       let b:pylint_makeprg_params = "--max-line-length"..&textwidth
+
+The global default is "--jobs=n" where n is the number of cores as reported
+by getconf, if executable. Otherwise it defaults to "".
 
 PYUNIT COMPILER                                                *compiler-pyunit*
 
index 37a8e266d58671f3c792ae66ddfa88ae7a9b153b..82a01e2d7312358365922a24bcafc0c9fc76d1ac 100644 (file)
@@ -6560,9 +6560,12 @@ compiler-hpada   ft_ada.txt      /*compiler-hpada*
 compiler-javac quickfix.txt    /*compiler-javac*
 compiler-make  quickfix.txt    /*compiler-make*
 compiler-manx  quickfix.txt    /*compiler-manx*
+compiler-mypy  quickfix.txt    /*compiler-mypy*
 compiler-pandoc        quickfix.txt    /*compiler-pandoc*
 compiler-perl  quickfix.txt    /*compiler-perl*
+compiler-pylint        quickfix.txt    /*compiler-pylint*
 compiler-pyunit        quickfix.txt    /*compiler-pyunit*
+compiler-ruff  quickfix.txt    /*compiler-ruff*
 compiler-select        quickfix.txt    /*compiler-select*
 compiler-tex   quickfix.txt    /*compiler-tex*
 compiler-typst quickfix.txt    /*compiler-typst*