Compare commits
5 Commits
af6a952cd8
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 9a7df8a2d6 | |||
| f0c134e482 | |||
| b05490a0f6 | |||
| 79572a45dd | |||
| 15467ba8f0 |
@@ -0,0 +1,49 @@
|
||||
# How chai should work
|
||||
|
||||
## 1. chai buffers URIs:
|
||||
Chai buffer uirs should be
|
||||
- `chai://PROVIDER/USER/REPO/OBJECT`
|
||||
- `chai://git:remote/OBJECT`
|
||||
- `chai://OBJECT` - (shortcut for `chai://git:origin/OBJECT`)
|
||||
|
||||
## 2. Objects
|
||||
- *nothing*: repo
|
||||
- `/issues`: list of issues
|
||||
- `/issue/ID`: for issue number *ID*
|
||||
- `/issue/new`: for creating new issue
|
||||
- `/prs`: list of pull/merge requests
|
||||
- `/pr/ID`: for pull request number *ID*
|
||||
- `/pr/new`: for creating new pull requests
|
||||
|
||||
## 3. How buffers should work
|
||||
|
||||
## 3.1. `/issues` and `/prs`:
|
||||
should show list of issues/PRs, you should be able to click on any issue/PR to see/edit it
|
||||
|
||||
## 3.2. `/issues/ID` and `/pr/ID`
|
||||
should show info in first block header in second block, in another block description and under it list of comments
|
||||
|
||||
## 3.3. `/issues/new` and `/prs/new`
|
||||
in first block metadata and info, in second block name in third block description (shows diffs dynamicly)
|
||||
|
||||
## 3.4. *nothing*
|
||||
should show repo name, list of contributors, keybinds for showing issues and prs etc
|
||||
|
||||
## 4. `:Chai` command
|
||||
creates `chai://` buffer in new neovim tab
|
||||
|
||||
syntax should be
|
||||
|
||||
`:Chai *repo info* *object info*`
|
||||
|
||||
so it could be
|
||||
|
||||
`:Chai kpgpmc femkromek chai.nvim issues 1`
|
||||
|
||||
or
|
||||
|
||||
`:Chai git:origin issues 1`
|
||||
|
||||
or
|
||||
|
||||
`:Chai issues 1`
|
||||
+21
-5
@@ -2,6 +2,10 @@
|
||||
|
||||
local M = {}
|
||||
|
||||
local buffer_list = {
|
||||
'test',
|
||||
}
|
||||
|
||||
local buffers = {}
|
||||
|
||||
function M.setup()
|
||||
@@ -10,11 +14,11 @@ end
|
||||
|
||||
-- should return created chai buffer
|
||||
local function resolve_buffer_path(path)
|
||||
if string.match(path, '^chai://test/?$') then
|
||||
local buffer = vim.deepcopy(require('chai.buffers.test'))
|
||||
buffer.args = {}
|
||||
|
||||
return buffer
|
||||
for _, value in ipairs(buffer_list) do
|
||||
local buf = require('chai.buffers.' .. value).check(path)
|
||||
if buf ~= nil then
|
||||
return buf
|
||||
end
|
||||
end
|
||||
|
||||
-- user is idiot imbecyle etc
|
||||
@@ -29,6 +33,9 @@ function M.create_buffer(buffer)
|
||||
end
|
||||
|
||||
function M.destroy_buffer(buffer)
|
||||
if buffers[buffer] == nil then
|
||||
return
|
||||
end
|
||||
if type(buffers[buffer].destroy) == 'function' then
|
||||
buffers[buffer].destroy(buffer)
|
||||
end
|
||||
@@ -36,18 +43,27 @@ function M.destroy_buffer(buffer)
|
||||
end
|
||||
|
||||
function M.on_hide(buffer)
|
||||
if buffers[buffer] == nil then
|
||||
return
|
||||
end
|
||||
if type(buffers[buffer].on_hide) == 'function' then
|
||||
buffers[buffer].on_hide(buffer)
|
||||
end
|
||||
end
|
||||
|
||||
function M.on_enter(buffer)
|
||||
if buffers[buffer] == nil then
|
||||
return
|
||||
end
|
||||
if type(buffers[buffer].on_enter) == 'function' then
|
||||
buffers[buffer].on_enter(buffer)
|
||||
end
|
||||
end
|
||||
|
||||
function M.on_write(buffer)
|
||||
if buffers[buffer] == nil then
|
||||
return
|
||||
end
|
||||
if type(buffers[buffer].on_write) == 'function' then
|
||||
buffers[buffer].on_write(buffer)
|
||||
end
|
||||
|
||||
@@ -1,8 +1,18 @@
|
||||
local M = {}
|
||||
|
||||
function M.init(vim_buffer)
|
||||
local Buffer = {}
|
||||
|
||||
function Buffer.init(vim_buffer)
|
||||
vim.api.nvim_buf_set_lines(vim_buffer, 0, -1, false, { "press q to exit" })
|
||||
|
||||
local provider_list = { "Providers:" }
|
||||
|
||||
for key, value in pairs(require('chai.config').options.providers) do
|
||||
table.insert(provider_list, key .. " " .. value.url)
|
||||
end
|
||||
|
||||
vim.api.nvim_buf_set_lines(vim_buffer, 3, -1, false, provider_list)
|
||||
|
||||
vim.keymap.set({ "n", "x" }, "q", function()
|
||||
vim.api.nvim_buf_delete(vim_buffer, { force = true })
|
||||
end, { buffer = vim_buffer })
|
||||
@@ -11,4 +21,14 @@ function M.init(vim_buffer)
|
||||
vim.bo[vim_buffer].modified = false
|
||||
end
|
||||
|
||||
function M.check(path)
|
||||
if string.match(path, '^chai://test/?$') then
|
||||
local buffer = vim.deepcopy(Buffer)
|
||||
buffer.args = {}
|
||||
|
||||
return buffer
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
return M
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
local M = {}
|
||||
|
||||
M.defaults = {
|
||||
servers = {},
|
||||
providers = {},
|
||||
}
|
||||
|
||||
M.options = {}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
local M = {}
|
||||
|
||||
local config = require('chai.config')
|
||||
|
||||
local provider_instances = {}
|
||||
|
||||
-- lazy loads providers of course
|
||||
function M.get_provider(name)
|
||||
if provider_instances[name] ~= nil then
|
||||
return provider_instances[name]
|
||||
end
|
||||
|
||||
if config.options.providers[name] == nil then
|
||||
error('unknown provider')
|
||||
end
|
||||
|
||||
local provider_config = config.options.providers[name]
|
||||
|
||||
local provider = require('chai.providers.' .. provider_config.type)
|
||||
|
||||
local provider_instance = provider.init(provider_config)
|
||||
provider_instances[name] = provider_instance
|
||||
return provider_instance
|
||||
end
|
||||
|
||||
return M
|
||||
@@ -0,0 +1,12 @@
|
||||
local M
|
||||
|
||||
local GiteaProvider = {}
|
||||
|
||||
function M.init(config)
|
||||
local provider = vim.deepcopy(GiteaProvider)
|
||||
provider.config = config
|
||||
|
||||
return provider
|
||||
end
|
||||
|
||||
return M
|
||||
Reference in New Issue
Block a user