Skip to content

Commit

Permalink
feature: completion for config function
Browse files Browse the repository at this point in the history
  • Loading branch information
adalessa committed Mar 4, 2024
1 parent a627d4c commit 4857fa3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions lua/laravel/null_ls/completion/config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
local api = require "laravel.api"

return function(done, should_quote)
local resp = api.tinker_execute "json_encode(array_keys(Arr::dot(Config::all())));"
if resp:failed() then
return
end

local configs = vim.json.decode(resp:prettyContent())
if configs == nil then
return
end

local candidates = {}

for _, config in pairs(configs) do
local insert = config
if should_quote then
insert = string.format("'%s'", config)
end
table.insert(candidates, {
label = string.format("%s (route)", config),
insertText = insert,
kind = vim.lsp.protocol.CompletionItemKind["Value"],
})
end

done { { items = candidates, isIncomplete = false } }
end
1 change: 1 addition & 0 deletions lua/laravel/null_ls/completion/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ local M = {}
local completions = {
view = require "laravel.null_ls.completion.view",
route = require "laravel.null_ls.completion.route",
config = require "laravel.null_ls.completion.config",
}

local function get_function_node(param_node)
Expand Down

0 comments on commit 4857fa3

Please sign in to comment.