Skip to content

Instantly share code, notes, and snippets.

@Amar1729
Last active November 20, 2019 22:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Amar1729/49221cee3b9fc48fa3033893757d4473 to your computer and use it in GitHub Desktop.
Save Amar1729/49221cee3b9fc48fa3033893757d4473 to your computer and use it in GitHub Desktop.
extend neomake's gradle classpath with javacomplete2
" -*- vim -*-
" FILE: neomake_java_helper.vim
" Function to help (neomake)[https://github.com/neomake/neomake/] find the
" gradle classpath.
" Uses (javacomplete2)[https://github.com/artur-shaik/vim-javacomplete2]
" to find and set the classpath.
function! s:GetBasePath()
return substitute(g:JavaComplete_GradlePath, 'build.gradle', 'src/main/java', '')
endfunction
function! FixNeomakeGradle()
if exists('g:JavaComplete_PluginLoaded') && exists('g:JavaComplete_ProjectKey')
if javacomplete#classpath#gradle#IfGradle()
" extend classpath manually
let l:path = javacomplete#util#GetBase("classpath" . g:FILE_SEP) . g:JavaComplete_ProjectKey
let l:javac_classpath = readfile(l:path)
let g:neomake_java_javac_classpath = s:GetBasePath() . ":" . l:javac_classpath[0]
endif
endif
endfunction
au BufEnter * :call FixNeomakeGradle()
@Amar1729
Copy link
Author

Amar1729 commented Sep 16, 2019

related neomake issue: neomake/neomake#1971

Easiest to drop this script in ~/.vim/after/ftplugin/java so it only applies to FileType java buffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment