Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
95b52bb
cache init commit
kostabekre Apr 27, 2025
10dfbac
rejected using sqlite, added basic vault indexing, filewatch
kostabekre May 4, 2025
7f7a3eb
A note can be searched by alias
kostabekre May 5, 2025
95854da
Merge remote-tracking branch 'upstream/main'
kostabekre May 6, 2025
e334d68
Updated the filewatch
kostabekre May 6, 2025
c109e6d
working version
kostabekre May 9, 2025
921ef52
Merge remote-tracking branch 'upstream/main'
kostabekre May 9, 2025
aa48f82
last todo
kostabekre May 9, 2025
dda1188
updated read me, fixed test
kostabekre May 9, 2025
3037db7
fix readme
kostabekre May 9, 2025
e8052e7
Updated changelog
kostabekre May 9, 2025
043ec03
moved changes in changelog to unreleased
kostabekre May 9, 2025
a39d9d1
removed 3.12 from changelog
kostabekre May 9, 2025
b80f913
added semicolon
kostabekre May 9, 2025
8e3df02
Updated config option to enable cache
kostabekre May 11, 2025
a16912e
Squash merge add-cache into main
kostabekre May 11, 2025
b496be5
code update
kostabekre May 11, 2025
d19bd80
Merge branch 'add-cache'
kostabekre May 11, 2025
7da49dd
Added log when a note is updated as a warning
kostabekre May 11, 2025
0a7f300
Merge branch 'main' into add-cache
kostabekre May 11, 2025
9dc7df8
Added a test warning
kostabekre May 11, 2025
f7f2aa5
checking get_cache_notes for error
kostabekre May 13, 2025
9714bc3
more description of errors
kostabekre May 13, 2025
64f914e
fix error
kostabekre May 13, 2025
2a2a40d
changed log warning to debug
kostabekre May 19, 2025
6d06a65
Merge branch 'add-cache' into develop
kostabekre May 21, 2025
bd14b1a
temp changes
kostabekre May 21, 2025
8d80abb
file watch sends multiple files but didn't test
kostabekre May 22, 2025
040e766
Fixed errors
kostabekre Jun 2, 2025
d353656
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Jun 2, 2025
2a37f1d
Updated Cache config
kostabekre Jun 2, 2025
b19e938
Added the file handle for root on Linux
kostabekre Jun 15, 2025
9da52d3
github code review changes
kostabekre Jun 15, 2025
a5f58d7
Merge branch 'add-cache'
kostabekre Jun 15, 2025
9dda489
Merge remote-tracking branch 'upstream/main'
kostabekre Jun 15, 2025
5bef2a6
github code review
kostabekre Jun 15, 2025
8084864
Merge remote-tracking branch 'upstream/main'
kostabekre Jun 23, 2025
ace8863
Merge branch 'main' into add-cache
kostabekre Jun 25, 2025
593d6a1
added tags, fixed bug with plenary (too many files), style fix
kostabekre Jun 25, 2025
e29f7ad
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Jun 25, 2025
78023b5
Apply suggestions from code review
neo451 Jun 25, 2025
d3b5366
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Jun 25, 2025
ea8bfa6
Merge branch 'add-cache' of github.com:kostabekre/obsidian.nvim into …
kostabekre Jun 25, 2025
2721082
Code review changes
kostabekre Jun 25, 2025
151d792
fix update errors
kostabekre Jun 25, 2025
2aec269
used joinpath for cross platform, added an option to show or hide tag…
kostabekre Jun 26, 2025
75c4cd9
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Jul 6, 2025
e7cdbd2
fix: dropped abc in cache, cache doesn't use client
kostabekre Jul 6, 2025
53d167a
fix: forgot to use Obsidian.opts in quick_switch
kostabekre Jul 6, 2025
6992c30
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Jul 12, 2025
0233ee6
A lock file is created for a workspace, when enabling filewatch
kostabekre Jul 16, 2025
d4d1931
.gitignore or .ignore is respected in filewatch and cache
kostabekre Jul 20, 2025
6dd1a7b
lock file fix: use pid to check if the neovim isntance, which created…
kostabekre Jul 20, 2025
65a8cc1
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Jul 20, 2025
f43d2dc
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Aug 1, 2025
b52a176
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Aug 12, 2025
9ead762
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Aug 13, 2025
ea5af9f
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Aug 17, 2025
5fe0083
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Aug 25, 2025
3a6ce80
moved lock file to the state folder, set the workspace based on the c…
kostabekre Sep 1, 2025
89dbe34
moved lock file from state to state/obsidian
kostabekre Sep 1, 2025
df75256
Merge remote-tracking branch 'upstream/main' into add-cache
kostabekre Sep 1, 2025
a46c848
use obsidian.async
kostabekre Sep 1, 2025
c5e8ba8
disable warning that a string should be passed instead of a number wh…
kostabekre Sep 1, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Added file-watch: code that tracks changed notes in the vault.
- Added cache: a JSON file, which stores aliases, last update date and path to the note. Updated using file-watch.
- Added a new configuration option - `cache`, which is disabled by default.
- Allow custom directory and ID logic for templates
- When filling out a template with user-provided substitution functions, pass a "context" object to each invocation so that users can respond accordingly.
- Added `obsidian.InsertTemplateContext` and `obsidian.CloneTemplateContext` as these new "context" objects.
Expand Down Expand Up @@ -104,6 +107,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Refactored workspace module for a better api.
- Fixed types in `opts.workspaces[*].overrides` to all be optional.

### Changed
- In telescope an option was added to search notes by aliases.

## [v3.12.0](https://github.com/obsidian-nvim/obsidian.nvim/releases/tag/v3.12.0) - 2025-06-05

### Added
Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ There's one entry point user command for this plugin: `Obsidian`

- `:Obsidian yesterday` to open/create the daily note for the previous working day.

- `:Obsidian rebuild_cache` to manually update the cache of the workspace.

### Demo

[![2024-01-31 14 22 52](https://github.com/epwalsh/obsidian.nvim/assets/8812459/2986e1d2-13e8-40e2-9c9e-75691a3b662e)](https://github.com/epwalsh/obsidian.nvim/assets/8812459/2986e1d2-13e8-40e2-9c9e-75691a3b662e)
Expand Down Expand Up @@ -566,6 +568,13 @@ require("obsidian").setup {
format = "{{properties}} properties {{backlinks}} backlinks {{words}} words {{chars}} chars",
},

-- Experimental feature, disabled by default.
cache = {
enabled = false,
path = "./.cache.json",
show_tags = false -- will show tags after a note name and after aliases.
},

---@class obsidian.config.FooterOpts
---
---@field enabled? boolean
Expand Down
11 changes: 6 additions & 5 deletions doc/obsidian_api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,11 @@ Return ~
Class ~
{obsidian.note.LoadOpts}
Fields ~
{max_lines} `(integer|)`?
{load_contents} `(boolean|)`?
{collect_anchor_links} `(boolean|)`?
{collect_blocks} `(boolean|)`?
{max_lines} `(integer|? Stops)` reading file if reached max lines.
{read_only_frontmatter} `(boolean|? Stops)` reading file if reached end of frontmatter.
{load_contents} `(boolean|? Save)` contents of the file if not frontmatter or block to obsidian.Note.contents. Still reads whole file if other options are true.
{collect_anchor_links} `(boolean|? Save)` anchor_links of the file if not in frontmatter or block to obsidian.Note.anchor_links. Still reads whole file if other options are true.
{collect_blocks} `(boolean|? Save)` code blocks to obsidian.Note.blocks. Still reads whole file if other options are true.

------------------------------------------------------------------------------
*obsidian.Note.from_file()*
Expand Down Expand Up @@ -892,4 +893,4 @@ Parameters ~
Return ~
`(string)` `(optional)`

vim:tw=78:ts=8:noet:ft=help:norl:
vim:tw=78:ts=8:noet:ft=help:norl:
146 changes: 146 additions & 0 deletions lua/obsidian/api.lua
Original file line number Diff line number Diff line change
Expand Up @@ -590,6 +590,152 @@ M.get_icon = function(path)
return nil
end

---Gets all notes from the vault.
---@param path string The path to the vault.
---@return string[]|? The path to the notes.
M.get_all_notes_from_vault = function(path)
local files = {}

local cmd
local find_command

-- checking for executable which support .ignore or .gitignore
if 1 == vim.fn.executable "rg" then
find_command = { "rg", "--files", "--color", "never", "--glob", "'*.md'", path }
cmd = "rg"
elseif 1 == vim.fn.executable "fd" then
find_command = { "fd", "--type", "f", "--color", "never", "--extension", "md", "--base-directory", path }
cmd = "fd"
elseif 1 == vim.fn.executable "fdfind" then
find_command = { "fdfind", "--type", "f", "--color", "never", "--extension", "md", "--base-directory", path }
cmd = "fdfind"
end

if cmd then
local handle = io.popen(table.concat(find_command, " "))

if not handle then
log.error("couldn't execute cmd " .. cmd)
return {}
end

for file in handle:lines() do
files[#files + 1] = file
end
else
-- If we couldn't find one of the executable, fallback to default implemendation
-- which doesn't respect .ignore or .gitignore.
for name, t in vim.fs.dir(path, { depth = 10 }) do
if t == "file" and vim.endswith(name, ".md") then
local full_path = vim.fs.joinpath(path, name)
files[#files + 1] = full_path
end
end
end

return files
end

---Use greedy search to get the folder of the file.
---@param file_path string
---@param sep string
---@return string
local get_directory_path = function(file_path, sep)
return file_path:match("(.*" .. sep .. ")")
end

---Gets all subfolders from the vault.
---@param path string The path to the vault.
---@return string[]|? The path to the subfolders
M.get_sub_dirs_from_vault = function(path)
local subdirs = {}

local cmd
local find_command

-- checking for executable which support .ignore or .gitignore
if 1 == vim.fn.executable "fd" then
find_command = { "fd", "--type", "d", "--color", "never", "--base-directory", path }
cmd = "fd"
elseif 1 == vim.fn.executable "fdfind" then
find_command = { "fdfind", "--type", "f", "--color", "never", "--base-directory", path }
cmd = "fdfind"
elseif 1 == vim.fn.executable "rg" then
-- rg doesn't support searching folders, so we will filter output manually.
-- Unfortunatly, this won't return folders which are empty.
find_command = { "rg", "--files", "--color", "never", "--glob", "'*.md'", path }
cmd = "rg"
end

if cmd then
local handle = io.popen(table.concat(find_command, " "))

if not handle then
log.error("couldn't execute cmd " .. cmd)
return {}
end

if cmd == "rg" then
local path_separator = "/"

local sysname = M.get_os()

if sysname == M.OSType.Windows then
path_separator = "\\"
end

for file in handle:lines() do
local subdir = get_directory_path(file, path_separator)

if not vim.tbl_contains(subdirs, subdir) then
subdirs[#subdirs + 1] = subdir
end
end
else
for subdir in handle:lines() do
subdirs[#subdirs + 1] = subdir
end
end
else
-- the user doesn't have tools which support .gitignore or .ignore,
-- fallback to getting all folders
for name, t in vim.fs.dir(path, { depth = 10 }) do
if t == "directory" then
local full_path = vim.fs.joinpath(path, name)
subdirs[#subdirs + 1] = full_path
end
end
end

return subdirs
end

---Cross-platform check if the pid exists.
---@param pid string
---@return boolean
M.check_pid_exists = function(pid)
local system = M.get_os()

if system == M.OSType.Windows then
local cmd = string.format('tasklist /FI "PID eq %d" /NH', pid)
local pipe = io.popen(cmd)
assert(pipe)
local output = pipe:read()
pipe:close()

return output:match(pid) ~= nil
else
local cmd = "kill -0 " .. pid
local ok = os.execute(cmd)

if ok then
return true
else
return false
end
end
end

--- Resolve a basename to full path inside the vault.
---
---@param src string
Expand Down
Loading
Loading