LuaLS / LuaLS/lua-language-server
Exact Classes Do Not Autocomplete Methods
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 4.4k
- Forks
- 442
- PR merge metrics
- No merged PRs in 30d
Description
### 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:

### Actual Behaviour
Methods are not completed.

### Reproduction steps
VSCode project with v3.11.0 plugin.
All defaults, no `.luarc.json`.
Ctrl-space at last line.
```lua
---@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](https://github.com/user-attachments/files/17549561/log.tar.gz)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue in a Visual Studio Code project with the v3.11.0 plugin using the provided Point class and Ctrl-space at the final line. Compare completion for the exact class with the normal class example. Done means the add method is offered for completion on the Point instance.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100