From 2a5e85e052ec00d90bd3b87dc111cd3212845fba Mon Sep 17 00:00:00 2001 From: Daniel Kempkens Date: Tue, 5 Apr 2022 23:13:56 +0200 Subject: [PATCH] nvim: Convert after hooks to fnl --- config/nvim/after/ftplugin/NvimTree.vim | 1 - config/nvim/after/ftplugin/elixir.fnl | 4 ++ config/nvim/after/ftplugin/elixir.vim | 6 --- config/nvim/after/ftplugin/erlang.vim | 1 - config/nvim/after/ftplugin/gitcommit.fnl | 3 ++ config/nvim/after/ftplugin/gitcommit.vim | 2 - config/nvim/after/ftplugin/list.vim | 6 --- config/nvim/after/ftplugin/make.fnl | 4 ++ config/nvim/after/ftplugin/make.vim | 3 -- config/nvim/after/ftplugin/markdown.fnl | 2 + config/nvim/after/ftplugin/markdown.vim | 1 - config/nvim/after/ftplugin/pandoc.vim | 1 - config/nvim/after/ftplugin/qf.vim | 6 --- config/nvim/after/ftplugin/text.fnl | 2 + config/nvim/after/ftplugin/text.vim | 1 - programs/nvim/default.nix | 59 +++++++++++++----------- 16 files changed, 48 insertions(+), 54 deletions(-) delete mode 100644 config/nvim/after/ftplugin/NvimTree.vim create mode 100644 config/nvim/after/ftplugin/elixir.fnl delete mode 100644 config/nvim/after/ftplugin/elixir.vim delete mode 100644 config/nvim/after/ftplugin/erlang.vim create mode 100644 config/nvim/after/ftplugin/gitcommit.fnl delete mode 100644 config/nvim/after/ftplugin/gitcommit.vim delete mode 100644 config/nvim/after/ftplugin/list.vim create mode 100644 config/nvim/after/ftplugin/make.fnl delete mode 100644 config/nvim/after/ftplugin/make.vim create mode 100644 config/nvim/after/ftplugin/markdown.fnl delete mode 100644 config/nvim/after/ftplugin/markdown.vim delete mode 100644 config/nvim/after/ftplugin/pandoc.vim delete mode 100644 config/nvim/after/ftplugin/qf.vim create mode 100644 config/nvim/after/ftplugin/text.fnl delete mode 100644 config/nvim/after/ftplugin/text.vim diff --git a/config/nvim/after/ftplugin/NvimTree.vim b/config/nvim/after/ftplugin/NvimTree.vim deleted file mode 100644 index 3b9b72a..0000000 --- a/config/nvim/after/ftplugin/NvimTree.vim +++ /dev/null @@ -1 +0,0 @@ -setlocal signcolumn=no diff --git a/config/nvim/after/ftplugin/elixir.fnl b/config/nvim/after/ftplugin/elixir.fnl new file mode 100644 index 0000000..f5c1584 --- /dev/null +++ b/config/nvim/after/ftplugin/elixir.fnl @@ -0,0 +1,4 @@ +(let [lo vim.opt_local] + (set lo.spell true) + (set lo.textwidth 120) + (set lo.colorcolumn :+1)) diff --git a/config/nvim/after/ftplugin/elixir.vim b/config/nvim/after/ftplugin/elixir.vim deleted file mode 100644 index 97b21a0..0000000 --- a/config/nvim/after/ftplugin/elixir.vim +++ /dev/null @@ -1,6 +0,0 @@ -setlocal comments=:# -setlocal commentstring=#\ %s - -setlocal spell -setlocal textwidth=120 -setlocal colorcolumn=+1 diff --git a/config/nvim/after/ftplugin/erlang.vim b/config/nvim/after/ftplugin/erlang.vim deleted file mode 100644 index 0e49e55..0000000 --- a/config/nvim/after/ftplugin/erlang.vim +++ /dev/null @@ -1 +0,0 @@ -iabbrev <= =< diff --git a/config/nvim/after/ftplugin/gitcommit.fnl b/config/nvim/after/ftplugin/gitcommit.fnl new file mode 100644 index 0000000..297379c --- /dev/null +++ b/config/nvim/after/ftplugin/gitcommit.fnl @@ -0,0 +1,3 @@ +(let [lo vim.opt_local] + (set lo.spell true) + (set lo.colorcolumn :+1)) diff --git a/config/nvim/after/ftplugin/gitcommit.vim b/config/nvim/after/ftplugin/gitcommit.vim deleted file mode 100644 index cebe5e6..0000000 --- a/config/nvim/after/ftplugin/gitcommit.vim +++ /dev/null @@ -1,2 +0,0 @@ -setlocal spell -setlocal colorcolumn=+1 diff --git a/config/nvim/after/ftplugin/list.vim b/config/nvim/after/ftplugin/list.vim deleted file mode 100644 index f20b088..0000000 --- a/config/nvim/after/ftplugin/list.vim +++ /dev/null @@ -1,6 +0,0 @@ -setlocal nonumber norelativenumber - -nnoremap :q! -nnoremap q :q! - -let b:toggle_line_style = v:false diff --git a/config/nvim/after/ftplugin/make.fnl b/config/nvim/after/ftplugin/make.fnl new file mode 100644 index 0000000..a73f189 --- /dev/null +++ b/config/nvim/after/ftplugin/make.fnl @@ -0,0 +1,4 @@ +(let [lo vim.opt_local] + (set lo.expandtab false) + (set lo.shiftwidth 2) + (set lo.softtabstop 0)) diff --git a/config/nvim/after/ftplugin/make.vim b/config/nvim/after/ftplugin/make.vim deleted file mode 100644 index caf8fe2..0000000 --- a/config/nvim/after/ftplugin/make.vim +++ /dev/null @@ -1,3 +0,0 @@ -setlocal noexpandtab -setlocal shiftwidth=2 -setlocal softtabstop=0 diff --git a/config/nvim/after/ftplugin/markdown.fnl b/config/nvim/after/ftplugin/markdown.fnl new file mode 100644 index 0000000..f19a35e --- /dev/null +++ b/config/nvim/after/ftplugin/markdown.fnl @@ -0,0 +1,2 @@ +(let [lo vim.opt_local] + (set lo.spell true)) diff --git a/config/nvim/after/ftplugin/markdown.vim b/config/nvim/after/ftplugin/markdown.vim deleted file mode 100644 index bcda2dd..0000000 --- a/config/nvim/after/ftplugin/markdown.vim +++ /dev/null @@ -1 +0,0 @@ -setlocal spell diff --git a/config/nvim/after/ftplugin/pandoc.vim b/config/nvim/after/ftplugin/pandoc.vim deleted file mode 100644 index bcda2dd..0000000 --- a/config/nvim/after/ftplugin/pandoc.vim +++ /dev/null @@ -1 +0,0 @@ -setlocal spell diff --git a/config/nvim/after/ftplugin/qf.vim b/config/nvim/after/ftplugin/qf.vim deleted file mode 100644 index f20b088..0000000 --- a/config/nvim/after/ftplugin/qf.vim +++ /dev/null @@ -1,6 +0,0 @@ -setlocal nonumber norelativenumber - -nnoremap :q! -nnoremap q :q! - -let b:toggle_line_style = v:false diff --git a/config/nvim/after/ftplugin/text.fnl b/config/nvim/after/ftplugin/text.fnl new file mode 100644 index 0000000..f19a35e --- /dev/null +++ b/config/nvim/after/ftplugin/text.fnl @@ -0,0 +1,2 @@ +(let [lo vim.opt_local] + (set lo.spell true)) diff --git a/config/nvim/after/ftplugin/text.vim b/config/nvim/after/ftplugin/text.vim deleted file mode 100644 index bcda2dd..0000000 --- a/config/nvim/after/ftplugin/text.vim +++ /dev/null @@ -1 +0,0 @@ -setlocal spell diff --git a/programs/nvim/default.nix b/programs/nvim/default.nix index d098f6b..ae0cfab 100644 --- a/programs/nvim/default.nix +++ b/programs/nvim/default.nix @@ -296,48 +296,55 @@ in ]); }; - xdg.configFile."nvim/lua" = { + xdg.configFile."nvim" = { source = pkgs.runCommandLocal "nvim-fennel-files" { nativeBuildInputs = [ pkgs.fennel pkgs.stylua ]; } '' - mkdir -p $out/configuration - mkdir -p $out/nifoc/utils + mkdir -p $out/lua/configuration + mkdir -p $out/lua/nifoc/utils + mkdir -p $out/after/ftplugin - fennel --use-bit-lib --compile "${../../config/nvim/init.fnl}" > "$out/configuration/init.lua" + fennel="fennel --use-bit-lib --compile" + config_store_path="${../../config/nvim}" - cat <>plugins.fnl - ${config.programs.neovim.generatedConfigs.fennel} - nil - EOF + # Init + $fennel "$config_store_path/init.fnl" > "$out/lua/configuration/init.lua" - fennel --use-bit-lib --compile "./plugins.fnl" > "$out/configuration/plugins.lua" - - nifoc_store_path="${../../config/nvim/nifoc}" - nifoc_store_lua="$(find "$nifoc_store_path" -type f -name '*.lua')" + # Utils + nifoc_store_path="$config_store_path/nifoc" nifoc_store_fnl="$(find "$nifoc_store_path" -type f -name '*.fnl')" - for luafile in $nifoc_store_lua; do - file_out_path="$(echo "$luafile" | sed "s|$nifoc_store_path/||")" - - echo "Copying $luafile ..." - cat "$luafile" > "$out/nifoc/$file_out_path" - done - for fnlfile in $nifoc_store_fnl; do file_out_path="$(echo "$fnlfile" | sed "s|$nifoc_store_path/||" | sed "s/.fnl$/.lua/")" echo "Compiling $fnlfile ..." - fennel --use-bit-lib --compile "$fnlfile" > "$out/nifoc/$file_out_path" + $fennel "$fnlfile" > "$out/lua/nifoc/$file_out_path" done - stylua $out/ - ''; - recursive = true; - }; + # Plugins + cat <>plugins.fnl + ${config.programs.neovim.generatedConfigs.fennel} + nil + EOF - xdg.configFile."nvim/after" = { - source = ../../config/nvim/after; + $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')" + + for fnlfile in $after_store_fnl; do + file_out_path="$(echo "$fnlfile" | sed "s|$after_store_path/||" | sed "s/.fnl$/.lua/")" + + echo "Compiling $fnlfile ..." + $fennel "$fnlfile" > "$out/after/$file_out_path" + done + + cp -r "$after_store_path/queries" "$out/after/" + + stylua "$out/" + ''; recursive = true; };