Process types/annotations in a file but not it's actual content
I use Lua both as programming language and as file format for storing data and dynamicaly loading it into Lua enviroment. Usually this data is generated, saved and loaded during a single script execution. These files are pretty big and contain a single value of known type which is returned.
Since these files are huge, they shouldn't be processed in a usual manner. Thus, they should be put into Lua.workspace.ignoreDir list. However, in that case the type of returned value will not processed as well (actually, it is processed as long as the file is opened, but once it's closed, language server forgets its type. Here is an example of such behaviour. filters.lua is a big table of words that are to be filtered during text processing)
I tried to put
---@meta annotation in that file in hopes that contents of returned table would not be processed but they were which was unexpected. I tried to use ---@diagnostic disable annotation but it seems that the file still is being diagnosted. I also tried to put ---@return table annotation on top of the file (since each lua file is basically a function) but this annotation is ignored.
So right now, it seems that a file can be either ignored or processed entirely. Is there a way to somehow specify types in a file but disable all other processing of it?
That's my current workaround. The problem is that it is way less error prone to provide (and change) return type in a required file than in all other files requiring it. Of course, it is still error prone since language server does not check the actual return type, but at least it can be fixed in a single change since I generate annotations along with data automatically upon file creation.
Another workaround could maybe be continuing to ignore that file and then create a definition file with @meta that defines the type and can be used with workspace.library.
Understood. I honestly hoped for something like
---@return table<string, boolean>
---@diagnostic disable
return {
---
}
where ---@return specifies what this file returns and ---@diagnostic disable just stops language server from futher analysis. So I could keep everything in a single file without the need to edit something outside from it.
I guess, it needs a 'Feature Request' tag and to be put away for better times