Closed BinaryFly closed 3 months ago
I feel like this is a specific issue with Windows, why I don't know yet, but I tried replicating this on my linux machine but wasn't able to reproduce this bug.
Hey @BinaryFly, could definitely be specified to Windows or the NVIM build, not sure. I'm assuming the error is happening inside the command function you defined? To make it more robust you could try getting the client instance at runtime by changing this line:
- tagstore = client:list_tags()
+ tagstore = require("obsidian").get_client():list_tags()
I tried your suggestion but unfortunately it gives back the same error, as mentioned before I also tried running the standalone command in neovim: :lua require("obsidian").get_client():list_tags()
, but this also doesn't work unfortunately.
Huh, I'm not sure what's going on. Could you post the full traceback when you get a chance?
Yes of course, the complete traceback for lua require("obsidian").get_client():list_tags()
:
E5108: Error executing lua ...cal/nvim-data/lazy/obsidian.nvim/lua/obsidian/client.lua:1480: calling 'find_tags' on bad self (table expected, got nil)
stack traceback:
[C]: in function 'find_tags'
...cal/nvim-data/lazy/obsidian.nvim/lua/obsidian/client.lua:1480: in function 'list_tags'
[string ":lua"]:1: in main chunk
I also added some vim.print
statements to the find_tags
function to determine what arguments were passed
--- Find all tags starting with the given search term(s).
---
---@param term string|string[] The search term.
---@param opts { search: obsidian.SearchOpts|?, timeout: integer|? }|?
---
---@return obsidian.TagLocation[]
Client.find_tags = function(self, term, opts)
vim.print("Self: Client")
vim.print(self)
vim.print("")
vim.print("Term:")
vim.print(term)
vim.print("")
vim.print("Opts:")
vim.print(opts)
opts = opts or {}
return block_on(function(cb)
return self:find_tags_async(term, cb, { search = opts.search })
end, opts.timeout)
end
This prints the following "self
"
Self: Client
<1>{
_default_opts = {
attachments = {
confirm_img_paste = true,
img_folder = "4. Archive/assets/imgs",
img_text_func = <function 1>
},
callbacks = <2>{
post_setup = <function 2>
},
completion = {
min_chars = 2,
nvim_cmp = true
},
daily_notes = {
date_format = "%Y-%m-%d",
default_tags = <3>{ "daily-notes" },
folder = "4. Archive/Dailies",
template = "daily.md"
},
disable_frontmatter = false,
follow_url_func = <function 3>,
log_level = 2,
mappings = <4>{
["<leader>ch"] = {
action = <function 4>,
opts = {
buffer = true
}
},
gf = {
action = <function 5>,
opts = {
buffer = true,
expr = true,
noremap = false
}
}
},
markdown_link_func = <function 6>,
new_notes_location = "current_dir",
note_id_func = <function 7>,
open_app_foreground = false,
open_notes_in = "current",
picker = {
note_mappings = <5>{
insert_link = "<C-l>",
new = "<C-x>"
},
tag_mappings = <6>{
insert_tag = "<C-l>",
tag_note = "<C-x>"
}
},
preferred_link_style = "wiki",
search_max_lines = 1000,
sort_by = "modified",
sort_reversed = true,
templates = {
folder = "4. Archive/Templates",
substitutions = <7>{}
},
ui = {
block_ids = <8>{
hl_group = "ObsidianBlockID"
},
bullets = <9>{
char = "•",
hl_group = "ObsidianBullet"
},
checkboxes = <10>{
[" "] = {
char = "",
hl_group = "ObsidianTodo",
order = 1
},
["!"] = {
char = "",
hl_group = "ObsidianImportant",
order = 3
},
[">"] = {
char = "",
hl_group = "ObsidianRightArrow",
order = 4
},
x = {
char = "",
hl_group = "ObsidianDone",
order = 5
},
["~"] = {
char = "",
hl_group = "ObsidianTilde",
order = 2
}
},
enable = true,
external_link_icon = <11>{
char = "",
hl_group = "ObsidianExtLinkIcon"
},
highlight_text = <12>{
hl_group = "ObsidianHighlightText"
},
hl_groups = <13>{
ObsidianBlockID = {
fg = "#89ddff",
italic = true
},
ObsidianBullet = {
bold = true,
fg = "#89ddff"
},
ObsidianDone = {
bold = true,
fg = "#89ddff"
},
ObsidianExtLinkIcon = {
fg = "#c792ea"
},
ObsidianHighlightText = {
bg = "#75662e"
},
ObsidianImportant = {
bold = true,
fg = "#d73128"
},
ObsidianRefText = {
fg = "#c792ea",
underline = true
},
ObsidianRightArrow = {
bold = true,
fg = "#f78c6c"
},
ObsidianTag = {
fg = "#89ddff",
italic = true
},
ObsidianTilde = {
bold = true,
fg = "#ff5370"
},
ObsidianTodo = {
bold = true,
fg = "#f78c6c"
}
},
max_file_length = 5000,
reference_text = <14>{
hl_group = "ObsidianRefText"
},
tags = <15>{
hl_group = "ObsidianTag"
},
update_debounce = 200
},
wiki_link_func = <function 8>,
workspaces = <16>{ {
name = "Obsidian Vault",
path = "C:\\Users\\BinaryFly/Documents/Obsidian Vault"
} }
},
_quiet = false,
buf_dir = {
filename = "C:/Users/BinaryFly/Documents/Obsidian Vault",
<metatable> = <17>{
__div = <function 9>,
__eq = <function 10>,
__index = <function 11>,
__tostring = <function 12>
}
},
callback_manager = {
callbacks = <table 2>,
client = <table 1>,
<metatable> = <18>{
__eq = <function 13>,
__index = {
as_tbl = <function 14>,
enter_note = <function 15>,
init = <function 16>,
leave_note = <function 17>,
mt = <table 18>,
new = <function 18>,
post_set_workspace = <function 19>,
post_setup = <function 20>,
pre_write_note = <function 21>
}
}
},
current_workspace = {
name = "Obsidian Vault",
path = {
filename = "C:/Users/BinaryFly/Documents/Obsidian Vault",
<metatable> = <table 17>
},
root = {
filename = "C:/Users/BinaryFly/Documents/Obsidian Vault",
<metatable> = <table 17>
},
<metatable> = <19>{
__eq = <function 22>,
__index = {
_unlock = <function 23>,
as_tbl = <function 24>,
get_default_workspace = <function 25>,
get_from_opts = <function 26>,
get_workspace_for_cwd = <function 27>,
get_workspace_for_dir = <function 28>,
init = <function 29>,
lock = <function 30>,
mt = <table 19>,
new = <function 31>,
new_from_buf = <function 32>,
new_from_cwd = <function 33>,
new_from_spec = <function 34>
},
__tostring = <function 35>
}
},
dir = {
filename = "C:/Users/BinaryFly/Documents/Obsidian Vault",
<metatable> = <table 17>
},
log = {
_log_level = 2,
debug = <function 36>,
err = <function 37>,
err_once = <function 38>,
error = <function 37>,
error_once = <function 37>,
flush = <function 39>,
info = <function 40>,
lazy_err = <function 41>,
lazy_error = <function 41>,
lazy_info = <function 42>,
lazy_log = <function 43>,
lazy_warn = <function 44>,
log = <function 45>,
log_once = <function 46>,
set_level = <function 47>,
warn = <function 48>,
warn_once = <function 49>
},
opts = {
attachments = {
confirm_img_paste = true,
img_folder = "4. Archive/assets/imgs",
img_text_func = <function 1>
},
callbacks = <table 2>,
completion = {
min_chars = 2,
nvim_cmp = true
},
daily_notes = {
date_format = "%Y-%m-%d",
default_tags = <table 3>,
folder = "4. Archive/Dailies",
template = "daily.md"
},
disable_frontmatter = false,
follow_url_func = <function 3>,
log_level = 2,
mappings = <table 4>,
markdown_link_func = <function 6>,
new_notes_location = "current_dir",
note_id_func = <function 7>,
open_app_foreground = false,
open_notes_in = "current",
picker = {
note_mappings = <table 5>,
tag_mappings = <table 6>
},
preferred_link_style = "wiki",
search_max_lines = 1000,
sort_by = "modified",
sort_reversed = true,
templates = {
folder = "4. Archive/Templates",
substitutions = <table 7>
},
ui = {
block_ids = <table 8>,
bullets = <table 9>,
checkboxes = <table 10>,
enable = true,
external_link_icon = <table 11>,
highlight_text = <table 12>,
hl_groups = <table 13>,
max_file_length = 5000,
reference_text = <table 14>,
tags = <table 15>,
update_debounce = 200
},
wiki_link_func = <function 8>,
workspaces = <table 16>
},
<metatable> = <20>{
__eq = <function 50>,
__index = {
_daily = <function 51>,
_prepare_search_opts = <function 52>,
_search_iter_async = <function 53>,
_search_opts_from_arg = <function 54>,
apply_async = <function 55>,
apply_async_raw = <function 56>,
as_tbl = <function 57>,
command = <function 58>,
create_note = <function 59>,
current_note = <function 60>,
daily = <function 61>,
daily_note_path = <function 62>,
find_backlinks = <function 63>,
find_backlinks_async = <function 64>,
find_files = <function 65>,
find_files_async = <function 66>,
find_notes = <function 67>,
find_notes_async = <function 68>,
find_tags = <function 69>,
find_tags_async = <function 70>,
follow_link_async = <function 71>,
format_link = <function 72>,
init = <function 73>,
list_tags = <function 74>,
list_tags_async = <function 75>,
mt = <table 20>,
new = <function 76>,
new_note = <function 77>,
new_note_id = <function 78>,
new_note_path = <function 79>,
open_note = <function 80>,
opts_for_workspace = <function 81>,
parse_title_id_path = <function 82>,
path_is_note = <function 83>,
picker = <function 84>,
resolve_link_async = <function 85>,
resolve_note = <function 86>,
resolve_note_async = <function 87>,
resolve_note_async_with_picker_fallback = <function 88>,
search_defaults = <function 89>,
set_workspace = <function 90>,
should_save_frontmatter = <function 91>,
switch_workspace = <function 92>,
templates_dir = <function 93>,
today = <function 94>,
tomorrow = <function 95>,
update_frontmatter = <function 96>,
update_ui = <function 97>,
vault_name = <function 98>,
vault_relative_path = <function 99>,
vault_root = <function 100>,
write_note = <function 101>,
write_note_to_buffer = <function 102>,
yesterday = <function 103>
},
__tostring = <function 104>
}
}
and these are the other arguments passed to find_tags
Term:
Opts:
{}
Everything being printed seems fine :/ You're right this is probably an async bug on Windows. I'm not sure what to do about this other than wait for the next Neovim release and hope they've fixed it. Sorry I can't be more help. Let me know if you find any more info.
Yeah I think so too unfortunately, well I'll close the issue for now then and wait for the next nvim release for Windows...
🐛 Describe the bug
I tried to write some functionality for myself which gives me the opportunity to add tags via the command line to obsidian. This allows me to add multiple tags at a time with completion and I like this more than the Telescope solution with
ObsidianTags
. I use the functionlist_tags
on my client here though and that returns the following error:This is how I use the
list_tags
method on the client in mypost_setup
callback in the obsidian config:I might also just use this method wrong, maybe I didn't understand how to use this the right way as well, but I feel like this has more to do with the asynchronous nature of
find_tags
because it does work sometimes in the fact that it doesn't throw an error and all the tags are loaded.:lua vim.print(require("obsidian").get_client():list_tags())"
also gives me back the same errorConfig
in lazy.nvim config:
My _obsidian.lua file
And all my mappings that I use for obsidian:
Environment