diff options
-rw-r--r-- | hm/soispha/conf/nvim/plgs/neorg/default.nix | 1 | ||||
-rw-r--r-- | hm/soispha/pkgs/default.nix | 3 | ||||
-rw-r--r-- | hm/soispha/pkgs/scripts.nix | 5 | ||||
-rwxr-xr-x | hm/soispha/pkgs/scripts/wrappers/neorg | 58 |
4 files changed, 44 insertions, 23 deletions
diff --git a/hm/soispha/conf/nvim/plgs/neorg/default.nix b/hm/soispha/conf/nvim/plgs/neorg/default.nix index 2014af9f..8d8015da 100644 --- a/hm/soispha/conf/nvim/plgs/neorg/default.nix +++ b/hm/soispha/conf/nvim/plgs/neorg/default.nix @@ -36,6 +36,7 @@ workspaces = { general = "~/repos/notes/general"; journal = "~/repos/notes/journal"; + projects = "~/repos/notes/projects"; }; }; "core.export".config = { diff --git a/hm/soispha/pkgs/default.nix b/hm/soispha/pkgs/default.nix index f6a4efa0..78624d5c 100644 --- a/hm/soispha/pkgs/default.nix +++ b/hm/soispha/pkgs/default.nix @@ -4,10 +4,11 @@ grades, system, flake_update, + config, ... }: with pkgs; let - shell-scripts = (import ./scripts.nix) {inherit pkgs sysLib;}; + shell-scripts = (import ./scripts.nix) {inherit pkgs sysLib config;}; Gui = { Terminals = [ diff --git a/hm/soispha/pkgs/scripts.nix b/hm/soispha/pkgs/scripts.nix index 837949be..e36ae62e 100644 --- a/hm/soispha/pkgs/scripts.nix +++ b/hm/soispha/pkgs/scripts.nix @@ -1,6 +1,7 @@ { pkgs, sysLib, + config, ... }: let write_script = { @@ -48,6 +49,10 @@ name = "neorg"; src = ./scripts/wrappers/neorg; dependencies = []; + replacementStrings = { + DEFAULT_NEORG_PROJECT_DIR = + config.programs.nixvim.plugins.neorg.modules."core.dirman".config.workspaces.projects; + }; }; update-sys-scr = write_script { name = "update-sys"; diff --git a/hm/soispha/pkgs/scripts/wrappers/neorg b/hm/soispha/pkgs/scripts/wrappers/neorg index ecd830e8..4d35ea32 100755 --- a/hm/soispha/pkgs/scripts/wrappers/neorg +++ b/hm/soispha/pkgs/scripts/wrappers/neorg @@ -6,7 +6,6 @@ SHELL_LIBRARY_VERSION="1.4.2" . %SHELL_LIBRARY_PATH # these are used in version() AUTHORS="Soispha" YEARS="2023" -VERSION="1.0.0" NAME="neorg" @@ -18,51 +17,66 @@ Usage: $NAME [--help|--version] <neorg workspace> Options: - --help | -h + --help | -h Display this help and exit. --version | -v Display version and copyright information and exit. + --task | -t + Open the neorg project associated with the current context. + If no context is set, drop to the selection prompt <neorg workspace> The neorg workspace to open at startup, an empty value drops you at a prompt to enter the workspace yourself EOF } -run_with_workspace() { +open_neorg_workspace() { nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace $1\n")" } -run_without_workspace() { +open_neorg_workspace_prompt() { nvim -c "NeorgStart" -s "$(ptmp ":Neorg workspace ")" } +open_current_task_context() { + current_context="$(task _get rc.context)"; + if [ "$current_context" ]; then + context_path="$(task _get rc.context."$current_context".rc.neorg_path)"; + [ "$context_path" ] || die "All contexts should have a 'neorg_path' set!" -neorg_workspace=""; -run=true; + # Perform shell expansion of Tilde + nvim "$(sed "s|~|$HOME|" "$(ptmp "%DEFAULT_NEORG_PROJECT_DIR/$context_path")")"; + else + dbg "No context active"; + open_neorg_workspace_prompt; + fi +} -while [ "$#" -ne 0 ]; do - case "$1" in +for arg in "$@"; do + case "$arg" in "--help" | "-h") - if [ "$run" = true ]; then - help - fi - run=false; + help; + exit 0; ;; "--version" | "-v") - if [ "$run" = true ]; then - version - fi - run=false; + version; + exit 0; + ;; + esac +done + +while [ "$#" -ne 0 ]; do + case "$1" in + "--task" | "-t") + open_current_task_context; + exit 0; ;; *) - neorg_workspace="$1"; + open_neorg_workspace "$1"; + exit 0; ;; esac shift 1 done -if [ "$neorg_workspace" ] && [ "$run" = true ];then - run_with_workspace "$neorg_workspace"; -elif [ "$run" = true ]; then - run_without_workspace -fi +open_neorg_workspace_prompt; # vim: ft=sh |