Skip to content

Commit cffef1b

Browse files
committed
WIP refactor lua bridge
1 parent a2e0414 commit cffef1b

20 files changed

Lines changed: 175 additions & 178 deletions
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
if _G._nvrh_is_initialized ~= true then
2+
_G._nvrh_is_initialized = true
3+
end

src/bridge_files/lua/init_bridge.lua

Lines changed: 0 additions & 13 deletions
This file was deleted.

src/bridge_files/lua/init_nvrh.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
---@field id integer
88
---@field client NvrhChannelClient?
99

10-
if should_initialize then
10+
if _G._nvrh_is_initialized ~= true then
11+
local nvrh_server_info, session_id, browser_script_path, editor_script_path, socket_path, windows_launcher_path =
12+
...
13+
1114
_G._nvrh = {
1215
---@type { [string]: boolean }
1316
mapped_ports = {},
@@ -39,9 +42,9 @@ if should_initialize then
3942
os.remove(socket_path)
4043

4144
if
42-
_G._nvrh.server_info.os == 'windows'
43-
and windows_launcher_path
44-
and windows_launcher_path ~= ''
45+
_G._nvrh.server_info.os == 'windows'
46+
and windows_launcher_path
47+
and windows_launcher_path ~= ''
4548
then
4649
os.remove(windows_launcher_path)
4750
end

src/bridge_files/lua/rpc_open_file.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
if should_initialize then
1+
if _G._nvrh_is_initialized ~= true then
2+
local editor_script_path = ...
3+
24
---@param filename string
35
---@param line? number
46
---@param col? number

src/bridge_files/lua/rpc_open_url.lua

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
if should_initialize then
1+
if _G._nvrh_is_initialized ~= true then
2+
local browser_script_path = ...
3+
24
---@param url string
35
function _G._nvrh.open_url(url)
46
for _, channel in ipairs(_G._nvrh.get_nvrh_channels()) do
@@ -16,6 +18,7 @@ if should_initialize then
1618
})
1719

1820
local original_open = vim.ui.open
21+
---@diagnostic disable-next-line: duplicate-set-field
1922
vim.ui.open = function(uri, opts)
2023
if type(uri) == 'string' and uri:match('^https?://') then
2124
_G._nvrh.open_url(uri)

src/bridge_files/lua/rpc_tunnel_port.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
if should_initialize then
1+
if _G._nvrh_is_initialized ~= true then
22
---@param port string|integer
33
function _G._nvrh.tunnel_port(port)
44
for _, channel in ipairs(_G._nvrh.get_nvrh_channels()) do
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local channel_id = ...
2+
13
for port, _ in pairs(_G._nvrh.mapped_ports) do
24
_G._nvrh._tunnel_port_with_channel(channel_id, port)
35
end

src/bridge_files/lua/setup_browser_script.lua

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/bridge_files/lua/setup_editor_script.lua

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/bridge_files/lua/setup_nvim_launcher.lua

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)