epwalsh / obsidian.nvim

Obsidian 🤝 Neovim
Apache License 2.0
3.83k stars 171 forks source link

have custom file types treated as markdown notes #658

Open sadtab opened 1 month ago

sadtab commented 1 month ago

🚀 The feature, motivation and pitch

I like to keep my leet code exercises as obsidian notes. We can markdown style comment blocks in a cpp file, the only issue is that Obsidian does not recognize a cpp extension as a note file, can we have the option to enable some custom file extensions (or patterns that match the file name) to be treated as a plain markdown note?

Alternatives

No response

Additional context

No response

JamiroFerrara commented 1 month ago

I would also be really interested in this. It would be amazing to be able to have an obsidian link in comments so i can directly link back to my vault. I could basically have documentation links where needed.

Haven't had much success hacking the library.

sadtab commented 1 month ago

I found this in the source code, but don't really know the architecure

https://github.com/epwalsh/obsidian.nvim/blob/ee298fd2136612a4ca6a745a4aec3f49ce6f94b0/lua/obsidian/client.lua#L580

Client.find_files_async = function(self, term, callback, opts)
  opts = opts or {}

  local matches = {}
  local tx, rx = channel.oneshot()
  local on_find_match = function(path_match)
    matches[#matches + 1] = Path.new(path_match)
  end

  local on_exit = function(_)
    tx()
  end

  local find_opts = self:_prepare_search_opts(opts.search)
  find_opts:add_exclude "*.md"
  find_opts.include_non_markdown = true

  search.find_async(self.dir, term, find_opts, on_find_match, on_exit)

  async.run(function()
    rx()
    return matches
  end, callback)
end
JamiroFerrara commented 1 month ago

@sadtab

This seems to only be realated to the ObsidianSearch feature. The "include_non_markdown" is used to build flags for rip-grep within the "build_find_cmd" function.

I assume a similar flag should be implemented within "workspaces" override configuration.