|
1 | | -(local {: autoload} (require :nfnl.module)) |
| 1 | +(local {: autoload : define} (require :nfnl.module)) |
2 | 2 | (local core (autoload :nfnl.core)) |
3 | 3 | (local str (autoload :nfnl.string)) |
4 | 4 | (local fs (autoload :nfnl.fs)) |
|
7 | 7 | (local config (autoload :nfnl.config)) |
8 | 8 | (local api (autoload :nfnl.api)) |
9 | 9 | (local notify (autoload :nfnl.notify)) |
| 10 | +(local vim _G.vim) |
| 11 | + |
| 12 | +(local M (define :nfnl.callback)) |
10 | 13 |
|
11 | 14 | (fn fennel-buf-write-post-callback-fn [root-dir cfg] |
12 | 15 | "Builds a function to be called on buf write. Adheres to the config passed |
|
30 | 33 |
|
31 | 34 | nil)) |
32 | 35 |
|
33 | | -(fn supported-path? [file-path] |
| 36 | +(fn M.supported-path? [file-path] |
34 | 37 | "Returns true if we can work with the given path. Right now we support a path if it's a string and it doesn't start with a protocol segment like fugitive://..." |
35 | 38 | (or |
36 | 39 | (when (core.string? file-path) |
37 | 40 | (not (file-path:find "^[%w-]+:/"))) |
38 | 41 | false)) |
39 | 42 |
|
40 | | -(fn fennel-filetype-callback [ev] |
| 43 | +(fn M.fennel-filetype-callback [ev] |
41 | 44 | "Called whenever we enter a Fennel file. It walks up the tree to find a |
42 | 45 | .nfnl.fnl (which can contain configuration). If found, we initialise the |
43 | 46 | compiler autocmd for the directory containing the .nfnl.fnl file. |
|
46 | 49 | different .nfnl.fnl configuration, wonderful!" |
47 | 50 |
|
48 | 51 | (let [file-path (fs.full-path (. ev :file))] |
49 | | - (when (supported-path? file-path) |
| 52 | + (when (M.supported-path? file-path) |
50 | 53 | (let [file-dir (fs.basename file-path) |
51 | 54 | {: config : root-dir : cfg} (config.find-and-load file-dir)] |
52 | 55 |
|
|
101 | 104 | :complete "file" |
102 | 105 | :nargs "?"})))))) |
103 | 106 |
|
104 | | -{: fennel-filetype-callback |
105 | | - : supported-path?} |
| 107 | +M |
0 commit comments