Comments (5)
I don't know if I can provide a very good explanation for it, but the basic idea is described here:
wincent/aspects/nvim/files/.config/nvim/lua/wincent/autoload.lua
Lines 1 to 23 in c298fa7
The "normal/idiomatic" Lua way to do this kind of thing would be to not have autoloading at all. Any time you need anything you would write require'something'
, and if you need to use it multiple times, you write out the require
multiple times β because modules are cached, these subsequent calls don't re-evaluate the module; they just return the already-loaded module.
The specific line you cite was added in f53783e, which says:
refactor(nvim): streamline global access
Yes, globals are evil, but it is 2 AM and I reserve the right to exercise poor judgment at this time of night.
Seriously though, I think the streamlining here makes for some real usability benefits (for example, see the improvement we get from doing
v:lua.wincent.something.blah()
as opposed toluaeval("require'wincent.something'.blah()")
; the quoting becomes dramatically simpler and less error prone), so I think it's worth it.
As you can see in that commit, this allowed me to remove a bunch of require'wincent'
calls and then just directly access "autoloaded" functions by chaining them off the wincent
global (eg. wincent.vim.setlocal
).
Overall I would describe all this as a "cute hack", but not necessarily a pattern I have seen anywhere else or would actively recommend. It might be a bit too magical to be a good idea. Does that answer your question, @SingularisArt?
from wincent.
Yes. Thank you.
Also, I've learned a ton from your youtube videos and I was wondering if you could create a youtube video talking about your neovim setup and how you configure your things. Like, the structure of the config and describe what each file/folder is doing.
from wincent.
Quick question regarding the usage of this function. I have all of my plugin configuration located at lua/SingularisArt/plugins
and I have a ton of files in there. How can I use this function to require all of the files in that directory?
My init.lua
in the lua/SingularisArt/plugins
directory is where I add my plugins using packer
. I tried to add this at the end of my init.lua
file:
return SingularisArt.autoload('SingularisArt.plugins')
You can view it here.
Thanks for your help and your time!
from wincent.
What you've got in there right now looks about right to me βΒ is it working?
from wincent.
Finally, I got it to work. I just had some problems with another file.
Thanks so much!
from wincent.
Related Issues (20)
- Print timing info at end of run
- nvim does not respect local settings HOT 2
- This line only works in .vim files HOT 2
- Undefined global key HOT 2
- E117: Unknown function: <SNR>140_CheckColorScheme HOT 2
- use Docker HOT 2
- Consider using some limited parallelism during install HOT 1
- Mutt HOT 3
- Figure out pattern for project-local reusable helpers
- Migrate to `vim.keymap` Lua API (new in Neovim v0.7.0)
- Implement "not" semantics for specifying which aspects to install
- zsh prompt looks weird HOT 2
- How does everything work?
- Statusline isn't working as expected HOT 6
- error while running a full install. netcat has no installation candidate HOT 4
- Prompt with non-breaking space doesn't work in Alacritty, ideas?
- Set up nvim-treesitter
- Figure out what is turning off `'spell'` in Markdown files HOT 1
- Consider using `includeIf` in Git config
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wincent.