Closed raven2cz closed 1 year ago
use the emmylua annotation will help the go to declaration
use the emmylua annotation will help the go to declaration
I tried it. And it doesn't work.
I have for example directory fishlive/layout
and there is file init.lua
where is the declaration of the fishlive.layout
module. So, I insert the annotation to this init.lua
document for the layout declaration:
---@module 'fishlive.layout'
local layout = { _NAME = "fishlive.layout" }
and this layout module is used in the rc.lua
file, like:
fishlive.layout.mirrored_tile.left
I tried to navigate to the @module 'fishlive.layout'
but it doesn't see it.
This is not emmylua annotation syntax, here should be
-- fishlive/layout.lua
---@class fishlive.layout
local layout = { _NAME = "fishlive.layout" }
return layout
and init,lua
-- init.lua
---@class fishlive
local fishlive = {}
---@type fishlive.layout
fishlive.layout = require "fishlive.layout"
almost winning. The linkage between init.lua
and layout.lua
with type and class works correctly.
The problem is still with rc.lua
. I signed with type
the fishlive module in the required path. So, in rc.lua
is new this:
---@type fishlive
local fishlive = require("fishlive")
So if I press ctrl+b on the type line, it is correctly jump to the appropriate directory to the init.lua
.
But I'm on the this line in the rc.lua
fishlive.layout.mirrored_tile.left
and I expect that the press ctrl+b on the layout
it jump to fishlive.layout
, but nothing happen. Ctrl+b on the fishlive jump to the required line on the top of rc.lua
. Is it possible to wire the fishlive.layout.mirrored_tile.left
to map fishlive.layout
declared class?
Ctrl b will jump to his definition
fishlive.layout = ...
define in init.lua, it will jump to init.lua if it define in layout.lua it will jump to layout.lua Or you accept the jump twice,first jump to init.lua and jump to the layout .lua by type fishlive.layout Jump work correctly in my machine.
It is too late now, If you have any questions, I'll see it tomorrow
So, thanks for help. Last question. Can you give me full example how to correctly navigate my basic line which I used very often?
fishlive.layout.mirrored_tile.left
First It means to navigate to fishlive.layout
submodule,
and second navigate to the defined table in the layout itself mirrored_tile
.
What is your best practice to annotate or use other techniques with emmylua? Or some tricks which quick navigation.
see navigate.zip and some practice resty api
Thanks for your examples. It very helps. I see the problem now.
The problem is organization of modules which are used. I attached image.
Our Lua Modules are organized by directories (packages), not by files. Each module is defined by init.lua
file which describes the parent module (for example fishlive
) or submodule (e.g. layout
).
Submodule is declared by standard mechanism without .init
suffix. It means layout = require "fishlive.layout"
not "fishlive.layout.init"
. mirrored_tile.lua
file is automatically attached to the module where is placed.
I tried to test it, and it seems that the linkage works if the .init
suffixes are used, but it doesn't work for approach package module structure without .init
. Is there some possibility to involve general/common mapping with init.lua
module declarations?
I guess, this issue duplicates #415 now. Maybe should focus on one of those...
I guess, this issue duplicates #415 now. Maybe should focus on one of those...
The author has been busy, so the problem is not solved yet. I also have a lot of projects mentioned.
I started to use vscode with lua integration. It works perfectly for awesomewm.
I'm using very often emmy lua in idea for AwesomeWM implementation.
It's working good. I'm big fan of this approach. There is one topic which can improve my work and speed up my process very rapidly.
The feature Go to declaration (ctrl+B) works very good if the expression corresponds with library name. For example,
naughty.notify()
is correctly navigated tonaughty.lua
it is correct.But for example:
awful.keyboard.append_client_keybindings()
, The aweful is the library defined by directoryawful/init.lua
and thekeyboard.lua
is declared in theinit.lua
and thekeyboard.lua
is placed in the directory awful. But this is not matched and jump to declaration doesn't work, it is not possible to jump tokeyboard.lua
too. No match found.Is it possible to extend Go to declaration for standard usage with directory and included lib files, like:
aweful/init.lua
andaweful/keyboard.lua
=>awful.keyboard.append_client_keybindings()
For more info, you can install awesome package, and look to libraries in
/usr/share/awesome/lib
package.I understand that always there will be dynamic linkages, lua is very dynamic. But this behavior with directory and inside libraries with same name is fixed concept which I see many times in different projects too.