diff options
author | zeertzjq <zeertzjq@outlook.com> | 2024-11-09 08:43:43 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2024-11-09 08:43:50 +0800 |
commit | b4c5e743ac66bd288017d769e06751cf9cda9a18 (patch) | |
tree | 4f4dcdf54ccd9cd6830455c04381728bf90f830e | |
parent | 5c600370e0c0980caffebc1c6563da2d750ff34a (diff) | |
download | rneovim-b4c5e743ac66bd288017d769e06751cf9cda9a18.tar.gz rneovim-b4c5e743ac66bd288017d769e06751cf9cda9a18.tar.bz2 rneovim-b4c5e743ac66bd288017d769e06751cf9cda9a18.zip |
vim-patch:6d9a145: runtime(compiler): add mypy and ruff compiler; update pylint linter
mypy and ruff come from
https://github.com/Konfekt/vim-compilers/tree/master/compiler and the
former was added by @pbnj-dragon
closes: vim/vim#16007
https://github.com/vim/vim/commit/6d9a145d719857fe461d045adf3b61ec4b4bb53f
Co-authored-by: Konfekt <Konfekt@users.noreply.github.com>
-rw-r--r-- | runtime/compiler/mypy.vim | 19 | ||||
-rw-r--r-- | runtime/compiler/pylint.vim | 26 | ||||
-rw-r--r-- | runtime/compiler/ruff.vim | 19 | ||||
-rw-r--r-- | runtime/doc/quickfix.txt | 27 |
4 files changed, 82 insertions, 9 deletions
diff --git a/runtime/compiler/mypy.vim b/runtime/compiler/mypy.vim new file mode 100644 index 0000000000..891488626a --- /dev/null +++ b/runtime/compiler/mypy.vim @@ -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 diff --git a/runtime/compiler/pylint.vim b/runtime/compiler/pylint.vim index 14e9696dbb..59408b4750 100644 --- a/runtime/compiler/pylint.vim +++ b/runtime/compiler/pylint.vim @@ -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 index 0000000000..11a69740d8 --- /dev/null +++ b/runtime/compiler/ruff.vim @@ -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 diff --git a/runtime/doc/quickfix.txt b/runtime/doc/quickfix.txt index 63109bdaf3..901aaf6e82 100644 --- a/runtime/doc/quickfix.txt +++ b/runtime/doc/quickfix.txt @@ -1366,6 +1366,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* |