aboutsummaryrefslogtreecommitdiff
path: root/runtime/lua/vim/_core/vimfn.lua
blob: 8cb07d3bbc72aabcd2302c168ee1a983291eb1e9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
-- Lua implementations of "vimfn" builtin functions (via `func_lua`).
--
-- Functions defined here are pure Lua, they don't have any explicit C impl, so they are named with
-- the "f_xx" convention, for discoverability.

local M = {}

--- Returns the hostname of the machine.
--- @return string
function M.f_hostname()
  return vim.uv.os_gethostname()
end

--- Returns all environment variables as a dictionary.
--- @return table<string, string>
function M.f_environ()
  local env = vim.uv.os_environ() ---@type table<string, string>
  if vim.fn.has('win32') == 1 then -- Vim/legacy behavior: force uppercase keys on Windows. #39443
    local upper = {} --- @type table<string, string>
    for k, v in pairs(env) do
      upper[k:upper()] = v
    end
    return upper
  end
  return env
end

return M