about summary refs log tree commit diff
path: root/lua
diff options
context:
space:
mode:
authoriurii plugatarov <[email protected]>2024-08-03 01:08:08 +0200
committeriurii plugatarov <[email protected]>2024-08-03 01:08:08 +0200
commit614b50a5cd2efcd1d88aa72c5a36aa4ef238dbfd (patch)
treef22c6f82f31bf42a8f9a00174797f56e003d70c9 /lua
parent498b6ef130bf654e4a2b19ca20cc1e9bad8b7922 (diff)
downloadsketchbook.nvim-614b50a5cd2efcd1d88aa72c5a36aa4ef238dbfd.tar.gz
use relative index
Diffstat (limited to '')
-rw-r--r--lua/sketchbook/update_index.lua32
1 files changed, 16 insertions, 16 deletions
diff --git a/lua/sketchbook/update_index.lua b/lua/sketchbook/update_index.lua
index 1a6044e..22fa47f 100644
--- a/lua/sketchbook/update_index.lua
+++ b/lua/sketchbook/update_index.lua
@@ -1,22 +1,22 @@
 local M = {}
 
 function M.update_index()
-  local notes_dir = vim.g.notes_directory or "~/notes/"
-  notes_dir = vim.fn.expand(notes_dir)
-  local index_file = notes_dir .. "index.md"
-  local notes = vim.fn.globpath(notes_dir, "*.md", false, true)
-  local content = { "# Index", "" }
-  for _, note in ipairs(notes) do
-    if vim.fn.fnamemodify(note, ":t") ~= "index.md" then
-      table.insert(content, "- [" .. vim.fn.fnamemodify(note, ":t:r") .. "](" .. note .. ")")
-    end
-  end
-  local file = io.open(index_file, "w")
-  for _, line in ipairs(content) do
-    file:write(line .. "\n")
-  end
-  file:close()
-  print "Index updated"
+	local notes_dir = vim.g.notes_directory or "~/notes/"
+	notes_dir = vim.fn.expand(notes_dir)
+	local index_file = notes_dir .. "index.md"
+	local notes = vim.fn.globpath(notes_dir, "*.md", false, true)
+	local content = { "# Index", "" }
+	for _, note in ipairs(notes) do
+		if vim.fn.fnamemodify(note, ":t") ~= "index.md" then
+			table.insert(content, "- [[" .. vim.fn.fnamemodify(note, ":t:r") .. "]]")
+		end
+	end
+	local file = io.open(index_file, "w")
+	for _, line in ipairs(content) do
+		file:write(line .. "\n")
+	end
+	file:close()
+	print("Index updated")
 end
 
 return M