From 20af7a937402018d38529d3ddbaaf7b8031303b1 Mon Sep 17 00:00:00 2001 From: ViViDboarder Date: Fri, 20 Oct 2023 16:59:19 -0700 Subject: [PATCH] Add Obsidian --- neovim/lua/plugins.lua | 22 ++++++++++++++++++++++ neovim/lua/plugins/completion.lua | 18 ++++++++++++------ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/neovim/lua/plugins.lua b/neovim/lua/plugins.lua index b857304..88ba6de 100644 --- a/neovim/lua/plugins.lua +++ b/neovim/lua/plugins.lua @@ -500,6 +500,28 @@ use({ end, }) +-- Obsidian notes +use({ + "epwalsh/obsidian.nvim", + requires = { + "nvim-lua/plenary.nvim", + }, + tag = "v1.14.2", + config = function() + -- vim.cmd(":Git pull") + require("obsidian").setup({ + workspaces = { + name = "personal", + path = "~/Documents/Obsidian", + }, + }) + end, + event = { + "BufRead " .. vim.fn.expand("~") .. "/Documents/Obsidian/**.md", + "BufNewFile " .. vim.fn.expand("~") .. "/Documents/Obsidian/**.md", + }, +}) + -- Auto sync after bootstrapping on a fresh box if packer_bootstrap ~= "" then packer.sync() diff --git a/neovim/lua/plugins/completion.lua b/neovim/lua/plugins/completion.lua index 10166c4..40ddc1c 100644 --- a/neovim/lua/plugins/completion.lua +++ b/neovim/lua/plugins/completion.lua @@ -18,6 +18,8 @@ function M.config_cmp() { name = "luasnip" }, { name = "buffer" }, { name = "spell" }, + { name = "obsidian" }, + { name = "obsidian_new" }, }, mapping = cmp.mapping.preset.insert({ -- Scroll docs with readline back - forward @@ -45,12 +47,16 @@ function M.config_cmp() }) -- Add a plug mapping to use in C-Space binding - require("utils").keymap_set( - "i", - "(cmp_complete)", - "lua require('cmp').complete()", - { desc = "Autocomplete" } - ) + local utils = require("utils") + utils.keymap_set("i", "(cmp_complete)", "lua require('cmp').complete()", { desc = "Autocomplete" }) + + -- Maybe add obsidian and obsidian new. This is done here in case obsidian.nvim is loaded before cmp + utils.try_require("cmp_obsidian", function(cmp_obsidian) + cmp.register_source("obsidian", cmp_obsidian.new()) + end) + utils.try_require("cmp_obsidian_new", function(cmp_obsidian_new) + cmp.register_source("obsidian_new", cmp_obsidian_new.new()) + end) end return M