I have added has('wsl') to Vim. This determines if Vim is running on a WSL system.
It is a reproduction of a feature in Neovim and uses the idea of determining if it is running on WSL(see: neovim/neovim#16153), but I have not appropriated any of the source code.
There are a few things to note in the code, which are as follows
・The position of the kernel_release variable declaration is far from where it is actually used.
・The variable "i" is used in another logic.
https://github.com/vim/vim/pull/10464
(4 files)
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@kat0h pushed 1 commit.
—
View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
There's a much simpler detection method that probe one of these two files:
/proc/sys/kernel/osrelease
/proc/version
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
・The variable "i" is used in another logic.
How about using vim_strup() and search with uppercase "MICROSOFT"?
And, in f_has(),
#if (defined(UNIX) || defined(VMS)) \
&& (!defined(MACOS_X) || defined(HAVE_CONFIG_H)) \
&& defined(HAVE_SYS_UTSNAME_H)WSL is on Linux so I think all need is checking only #if defined(__linux__) && defined(HAVE_SYS_UTSNAME_H).
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
Thank you for checking my PR.
@LemonBoy
Thanks for the suggestion on how to determine WSL. I chose this method because I thought that using uname syscall would be faster to execute and simpler to code than the method of reading the file.
@ichizok
Thanks for the suggestion to use vim_strup(). I was not aware of the existence of vim_strup() and have made the change as I think it is appropriate to use this method in place of the for statement.
Also, thanks for pointing out the appropriate #if condition.
@ Gary (sorry, I don't know how to reply well to vim-ml)
Thanks for pointing that out.
WSL users sometimes use Vim in conjunction with Windows. For example, clipboard integration. At this time, users are aware that Vim is running on WSL.
For this reason, I believe it would be beneficial to users to provide a way to distinguish wsl as well as has('unix'), has('mac'), and has('win64'), even though WSL is Linux.
Also, has('wsl') is implemented in neovim. Of course, Vim and Neovim are different projects, and there is no need to adapt Vim to Neovim's specifications. However, I believe it would be beneficial to be able to identify wsl in a similar API.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
I use if exists("$WSLENV") for that.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
—
Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.![]()
@ Gary
My understanding of the purpose of has() was lacking. Thank you very much for your kind explanation.
I will close this PR.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
Closed #10464.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
Assuming that if exists("$WSLENV") works, then I don't see a reason for a has() item.
Adding a remark about WSL in the help seems useful. How about this:
When using Vim on WSL (Windows Subsystem for Linux) the remarks here do not
apply, `has('win32')` will return false then. In case you need to know
whether Vim is running on WSL you can use `exists('$WSLENV')`.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
I believe it would be beneficial to give users a hint on how to determine WSL.
I have verified that exists('$WSLENV') works as intended in Windows, WSL, Linux and Mac environments.
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()
It is here:
835ee98#diff-c951a6c3c6aa1b6ef94a0348e454fd20590c3d4dc0503e3bb3755ad28bd16179
—
Reply to this email directly, view it on GitHub.
You are receiving this because you commented.![]()