mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +01:00
feat: also show users in sidebar
This commit is contained in:
parent
174f479617
commit
f6661de905
1 changed files with 26 additions and 6 deletions
|
@ -21,14 +21,27 @@ local function update_window()
|
||||||
if buffer_id == nil then error("cannot update window while codemp buffer is unset") end
|
if buffer_id == nil then error("cannot update window while codemp buffer is unset") end
|
||||||
row_to_buffer = {}
|
row_to_buffer = {}
|
||||||
local buffer_to_row = {}
|
local buffer_to_row = {}
|
||||||
|
local user_to_row = {}
|
||||||
local off = {}
|
local off = {}
|
||||||
local tree = state.client:get_workspace(state.workspace).filetree
|
local tree = state.client:get_workspace(state.workspace).filetree
|
||||||
vim.api.nvim_set_option_value('modifiable', true, { buf = buffer_id })
|
vim.api.nvim_set_option_value('modifiable', true, { buf = buffer_id })
|
||||||
utils.buffer.set_content(
|
local tmp = ">| codemp\n"
|
||||||
buffer_id,
|
tmp = tmp .. " |: " .. state.workspace .. "\n"
|
||||||
">| codemp\n |: " .. state.workspace .. "\n |\n |- "
|
tmp = tmp .. " |\n"
|
||||||
.. vim.fn.join(tree, "\n |- ")
|
local base_row = 3
|
||||||
)
|
for n, path in pairs(tree) do
|
||||||
|
tmp = tmp .. " |- " .. path .. "\n"
|
||||||
|
base_row = 3 + n
|
||||||
|
buffer_to_row[path] = base_row
|
||||||
|
end
|
||||||
|
tmp = tmp .. "\n\n\n"
|
||||||
|
base_row = base_row + 3
|
||||||
|
for usr, _ in pairs(buffers.users) do
|
||||||
|
tmp = tmp .. "* + " .. usr .. "\n"
|
||||||
|
base_row = base_row + 1
|
||||||
|
user_to_row[usr] = base_row
|
||||||
|
end
|
||||||
|
utils.buffer.set_content(buffer_id, tmp)
|
||||||
vim.highlight.range(buffer_id, ns, 'InlayHint', {0,0}, {0, 2})
|
vim.highlight.range(buffer_id, ns, 'InlayHint', {0,0}, {0, 2})
|
||||||
vim.highlight.range(buffer_id, ns, 'Title', {0,3}, {0, 9})
|
vim.highlight.range(buffer_id, ns, 'Title', {0,3}, {0, 9})
|
||||||
vim.highlight.range(buffer_id, ns, 'InlayHint', {1,1}, {1, 3})
|
vim.highlight.range(buffer_id, ns, 'InlayHint', {1,1}, {1, 3})
|
||||||
|
@ -47,8 +60,11 @@ local function update_window()
|
||||||
if off[row] == nil then
|
if off[row] == nil then
|
||||||
off[row] = 0
|
off[row] = 0
|
||||||
end
|
end
|
||||||
vim.highlight.range(buffer_id, ns, utils.color(user), {row,4+off[row]}, {row, 5+off[row]})
|
vim.highlight.range(buffer_id, ns, utils.color(user), {row-1,4+off[row]}, {row-1, 5+off[row]})
|
||||||
off[row] = off[row] + 1
|
off[row] = off[row] + 1
|
||||||
|
row = user_to_row[user]
|
||||||
|
vim.highlight.range(buffer_id, ns, 'InlayHint', {row-1, 0}, {row-1, 1})
|
||||||
|
vim.highlight.range(buffer_id, ns, utils.color(user), {row-1, 2}, {row-1, 3})
|
||||||
end
|
end
|
||||||
vim.api.nvim_set_option_value('modifiable', false, { buf = buffer_id })
|
vim.api.nvim_set_option_value('modifiable', false, { buf = buffer_id })
|
||||||
end
|
end
|
||||||
|
@ -58,6 +74,10 @@ local function open_buffer_under_cursor()
|
||||||
if buffer_id == nil then return end
|
if buffer_id == nil then return end
|
||||||
local cursor = vim.api.nvim_win_get_cursor(window_id)
|
local cursor = vim.api.nvim_win_get_cursor(window_id)
|
||||||
local path = row_to_buffer[cursor[1]]
|
local path = row_to_buffer[cursor[1]]
|
||||||
|
if path == nil then
|
||||||
|
print(" /!\\ not a buffer")
|
||||||
|
return
|
||||||
|
end
|
||||||
if prev_window ~= nil then
|
if prev_window ~= nil then
|
||||||
vim.api.nvim_set_current_win(prev_window)
|
vim.api.nvim_set_current_win(prev_window)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue