aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMahmoud Al-Qudsi <mqudsi@neosmart.net>2017-09-27 13:38:24 -0500
committerJustin M. Keyes <justinkz@gmail.com>2018-01-30 21:12:49 +0100
commit5d2dd2ebe28c31f223d77355a8f9d40adfb41c82 (patch)
tree05285ed29c5b2d678cda737d2ae03b2fd80debef
parent8728a5d50bc3339db81c7f29d59c55f9f817f06c (diff)
downloadrneovim-5d2dd2ebe28c31f223d77355a8f9d40adfb41c82.tar.gz
rneovim-5d2dd2ebe28c31f223d77355a8f9d40adfb41c82.tar.bz2
rneovim-5d2dd2ebe28c31f223d77355a8f9d40adfb41c82.zip
win: has("wsl") on Windows Subsystem for Linux #7330
Per CMAKE docs, CMAKE_HOST_SYSTEM_VERSION is the result of `uname -r`: https://cmake.org/cmake/help/v3.4/variable/CMAKE_HOST_SYSTEM_VERSION.html?highlight=uname A numeric version string for the system. On systems that support uname, this variable is set to the output of uname -r. On other systems this is set to major-minor version numbers. On Windows it is something like "6.1", so it won't match ".*-Microsoft". Closes #7329
-rw-r--r--config/CMakeLists.txt5
-rw-r--r--config/config.h.in1
-rw-r--r--runtime/doc/eval.txt1
-rw-r--r--src/nvim/eval.c3
-rw-r--r--test/functional/eval/has_spec.lua6
5 files changed, 16 insertions, 0 deletions
diff --git a/config/CMakeLists.txt b/config/CMakeLists.txt
index c3643db205..63cb3cc0d6 100644
--- a/config/CMakeLists.txt
+++ b/config/CMakeLists.txt
@@ -12,6 +12,11 @@ check_type_size("size_t" SIZEOF_SIZE_T)
check_type_size("long long" SIZEOF_LONG_LONG)
check_type_size("void *" SIZEOF_VOID_PTR)
+if (CMAKE_HOST_SYSTEM_VERSION MATCHES ".*-Microsoft")
+ # Windows Subsystem for Linux
+ set(HAVE_WSL 1)
+endif()
+
check_symbol_exists(_NSGetEnviron crt_externs.h HAVE__NSGETENVIRON)
# Headers
diff --git a/config/config.h.in b/config/config.h.in
index 410d9cc825..106013425d 100644
--- a/config/config.h.in
+++ b/config/config.h.in
@@ -48,6 +48,7 @@
#cmakedefine HAVE_UTIME_H
#cmakedefine HAVE_UTIMES
#cmakedefine HAVE_WORKING_LIBINTL
+#cmakedefine HAVE_WSL
#cmakedefine UNIX
#cmakedefine USE_FNAME_CASE
#cmakedefine HAVE_SYS_UIO_H
diff --git a/runtime/doc/eval.txt b/runtime/doc/eval.txt
index 8771604c89..37a4962732 100644
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -8445,6 +8445,7 @@ win32 Windows version of Vim (32 or 64 bit).
winaltkeys Compiled with 'winaltkeys' option.
windows Compiled with support for more than one window.
writebackup Compiled with 'writebackup' default on.
+wsl WSL (Windows Subsystem for Linux) version of Vim.
*string-match*
Matching a pattern in a String
diff --git a/src/nvim/eval.c b/src/nvim/eval.c
index 07a9e9286d..67538c248e 100644
--- a/src/nvim/eval.c
+++ b/src/nvim/eval.c
@@ -10671,6 +10671,9 @@ static void f_has(typval_T *argvars, typval_T *rettv, FunPtr fptr)
"windows",
"winaltkeys",
"writebackup",
+#if defined(HAVE_WSL)
+ "wsl",
+#endif
"nvim",
};
diff --git a/test/functional/eval/has_spec.lua b/test/functional/eval/has_spec.lua
index 78c4e08fde..a3af2d1a20 100644
--- a/test/functional/eval/has_spec.lua
+++ b/test/functional/eval/has_spec.lua
@@ -57,4 +57,10 @@ describe('has()', function()
eq(0, funcs.has("unnamedplus"))
end
end)
+
+ it('"wsl"', function()
+ if 1 == funcs.has('win32') or 1 == funcs.has('mac') then
+ eq(0, funcs.has('wsl'))
+ end
+ end)
end)