Skip to content

Exact Classes Do Not Autocomplete Methods #2919

Open
@alex-courtis

Description

@alex-courtis

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Linux

What is the issue affecting?

Completion

Expected Behaviour

Autocomplete should complete methods on instances of (exact) classes.

Expected completion for a normal class:
20241029_094227

Actual Behaviour

Methods are not completed.

20241029_094211

Reproduction steps

VSCode project with v3.11.0 plugin.

All defaults, no .luarc.json.

Ctrl-space at last line.

---@class (exact) Point
--@class Point
---@field x number
---@field y number
local Point = {}

function Point:new(o)
  o = o or {}

  setmetatable(o, self)
  self.__index = self ---@diagnostic disable-line: inject-field

  return o
end

---@param i integer
function Point:add(i)
  self.x = self.x + i
end

---@type Point
local point = Point:new({ x = 1, y = 2 })

point:

Additional Notes

Many thanks for all the fantastic work - luals makes me so much more productive!

Log File

log.tar.gz

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