codemp-nvim/lua/codemp/client.lua
alemi 32e056de91
fix: check for nil and empty string
empty string is not falsy in lua? idk
2024-09-17 17:50:58 +02:00

22 lines
638 B
Lua

local workspace = require("codemp.workspace")
local function connect()
---@type Config
local tmp_cfg = vim.tbl_extend('force', {}, CODEMP.config)
if tmp_cfg.username == nil or #tmp_cfg.username == 0 then
tmp_cfg.username = vim.g.codemp_username or vim.fn.input("username > ", "")
end
if tmp_cfg.password == nil or #tmp_cfg.password == 0 then
tmp_cfg.password = vim.g.codemp_password or vim.fn.input("password > ", "")
end
CODEMP.native.connect(tmp_cfg):and_then(function (client)
print(" ++ connected")
CODEMP.client = client
require('codemp.window').update()
workspace.list()
end)
end
return {
connect = connect
}