Extend vim_rest_console_extensions with auto filename generation
parent
f56683ae0f
commit
e859bfc65d
|
@ -0,0 +1,19 @@
|
|||
-------------------------------------------------------------------------------
|
||||
-- - Common projects library -
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
local M = {}
|
||||
|
||||
-- Gets project root directory based on projectionist
|
||||
function M.get_project_root()
|
||||
return vim.fn['projectionist#path']()
|
||||
end
|
||||
|
||||
-- Get unique project ID based on git repository
|
||||
function M.get_project_id()
|
||||
local remote_url = vim.fn['fugitive#RemoteUrl']()
|
||||
remote_url = remote_url:gsub("/", ":")
|
||||
return remote_url
|
||||
end
|
||||
|
||||
return M
|
|
@ -42,12 +42,26 @@ function M.open_scratch_rest_console()
|
|||
end
|
||||
|
||||
-- Opens up a rest console which can be saved -- cached by name
|
||||
function M.open_cached_rest_console(name)
|
||||
function M.open_cached_rest_console(...)
|
||||
local name = select(1, ...)
|
||||
if (select('#', ...) == 0) then
|
||||
name = require'common.projects'.get_project_id()
|
||||
end
|
||||
open_cached_rest_console(name)
|
||||
end
|
||||
|
||||
-- Opens up a rest console which can be saved -- cached by name
|
||||
function M.open_named_cached_rest_console(name)
|
||||
name = require'common.projects'.get_project_id() .. name
|
||||
open_cached_rest_console(name)
|
||||
end
|
||||
|
||||
-- Opens up a rest console based on local file path
|
||||
function M.open_rest_console(file)
|
||||
function M.open_local_rest_console(...)
|
||||
local file = select(1, ...)
|
||||
if (select('#', ...) == 0) then
|
||||
file = 'default'
|
||||
end
|
||||
open_rest_console(file)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,6 +3,6 @@
|
|||
-------------------------------------------------------------------------------
|
||||
|
||||
vim.cmd[[command! -nargs=0 ScratchRestConsole :lua require('vim_rest_console_extensions').open_scratch_rest_console()]]
|
||||
vim.cmd[[command! -nargs=1 RestConsole :lua require('vim_rest_console_extensions').open_cached_rest_console(<f-args>)]]
|
||||
vim.cmd[[command! -nargs=1 RestConsoleLocal :lua require('vim_rest_console_extensions').open_local_rest_console(<f-args>)]]
|
||||
vim.cmd[[command! -nargs=1 RestConsoleCached :lua require('vim_rest_console_extensions').open_cached_rest_console(<f-args>)]]
|
||||
vim.cmd[[command! -nargs=? RestConsole :lua require('vim_rest_console_extensions').open_cached_rest_console(<f-args>)]]
|
||||
vim.cmd[[command! -nargs=? RestConsoleLocal :lua require('vim_rest_console_extensions').open_local_rest_console(<f-args>)]]
|
||||
vim.cmd[[command! -nargs=1 RestConsoleCached :lua require('vim_rest_console_extensions').open_named_cached_rest_console(<f-args>)]]
|
||||
|
|
Loading…
Reference in New Issue