termux / termux-packages

A package build system for Termux.
https://termux.dev
Other
12.99k stars 2.99k forks source link

[Bug]: Neovim is built with an outdated LuaJIT, which seems to cause some issues. #19157

Closed YogiLiu closed 7 months ago

YogiLiu commented 7 months ago

Problem description

I'm not familiar with Lua. For relevant details, please refer to: https://github.com/LazyVim/LazyVim/issues/1973

What steps will reproduce the bug?

The steps to reproduce are similar to https://github.com/LazyVim/LazyVim/issues/1973, but I made additional configuration to use the system clang instead of downloading it through mason:

-- ~/.config/nvim/lua/plugins/clangd.lua
return {
  {
    "neovim/nvim-lspconfig",
    opts = {
      ---@type lspconfig.options
      servers = {
        clangd = {
          mason = false,
        },
      },
    },
  },
}

What is the expected behavior?

No response

System information

termux-info:

Termux Variables:
TERMUX_APK_RELEASE=F_DROID
TERMUX_APP_PACKAGE_MANAGER=apt
TERMUX_APP_PID=13441
TERMUX_IS_DEBUGGABLE_BUILD=0
TERMUX_MAIN_PACKAGE_FORMAT=debian
TERMUX_VERSION=0.118.0
TERMUX__USER_ID=0
Packages CPU architecture:
aarch64
Subscribed repositories:
# sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/termux/apt/termux-main stable main
Updatable packages:
All packages up to date
termux-tools version:
1.40.5
Android version:
14
Kernel build information:
Linux localhost 4.19.157-perf-gf2cf2f4ff68a #1 SMP PREEMPT Tue Jan 23 13:49:07 UTC 2024 aarch64 Android
Device manufacturer:
Xiaomi
Device model:
23043RP34C
LD Variables:
LD_LIBRARY_PATH=
LD_PRELOAD=/data/data/com.termux/files/usr/lib/libtermux-exec.so
Installed termux plugins:
com.termux.styling versionCode:31
TomJo2000 commented 7 months ago

Please provide the error you are getting verbatim next time. From a cursory glance I am guessing you are nesting the returned table one level too deeply.

If you have a look at the screenshot you can see the returned tables is wrapped in an extra table, which is not the format lazy.nvim is expecting. image

Bracket highlighting achieved with rainbow-delimiters.nvim

Please see if this resolves your issue.

-- ~/.config/nvim/lua/plugins/clangd.lua
return {
  "neovim/nvim-lspconfig",
  opts = {
    ---@type lspconfig.options
    servers = {
      clangd = {
        mason = false,
      },
    },
  },
}
YogiLiu commented 7 months ago

@TomJo2000 Thank you for your answer. I'm sorry that I didn't explain the problem clearly and I feel ashamed of my disrespectful behavior.

LazyVim is a Neovim setup powered by lazy.nvim, they are not the same project. So this problem has nothing to do with the format of lazy.vim.

I will now list my reproduction steps in detail. These steps are referenced from lazyvim's official website :

  1. Execute pkg update
  2. Install neovim and some dependencies: pkg install neovim git lazygit clang ripgrep fd make
  3. Clone the LazyVim starter: git clone https://github.com/LazyVim/starter ~/.config/nvim
  4. Remove the .git folder: rm -rf ~/.config/nvim/.git
  5. Launch neovim and wait for installation to complete
  6. Create ~/.config/nvim/lua/plugins/clangd.lua and write above lua code to it
  7. Enable lang.clangd in :LazyExtras and then restart neovim
  8. Open new file a.c and then type #include, the error message will appear in noice

The complete error message is ...ers/foo/.local/share/nvim/lazy/nvim-cmp/lua/cmp/view.lua:110: invalid order function for sorting.

According to https://github.com/LazyVim/LazyVim/issues/1973, the problem seems to be caused by the version of LuaJIT.

I originally encountered this problem on my tablet. In order to reproduce the problem, the above operations were completed on my mobile phone. The termux on the mobile phone was also newly installed.

Screenshot:

Screenshot_20240205-035833

TomJo2000 commented 7 months ago

Thank you for your answer. I'm sorry that I didn't explain the problem clearly and I feel ashamed of my disrespectful behavior.

Oh no worries you weren't being disrespectful, it's quite natural to make mistakes, that's how you learn.


I'm familar with LazyVim and lazy.nvim, though I do not use C/C++ or Clangd myself. So I'm not exactly sure how to interpret the error you have provided.

It's certainly possible LuaJIT is at fault, though that wouldn't immediately make sense to me.

TomJo2000 commented 7 months ago

I did some initial digging and our LuaJIT version is currently built against LuaJIT 2.1.1703358377. LuaJIT doesn't do numbered releases so the last part of the version number is a UNIX Epoch timestamp. This one translates to:

date -u --date='@1703358377'
# Sat Dec 23 07:06:17 PM UTC 2023

Which is newer than the versions mentioned in the LazyVim issue you mentioned, as such provided your LuaJIT is up to date with the version on the repos it should not be effected by the same bug.

YogiLiu commented 7 months ago

I have installed the latest version of LuaJIT, but the output of luajit -v is LuaJIT 2.1.0-beta3 -- Copyright (C) 2005-2021 Mike Pall. https://luajit.org/, and the output of nvim --version is

NVIM v0.9.5
Build type: Release
LuaJIT 2.1.0-beta3

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/data/data/com.termux/files/usr/share/nvim"

Run :checkhealth for more info
YogiLiu commented 7 months ago

Neovim seems to have built-in LuaJIT, and there is no need to install additional LuaJIT in the repos.

YogiLiu commented 7 months ago

I did some investigation, and it seems that this is caused by https://github.com/termux/termux-packages/issues/18847. The current LuaJIT version in the repos has actually been stuck at two years ago.

TomJo2000 commented 7 months ago

Ah that makes sense now. Do you mind if I close this as a duplicate of #18847 then?

YogiLiu commented 7 months ago

OK, I can subscribe https://github.com/termux/termux-packages/issues/18847 to follow the latest status.