diff --git a/config/nvim/fnl/autocolors.fnl b/config/nvim/fnl/autocolors.fnl new file mode 100644 index 0000000..02375f9 --- /dev/null +++ b/config/nvim/fnl/autocolors.fnl @@ -0,0 +1,18 @@ +; +; This file is to be called AFTER the color plugins have been loaded +; +(fn set-theme-for-directory [] + (let [cwd (vim.fn.getcwd) + directory-themes {:acide/trazo-backend :github_light + :acide/trazo-frontend :onelight + :csharp :caret + :zig :ayu-dark}] + (var theme "randomhue") + (each [dir dir-theme (pairs directory-themes)] + (when (string.find cwd dir 1 true) (set theme dir-theme) (lua :break))) + (vim.cmd (.. "colorscheme " theme)))) + +(vim.api.nvim_create_autocmd [:DirChanged] + {:callback (fn [] (set-theme-for-directory))}) + +(set-theme-for-directory) diff --git a/config/nvim/fnl/config.fnl b/config/nvim/fnl/config.fnl index ee4a1e5..09e41ef 100644 --- a/config/nvim/fnl/config.fnl +++ b/config/nvim/fnl/config.fnl @@ -76,20 +76,5 @@ :group (vim.api.nvim_create_augroup :kickstart-highlight-yank {:clear true})}) -(fn set-theme-for-directory [] - (let [cwd (vim.fn.getcwd) - directory-themes {:acide/trazo-backend :github_light - :acide/trazo-frontend :onelight - :csharp :caret - :zig :ayu-dark}] - (var theme "vim") - (each [dir dir-theme (pairs directory-themes)] - (when (string.find cwd dir 1 true) (set theme dir-theme) (lua :break))) - (vim.cmd (.. "colorscheme " theme)))) - -(vim.api.nvim_create_autocmd [:DirChanged] - {:callback (fn [] (set-theme-for-directory))}) - -(set-theme-for-directory) (print "I have been setup with Fennel :D") diff --git a/config/nvim/init.lua b/config/nvim/init.lua index 8297e5b..b662153 100644 --- a/config/nvim/init.lua +++ b/config/nvim/init.lua @@ -49,3 +49,6 @@ require("lazy").setup({ { import = "plugins" }, }, }) + +-- set color theme depending on the current folder +require("autocolors")