Skip to content

Commit

Permalink
feat(lsp): support rust-analyzer/viewRecursiveMemoryLayout
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Oct 23, 2023
1 parent 966a2b9 commit c1bcc56
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lua/rustaceanvim/commands/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ local command_tbl = {
joinLines = function(_)
require('rustaceanvim.commands.join_lines')()
end,
memoryLayout = function(_)
require('rustaceanvim.commands.memory_layout')()
end,
moveItem = function(args)
if #args == 0 then
vim.notify("moveItem: called without 'up' or 'down'", vim.log.levels.ERROR)
Expand Down
31 changes: 31 additions & 0 deletions lua/rustaceanvim/commands/memory_layout.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
local ui = require('rustaceanvim.ui')

local M = {}

---@return lsp_range_params

---@type integer | nil
local latest_buf_id = nil

local function parse(_)
local ret = {}
-- TODO:
error('not implemented')
return ret
end

local function handler(_, result)
ui.delete_buf(latest_buf_id)
latest_buf_id = vim.api.nvim_create_buf(false, true)
ui.split(true, latest_buf_id)
vim.api.nvim_buf_set_name(latest_buf_id, 'memory.layout.rust')
vim.api.nvim_buf_set_text(latest_buf_id, 0, 0, 0, 0, parse(result))
ui.resize(true, '-25')
end

local rl = require('rustaceanvim.rust_analyzer')
function M.memory_layout()
rl.buf_request(0, 'rust-analyzer/viewRecursiveMemoryLayout', vim.lsp.util.make_position_params(), handler)
end

return M.memory_layout

0 comments on commit c1bcc56

Please sign in to comment.