From 5df13cf7c8b4a9039ec145da12d5d94cc59b2267 Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Thu, 12 May 2022 21:49:19 +0200 Subject: [PATCH] nvim: Macros! --- config/nvim/macros/cmd.fnl | 12 ++++++++++++ config/nvim/nifoc/theme.fnl | 12 ++++-------- programs/nvim/default.nix | 27 ++++++++++++++++++--------- 3 files changed, 34 insertions(+), 17 deletions(-) create mode 100644 config/nvim/macros/cmd.fnl diff --git a/config/nvim/macros/cmd.fnl b/config/nvim/macros/cmd.fnl new file mode 100644 index 0000000..811f95c --- /dev/null +++ b/config/nvim/macros/cmd.fnl @@ -0,0 +1,12 @@ +(let [mod {}] + (fn mod.colorscheme [name] + `(vim.api.nvim_cmd {:cmd :colorscheme :args [,name]} [])) + + (fn mod.highlight [name value] + `(vim.api.nvim_set_hl 0 ,name ,value)) + + (fn mod.highlight-link [src dst] + `(vim.api.nvim_cmd {:cmd :highlight :args [:link ,src ,dst]} [])) + + mod) + diff --git a/config/nvim/nifoc/theme.fnl b/config/nvim/nifoc/theme.fnl index 53cb914..eabbe94 100644 --- a/config/nvim/nifoc/theme.fnl +++ b/config/nvim/nifoc/theme.fnl @@ -1,19 +1,15 @@ +(import-macros {: colorscheme : highlight : highlight-link} :../macros/cmd) + (let [mod {} o vim.opt g vim.g - cmd vim.cmd dracula (require :dracula) - dracula-colors (dracula.colors) - highlight (partial vim.api.nvim_set_hl 0)] - (fn highlight-link [src dst] - (let [cmd-str (.. "highlight link " src " " dst)] - (cmd cmd-str))) - + dracula-colors (dracula.colors)] (fn mod.setup [] (set g.dracula_show_end_of_buffer false) (set g.dracula_italic_comment true) (set o.background :dark) - (cmd "colorscheme dracula") + (colorscheme :dracula) ;; vim-matchup (highlight :MatchParen {:fg dracula-colors.orange :bold true :italic true}) (highlight :MatchWord {:italic true}) diff --git a/programs/nvim/default.nix b/programs/nvim/default.nix index 5e45445..e6365ec 100644 --- a/programs/nvim/default.nix +++ b/programs/nvim/default.nix @@ -315,10 +315,16 @@ in mkdir -p $out/lua/nifoc/utils mkdir -p $out/after/ftplugin - fennel="fennel --use-bit-lib --compile" config_store_path="${../../config/nvim}" + fennel="fennel --use-bit-lib --compile" + + echo "Using fennel command: $fennel" + + # Change PWD to config directory + cd "$config_store_path" # Init + echo "Compiling init.fnl ..." $fennel "$config_store_path/init.fnl" > "$out/lua/configuration/init.lua" # Utils @@ -332,14 +338,6 @@ in $fennel "$fnlfile" > "$out/lua/nifoc/$file_out_path" done - # Plugins - cat <>plugins.fnl - ${config.programs.neovim.generatedConfigs.fennel} - nil - EOF - - $fennel "./plugins.fnl" > "$out/lua/configuration/plugins.lua" - # After after_store_path="$config_store_path/after" after_store_fnl="$(find "$after_store_path" -type f -name '*.fnl')" @@ -351,6 +349,17 @@ in $fennel "$fnlfile" > "$out/after/$file_out_path" done + # Plugins + echo "Compiling plugin configuration ..." + { + cat < "$out/lua/configuration/plugins.lua" + + # Other + echo "Copying tree-sitter queries ..." cp -r "$after_store_path/queries" "$out/after/" stylua "$out/"