willothy / moveline.nvim

Neovim plugin for moving lines up and down
MIT License
137 stars 4 forks source link

Can't require() moveline plugin #8

Closed korniychuk closed 1 year ago

korniychuk commented 1 year ago

Here is the call function() require('moveline').up() end.

E5108: Error executing lua: /Users/anton/.config/nvim/lua/user/mappings.lua:74: module 'moveline' not found:
        no field package.preload['moveline']
        no file './moveline.lua'
        no file '/opt/homebrew/share/luajit-2.1.0-beta3/moveline.lua'
        no file '/usr/local/share/lua/5.1/moveline.lua'
        no file '/usr/local/share/lua/5.1/moveline/init.lua'
        no file '/opt/homebrew/share/lua/5.1/moveline.lua'
        no file '/opt/homebrew/share/lua/5.1/moveline/init.lua'
        no file '/Users/anton/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/moveline.lua'
        no file '/Users/anton/.cache/nvim/packer_hererocks/2.1.0-beta3/share/lua/5.1/moveline/init.lua'
        no file '/Users/anton/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/moveline.lua'
        no file '/Users/anton/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/luarocks/rocks-5.1/moveline/init.lua'
        no file './moveline.so'
        no file '/usr/local/lib/lua/5.1/moveline.so'
        no file '/opt/homebrew/lib/lua/5.1/moveline.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file '/Users/anton/.cache/nvim/packer_hererocks/2.1.0-beta3/lib/lua/5.1/moveline.so'
stack traceback:
        [C]: in function 'require'
        /Users/anton/.config/nvim/lua/user/mappings.lua:74: in function </Users/anton/.config/nvim/lua/user/mappings.lua:74>
Press ENTER or type command to continue

❯ nvim --version NVIM v0.9.0 Build type: Release LuaJIT 2.1.0-beta3

❯ rustc --version rustc 1.69.0 (84c898d65 2023-04-16) (built from a source tarball)

❯ lua -v Lua 5.4.4 Copyright (C) 1994-2022 Lua.org, PUC-Rio

In :checkhelth there is no moveline plugin.

Packer Status shows the plugin as installed.

image
willothy commented 1 year ago

Are you sure it built properly? Have you tried rebuilding the plugin manually?

korniychuk commented 1 year ago

I'm not sure. Give me please some recommendations about:

  1. How to check that it is built properly? (Packer.nvim didn't show any errors after I installed Rust)
  2. How to rebuild manually?
cgbur commented 1 year ago

edit: realized I had misconfiguration, here is the same error,

with lazy

return {
    'willothy/moveline.nvim',
    build = 'make',
    lazy = true,
    init = function()
        require("config.utils").load_mapping "moveline"
    end,
}

leads to the same not found error.

E5108: Error executing lua [string ":lua"]:1: module 'moveline' not found:
        no field package.preload['moveline']
cache_loader: module moveline not found
cache_loader_lib: module moveline not found
        no file './moveline.lua'
        no file '/home/cgbur/neovim/.deps/usr/share/luajit-2.1.0-beta3/moveline.lua'
        no file '/usr/local/share/lua/5.1/moveline.lua'
        no file '/usr/local/share/lua/5.1/moveline/init.lua'
        no file '/home/cgbur/neovim/.deps/usr/share/lua/5.1/moveline.lua'
        no file '/home/cgbur/neovim/.deps/usr/share/lua/5.1/moveline/init.lua'
        no file './moveline.so'
        no file '/usr/local/lib/lua/5.1/moveline.so'
        no file '/home/cgbur/neovim/.deps/usr/lib/lua/5.1/moveline.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        [string ":lua"]:1: in main chunk

when lazy = false, everything seems fine. Maybe this has to do with the native plugin? Do not have this with other plugins.

willothy commented 1 year ago

I've looked into this a bit, and it appears to be related to lazy.nvim and not this plugin. When lazy-loading a native plugin you need to specify an event, key, etc. to load the plugin correctly. Otherwise, you cannot lazy load it.