mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +01:00
feat: moved and improved files sidebar
This commit is contained in:
parent
6cc3b5f119
commit
14a8bfe1f8
2 changed files with 21 additions and 25 deletions
|
@ -15,8 +15,6 @@ local function filter(needle, haystack)
|
||||||
return hints
|
return hints
|
||||||
end
|
end
|
||||||
|
|
||||||
local tree_buf = nil;
|
|
||||||
|
|
||||||
vim.api.nvim_create_user_command(
|
vim.api.nvim_create_user_command(
|
||||||
"MP",
|
"MP",
|
||||||
function (args)
|
function (args)
|
||||||
|
@ -39,19 +37,7 @@ vim.api.nvim_create_user_command(
|
||||||
buffers.sync(client.workspace)
|
buffers.sync(client.workspace)
|
||||||
elseif args.fargs[1] == "buffers" then
|
elseif args.fargs[1] == "buffers" then
|
||||||
if client.workspace == nil then error("connect to a workspace first") end
|
if client.workspace == nil then error("connect to a workspace first") end
|
||||||
local tree = workspace.buffers(client.workspace)
|
workspace.open_buffer_tree(client.workspace)
|
||||||
if tree_buf == nil then
|
|
||||||
tree_buf = vim.api.nvim_create_buf(false, true)
|
|
||||||
vim.api.nvim_buf_set_name(tree_buf, "codemp::" .. client.workspace)
|
|
||||||
vim.api.nvim_set_option_value('buftype', 'nofile', { buf = tree_buf })
|
|
||||||
vim.api.nvim_set_option_value('nomodifiable', true, { buf = tree_buf })
|
|
||||||
end
|
|
||||||
utils.buffer.set_content(tree_buf, "> " .. vim.fn.join(tree, "\n> "))
|
|
||||||
vim.api.nvim_open_win(tree_buf, true, {
|
|
||||||
win = 0,
|
|
||||||
split = 'left',
|
|
||||||
width = 20,
|
|
||||||
})
|
|
||||||
-- elseif args.fargs[1] == "users" then
|
-- elseif args.fargs[1] == "users" then
|
||||||
-- if client.workspace == nil then error("connect to a workspace first") end
|
-- if client.workspace == nil then error("connect to a workspace first") end
|
||||||
-- workspace.users(client.workspace)
|
-- workspace.users(client.workspace)
|
||||||
|
|
|
@ -5,6 +5,7 @@ local buffers = require('codemp.buffers')
|
||||||
local async = require('codemp.async')
|
local async = require('codemp.async')
|
||||||
|
|
||||||
local user_hl = {}
|
local user_hl = {}
|
||||||
|
local tree_buf = nil
|
||||||
local available_colors = { -- TODO these are definitely not portable!
|
local available_colors = { -- TODO these are definitely not portable!
|
||||||
"ErrorMsg",
|
"ErrorMsg",
|
||||||
"WarningMsg",
|
"WarningMsg",
|
||||||
|
@ -62,22 +63,31 @@ local function leave()
|
||||||
print(" -- left workspace")
|
print(" -- left workspace")
|
||||||
end
|
end
|
||||||
|
|
||||||
local function list_users(workspace)
|
local function open_buffer_tree(workspace)
|
||||||
local workspace = native.get_workspace(workspace)
|
local tree = native.get_workspace(workspace).filetree
|
||||||
for _, buffer in pairs(workspace.users) do
|
if tree_buf == nil then
|
||||||
print(" - " .. buffer)
|
tree_buf = vim.api.nvim_create_buf(false, true)
|
||||||
|
vim.api.nvim_buf_set_name(tree_buf, "codemp::" .. workspace)
|
||||||
|
vim.api.nvim_set_option_value('buftype', 'nofile', { buf = tree_buf })
|
||||||
end
|
end
|
||||||
end
|
vim.api.nvim_set_option_value('modifiable', true, { buf = tree_buf })
|
||||||
|
utils.buffer.set_content(tree_buf, "codemp::" .. workspace .. "\n\n- " .. vim.fn.join(tree, "\n- "))
|
||||||
local function list_buffers(workspace)
|
vim.api.nvim_set_option_value('modifiable', false, { buf = tree_buf })
|
||||||
return native.get_workspace(workspace).filetree
|
vim.api.nvim_open_win(tree_buf, true, {
|
||||||
|
win = 0,
|
||||||
|
split = 'left',
|
||||||
|
width = 20,
|
||||||
|
})
|
||||||
|
vim.api.nvim_set_option_value('relativenumber', false, {})
|
||||||
|
vim.api.nvim_set_option_value('number', false, {})
|
||||||
|
vim.api.nvim_set_option_value('cursorlineopt', 'line', {})
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
join = join,
|
join = join,
|
||||||
leave = leave,
|
leave = leave,
|
||||||
buffers = list_buffers,
|
|
||||||
users = list_users,
|
|
||||||
map = user_hl,
|
map = user_hl,
|
||||||
colors = available_colors,
|
colors = available_colors,
|
||||||
|
open_buffer_tree = open_buffer_tree,
|
||||||
|
buffer_tree = tree_buf,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue