From 8513066ee1ae2569f0a35e886afa3f8293c9a026 Mon Sep 17 00:00:00 2001 From: wsdjeg Date: Wed, 29 Mar 2023 13:41:52 +0800 Subject: [PATCH] fix(java): disable neomake when lsp enabled --- autoload/SpaceVim/layers/lang/java.vim | 20 ++++++++++++++++++-- autoload/SpaceVim/layers/lsp.vim | 2 +- doc/SpaceVim.txt | 2 ++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/autoload/SpaceVim/layers/lang/java.vim b/autoload/SpaceVim/layers/lang/java.vim index 82927db69..c8c8f1de5 100644 --- a/autoload/SpaceVim/layers/lang/java.vim +++ b/autoload/SpaceVim/layers/lang/java.vim @@ -33,6 +33,7 @@ " '' " ] " < +" 4. `enabled_linters`: Set the enabled linters for java, default is `['javac']`. " @subsection Mappings " > " Import key bindings: @@ -129,6 +130,7 @@ let s:java_file_head = [ \ '' \ ] let s:java_interpreter = 'java' +let s:enabled_linters = ['javac'] function! SpaceVim#layers#lang#java#plugins() abort let plugins = [] @@ -149,8 +151,19 @@ function! SpaceVim#layers#lang#java#config() abort call add(g:spacevim_project_rooter_patterns, 'build.gradle') " for neomake - " - let g:neomake_java_javac_options = ['-J-Duser.language=en'] + " neomake will be disabled when lsp is enabled for java. + if SpaceVim#layers#lsp#check_filetype('java') + \ || SpaceVim#layers#lsp#check_server('jdtls') + let g:neomake_java_enabled_makers = [] + else + if g:spacevim_lint_engine ==# 'neomake' + let g:neomake_java_javac_options = ['-J-Duser.language=en'] + let g:neomake_java_enabled_makers = s:enabled_linters + for lint in g:neomake_java_enabled_makers + let g:neomake_java_{lint}_remove_invalid_entries = 1 + endfor + endif + endif " defined JDTLS_HOME @@ -159,6 +172,7 @@ function! SpaceVim#layers#lang#java#config() abort endif if SpaceVim#layers#lsp#check_filetype('java') + \ || SpaceVim#layers#lsp#check_server('jdtls') call SpaceVim#mapping#gd#add('java', function('SpaceVim#lsp#go_to_def')) else call SpaceVim#mapping#gd#add('java', function('s:go_to_def')) @@ -332,6 +346,7 @@ function! s:language_specified_mappings() abort \ 'send selection and keep code buffer focused', 1) if SpaceVim#layers#lsp#check_filetype('java') + \ || SpaceVim#layers#lsp#check_server('jdtls') nnoremap K :call SpaceVim#lsp#show_doc() call SpaceVim#mapping#space#langSPC('nnoremap', ['l', 'd'], @@ -367,6 +382,7 @@ function! SpaceVim#layers#lang#java#set_variable(var) abort let s:java_formatter_jar = get(a:var, \ 'java_formatter_jar', \ s:java_formatter_jar) + let s:enabled_linters = get(a:var, 'enabled_linters', s:enabled_linters) endfunction " vim:set et sw=2 cc=80: diff --git a/autoload/SpaceVim/layers/lsp.vim b/autoload/SpaceVim/layers/lsp.vim index 1dd4bc0ea..6dd85a788 100644 --- a/autoload/SpaceVim/layers/lsp.vim +++ b/autoload/SpaceVim/layers/lsp.vim @@ -267,7 +267,7 @@ endfunction function! SpaceVim#layers#lsp#check_filetype(ft) abort if s:use_nvim_lsp - return 1 + return 0 else return index(s:enabled_fts, a:ft) != -1 endif diff --git a/doc/SpaceVim.txt b/doc/SpaceVim.txt index 030fb10ee..3dc03c25a 100644 --- a/doc/SpaceVim.txt +++ b/doc/SpaceVim.txt @@ -3513,6 +3513,8 @@ LAYER OPTIONS '' ] < + 4. `enabled_linters`: Set the enabled linters for java, default is + `['javac']`. MAPPINGS >