-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Open
Labels
Description
Steps to reproduce
Hi, not sure if this is a bug or just my misunderstanding.
There is :h v:none
which says that we can use is v:none
to compare "something" with v:none
However, running the simple code:
vim9script
def None(): any
return v:none
enddef
if None() is v:none
echow "None"
endif
Expected behaviour
Should be able to compare function return value with v:none
?
Use case is to use omnicompletion function result with set complete=f{func}
:
def LspSetup()
if !exists("g:loaded_lsp")
return
endif
def g:LspCompletor(maxitems: number, findstart: number, base: string): any
if findstart == 1
return g:LspOmniFunc(findstart, base)
endif
var data = g:LspOmniFunc(findstart, base)
# can't use it here, due to error `E1072 Can not compary any with special`
# return data isnot v:none ? {words: data->slice(0, maxitems), refresh: 'always'} : data
# using this instead
if type(data) == v:t_list
return {words: data->slice(0, maxitems), refresh: 'always'}
else
return v:none
endif
enddef
set complete+=ffunction("g:LspCompletor"\\,[10])
g:LspOptionsSet({ autoComplete: false, omniComplete: true })
enddef
Version of Vim
9.1.1401
Environment
debian12