Closed jgb closed 1 year ago
I just ran into this after reinstalling my plugins with neovim
This is due to commit 6585499. This change uses the current highlight groups for treesitter. Can you execute NightfoxCompile
and see if that solves your issue.
I can confirm that NightfoxCompile
fixed this on my end. Thanks @EdenEast!
@EdenEast the issue remains in vim/gvim (even if I do the NightfoxCompile in neovim first)
For vim could you try:
require("nightfox").setup({
options = {
modules = {
native_lsp = {
enable = false,
},
treesitter = false,
},
},
})
This would disable neovim specific modules.
Could we disable incompatible modules by default?
If this did solve the issue I would set these modules to be enabled only if neovim. Still unsure about the precompiled files. These are only used if there is now setup function called and the user has not compiled themselves.
I don't know what the best solution is, but in the current state nightfox unfortuntely isn't really compatible with vanilla vim any longer.
On win 11, upgrading Neovim from 0.7.2
to 0.8.0
fixed the issue.
Used the command: winget upgrade Neovim
NightfoxCompile
throw an error: nightfox/lua/nightfox/lib/color.lua:105: attempt to index a nil value (upvalue 'bitopt')
Vim 9.0.800
NightfoxCompile
also fails for me with the same error message (Vim 9.0.844). I was going to try disabling the neovim modules as suggested in https://github.com/EdenEast/nightfox.nvim/issues/218#issuecomment-1285666881, but I just can't figure out where to put the config snippet. I'm sure I'm overlooking something obvious, but nothing I've tried has worked. The closest I got was putting it in a
lua << END
...
END
block but that throws an error that "module nightfox not found". I'd really appreciate any pointers anyone can give.
@zb140, the updated version sets those values to whatever boolean util.is_nvim
holds (I'd assume false
if using vim), so you could modify the file (lua/nightfox/config.lua
) directly and set it to false
. Having done that myself, it makes no difference, NightfoxCompile
still failing with:
lua/nightfox/lib/color.lua:206: bad argument #1 to 'lshift' (number has no integer representation)
Which is this line:
local bitopt = util.is_nvim and bit or bit32 or bit
Depending on whether I set this to bit
or bit32
, I either get the same error as above or the one mentioned by this comment.
I thought it had something to do with there being no Lua bitop
library installed on my system (AFAIU, if you have vim compiled against LuaJIT, bitop
should be included by default/bitops are builtin), but installing bitop
didn't fix it either, and that may be because bitop
is not compatible with Lua 5.3, which my binary happens to be compiled against.
Not sure what the solution is.
Thanks @xuoe! That's actually given me enough to work with that I've actually got it working. There seems to be a couple of issues at play here:
bitop
, some versions need bit32
, and some versions (notably 5.3+) support bitwise operators natively.Color:to_hex()
tries to perform bitwise math numbers that are not necessarily integers. Specifically, the individual color components are floats, and to_hex()
just multiplies them by 0xff
and passes them straight to lshift
I worked around these issues by replacing line 26 in color.lua
with this code:
local function get_bitopt(op)
return function(a,b)
a = util.round(a)
b = util.round(b)
return op(a,b)
end
end
local native_bitopt = {
lshift = get_bitopt(function(a,b) return a << b end),
rshift = get_bitopt(function(a,b) return a >> b end),
band = get_bitopt(function(a,b) return a & b end),
bor = get_bitopt(function(a,b) return a | b end),
}
local bitopt = util.is_nvim and bit or bit32 or bit or native_bitopt
Now :NightfoxCompile
works fine, and I can use the color schemes without issue in Vim 9 😄
Great work, @zb140! That solved it for me as well (I just replaced native_bitopt
with bitopt
in-place and ran :NightfoxCompile
). Hadn't known Lua 5.3 had native support for bitwise operations.
Thanks to everyone for looking into this. I am thinking of using the solution @zb140 commented as a fallback if it cant find the neovim luajit is not found. That should handle different lua versions for the color lib.
I tried to have this working but you cant have 5.2 and 5.3 in the same file. There is no way to guard the >>.
Depending on your appetite for dirty hacks, you might be able to get away with something like this:
local function get_bitopt(op)
return function(a,b)
a = util.round(a)
b = util.round(b)
return load("return " .. op)()(a,b)
end
end
local native_bitopt = {
lshift = get_bitopt("function(a,b) return a << b end"),
rshift = get_bitopt("function(a,b) return a >> b end"),
band = get_bitopt("function(a,b) return a & b end"),
bor = get_bitopt("function(a,b) return a | b end"),
}
But everything I know about Lua I learned in the last 12 hours, so there may be good reasons to avoid it, even over and above the standard "eval
is evil" arguments...
@EdenEast, what about exporting bitop
from two different files, one for Lua 5.3 (which exports @zb140's native bitop wrappers) and one for earlier versions (which exports either bit
or bit32
, as before), and then require
ing one or the other in color.lua
based on the value of _VERSION
?
EDIT: or something like this:
local version = tonumber(string.sub(_VERSION, 5, 7)) -- LuaJIT-compatible
local bitop = version >= 5.3 and require("bitop_native") or (util.is_nvim and bit or bit32 or bit)
For others that were having issues with the compile file in vim could I get some help testing this pr #241 which makes the compiler automatic. This change should support vim better and be overall much faster.
I tested it with my nix-shell version of vim but testing on more setups would help.
I have tested on feat/auto-compile
branch. However, I still have the same issue.
[error][nightfox]: Unable to find lua library `bit` or `bit32`. Please make sure lua vesion is 5.1 or 5.2
/Users/xxxx/yyyy/vim/vimrc の処理中にエラーが検出されました:
行 179:
...m/pack/jetpack/opt/nightfox.nvim/lua/nightfox/config.lua:107: attempt to call a nil value (field 'hash')
:version
:version
VIM - Vi IMproved 9.0 (2022 Jun 28, compiled Sep 15 2022 18:56:17)
macOS 版 - x86_64
適用済パッチ: 1-472
Compiled by Homebrew
Huge 版 with MacVim GUI. 機能の一覧 有効(+)/無効(-)
+acl +cmdline_hist +ex_extra +job +mouseshape +packages +signs +terminfo +visualextra
+arabic +cmdline_info +extra_search +jumplist +mouse_dec +path_extra +smartindent +termresponse +vreplace
+autocmd +comments -farsi +keymap -mouse_gpm +perl -sodium +textobjects +wildignore
+autochdir +conceal +file_in_path +lambda -mouse_jsbterm +persistent_undo -sound +textprop +wildmenu
-autoservername +cryptv +find_in_path +langmap +mouse_netterm +popupwin +spell +timers +windows
+balloon_eval +cscope +float +libcall +mouse_sgr +postscript +startuptime +title +writebackup
+balloon_eval_term +cursorbind +folding +linebreak -mouse_sysmouse +printer +statusline +toolbar -X11
+browse +cursorshape -footer +lispindent +mouse_urxvt +profile -sun_workshop +transparency -xfontset
++builtin_terms +dialog_con_gui +fork() +listcmds +mouse_xterm -python +syntax +user_commands +xim
+byte_offset +diff +fullscreen +localmap +multi_byte +python3 +tag_binary +vartabs -xpm
+channel +digraphs +gettext +lua +multi_lang +quickfix -tag_old_static +vertsplit -xsmp
+cindent +dnd -hangul_input +menu -mzscheme +reltime -tag_any_white +vim9script -xterm_clipboard
+clientserver -ebcdic +iconv +mksession +netbeans_intg +rightleft +tcl +viminfo -xterm_save
+clipboard +emacs_tags +insert_expand +modify_fname +num64 +ruby +termguicolors +virtualedit
+cmdline_compl +eval +ipv6 +mouse +odbeditor +scrollbind +terminal +visual
システム vimrc: "$VIM/vimrc"
ユーザー vimrc: "$HOME/.vimrc"
第2ユーザー vimrc: "~/.vim/vimrc"
ユーザー exrc: "$HOME/.exrc"
システム gvimrc: "$VIM/gvimrc"
ユーザー gvimrc: "$HOME/.gvimrc"
第2ユーザー gvimrc: "~/.vim/gvimrc"
デフォルトファイル: "$VIMRUNTIME/defaults.vim"
システムメニュー: "$VIMRUNTIME/menu.vim"
省略時の $VIM: "/Applications/MacVim.app/Contents/Resources/vim"
コンパイル: clang -c -I. -Iproto -DHAVE_CONFIG_H -DFEAT_GUI_MACVIM -Wall -Wno-unknown-pragmas -pipe -DMACOS_X -DMACOS_X_DARWIN -g -O2 -arch x86_64 -D_REENTRANT -U_FORTIFY_SOURCE
-D_FORTIFY_SOURCE=1
リンク: clang -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -L. -fstack-protector-str
ong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl@1.1/lib -L/usr/local/opt/readline/lib -arch x86_64 -L/usr/local/lib -o Vim -lm -lncurses -liconv /usr/
local/lib/libintl.a -framework AppKit -L/usr/local/opt/lua/lib -llua5.4 -L/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE -lperl -L/usr/local/opt/python@3.10/Framework
s/Python.framework/Versions/3.10/lib/python3.10/config-3.10-darwin -lpython3.10 -framework CoreFoundation -F/System/Library/Frameworks -framework Tcl -framework CoreFoundation -
lruby.3.1 -L/usr/local/Cellar/ruby/3.1.2_1/lib
Thanks for checking it out. I have added a native bit file for 5.3 like the suggestion from @xuoe. Let me know it this solves your issue.
Thank you for updating. I guess that you forgot to add bxor
in native_bitops.lua
Resolved with #241
Description
When starting vim/gvim with nightfox theme enabled, since yesterday I get this error repeated a few dozen times:
Error detected while processing nightfox.vim line 9:
W18: Invalid character in group name
I'm on vim 9.0.0626-1 on debian.