robin/laufey

git clone https://git.robinwobin.dev/robin/laufey

Justin M. Keyesfix(env): force uppercase environ() keys on Windows #395236a87ef75b3

master
801 B28 linesraw
1-- Lua implementations of "vimfn" builtin functions (via `func_lua`).
2--
3-- Functions defined here are pure Lua, they don't have any explicit C impl, so they are named with
4-- the "f_xx" convention, for discoverability.
5
6local M = {}
7
8--- Returns the hostname of the machine.
9--- @return string
10function M.f_hostname()
11  return vim.uv.os_gethostname()
12end
13
14--- Returns all environment variables as a dictionary.
15--- @return table<string, string>
16function M.f_environ()
17  local env = vim.uv.os_environ() ---@type table<string, string>
18  if vim.fn.has('win32') == 1 then -- Vim/legacy behavior: force uppercase keys on Windows. #39443
19    local upper = {} --- @type table<string, string>
20    for k, v in pairs(env) do
21      upper[k:upper()] = v
22    end
23    return upper
24  end
25  return env
26end
27
28return M