summaryrefslogtreecommitdiffstatshomepage
path: root/runtime/lua/vim/_core/server.lua
diff options
context:
space:
mode:
authorJustin M. Keyes <justinkz@gmail.com>2025-07-11 08:33:29 -0400
committerJustin M. Keyes <justinkz@gmail.com>2025-07-28 22:00:25 -0400
commit56a4ef3c213d87bfba5f361376bd23eefdf6c6ec (patch)
treee300471cee1caaf3b86b4f38727ed95801b7c124 /runtime/lua/vim/_core/server.lua
parentdc67ba948eec0a5628eff0b15ce87a7d27f58bb3 (diff)
docs: lsp, ui events, dev guidance, osc7
fix #34981
Diffstat (limited to 'runtime/lua/vim/_core/server.lua')
-rw-r--r--runtime/lua/vim/_core/server.lua15
1 files changed, 8 insertions, 7 deletions
diff --git a/runtime/lua/vim/_core/server.lua b/runtime/lua/vim/_core/server.lua
index 281a5705ea..367dfe2ff3 100644
--- a/runtime/lua/vim/_core/server.lua
+++ b/runtime/lua/vim/_core/server.lua
@@ -1,17 +1,18 @@
local M = {}
---- Called by builtin serverlist(). Returns all running servers.
---- in stdpath("run"). Does not include named pipes or TCP servers.
+--- Called by builtin serverlist(). Returns all running servers in stdpath("run").
+---
+--- - TODO: track TCP servers, somehow.
+--- - TODO: support Windows named pipes.
---
--- @param listed string[] Already listed servers
---- @return string[] A list of currently running servers in stdpath("run")
+--- @return string[] # List of servers found on the current machine in stdpath("run").
function M.serverlist(listed)
- -- TODO: also get named pipes on Windows
local socket_paths = vim.fs.find(function(name, _)
return name:match('nvim.*')
end, { path = vim.fn.stdpath('run'), type = 'socket', limit = math.huge })
- local running_sockets = {}
+ local found = {} ---@type string[]
for _, socket in ipairs(socket_paths) do
-- Don't list servers twice
if not vim.list_contains(listed, socket) then
@@ -20,14 +21,14 @@ function M.serverlist(listed)
-- Check that the server is responding
-- TODO: do we need a timeout or error handling here?
if vim.fn.rpcrequest(chan, 'nvim_get_chan_info', 0).id then
- table.insert(running_sockets, socket)
+ table.insert(found, socket)
end
vim.fn.chanclose(chan)
end
end
end
- return running_sockets
+ return found
end
return M