Skip to content

fix: respect showParams config for local function completion #2735

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* `NEW` Add postfix snippet for `unpack`
* `FIX` `diagnostics.severity` defaulting to "Warning" when run using `--check` [#2730](https://github.com/LuaLS/lua-language-server/issues/2730)
* `NEW` Add support for lambda style functions, `|paramList| expr` is syntactic sugar for `function(paramList) return expr end`
* `FIX` Respect `completion.showParams` config for local function completion
* `CHG` Improve performance of multithreaded `--check` and `undefined-field` diagnostic

## 3.9.3
Expand Down
8 changes: 7 additions & 1 deletion script/core/completion/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ end

local function checkLocal(state, word, position, results)
local locals = guide.getVisibleLocals(state.ast, position)
local showParams = config.get(state.uri, 'Lua.completion.showParams')
for name, source in util.sortPairs(locals) do
if isSameSource(state, source, position) then
goto CONTINUE
Expand Down Expand Up @@ -372,7 +373,12 @@ local function checkLocal(state, word, position, results)
for _, def in ipairs(defs) do
if (def.type == 'function' and not vm.isVarargFunctionWithOverloads(def))
or def.type == 'doc.type.function' then
local funcLabel = name .. getParams(def, false)
local funcLabel
if showParams then
funcLabel = name .. getParams(def, false)
else
funcLabel = name
end
buildFunction(results, source, def, false, {
label = funcLabel,
match = name,
Expand Down
Loading