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
|
||||
end
|
||||
|
||||
local tree_buf = nil;
|
||||
|
||||
vim.api.nvim_create_user_command(
|
||||
"MP",
|
||||
function (args)
|
||||
|
@ -39,19 +37,7 @@ vim.api.nvim_create_user_command(
|
|||
buffers.sync(client.workspace)
|
||||
elseif args.fargs[1] == "buffers" then
|
||||
if client.workspace == nil then error("connect to a workspace first") end
|
||||
local tree = workspace.buffers(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,
|
||||
})
|
||||
workspace.open_buffer_tree(client.workspace)
|
||||
-- elseif args.fargs[1] == "users" then
|
||||
-- if client.workspace == nil then error("connect to a workspace first") end
|
||||
-- workspace.users(client.workspace)
|
||||
|
|
|
@ -5,6 +5,7 @@ local buffers = require('codemp.buffers')
|
|||
local async = require('codemp.async')
|
||||
|
||||
local user_hl = {}
|
||||
local tree_buf = nil
|
||||
local available_colors = { -- TODO these are definitely not portable!
|
||||
"ErrorMsg",
|
||||
"WarningMsg",
|
||||
|
@ -62,22 +63,31 @@ local function leave()
|
|||
print(" -- left workspace")
|
||||
end
|
||||
|
||||
local function list_users(workspace)
|
||||
local workspace = native.get_workspace(workspace)
|
||||
for _, buffer in pairs(workspace.users) do
|
||||
print(" - " .. buffer)
|
||||
local function open_buffer_tree(workspace)
|
||||
local tree = native.get_workspace(workspace).filetree
|
||||
if tree_buf == nil then
|
||||
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
|
||||
|
||||
local function list_buffers(workspace)
|
||||
return native.get_workspace(workspace).filetree
|
||||
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- "))
|
||||
vim.api.nvim_set_option_value('modifiable', false, { buf = tree_buf })
|
||||
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
|
||||
|
||||
return {
|
||||
join = join,
|
||||
leave = leave,
|
||||
buffers = list_buffers,
|
||||
users = list_users,
|
||||
map = user_hl,
|
||||
colors = available_colors,
|
||||
open_buffer_tree = open_buffer_tree,
|
||||
buffer_tree = tree_buf,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue