Comments (34)
Here is an example in "workspace.lua"
nvim-ide/lua/ide/workspaces/workspace.lua
Line 44 in ca17635
As you can see, you should be able to access config like a global with "require("ide").config". Im not sure why this wouldnt work for you.
from nvim-ide.
I will give it a quick try but you might have to do it because I'm going away and won't be able to work on it.
from nvim-ide.
How can I get the log_level
value from the config into the logger.lua file?
I tried to do require('ide')
at the top of the logger file and then access the config table from that but it gave an error saying there was an error loading the module.
from nvim-ide.
Hmm ok, i'll see if i might have been doing something wrong. thanks
from nvim-ide.
After playing around with things I still can't get the require to work. The error it gives me is loop or previous error loading module 'ide'
and I can't find anywhere where it would be a loop (unless I don't completely understand lua's require system).
from nvim-ide.
Hey @ldelossa I was looking in to this and I see what BeeverFeever was saying; There's a module dep loop when it comes to requiring 'ide' inside of logger due to the panels already requiring it.
I believe we talked about it before, but how would you feel about if, instead of obtaining a copy of the config in whichever modules need it, we global the config and copy in to it on init so we can just call IDEConfig.whatever
instead?
Not sure what I was thinking there, that's not how globals work. Could we instead just cascade down the config? Otherwise, I'm not sure how else we can get the config into logger properly.
from nvim-ide.
If we move config out of init.lua, to its own file, and update all the imports, this solves the issue, right?
The config module can be "export only" which should break any loops.
from nvim-ide.
I think that will work. Do you want a PR for it?
from nvim-ide.
Yup!
from nvim-ide.
@BeeverFeever Do you want to work on this? If not, I can go at it later today.
from nvim-ide.
Sounds good, just let me know.
from nvim-ide.
Ok will do.
from nvim-ide.
Quick question, with the panel_groups in the config, do you think they should just be set in the setup function in init.lua
before mergeing the users config? Otherwise a require is needed in config.lua
(the new file with the default config)
from nvim-ide.
I think doing the requires in the config.lua
is fine? Maybe by doing something like:
local bufferlist = require('ide.components.bufferlist').Name
from nvim-ide.
Ok I'll see if that might work.
from nvim-ide.
Should work, the init.lua files in each component dir dont need to refer to config.
from nvim-ide.
It still doesn't work. The only way I can think of getting it to work is by hard coding the values in. So for example you just put the name of the components you want as a string rather than using a require.
from nvim-ide.
@ldelossa The problem is that the components are referring to logger though.
from nvim-ide.
@BeeverFeever yes I see.
main...refactor-for-logger - Here is a base refactor, I think this is fine, we'll just expose a method in the logger which sets the log level, and not give it the full config.
Want to use this as base to work the rest of the PR out?
from nvim-ide.
Yeah sure, that looks pretty good.
from nvim-ide.
@ldelossa Just wondering, do you want to use the vim.log.levels.
for the logger levels or could I go with something where we set a table of log levels, like:
(in logger.lua)
local log_levels = {
['debug'] = 1,
['error'] = 2,
['warning'] = 3,
['info'] = 4,
}
and then use those values to detect whether to log the message or not?
from nvim-ide.
This is what I've got so far. BeeverFeever/nvim-ide@47225a6
from nvim-ide.
The 'set_log_level' probably take either a string, or an integer. But the log_level variable should probably be an int, so you can determine if you should log with a '>' or '<' evaluation.
from nvim-ide.
Ok sounds good. I will make those changes and tidy it up then make a pr if it looks good to you otherwise?
from nvim-ide.
Also one more thing sorry, how would I run the logger tests?
from nvim-ide.
Your diff looks fine, maybe we add a function which checks the incoming log_level variable to see if its a string or int, and attempt to return an integer.
Then we can do one more pass which removes all the strings in favor of using vim.log.levels
directly. If we feel thats better.
from nvim-ide.
Yeah that sounds better than using strings. Just wanted to make sure, did you want it to only log the level that is set by Logger.log_level
or did you want it to log the set level and anything 'higher' than it?
from nvim-ide.
Log level and higher. So if you set for "debug" it should log debug and all higher levels.
Tests are best effort so far. You can add them if youd like.
from nvim-ide.
Ok thanks, how would I run the tests?
from nvim-ide.
We don't have automated tests at this point. Most of the time I run tests manually to confirm something works.
from nvim-ide.
Ahh ok fair enough
from nvim-ide.
I have done a bit but I ran into a problem where it seemed like Logger.log_level
was just being set to nil and I was getting an error saying attempt to compare number with nil
. I have no clue why this is happening.
BeeverFeever/nvim-ide@020a211
I hate leaving this broken right now but I just don't have any more time right now to work on it. If someone else wants to look at it they can or I will pick it up again in a couple days to see if I can get it to work.
from nvim-ide.
@distek did you want to take it from here? If not I will.
@BeeverFeever no worries - glad you got to take a stab at it.
from nvim-ide.
Still needs an over-all logging pass, to place info logs in more appropriate places, but the leveled logging stuff is done.
from nvim-ide.
Related Issues (20)
- Can you provide a docker image?
- Error on neovim exit HOT 7
- newlines in Outline causing error HOT 7
- Option to prevent terminal browser auto open on start HOT 2
- Cannot leave terminal in VI mode HOT 1
- Error while calling lua chunk: attempt to index a boolean value in nvim-ide plugin HOT 1
- "Unknown function: rand" Error while loading nvim-ide HOT 2
- When there are other panels (dap-ui), opening a diff would messed up the layout
- `:Workspace RightPanelToggle` from a keymap doesn't work the first time, unless you do a keymap for `:Workspace LeftPanelToggle` first HOT 2
- Attempt to concatenate field 'name' (a nil value) HOT 9
- Expected lua string HOT 6
- error on focus of hidden component
- Warning at launch HOT 2
- Fail to expand file Explorer HOT 4
- Question mark icons in outline even when nerd font is installed HOT 3
- Explorer holds on to cwd when tab was created HOT 6
- Error when starting more than one terminal from terminal browser HOT 5
- Explorer: When you create a file, if cursor is over a non-expanded directory, it should create the file in the parent directory HOT 4
- More questions than problems HOT 1
- Panel size changes when terminal is created HOT 5
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 nvim-ide.