mirror of
				https://github.com/NotAShelf/nvf.git
				synced 2025-10-31 19:12:38 +00:00 
			
		
		
		
	feat(obsidian-nvim): custom setup
This commit is contained in:
		
					parent
					
						
							
								88c22ef026
							
						
					
				
			
			
				commit
				
					
						e5fba51877
					
				
			
		
					 2 changed files with 44 additions and 46 deletions
				
			
		|  | @ -6,9 +6,9 @@ | ||||||
|   inherit (lib.modules) mkIf; |   inherit (lib.modules) mkIf; | ||||||
|   inherit (lib.nvim.dag) entryAnywhere; |   inherit (lib.nvim.dag) entryAnywhere; | ||||||
|   inherit (lib.nvim.binds) pushDownDefault; |   inherit (lib.nvim.binds) pushDownDefault; | ||||||
|  |   inherit (lib.nvim.lua) toLuaObject; | ||||||
| 
 | 
 | ||||||
|   cfg = config.vim.notes.obsidian; |   cfg = config.vim.notes.obsidian; | ||||||
|   auto = config.vim.autocomplete; |  | ||||||
| in { | in { | ||||||
|   config = mkIf cfg.enable { |   config = mkIf cfg.enable { | ||||||
|     vim = { |     vim = { | ||||||
|  | @ -23,28 +23,7 @@ in { | ||||||
|       }; |       }; | ||||||
| 
 | 
 | ||||||
|       luaConfigRC.obsidian = entryAnywhere '' |       luaConfigRC.obsidian = entryAnywhere '' | ||||||
|         require("obsidian").setup({ |         require("obsidian").setup(${toLuaObject cfg.setupOpts}) | ||||||
|           dir = "${cfg.dir}", |  | ||||||
|           completion = { |  | ||||||
|             nvim_cmp = ${ |  | ||||||
|           if (auto.type == "nvim-cmp") |  | ||||||
|           then "true" |  | ||||||
|           else "false" |  | ||||||
|         } |  | ||||||
|           }, |  | ||||||
|           daily_notes = { |  | ||||||
|             folder = ${ |  | ||||||
|           if (cfg.daily-notes.folder == "") |  | ||||||
|           then "nil," |  | ||||||
|           else "'${cfg.daily-notes.folder}'," |  | ||||||
|         } |  | ||||||
|             date_format = ${ |  | ||||||
|           if (cfg.daily-notes.date-format == "") |  | ||||||
|           then "nil," |  | ||||||
|           else "'${cfg.daily-notes.date-format}'," |  | ||||||
|         } |  | ||||||
|           } |  | ||||||
|         }) |  | ||||||
|       ''; |       ''; | ||||||
|     }; |     }; | ||||||
|   }; |   }; | ||||||
|  |  | ||||||
|  | @ -1,33 +1,52 @@ | ||||||
| {lib, ...}: let | { | ||||||
|   inherit (lib.options) mkEnableOption mkOption; |   config, | ||||||
|   inherit (lib.types) str bool; |   lib, | ||||||
|  |   ... | ||||||
|  | }: let | ||||||
|  |   inherit (lib) mkEnableOption mkOption types mkRenamedOptionModule; | ||||||
| in { | in { | ||||||
|  |   imports = let | ||||||
|  |     renamedSetupOption = oldPath: newPath: | ||||||
|  |       mkRenamedOptionModule | ||||||
|  |       (["vim" "notes" "obsidian"] ++ oldPath) | ||||||
|  |       (["vim" "notes" "obsidian" "setupOpts"] ++ newPath); | ||||||
|  |   in [ | ||||||
|  |     (renamedSetupOption ["dir"] ["dir"]) | ||||||
|  |     (renamedSetupOption ["daily-notes" "folder"] ["daily_notes" "folder"]) | ||||||
|  |     (renamedSetupOption ["daily-notes" "date-format"] ["daily_notes" "date_format"]) | ||||||
|  |     (renamedSetupOption ["completion"] ["completion"]) | ||||||
|  |   ]; | ||||||
|   options.vim.notes = { |   options.vim.notes = { | ||||||
|     obsidian = { |     obsidian = { | ||||||
|       enable = mkEnableOption "complementary neovim plugins for Obsidian editor"; |       enable = mkEnableOption "complementary neovim plugins for Obsidian editor"; | ||||||
|       dir = mkOption { |  | ||||||
|         type = str; |  | ||||||
|         default = "~/my-vault"; |  | ||||||
|         description = "Obsidian vault directory"; |  | ||||||
|       }; |  | ||||||
| 
 | 
 | ||||||
|       daily-notes = { |       setupOpts = lib.nvim.types.mkPluginSetupOption "Obsidian.nvim" { | ||||||
|         folder = mkOption { |         dir = mkOption { | ||||||
|           type = str; |           type = types.str; | ||||||
|           default = ""; |           default = "~/my-vault"; | ||||||
|           description = "Directory in which daily notes should be created"; |           description = "Obsidian vault directory"; | ||||||
|         }; |         }; | ||||||
|         date-format = mkOption { |  | ||||||
|           type = str; |  | ||||||
|           default = ""; |  | ||||||
|           description = "Date format used for creating daily notes"; |  | ||||||
|         }; |  | ||||||
|       }; |  | ||||||
| 
 | 
 | ||||||
|       completion = { |         daily_notes = { | ||||||
|         nvim_cmp = mkOption { |           folder = mkOption { | ||||||
|           type = bool; |             type = types.nullOr types.str; | ||||||
|           description = "If using nvim-cmp, otherwise set to false"; |             default = null; | ||||||
|  |             description = "Directory in which daily notes should be created"; | ||||||
|  |           }; | ||||||
|  |           date_format = mkOption { | ||||||
|  |             type = types.nullOr types.str; | ||||||
|  |             default = null; | ||||||
|  |             description = "Date format used for creating daily notes"; | ||||||
|  |           }; | ||||||
|  |         }; | ||||||
|  | 
 | ||||||
|  |         completion = { | ||||||
|  |           nvim_cmp = mkOption { | ||||||
|  |             # if using nvim-cmp, otherwise set to false | ||||||
|  |             type = types.bool; | ||||||
|  |             description = "If using nvim-cmp, otherwise set to false"; | ||||||
|  |             default = config.vim.autocomplete.type == "nvim-cmp"; | ||||||
|  |           }; | ||||||
|         }; |         }; | ||||||
|       }; |       }; | ||||||
|     }; |     }; | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Ching Pei Yang
				Ching Pei Yang