diff options
| author | Justin M. Keyes <justinkz@gmail.com> | 2026-06-30 21:33:32 +0200 |
|---|---|---|
| committer | Justin M. Keyes <justinkz@gmail.com> | 2026-07-01 13:26:21 +0200 |
| commit | 34efdadb4e865ff28e34dcce19e8abc1dd383651 (patch) | |
| tree | ca8b296f778d4a46df358ab045a0b430a99c86e3 /runtime/lua/vim/_core | |
| parent | d253acca35205a2277af8fae5cf4a3ea3e1bb302 (diff) | |
| download | rneovim-34efdadb4e865ff28e34dcce19e8abc1dd383651.tar.gz rneovim-34efdadb4e865ff28e34dcce19e8abc1dd383651.tar.bz2 rneovim-34efdadb4e865ff28e34dcce19e8abc1dd383651.zip | |
feat(health): report ulimit info
Problem:
Nvim shows `(libuv) kqueue(): Too many open files` on macos.
ref https://github.com/neovim/neovim/issues/40238
Solution:
Add a healthcheck for this situation.
Diffstat (limited to 'runtime/lua/vim/_core')
| -rw-r--r-- | runtime/lua/vim/_core/proc.lua | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/runtime/lua/vim/_core/proc.lua b/runtime/lua/vim/_core/proc.lua new file mode 100644 index 0000000000..36bde5309a --- /dev/null +++ b/runtime/lua/vim/_core/proc.lua @@ -0,0 +1,20 @@ +-- OS/process utils. + +local M = {} + +--- Counts (approximate) open file descriptors for this process. Works on Linux/macOS/BSD. +---@return integer? # Number of open fds, or nil if `/dev/fd` failed (fds exhausted, or unavailable/Windows). +function M.count_open_fds() + local n = 0 + for _, _, err in vim.fs.dir('/dev/fd', { err = true }) do + -- If `/dev/fd` scan failed (e.g. EMFILE when fds exhausted), count would be misleading. + if err then + return nil + end + n = n + 1 + end + -- Discount the scan's own descriptor. + return math.max(0, n - 1) +end + +return M |