mirror of
https://github.com/hexedtech/codemp.git
synced 2024-12-23 13:24:54 +01:00
fix: friendlier conn addr and logging
This commit is contained in:
parent
f7cba63456
commit
07b8e3a517
2 changed files with 14 additions and 4 deletions
|
@ -60,16 +60,26 @@ local function unhook_callbacks(buffer)
|
|||
vim.keymap.del('i', '<CR>', { buffer = buffer })
|
||||
end
|
||||
|
||||
local function auto_address(addr)
|
||||
if not string.find(addr, "://") then
|
||||
addr = string.format("http://%s", addr)
|
||||
end
|
||||
if not string.find(addr, ":", 7) then -- skip first 7 chars because 'https://'
|
||||
addr = string.format("%s:50051", addr)
|
||||
end
|
||||
return addr
|
||||
end
|
||||
|
||||
vim.api.nvim_create_user_command('Connect',
|
||||
function(args)
|
||||
if M.jobid ~= nil then
|
||||
if M.jobid ~= nil and M.jobid > 0 then
|
||||
print("already connected, disconnect first")
|
||||
return
|
||||
end
|
||||
local bin_args = { BINARY }
|
||||
if #args.fargs > 0 then
|
||||
table.insert(bin_args, "--host")
|
||||
table.insert(bin_args, args.fargs[1])
|
||||
table.insert(bin_args, auto_address(args.fargs[1]))
|
||||
end
|
||||
if vim.g.codemp_remote_debug then
|
||||
table.insert(bin_args, "--remote-debug")
|
||||
|
|
|
@ -255,7 +255,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
.init(),
|
||||
}
|
||||
|
||||
let client = BufferClient::connect(args.host).await?;
|
||||
let client = BufferClient::connect(args.host.clone()).await?;
|
||||
|
||||
let handler: NeovimHandler = NeovimHandler {
|
||||
client: client.into(),
|
||||
|
@ -263,7 +263,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||
|
||||
let (_nvim, io_handler) = create::new_parent(handler).await;
|
||||
|
||||
info!("++ codemp started");
|
||||
info!("++ codemp connected: {}", args.host);
|
||||
|
||||
if let Err(e) = io_handler.await? {
|
||||
error!("worker stopped with error: {}", e);
|
||||
|
|
Loading…
Reference in a new issue