{
  lib,
  config,
  ...
}: {
  options.mods.obsidian.enable =
    lib.mkEnableOption "enables obsidian";

  config = lib.mkIf config.mods.obsidian.enable {
    programs.nvf.settings.vim.notes.obsidian = {
      enable = true;
      setupOpts = {
        workspaces = [
          {
            name = "agentic";
            path = "~/work/vaults/agentic";
          }
        ];
        completion.nvim_cmp = true;

        note_id_func =
          lib.generators.mkLuaInline
          # lua
          ''
            function(title)
              local suffix = ""
              if title ~= nil then
                -- If title is given, transform it into valid file name.
                suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower()
              else
                -- If title is nil, just add 4 random uppercase letters to the suffix.
                for _ = 1, 4 do
                  suffix = suffix .. string.char(math.random(65, 90))
                end
              end
              return tostring(os.date("%Y%m%d%H%M%S")) .. "-" .. suffix
            end
          '';

        ui = {
          enable = true;
          update_debounce = 200;
          max_file_length = 5000;
          checkboxes = {
            " " = {
              char = "󰄱";
              hl_group = "ObsidianTodo";
            };
            "x" = {
              char = "";
              hl_group = "ObsidianDone";
            };
            ">" = {
              char = "";
              hl_group = "ObsidianRightArrow";
            };
            "~" = {
              char = "󰰱";
              hl_group = "ObsidianTilde";
            };
            "!" = {
              char = "";
              hl_group = "ObsidianImportant";
            };
          };
          bullets = {
            char = "•";
            hl_group = "ObsidianBullet";
          };
          external_link_icon = {
            char = "";
            hl_group = "ObsidianExtLinkIcon";
          };
          reference_text = {hl_group = "ObsidianRefText";};
          highlight_text = {hl_group = "ObsidianHighlightText";};
          tags = {hl_group = "ObsidianTag";};
          block_ids = {hl_group = "ObsidianBlockID";};
          hl_groups = {
            ObsidianTodo = {
              bold = true;
              fg = "#f78c6c";
            };
            ObsidianDone = {
              bold = true;
              fg = "#89ddff";
            };
            ObsidianRightArrow = {
              bold = true;
              fg = "#f78c6c";
            };
            ObsidianTilde = {
              bold = true;
              fg = "#ff5370";
            };
            ObsidianImportant = {
              bold = true;
              fg = "#d73128";
            };
            ObsidianBullet = {
              bold = true;
              fg = "#89ddff";
            };
            ObsidianRefText = {
              underline = true;
              fg = "#c792ea";
            };
            ObsidianExtLinkIcon = {fg = "#c792ea";};
            ObsidianTag = {
              italic = true;
              fg = "#89ddff";
            };
            ObsidianBlockID = {
              italic = true;
              fg = "#89ddff";
            };
            ObsidianHighlightText = {bg = "#75662e";};
          };
        };
      };
    };
  };
}
