diff --git a/plugin/licenser.vim b/plugin/licenser.vim index 55e9689..7103708 100644 --- a/plugin/licenser.vim +++ b/plugin/licenser.vim @@ -86,9 +86,19 @@ function! s:GetCommentStyle(filetype) abort endfunction function! s:AddLicenseHeader(license) abort - let plugin_dir = fnamemodify(expand(''), ':h:h') + let plugin_dir = fnamemodify(resolve(expand('')), ':h:h') let license_file = plugin_dir . '/licenses/' . a:license . '.txt' + if !filereadable(license_file) + for runtime_path in split(&runtimepath, ',') + let alt_license_file = runtime_path . '/licenses/' . a:license . '.txt' + if filereadable(alt_license_file) + let license_file = alt_license_file + break + endif + endfor + endif + if !filereadable(license_file) echohl ErrorMsg echo 'License file not found: ' . license_file @@ -131,9 +141,19 @@ function! s:AddLicenseHeader(license) abort endfunction function! s:CompleteFiletype(A, L, P) abort - let plugin_dir = fnamemodify(expand(''), ':h:h') + let plugin_dir = fnamemodify(resolve(expand('')), ':h:h') let licenses_dir = plugin_dir . '/licenses/' + if !isdirectory(licenses_dir) + for runtime_path in split(&runtimepath, ',') + let alt_licenses_dir = runtime_path . '/licenses/' + if isdirectory(alt_licenses_dir) + let licenses_dir = alt_licenses_dir + break + endif + endfor + endif + if !isdirectory(licenses_dir) return [] endif