mirror of
https://github.com/neovim/neovim
synced 2025-07-15 16:51:49 +00:00
fix(tutor): cannot find tutors in pack/*/start/* #34689
Problems: - Unlike in Vim, Neovim does not report pack/*/start/* in the resolved value of 'rtp' (see `:help packages-runtimepath`) - This means that the tutor plugin cannot find the tutors in pack/*/start/* Solution: - Use nvim_list_runtime_paths() instead of &rtp
This commit is contained in:
@ -170,14 +170,18 @@ endfunction
|
|||||||
" returns a list of all tutor files matching the given name
|
" returns a list of all tutor files matching the given name
|
||||||
function! tutor#GlobTutorials(name, locale)
|
function! tutor#GlobTutorials(name, locale)
|
||||||
let locale = a:locale
|
let locale = a:locale
|
||||||
|
" pack/*/start/* are not reported in &rtp
|
||||||
|
let rtp = nvim_list_runtime_paths()
|
||||||
|
\ ->map({_, v -> escape(v:lua.vim.fs.normalize(v), ',')})
|
||||||
|
\ ->join(',')
|
||||||
" search for tutorials:
|
" search for tutorials:
|
||||||
" 1. non-localized
|
" 1. non-localized
|
||||||
let l:tutors = s:GlobPath(&rtp, 'tutor/'.a:name.'.tutor')
|
let l:tutors = s:GlobPath(rtp, 'tutor/'.a:name.'.tutor')
|
||||||
" 2. localized for current locale
|
" 2. localized for current locale
|
||||||
let l:locale_tutors = s:GlobPath(&rtp, 'tutor/'.locale.'/'.a:name.'.tutor')
|
let l:locale_tutors = s:GlobPath(rtp, 'tutor/'.locale.'/'.a:name.'.tutor')
|
||||||
" 3. fallback to 'en'
|
" 3. fallback to 'en'
|
||||||
if len(l:locale_tutors) == 0
|
if len(l:locale_tutors) == 0
|
||||||
let l:locale_tutors = s:GlobPath(&rtp, 'tutor/en/'.a:name.'.tutor')
|
let l:locale_tutors = s:GlobPath(rtp, 'tutor/en/'.a:name.'.tutor')
|
||||||
endif
|
endif
|
||||||
call extend(l:tutors, l:locale_tutors)
|
call extend(l:tutors, l:locale_tutors)
|
||||||
return uniq(sort(l:tutors, 's:Sort'), 's:Sort')
|
return uniq(sort(l:tutors, 's:Sort'), 's:Sort')
|
||||||
|
Reference in New Issue
Block a user