We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents d22b113 + b25a5ff commit aeaca88Copy full SHA for aeaca88
lua/lib/os.lua
@@ -0,0 +1,24 @@
1
+local M = {}
2
+
3
+---@return string the os name about nvim running on
4
+function M.detect_os()
5
+ if vim.fn.filereadable("/etc/NIXOS") == 1 then
6
+ return "nixos"
7
+ end
8
9
+ if vim.fn.executable("sw_vers") == 1 then
10
+ return "macos"
11
12
13
+ if vim.fn.executable("explorer.exe") == 1 then
14
+ return "windows"
15
16
17
+ if vim.fn.system("uname -s") == "Linux\n" then
18
+ return "linux"
19
20
21
+ return "unsupported"
22
+end
23
24
+return M
spec/lib/os_spec.lua
@@ -0,0 +1,7 @@
+local lib = require("lib.os")
+describe("lib", function()
+ it("os#detect_os", function()
+ assert.are.same(lib.detect_os(), "linux")
+ end)
+end)
0 commit comments