@@ -13,7 +13,6 @@ local Logger = require("eca.logger")
1313--- @field on_stop function Callback when the server stops
1414--- Called when a notification is received(message without an ID)
1515--- @field on_notification fun ( server : eca.Server , message : table )
16- --- @field capabilities eca.ServerCapabilities Server capabilities
1716--- @field private path_finder eca.PathFinder Server path finder
1817--- @field pending_requests { id : fun ( err , data )} -- outgoing requests with callbacks
1918local M = {}
@@ -50,7 +49,6 @@ function M.new(opts)
5049 path_finder = opts .path_finder ,
5150 messages = {},
5251 pending_requests = {},
53- capabilities = {},
5452 initialized = false ,
5553 next_id = 0 ,
5654 }, { __index = M })
@@ -67,7 +65,7 @@ local function on_stdout(server)
6765 if # message .content ~= message .content_length then
6866 return
6967 end
70- table.insert (messages , message )
68+ table.insert (server . messages , message )
7169 local msg = vim .json .decode (message .content )
7270 server :handle_message (msg )
7371 end )
@@ -171,20 +169,18 @@ function M:initialize()
171169 },
172170 },
173171 workspaceFolders = workspace_folders ,
174- }, function (err , result )
172+ }, function (err , _ )
175173 if err then
176174 Logger .notify (" Could not initialize server: " .. err , vim .log .levels .ERROR )
177175 return
178176 end
179- if result then
180- self .capabilities = result
181- end
182177
183178 self :send_notification (" initialized" , {})
184179
185180 if self .on_initialize then
186181 self .on_initialize ()
187182 end
183+ self .initialized = true
188184 end )
189185end
190186
@@ -259,6 +255,7 @@ function M:send_request(method, params, callback)
259255 end
260256
261257 local json = vim .json .encode (message )
258+ table.insert (self .messages , { content = json , content_length = # json })
262259 local content = string.format (" Content-Length: %d\r\n\r\n %s" , # json , json )
263260 self .process :write (content )
264261end
0 commit comments