diff options
| author | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-09-07 17:32:59 +0200 |
|---|---|---|
| committer | Ariel D'Alessandro <dalessandro.ariel@gmail.com> | 2023-09-07 17:32:59 +0200 |
| commit | 7152b5c26fbbfc4e84d8ccfa6917ca71fab14cc5 (patch) | |
| tree | b8e6356c47cfd36bd73f686d89a732297712c615 /lua/alpha/lsp/attach.lua | |
| parent | 75c19f44876bc6833ecd5ccb0d715cab8d70416b (diff) | |
| download | nvim-conf-7152b5c26fbbfc4e84d8ccfa6917ca71fab14cc5.tar.gz nvim-conf-7152b5c26fbbfc4e84d8ccfa6917ca71fab14cc5.zip | |
updates and improvements
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() |