nvim-orgmode / telescope-orgmode.nvim

Neovim plugin. Telescope.nvim extension that adds orgmode.nvim integration.
MIT License
10 stars 5 forks source link

Fix/deprecation warnings #7

Closed lyz-code closed 6 months ago

lyz-code commented 7 months ago

Closes #5

lyz-code commented 7 months ago

@kristijanhusak can you please take a look and suggest what I'm doing wrong? With these changes the plugin doesn't work with nightly

kristijanhusak commented 7 months ago

@lyz-code you are using some internals that were changed. I'll expose some API calls for you so you can leverage that instead. I'll let you know.

kristijanhusak commented 7 months ago

@lyz-code I just pushed https://github.com/nvim-orgmode/orgmode/commit/b47e76f404dd908ad6c652abb6b915b2be564418 to nightly branch, that adds two new API methods:

get_closest_headline on file class refile on the main API class

This should cover all needs for your plugin here. This is a usage example:

  local api = require('orgmode.api')

  local closest_headline = api.current():get_closest_headline()

  -- Refile to the end of the destination file
  local destination = api.load('/path/to/destination/file.org')

  -- Or refile to specific headline in the destination
  local destination = api.load('/path/to/destination/file.org').headline[3]

  -- If doing refile from capture window, it will be automatically closed after the refile
  -- So there is no need to worry about that
  return api.refile({
    source = closest_headline,
    destination = destination
  })
lyz-code commented 7 months ago

Thank you so much as always for your quick answer and fix. I'll try to implement it today <3

lyz-code commented 7 months ago

The code is much cleaner now @kristijanhusak thank you so much. I'll wait for the nightly branch to be merged in order to merge this one

kristijanhusak commented 6 months ago

@lyz-code Note that nightly was merged into master so you can merge this in.

lyz-code commented 6 months ago

Thanks for thinking of me and notifying of the merge <3