File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -125,18 +125,41 @@ require("focal").setup({
125125
126126## Custom Sources
127127
128- Register adapters for unsupported file explorers:
128+ Register adapters for unsupported file explorers. Sources can be registered before or after ` setup() ` — order doesn't matter :
129129
130130``` lua
131131require (" focal" ).register_source ({
132132 filetype = " my_explorer" ,
133133 get_path = function ()
134134 -- return the absolute path of the file under cursor, or nil
135- return " /path/to/image.png"
135+ local node = require (" my_explorer" ).get_current_node ()
136+ if node and node .type == " file" then
137+ return node .absolute_path
138+ end
139+ return nil
136140 end ,
137141})
138142```
139143
144+ With lazy.nvim, use ` opts ` as normal — focal handles queuing:
145+
146+ ``` lua
147+ {
148+ " hmdfrds/focal.nvim" ,
149+ event = " VeryLazy" ,
150+ dependencies = { " 3rd/image.nvim" },
151+ opts = {},
152+ init = function ()
153+ require (" focal" ).register_source ({
154+ filetype = " my_explorer" ,
155+ get_path = function ()
156+ return require (" my_explorer" ).get_file_under_cursor ()
157+ end ,
158+ })
159+ end ,
160+ }
161+ ```
162+
140163## Custom Renderers
141164
142165Register renderers for new file types:
You can’t perform that action at this time.
0 commit comments