mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 07:24:52 +01:00
feat: show file tree in split
This commit is contained in:
parent
40a8c49960
commit
388196ae5e
2 changed files with 17 additions and 5 deletions
|
@ -1,6 +1,7 @@
|
|||
local client = require('codemp.client')
|
||||
local buffers = require('codemp.buffer')
|
||||
local workspace = require('codemp.workspace')
|
||||
local utils = require('codemp.utils')
|
||||
|
||||
local native = require('codemp.loader').load()
|
||||
|
||||
|
@ -14,6 +15,8 @@ local function filter(needle, haystack)
|
|||
return hints
|
||||
end
|
||||
|
||||
local tree_buf = nil;
|
||||
|
||||
vim.api.nvim_create_user_command(
|
||||
"MP",
|
||||
function (args)
|
||||
|
@ -36,7 +39,19 @@ 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
|
||||
workspace.buffers(client.workspace)
|
||||
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,
|
||||
})
|
||||
-- elseif args.fargs[1] == "users" then
|
||||
-- if client.workspace == nil then error("connect to a workspace first") end
|
||||
-- workspace.users(client.workspace)
|
||||
|
|
|
@ -70,10 +70,7 @@ local function list_users(workspace)
|
|||
end
|
||||
|
||||
local function list_buffers(workspace)
|
||||
local workspace = native.get_workspace(workspace)
|
||||
for _, buffer in pairs(workspace.filetree) do
|
||||
print(" > " .. buffer)
|
||||
end
|
||||
return native.get_workspace(workspace).filetree
|
||||
end
|
||||
|
||||
return {
|
||||
|
|
Loading…
Reference in a new issue