Giter Club home page Giter Club logo

Comments (2)

nanotee avatar nanotee commented on May 18, 2024 2

Thanks! I had your issue in mind when writing this, it's part of what prompted me to start the guide

My understanding of the differences if you're not doing anything with modules is basically the same as yours:

  • :luafile will execute a script regardless of whether it's been executed before
  • :luafile, being an ex command, takes a path that's either absolute or relative to the working directory of the current window
  • :lua require('foo') prevents the script from being parsed and executed a second time (unless you're setting package.loaded['foo'] to nil or false)
  • :lua require('foo') uses package.path to search for modules

I'm far from being a Lua expert though, so there might be other things to take into account.

It'd be good to add a section explaining these differences, although I would expect :luafile to become less useful once Neovim supports loading init.lua directly. Not really sure where such a section would go, maybe after v:lua?

from nvim-lua-guide.

clason avatar clason commented on May 18, 2024

Thanks! I had your issue in mind when writing this, it's part of what prompted me to start the guide

I was wondering whether it was a coincidence that it addressed so many of my questions directly :)

It'd be good to add a section explaining these differences, although I would expect :luafile to become less useful once Neovim supports loading init.lua directly. Not really sure where such a section would go, maybe after v:lua?

I think it's sufficient to make a brief remark on this in the section on luafile -- that's where I expect people (like me) have the question "should I do this or lua require then? does it make a difference?"

(Not sure it'll become obsolete, although that depends on how exactly init.lua is handled. I use it for sourcing small lua-only plugin configurations, for which I'd use config/plugin files in vimscript -- if lua files are automatically sourced in that directory, I do indeed see this becoming less useful.)

from nvim-lua-guide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.