iamcco / vim-language-server

VImScript language server, LSP for vim script
507 stars 17 forks source link

Feature Request: Speculate about undefined autoload function names #92

Open w0rp opened 1 year ago

w0rp commented 1 year ago

This is a suggestion for a feature that can be implemented. Whenever you are in a path that ends with autoload/foo/bar.vim and you are trying to call a function foo#bar#Baz that doesn't exist in the script, we could probably safely assume that the function doesn't exist in the if not defined in the file, and output a warning for calling it, just like the language server can for s: functions.

A potential gotcha for an implementation of this is that autoload files aren't the only place where it's actually possible to define them. ALE defines them in ale_linters files all over the place and in Vader tests. (The test code redefines functions to mock them.) I think a good implementation could output an error specifically in the context of an autoload/ file path, and say nothing about the functions in other files.

This suggestion is just for the functions defined and called inside of the same script, not for searching over all of &runtimepath to find if a function is defined anywhere, which may be impossible to know given the information above. We can at least make life easier in the one case where we can say for (almost) certain the the function being called isn't defined. I suggest the problem type is a warning as the function call could actually execute.