Definition files for lunarmodules/Penlight 1.13.1 to use with LuaLS/lua-language-server. The annotations have been manually re-written directly from the docs and source code to be parsable by the LSP.
Some features are missing from the library simply because the LSP doesn't support them. The most pressing features are currently:
- Generic classes. Being able to create e.g. a
pl.List<string>would be wonderful. One thing that is missing is annotating "function units" (as infun(...): ...) and operator annotations with generic parameters. - Setting outdated modules like
textandxmlas deprecated when requiring them directly. - More robust generic function support. Variadic type packs are not very strict, and generic types often leak into the return type.
Some features are missing simply because I don't know how to lint them. The most pressing ones are in the pl.comprehension and pl.func file.
Definition files can be installed via luarocks:
luarocks install lls-addon-penlightor by using the addon manager, under "Penlight".
For manual installation, add these settings to your settings.json file.
The plugin is used to generate global imports when it finds ---@module "pl" or require("pl") in any file. This works for most if not all outlandish representations of the syntax like --[=[@module [[pl]]]=].
The plugin doesn't do anything special for requires that execute conditionally, e.g.
-- this injects globals
if false then
require("pl")
end
-- this doesn't inject globals
local plString = "pl"
require(plString)For a more detailed description of how to install a library of definition files, see the LSP's wiki.
The types provided by this library are, exhaustively:
-
Classes, given as
pl.[CLASS NAME]. Every class is listed below:Name Module Source plpl.initpl.apppl.apppl.array2dpl.array2dpl.ClassModulepl.classpl.compatpl.compatpl.configpl.configpl.DataModulepl.datapl.dirpl.dirpl.filepl.filepl.funcpl.funcpl.inputpl.inputpl.lapppl.lapppl.lexerpl.lexerpl.luabalancedpl.luabalancedpl.operatorpl.operatorpl.pathpl.pathpl.permutepl.permutepl.prettypl.prettypl.seqpl.seqpl.sippl.sippl.strictpl.strictpl.stringiopl.stringiopl.stringxpl.stringxpl.tablexpl.tablexpl.templatepl.templatepl.testpl.testpl.textpl.textpl.typespl.typespl.urlpl.urlpl.utilspl.utilspl.xmlpl.xmlpl.ConfigReadConfigpl.configpl.Data.ReadConfigpl.datapl.Data.Optionspl.datapl.Data.QueryArgpl.datapl.DateBasepl.Datepl.DateClasspl.Datepl.Datepl.Datepl.Date.IntervalBasepl.Datepl.Date.IntervalClasspl.Datepl.Date.Intervalpl.Datepl.Date.FormatBasepl.Datepl.Date.FormatClasspl.Datepl.Date.Formatpl.Datepl.ListBasepl.Listpl.ListClasspl.Listpl.List<T>pl.Listpl.MapBasepl.Mappl.MapClasspl.Mappl.Map<K, V>pl.Mappl.MultiMapBasepl.MultiMappl.MultiMapClasspl.MultiMappl.MultiMap<K, V>pl.MultiMappl.OrderedMapBasepl.OrderedMappl.OrderedMapClasspl.OrderedMappl.OrderedMap<K, V>pl.OrderedMappl.SetClasspl.Setpl.Set<T>pl.Setpl.Classpl.classpl.Instancepl.classpl.Comprehensionpl.comprehensionpl.ConfigReadConfigpl.configpl.Datapl.datapl.Data.ReadConfigpl.datapl.Data.Optionspl.datapl.Data.QueryArgpl.datapl.PlaceholderExpressionFieldspl.funcpl.PlaceholderExpressionpl.funcpl.InputFieldsOptionspl.inputpl.Sequence<T>pl.seqpl.Sequence2<T, U>pl.seqpl.Sequence3<T, U, V>pl.seqpl.Sequence4<T, U, V, W>pl.seqpl.Sequence5<T, U, V, W, X>pl.seqpl.StringIOWriterpl.stringiopl.StringIOReaderpl.stringiopl.Templatepl.stringxpl.CompiledTemplatepl.templatepl.CompiledTemplate.Optionspl.templatepl.Tuplepl.testpl.DeprecationOptionspl.utilspl.XMLNodepl.xmlThere is also a
@classannotation for each module andpl. -
Aliases, given as
pl.[ALIAS NAME]. Every alias is listed below:Name Module Source pl.TokenStreampl.lexerpl.LexerFilterpl.lexerpl.LexerOptionspl.lexerpl.BoolBinOpStringpl.operatorpl.BoolOrderedBinOpStringpl.operatorpl.BinOpStringpl.operatorpl.UnOpStringpl.operatorpl.MultiOpStringpl.operatorpl.OpStringpl.operatorpl.seq.Iterable<T>pl.seqpl.seq.Iterable2<T, U>pl.seqpl.seq.Iterable3<T, U, V>pl.seqpl.seq.Iterable4<T, U, V, W>pl.seqpl.seq.Iterable5<T, U, V, W, X>pl.seqpl.ObjectWithMethodAndTwoArguments<Method, A1, A2, R>pl.seqpl.ObjectWithMethodAndOneArgument<Method, A, R>pl.seqpl.ObjectWithMethodAndNoArguments<Method, R>pl.seqpl.SipOptionspl.sipI should probably simplify the
pl.seqaliases...
Most classes have documentation of their constructor in the form of their _init method. The only easy way to view this would be to type [CLASS NAME]:_init in your editor, or doing the same with an instance. This might be changed so it is attached to the class itself, although that is undecided.