aboutsummaryrefslogtreecommitdiffstats
path: root/lua/alpha/scratchs/intelephense_symbol.lua
blob: 3f039f3d49f59d4ffbfcabc2ede800af42ad8811 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
local function get_intelephense_buffer()
    local clients = vim.lsp.get_active_clients({ name = "intelephense" })
    if #clients == 0 then
        return
    end

    local intelephense = clients[1]

    local attached_buffers = intelephense.attached_buffers

    for key, val in pairs(attached_buffers) do
        if val then
            return key
        end
    end

    return nil
end

vim.keymap.set({'n'}, '<leader>pc', function ()
    local buffer = get_intelephense_buffer()

    if buffer == nil then
        return
    end

    require("telescope.builtin").lsp_workspace_symbols({ bufnr = buffer, query = vim.fn.expand("<cword>") })
end)