natecraddock / telescope-zf-native.nvim

native telescope bindings to zf for sorting results
MIT License
145 stars 5 forks source link

add hint how to correctly setup luarocks for luajit in neovim xor fetch artifacts in lazy #21

Closed matu3ba closed 2 hours ago

matu3ba commented 1 week ago

I have system-setup with lua 5.4 (default). The error :Lazy sync shows

  Failed (1)
    ● telescope-zf-native.nvim 0.11ms  start
        ...al/share/nvim/lazy/lazy.nvim/lua/lazy/manage/task/fs.lua:9: /home/misterspoon/.local/share/nvim/lazy/telescope-zf-native.nvim should be a directory!
        `lua` version `5.1` needed, but found `Lua 5.4.6  Copyright (C) 1994-2023 Lua.org, PUC-Rio`
        `lua5.1` or `lua` version `5.1` not installed

        This plugin requires `luarocks`. Try one of the following:
         - fix your `luarocks` installation
         - enable `hererocks` with `opts.rocks.hererocks = true`
         - disable `luarocks` support completely with `opts.rocks.enabled = false`

See also lazy error https://github.com/folke/lazy.nvim/issues/1575

If I change my usage of lazy to require('lazy').setup('my_plugins', { pkg = { sources = "" } }), then I get

Build (1)
● telescope-zf-native.nvim 0.33ms  start     ■ needs build
    dir     /home/misterspoon/.local/share/nvim/lazy/telescope-zf-native.nvim
    url     https://github.com/natecraddock/telescope-zf-native.nvim
    version 1.0.0
    tag     v1.0.0
    branch  master
    commit  3f565ad
    readme  README.md
  ✔ [task] fetch 2058.41ms
    Anfordern des Submoduls zf
    Anfordern des Submoduls zf/lib/ziglyph
  ✔ [task] status 14.55ms
  ✔ [task] checkout 0.08ms

The problem was introduced with d746bfa.

After experimentation I found out this worked:

require('lazy').setup('my_plugins', { rocks = { enabled = false } })

However is that intended how it should be solved?

NTBBloodbath commented 1 week ago

Hi,

This problem is due to the fact that lazy.nvim uses Lua5.1 for luarocks integration since it is the version that Neovim uses. I think installing the lua5.1 package (name may vary depending on Linux distribution) would be enough for it to work.

I'm not too sure about the error below about the absence of luarocks. Is it installed on your system? If not, you could try the hererocks hint from the error message in your lazy.nvim configuration.

natecraddock commented 1 week ago

Hmm I didn't realize adding the rockspec stuff would interfere with normal package installation...

It looks like from https://github.com/folke/lazy.nvim/issues/1576 you should set opts.pkg.sources to nil? Does that work for you?

NTBBloodbath commented 1 week ago

Hmm I didn't realize adding the rockspec stuff would interfere with normal package installation...

In theory it shouldn't, but the implementation of luarocks in lazy.nvim was done very hastily and without a proper setup to treat it like a first-class citizen (it doesn't even have sane defaults when luarocks isn't installed it seems) :/

Let's wait for @matu3ba's response to find out how he solved the problem and add some installation notes to the readme in case someone else runs into this issue.

matu3ba commented 6 days ago

It looks like from https://github.com/folke/lazy.nvim/issues/1576 you should set opts.pkg.sources to nil? Does that work for you?

require('lazy').setup('my_plugins', { pkw = { sources = nil } })

fails with

Failed (1)
● telescope-zf-native.nvim 0.19ms  start     ■ build failed
    `lua` version `5.1` needed, but found `Lua 5.4.6  Copyright (C) 1994-2023 Lua.org, PUC-Rio`
    `lua5.1` or `lua` version `5.1` not installed

    This plugin requires `luarocks`. Try one of the following:
    ╎- fix your `luarocks` installation
    ╎- enable `hererocks` with `opts.rocks.hererocks = true`
    ╎- disable `luarocks` support completely with `opts.rocks.enabled = false`

However, it at least suggests one working for me solution of opts.rocks.enabled = false boiling down to

require('lazy').setup('my_plugins', { rocks = { enabled = false } })

Proper usage of luarocks with multiple lua and luajit versions.

After some investigation, it looks like nobody bothered to write docs on luarocks repo. It depends on the distro, if they support multipe versions, otherwise one has to use luarocks installations for the specific lua(jit) version. https://stackoverflow.com/questions/30362466/with-multiple-versions-of-lua-installed-is-it-possible-to-specify-which-one-luar

Only switching between lua(jit) versions can be done via https://github.com/DhavalKapil/luaver, which boils down to something like http://lua-users.org/wiki/LuaRocksConfig or https://www.reddit.com/r/lua/comments/18yci9m/luarocks_how_do_i_change_the_installation/.

Luarocks itself can be configured via https://github.com/luarocks/luarocks/wiki/config and queried via lurocks config for which I have

      file = "/home/misterspoon/.luarocks/config-5.1.lua",

and content of config-5.1.lua is

lua_version = "5.1"

From what I understand nlua invokage is properly managed by https://github.com/mfussenegger/nlua, but I need to read through the lazy code to understand how luarocks can be invoked to not use the system default and instead neovim luajit. Unfortunately the docs are not good on that, meaning there is no :help lazy.nvim-X-luarocks.

Not having luajit getting picked up by lazy to be used in luarocks feels like a bad default though.

natecraddock commented 3 hours ago

Hmm. So does my plugin need to do anything different here? Or is this an issue in lazy.nvim?

matu3ba commented 3 hours ago

Hmm. So does my plugin need to do anything different here? Or is this an issue in lazy.nvim?

The issue is in lazy.nvim, which provides no sane defaults for luarocks. A hint in the README to use something like require('lazy').setup('my_plugins', { rocks = { enabled = false } }) would be nice though.

The main point of this issues is to guide others running into the same problem.

Otherwise, feel free to close.

natecraddock commented 2 hours ago

Added a note to the readme! Thanks and sorry for the trouble