NyaoVim icon indicating copy to clipboard operation
NyaoVim copied to clipboard

Detect nyaovim with `has` command

Open techhazard opened this issue 8 years ago • 6 comments

I would like to be able to detect if nyaovim is running or not so I can load plugins conditionally. E.g. withhas('nyaovim') just like has('nvim') and has('python')

Expected Behavior

running nyaovim: :echo has('nyaovim') -> 1 running gui or terminal: :echo has('nyaovim') -> 0

Actual Behavior

running nyaovim: :echo has('nyaovim') -> 0 running gui or terminal: :echo has('nyaovim') -> 0

Steps to Reproduce (including precondition)

  1. Start nyaovim
  2. run the following command: :echo has('nyaovim')
  3. output should return 0 (I would have expected 1)

Screenshot on This Problem (if possible)

I do not think that is neccessary

Your Environment

  • OS: OSX
  • NyaoVim version: 0.0.22
  • nvim version: 0.1.7
  • Keyboard layout: programmer-dvorak

techhazard avatar Apr 21 '17 09:04 techhazard

has() is a built-in function. So we can't change it's behavior. Instead, we can check if g:nyaovim_version variable exists or not.

if exists('g:nyaovim_version')
  " Code for NyaoVim
endif

The variable is set in command line argument: https://github.com/rhysd/NyaoVim/blob/master/renderer/nyaovim-app.ts#L253

rhysd avatar Apr 21 '17 09:04 rhysd

That would work. Sadly it doesn't for me. :echo exists('g:nyaovim_version') returns 0 :-( I do not have to use that command line argument manually, right?

techhazard avatar Apr 21 '17 09:04 techhazard

Hmm... I don't have any idea why the variable does not exist.

You don't need to set the command line argument manually. It is automatically set by NyaoVim.

rhysd avatar Apr 21 '17 09:04 rhysd

Anything I can do to debug the issue?

NyaoVim version 0.0.22
  electron : 1.4.13
  chrome : 53.0.2785.143
  node : 6.5.0
  v8 : 5.3.332.47
NVIM 0.1.7
Build type: Release
Compilation: /nix/store/yxg0zzcyjndcp6ilixv8wc50sg89b5r3-clang-wrapper-4.0.0/bin/clang -Wconversion -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -O2 -DNDEBUG -DDISABLE_LOG -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -DHAVE_CONFIG_H -I/private/var/tmp/nix-build-neovim-0.1.7.drv-0/neovim-v0.1.7-src/build/config -I/private/var/tmp/nix-build-neovim-0.1.7.drv-0/neovim-v0.1.7-src/src -I/nix/store/lgprhs9d1bi8s9y06ccfmg1nksn4wbdm-libuv-1.11.0/include -I/nix/store/iinrspsbs43lwrcjgs52wgsjw10vxclv-libmsgpack-2.0.0/include -I/nix/store/8gjpvb1my8iczkinsqd7zmbidf0w0xn9-unibilium-1.2.0/include -I/nix/store/7skb10mc11rclwzni6798agb00d0rxsi-libtermkey-0.19/include -I/nix/store/xj64af8sfrlyggvl63z0byj2b7ng17d3-neovim-libvterm-2016-10-07/include -I/nix/store/i6smd9fqcp1wk4ihgypp3zflqqicvkfb-jemalloc-4.5.0/include -I/nix/store/410ya8c9f25n9vpqhb4n05891hq9nr1d-gettext-0.19.8/include -I/private/var/tmp/nix-build-neovim-0.1.7.drv-0/neovim-v0.1.7-src/build/src/nvim/auto -I/private/var/tmp/nix-build-neovim-0.1.7.drv-0/neovim-v0.1.7-src/build/include
Compiled by nixbld4

Optional features included (+) or not (-): +acl   -iconv    +jemalloc +tui
For differences from Vim, see :help vim-differences

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/nix/store/aznha3w0mdsv46mg42kn4zz04ifh0aiw-neovim-0.1.7/share/nvim"

techhazard avatar Apr 21 '17 09:04 techhazard

Thank you for your information and offer. But I need to try to reproduce at first with the latest neovim.

rhysd avatar Apr 21 '17 10:04 rhysd

Same issue here: on Linux it's exists, while on Windows it isn't.

Linux (Ubuntu 16.04 LTS "Xenial Xerus" x64)

  • Neovim 0.2.1-dev
  • NyaoVim 0.0.22
  • Node 4.2.6

Windows 7 x64

  • Neovim 0.2.1.190
  • NyaoVim 0.0.22
  • Node 6.9.5

bimlas avatar May 21 '17 20:05 bimlas