Skip to content

Commit 4cbcfec

Browse files
committed
Fix #59 by looking up config from the project dir, not the cwd
1 parent c14926c commit 4cbcfec

File tree

4 files changed

+54
-45
lines changed

4 files changed

+54
-45
lines changed

fnl/nfnl/api.fnl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@
99

1010
(local M (define :nfnl.api))
1111

12-
(fn M.find-orphans [opts]
12+
(fn M.find-orphans [{: passive? : dir}]
1313
"Find orphan Lua files that were compiled from a Fennel file that no longer exists. Display them with notify. Set opts.passive? to true if you don't want it to tell you that there are no orphans."
14-
(let [dir (vim.fn.getcwd)
14+
(let [dir (or dir (vim.fn.getcwd))
1515
{: config : root-dir : cfg} (config.find-and-load dir)]
1616
(if config
1717
(let [orphan-files (gc.find-orphan-lua-files {: root-dir : cfg})]
1818
(if (core.empty? orphan-files)
19-
(when (not (core.get opts :passive?))
19+
(when (not passive?)
2020
(notify.info "No orphan files detected."))
2121
(notify.warn
2222
"Orphan files detected, delete them with :NfnlDeleteOrphans.\n"
@@ -30,9 +30,9 @@
3030
(notify.warn "No .nfnl.fnl configuration found.")
3131
[]))))
3232

33-
(fn M.delete-orphans []
33+
(fn M.delete-orphans [{: dir}]
3434
"Delete orphan Lua files that were compiled from a Fennel file that no longer exists."
35-
(let [dir (vim.fn.getcwd)
35+
(let [dir (or dir (vim.fn.getcwd))
3636
{: config : root-dir : cfg} (config.find-and-load dir)]
3737
(if config
3838
(let [orphan-files (gc.find-orphan-lua-files {: root-dir : cfg})]

fnl/nfnl/callback.fnl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,9 @@
2424
:source (nvim.get-buf-content-as-string (. ev :buf))})
2525

2626
(when (cfg [:orphan-detection :auto?])
27-
(api.find-orphans {:passive? true}))
27+
(api.find-orphans
28+
{:dir root-dir
29+
:passive? true}))
2830

2931
nil))
3032

@@ -85,15 +87,19 @@
8587

8688
(vim.api.nvim_buf_create_user_command
8789
ev.buf :NfnlFindOrphans
88-
#(api.find-orphans)
90+
#(api.find-orphans {:dir (core.first (core.get $ :fargs))})
8991
{:desc "Executes (nfnl.api/find-orphans) which will find and display all Lua files that no longer have a matching Fennel file."
90-
:force true})
92+
:force true
93+
:complete "file"
94+
:nargs "?"})
9195

9296
(vim.api.nvim_buf_create_user_command
9397
ev.buf :NfnlDeleteOrphans
94-
#(api.delete-orphans)
98+
#(api.delete-orphans {:dir (core.first (core.get $ :fargs))})
9599
{:desc "Executes (nfnl.api/delete-orphans) deletes any orphan Lua files that no longer have their original Fennel file they were compiled from."
96-
:force true}))))))
100+
:force true
101+
:complete "file"
102+
:nargs "?"}))))))
97103

98104
{: fennel-filetype-callback
99105
: supported-path?}

lua/nfnl/api.lua

Lines changed: 31 additions & 28 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lua/nfnl/callback.lua

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)