aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgit-bruh <prathamIN@proton.me>2024-04-07 01:57:40 +0530
committerFlorian Fischer <florian.fischer@muhq.space>2024-04-30 22:18:24 +0200
commite505535d40d44a0bda341b37a5611663ef9815fe (patch)
tree5c95a4f045370ffffb27ffeb73cd6342150adcdb
parent2dc7e3a6fbad8b333648361bfffd2a332e496ab6 (diff)
downloadvis-lspc-e505535d40d44a0bda341b37a5611663ef9815fe.tar.gz
vis-lspc-e505535d40d44a0bda341b37a5611663ef9815fe.zip
lspc, init: emit LS_INITIALIZED and implicitly call lspc_open on server init
-rw-r--r--init.lua25
-rw-r--r--lspc.lua3
2 files changed, 28 insertions, 0 deletions
diff --git a/init.lua b/init.lua
index 389f3b4..4f34741 100644
--- a/init.lua
+++ b/init.lua
@@ -978,6 +978,8 @@ local function lspc_handle_initialize_response(ls, result)
settings = ls.settings,
})
end
+
+ vis.events.emit(lspc.events.LS_INITIALIZED, ls)
end
-- method response dispatcher
@@ -1756,6 +1758,29 @@ vis.events.subscribe(vis.events.FILE_OPEN, function(file)
lspc_open(ls, win, file)
end)
+vis.events.subscribe(vis.events.FILE_SAVE_POST, function(file, path)
+ if not vis.win or vis.win.file ~= file then
+ return
+ end
+
+ local ls = lspc_get_usable_ls(vis.win.syntax)
+ if not ls then
+ return
+ end
+
+ if not ls.open_files[path] then
+ lspc_open(ls, vis.win, file)
+ end
+
+ ls_send_did_change(ls, file)
+end)
+
+vis.events.subscribe(lspc.events.LS_INITIALIZED, function(ls)
+ if vis.win and vis.win.file and lspc_get_usable_ls(vis.win.syntax) == ls then
+ lspc_open(ls, vis.win, vis.win.file)
+ end
+end)
+
vis:option_register('lspc-highlight-diagnostics', 'string', function(value)
lspc.highlight_diagnostics = value
return true
diff --git a/lspc.lua b/lspc.lua
index a1acb86..767c519 100644
--- a/lspc.lua
+++ b/lspc.lua
@@ -56,6 +56,9 @@ local lspc = {
-- How to present messages to the user.
-- 'message': use vis:message; 'open': use a new split window allowing for syntax highlighting
show_message = 'message',
+
+ -- events
+ events = {LS_INITIALIZED = 'LspcEvent::LS_INITIALIZED'},
}
--