mirror of
https://github.com/hexedtech/codemp-nvim.git
synced 2024-11-22 07:24:52 +01:00
chore: separate connect command
This commit is contained in:
parent
380257945e
commit
83c2a2c7e4
2 changed files with 26 additions and 11 deletions
24
src/client.lua
Normal file
24
src/client.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
local native = require("codemp.loader").load()
|
||||
local window = require("codemp.window")
|
||||
local session = require("codemp.session")
|
||||
local workspace = require("codemp.workspace")
|
||||
|
||||
local function connect(host, bang)
|
||||
if host == nil then host = 'http://codemp.alemi.dev:50054' end
|
||||
local user, password
|
||||
if bang then -- ignore configured values
|
||||
user = vim.fn.input("username > ", "")
|
||||
password = vim.fn.input("password > ", "")
|
||||
else
|
||||
user = vim.g.codemp_username or vim.fn.input("username > ", "")
|
||||
password = vim.g.codemp_password or vim.fn.input("password > ", "")
|
||||
end
|
||||
session.client = native.connect(host, user, password):await()
|
||||
session.available = workspace.list(session.client)
|
||||
window.update()
|
||||
print(" ++ connected to " .. host .. " as " .. user)
|
||||
end
|
||||
|
||||
return {
|
||||
connect = connect
|
||||
}
|
|
@ -3,6 +3,7 @@ local buffers = require('codemp.buffers')
|
|||
local workspace = require('codemp.workspace')
|
||||
local utils = require('codemp.utils')
|
||||
local window = require('codemp.window')
|
||||
local client = require("codemp.client")
|
||||
|
||||
local native = require('codemp.loader').load()
|
||||
|
||||
|
@ -19,17 +20,7 @@ end
|
|||
-- always available
|
||||
local base_actions = {
|
||||
connect = function(host, bang)
|
||||
if host == nil then host = 'http://codemp.alemi.dev:50053' end
|
||||
local user, password
|
||||
if bang then -- ignore configured values
|
||||
user = vim.fn.input("username > ", "")
|
||||
password = vim.fn.input("password > ", "")
|
||||
else
|
||||
user = vim.g.codemp_username or vim.fn.input("username > ", "")
|
||||
password = vim.g.codemp_password or vim.fn.input("password > ", "")
|
||||
end
|
||||
state.client = native.connect(host, user, password):await()
|
||||
print(" ++ connected to " .. host .. " as " .. user)
|
||||
client.connect(host, bang)
|
||||
end,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue