mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 15:34:53 +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 client = require('codemp.client')
|
||||||
local buffers = require('codemp.buffer')
|
local buffers = require('codemp.buffer')
|
||||||
local workspace = require('codemp.workspace')
|
local workspace = require('codemp.workspace')
|
||||||
|
local utils = require('codemp.utils')
|
||||||
|
|
||||||
local native = require('codemp.loader').load()
|
local native = require('codemp.loader').load()
|
||||||
|
|
||||||
|
@ -14,6 +15,8 @@ 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)
|
||||||
|
@ -36,7 +39,19 @@ 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
|
||||||
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
|
-- 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)
|
||||||
|
|
|
@ -70,10 +70,7 @@ local function list_users(workspace)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function list_buffers(workspace)
|
local function list_buffers(workspace)
|
||||||
local workspace = native.get_workspace(workspace)
|
return native.get_workspace(workspace).filetree
|
||||||
for _, buffer in pairs(workspace.filetree) do
|
|
||||||
print(" > " .. buffer)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Reference in a new issue