Skip to content

No autocomplete for the "submodules" of a library when those included from init.lua #3409

Description

@LRDPRDX

Dear developers, I've read similar existing issues but didn't find the answer.

I have a library (which I am the developer of) which has this structure:

Image

and init.lua is

local UI = (...) .. '.'

return {
    Block     = require(UI .. 'Block'),
    Image     = require(UI .. 'Image'),
    Label     = require(UI .. 'Label'),
    Layout    = require(UI .. 'Layout'),
    Rectangle = require(UI .. 'Rectangle'),
    Stack     = require(UI .. 'Stack'),

    ImageButton = require(UI .. 'ImageButton'),
    TextField   = require(UI .. 'TextField'),

    utils     = require(UI .. 'utils')
}

and the rockspec contains this:

build = {
   type = 'builtin',
   modules = {
      ['likelihud']             = 'likelihud/init.lua',
      ['likelihud.Block']       = 'likelihud/Block.lua',
      ['likelihud.Image']       = 'likelihud/Image.lua',
      ['likelihud.Label']       = 'likelihud/Label.lua',
      ['likelihud.Layout']      = 'likelihud/Layout.lua',
      ['likelihud.Rectangle']   = 'likelihud/Rectangle.lua',
      ['likelihud.Stack']       = 'likelihud/Stack.lua',
      ['likelihud.ImageButton'] = 'likelihud/ImageButton.lua',
      ['likelihud.TextField']   = 'likelihud/TextField.lua',
      ['likelihud.utils']       = 'likelihud/utils.lua',
   },
}

So after install I have

Image

Coc-config:

{
    "suggest.noselect": true,
    "Lua.workspace.library" : [
        "/usr/local/share/lua/5.1"
    ]
}

The problem

If I write

local Button = require('likelihud.ImageButton')

I get autocomplete for Button.

But if instead I do

local ui = require('likelihud')

I get only those fields when I do ui., but the fields are unknown. :

Image

So the problem LSP doesn't resolve this (...) .. '.' inside init.lua. Should I somehow change how init.lua provides those files or how to fix that ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions