diff options
Diffstat (limited to 'lua/alpha/lsp/attach.lua')
| -rw-r--r-- | lua/alpha/lsp/attach.lua | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lua/alpha/lsp/attach.lua b/lua/alpha/lsp/attach.lua index e15ad92..6fc415c 100644 --- a/lua/alpha/lsp/attach.lua +++ b/lua/alpha/lsp/attach.lua @@ -5,6 +5,51 @@ local filetype_attach = setmetatable({ vim.api.nvim_buf_create_user_command(bufnr, "LspPhpactorReindex", function() vim.lsp.buf_notify(bufnr, "phpactor/index/reindex", {}) end, {}) + + vim.api.nvim_buf_create_user_command(bufnr, 'LspPhpactorStatus', function() + local results, _ = vim.lsp.buf_request_sync(bufnr, "phpactor/status", {["return"]=true}) + + local content = '' + + for _, res in pairs(results or {}) do + if res ~= nil and res["result"] ~= nil then + content = content .. res["result"] + end + end + + + local Popup = require("nui.popup") + local event = require("nui.utils.autocmd").event + + local popup = Popup({ + enter = true, + focusable = true, + border = { + style = "rounded", + }, + position = "50%", + size = { + width = "80%", + height = "60%", + }, + }) + + -- mount/open the component + popup:mount() + + -- unmount component when cursor leaves buffer + popup:on(event.BufLeave, function() + popup:unmount() + end) + local out = {}; + for match in string.gmatch(content, "[^\n]+") do + table.insert(out, match); + end + + vim.api.nvim_buf_set_option(popup.bufnr, "filetype", "markdown") + vim.api.nvim_buf_set_lines(popup.bufnr, 0, 1, false, out) + + end, {}) end, }, { __index = function() |