Merge pull request #33994 from brianhuster/vim-3704b5b

vim-patch:37045b5,9.1.1384 && fix(tutor): `l:lang` is undefined
This commit is contained in:
zeertzjq
2025-05-13 10:07:51 +08:00
committed by GitHub
5 changed files with 61 additions and 25 deletions

View File

@ -120,6 +120,8 @@ endfunction
" Tutor Cmd: {{{1
function! s:Locale()
" Make sure l:lang exists before returning.
let l:lang = 'en_US'
if exists('v:lang') && v:lang =~ '\a\a'
let l:lang = v:lang
elseif $LC_ALL =~ '\a\a'
@ -132,8 +134,6 @@ function! s:Locale()
endif
elseif $LANG =~ '\a\a'
let l:lang = $LANG
else
let l:lang = 'en_US'
endif
return split(l:lang, '_')
endfunction
@ -220,6 +220,7 @@ function! tutor#TutorCmd(tutor_name)
call tutor#SetupVim()
exe "edit ".l:to_open
call tutor#EnableInteractive(v:true)
call tutor#ApplyTransform()
endfunction
@ -229,6 +230,27 @@ function! tutor#TutorCmdComplete(lead,line,pos)
return join(l:names, "\n")
endfunction
" Enables/disables interactive mode.
function! tutor#EnableInteractive(enable)
let enable = a:enable
if enable
setlocal buftype=nofile
setlocal concealcursor+=inv
setlocal conceallevel=2
call tutor#ApplyMarks()
augroup tutor_interactive
autocmd! TextChanged,TextChangedI <buffer> call tutor#ApplyMarksOnChanged()
augroup END
else
setlocal buftype<
setlocal concealcursor<
setlocal conceallevel<
if exists('#tutor_interactive')
autocmd! tutor_interactive * <buffer>
endif
endif
endfunction
function! tutor#ApplyTransform()
if has('win32')
sil! %s/{unix:(\(.\{-}\)),win:(\(.\{-}\))}/\2/g

View File

@ -1,19 +1,18 @@
" vim: fdm=marker
" Tutor filetype plugin
" Language: Tutor (the new tutor plugin)
" Maintainer: This runtime file is looking for a new maintainer.
" Last Change: 2025 May 10
" Contributors: Phạm Bình An <phambinhanctb2004@gmail.com>
" Original Author: Felipe Morales <hel.sheep@gmail.com>
" Last Change:
" 2025 May 10 set b:undo_ftplugin
" 2025 May 12 update b:undo_ftplugin
" Base: {{{1
call tutor#SetupVim()
" Buffer Settings: {{{1
setlocal noreadonly
if !exists('g:tutor_debug') || g:tutor_debug == 0
setlocal buftype=nofile
setlocal concealcursor+=inv
setlocal conceallevel=2
else
setlocal buftype=
setlocal concealcursor&
setlocal conceallevel=0
endif
setlocal noundofile
setlocal keywordprg=:help
@ -39,7 +38,7 @@ call tutor#SetNormalMappings()
sign define tutorok text=texthl=tutorOK
sign define tutorbad text=texthl=tutorX
if !exists('g:tutor_debug') || g:tutor_debug == 0
call tutor#ApplyMarks()
autocmd! TextChanged,TextChangedI <buffer> call tutor#ApplyMarksOnChanged()
endif
let b:undo_ftplugin = "setl foldmethod< foldexpr< foldlevel< undofile< keywordprg< iskeyword< |"
\ . "call tutor#EnableInteractive(v:false) |"
" vim: fdm=marker

View File

@ -1,3 +1,9 @@
" Tutor: New Style Tutor Plugin :h vim-tutor-mode
" Maintainer: This runtime file is looking for a new maintainer.
" Contributors: Phạm Bình An <phambinhanctb2004@gmail.com>
" Original Author: Felipe Morales <hel.sheep@gmail.com>
" Date: 2025 May 12
if exists('g:loaded_tutor_mode_plugin') || &compatible
finish
endif

View File

@ -17,15 +17,8 @@ Table of contents:
## SETTING UP *setting-up*
First, you'll need to enable "debug" mode
~~~ cmd
:let g:tutor_debug = 1
~~~
This will allow saving changes to the tutor files and will disable conceals, so
you can more easily check your changes.
After this, create a new .tutor file (we will be practicing on this very file, so you
don't need to do this now):
Create a new .tutor file (we will be practicing on this very file, so you don't
need to do this now):
~~~ cmd
:e new-tutorial.tutor
~~~

View File

@ -0,0 +1,16 @@
" Test for the new-tutor plugin
func SetUp()
set nocompatible
runtime plugin/tutor.vim
endfunc
func Test_auto_enable_interactive()
Tutor
call assert_equal('nofile', &buftype)
call assert_match('tutor#EnableInteractive', b:undo_ftplugin)
edit Xtutor/Xtest.tutor
call assert_true(empty(&buftype))
call assert_match('tutor#EnableInteractive', b:undo_ftplugin)
endfunc