From ed86e538190c84f3e6aa47d7b7b7c51ea62601ad Mon Sep 17 00:00:00 2001 From: Fred Drake Date: Sat, 15 Feb 2025 23:05:10 -0500 Subject: [PATCH] Added Obsidian --- config/keys.nix | 69 ++++++++++++++++++++++++++++++++++++++++++++-- config/options.nix | 2 ++ config/plugins.nix | 16 ++++++++++- config/sets.nix | 58 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 141 insertions(+), 4 deletions(-) diff --git a/config/keys.nix b/config/keys.nix index 3a0d307..ac30e01 100644 --- a/config/keys.nix +++ b/config/keys.nix @@ -31,10 +31,15 @@ group = "Buffer"; } { - __unkeyed-1 = "o"; + __unkeyed-1 = "S"; group = "SOPS"; icon = ""; } + { + __unkeyed-1 = "O"; + group = "Obsidian"; + icon = "󰎚"; + } { __unkeyed-1 = "d"; group = "Debug"; @@ -283,6 +288,14 @@ options.desc = "Quick Menu"; } + # Outline + { + mode = "n"; + key = "o"; + action = "Outline"; + options.desc = "Outline"; + } + # FZF-Lua custom commands -- I want to limit to current directory { mode = "n"; @@ -346,17 +359,67 @@ # SOPS { mode = "n"; - key = "od"; + key = "Sd"; action = "!sops -d -i %"; options.desc = "Decrypt SOPS File"; } { mode = "n"; - key = "oe"; + key = "Se"; action = "!sops -e -i %"; options.desc = "Encrypt SOPS File"; } + # Obsidian + { + mode = "n"; + key = "On"; + action = "ObsidianNew"; + options.desc = "New Note"; + } + { + mode = "n"; + key = "Oo"; + action = "ObsidianQuickSwitch"; + options.desc = "Open Note"; + } + { + mode = "n"; + key = "Ol"; + action = "ObsidianBacklinks"; + options.desc = "Backlinks"; + } + { + mode = "n"; + key = "Ot"; + action = "ObsidianTags"; + options.desc = "Tags"; + } + { + mode = "n"; + key = "Ow"; + action = "ObsidianWorkspace"; + options.desc = "Change workspace"; + } + { + mode = "n"; + key = "Op"; + action = "ObsidianPasteImg"; + options.desc = "Paste image"; + } + { + mode = "n"; + key = "Oc"; + action = "ObsidianToggleCheckbox"; + options.desc = "Toggle checkbox"; + } + { + mode = "n"; + key = "Of"; + action = "ObsidianSearch"; + options.desc = "Find notes"; + } + # Git { mode = "n"; diff --git a/config/options.nix b/config/options.nix index f8c8f7d..3d2c27c 100644 --- a/config/options.nix +++ b/config/options.nix @@ -28,6 +28,8 @@ swapfile = false; undofile = true; # Build-in persistent undo undolevels = 10000; + + conceallevel = 2; }; }; } diff --git a/config/plugins.nix b/config/plugins.nix index 71a0343..e2b5699 100644 --- a/config/plugins.nix +++ b/config/plugins.nix @@ -1,10 +1,22 @@ -{pkgs, ...}: { +{pkgs, ...}: let + outline-nvim = pkgs.vimUtils.buildVimPlugin { + name = "outline-nvim"; + src = pkgs.fetchFromGitHub { + owner = "hedyhli"; + repo = "outline.nvim"; + rev = "d5c29ee3ff3b7d1bdd454b37698316e67808c36e"; + hash = "sha256-uWMHUkrGo8D3nUvYrDcXOWbXLWvFv9rWsBxLfR2ckcY="; + }; + nvimSkipModule = "outline.providers.norg"; + }; +in { extraPlugins = with pkgs; [ vimPlugins.supermaven-nvim # AI code completion vimPlugins.vim-dadbod # DB client vimPlugins.vim-dadbod-completion # DB completion vimPlugins.vim-dadbod-ui # DB UI vimPlugins.vim-tmux-navigator # tmux navigation + outline-nvim ]; extraConfigLua = '' @@ -32,5 +44,7 @@ require("notify").setup({ background_colour = "#000000", }) + + require("outline").setup {} ''; } diff --git a/config/sets.nix b/config/sets.nix index 2f3b0c3..0243d69 100644 --- a/config/sets.nix +++ b/config/sets.nix @@ -63,6 +63,64 @@ }; }; + obsidian.enable = true; + obsidian.settings = { + attachments.img_folder = "Attachments"; + completion = { + min_chars = 2; + nvim_cmp = true; + }; + daily_notes = { + folder = "notes/dailies"; + date_format = "%Y-%m-%d"; + alias_format = "%B %-d, %Y"; + template = "templates/daily.md"; + }; + new_notes_location = "current_dir"; + note_id_func = '' + function(title) + local date = os.date("%Y-%m-%d %H%M") + local suffix = "" + if title ~= nil then + suffix = title:gsub(" ", "-"):gsub("[^A-Za-z0-9-]", ""):lower() + else + for _ = 1, 4 do + suffix = suffix .. string.char(math.random(65, 90)) + end + end + return date .. "-" .. suffix + end + ''; + workspaces = [ + { + name = "personal"; + path = "~/Source/gitea-app.internal.freddrake.com/fdrake/PKM-Personal"; + } + ]; + wiki_link_func = "use_alias_only"; + disable_frontmatter = true; + templates = { + folder = "Templates"; + date_format = "%Y-%m-%d"; + time_format = "%H:%M"; + substitutions = {}; + }; + follow_url_func = '' + function(url) + -- Open the URL in the default web browser. + vim.fn.jobstart({"open", url}) -- Mac OS + -- vim.fn.jobstart({"xdg-open", url}) -- linux + -- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows + -- vim.ui.open(url) -- need Neovim 0.10.0+ + end''; + follow_img_func = '' + function(img) + vim.fn.jobstart { "qlmanage", "-p", img } -- Mac OS quick look preview + -- vim.fn.jobstart({"xdg-open", url}) -- linux + -- vim.cmd(':silent exec "!start ' .. url .. '"') -- Windows + end''; + }; + neo-tree.enable = true; noice.enable = true; notify.enable = true;