diff --git a/modules/lsp/init.lua b/modules/lsp/init.lua
index 618d49e..12b9ffe 100644
--- a/modules/lsp/init.lua
+++ b/modules/lsp/init.lua
@@ -190,18 +190,33 @@ function Server.new(cmd, init_options)
     }
   })
   server.capabilities = result.capabilities
-  server:notify('initialized') -- required by protocol
+  server:notify('initialized', {}) -- required by protocol
   return server
 end
 
 ---
+-- Read a line from the LSP process and remove any ^M from the end.
+local function my_read_line(proc)
+    local line = proc:read()
+    if line:sub(-1, -1) == "\r" then
+        return line:sub(1, -2)
+    else
+        return line
+    end
+end
+
+---
 -- Reads and returns an incoming JSON message from this language server.
 -- @return table of data from JSON
 function Server:read()
-  local line = self.proc:read()
-  while not line:find('^Content%-Length: %d+$') do line = self.proc:read() end
-  local len = tonumber(line:match('%d+$'))
-  while #line > 0 do line = self.proc:read() end -- skip other headers
+  local line = my_read_line(self.proc)
+  while not line:find('^Content%-Length: %d+$') do
+    line = my_read_line(self.proc)
+  end
+  local len = tonumber(line:match('%d+%s*$'))
+  while #line > 0 do
+    line = my_read_line(self.proc)
+  end -- skip other headers
   local data = self.proc:read(len)
   if M.log_rpc then self:log('RPC recv: '..data) end
   return json.decode(data)

