You could :help filter()
the lines to get a list of lines containing TODO
:
let lines = getline(1, '$')
let todos = filter(lines, 'v:val =~? " TODO "')
return len(todos) > 0 ? 'TD' : ''
The same thing, expressed in a slightly more "modern" way:
return getline(1, '$')
->filter('v:val =~? " TODO "')
->len() > 0 ? 'TD' : ''
See :help method
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…