mirror of
https://github.com/hexedtech/codemp-vscode.git
synced 2024-11-25 08:54:48 +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 })
|
vim.keymap.del('i', '<CR>', { buffer = buffer })
|
||||||
end
|
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',
|
vim.api.nvim_create_user_command('Connect',
|
||||||
function(args)
|
function(args)
|
||||||
if M.jobid ~= nil then
|
if M.jobid ~= nil and M.jobid > 0 then
|
||||||
print("already connected, disconnect first")
|
print("already connected, disconnect first")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local bin_args = { BINARY }
|
local bin_args = { BINARY }
|
||||||
if #args.fargs > 0 then
|
if #args.fargs > 0 then
|
||||||
table.insert(bin_args, "--host")
|
table.insert(bin_args, "--host")
|
||||||
table.insert(bin_args, args.fargs[1])
|
table.insert(bin_args, auto_address(args.fargs[1]))
|
||||||
end
|
end
|
||||||
if vim.g.codemp_remote_debug then
|
if vim.g.codemp_remote_debug then
|
||||||
table.insert(bin_args, "--remote-debug")
|
table.insert(bin_args, "--remote-debug")
|
||||||
|
|
|
@ -255,7 +255,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
.init(),
|
.init(),
|
||||||
}
|
}
|
||||||
|
|
||||||
let client = BufferClient::connect(args.host).await?;
|
let client = BufferClient::connect(args.host.clone()).await?;
|
||||||
|
|
||||||
let handler: NeovimHandler = NeovimHandler {
|
let handler: NeovimHandler = NeovimHandler {
|
||||||
client: client.into(),
|
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;
|
let (_nvim, io_handler) = create::new_parent(handler).await;
|
||||||
|
|
||||||
info!("++ codemp started");
|
info!("++ codemp connected: {}", args.host);
|
||||||
|
|
||||||
if let Err(e) = io_handler.await? {
|
if let Err(e) = io_handler.await? {
|
||||||
error!("worker stopped with error: {}", e);
|
error!("worker stopped with error: {}", e);
|
||||||
|
|
Loading…
Reference in a new issue