Skip to content

Insert link #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 22, 2024
Merged

Insert link #16

merged 1 commit into from
May 22, 2024

Conversation

seflue
Copy link
Collaborator

@seflue seflue commented May 21, 2024

This feature relies on a refactoring proposed in PR #15.
@lyz-code After that PR has been merged, I would rebase the current one, which consists actually only of one commit and only adds code.

@seflue
Copy link
Collaborator Author

seflue commented May 21, 2024

@lyz-code This feature uses an API extension proposed in PR #731 in nvim-orgmode. It does not break existing functionality, but as soon as a user creates a mapping and triggers it (or trys to run the Telescope extension with :Telescope insert_link he will get an error as long as nvim-orgmode has not been updated.

You can try it out on your machine by cloning my fork of nvim-orgmode.

@@ -0,0 +1,61 @@
-- Type-hints copied from nvim-orgmode to simplify development
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why these need to be copied over?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The LSP doesn't see types from a different lua module during development. Copying them into this file helped me a lot to see the types which got returned from the API functions.

Is there a way to tell the LSP where to look for them without copying them over?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you using https://github.com/folke/neodev.nvim ?

If yes, you can have it load all the plugins in the LSP so you get the autocompletion like this:

  require('neodev').setup({
    override = function(_, options)
      if not options.plugins then
        options.plugins = true
      end
      return options
    end,
  })

This is happening anyway when you are loading your config, but when you develop in a plugin it needs to explicit. I use only this by default since I don't need other:

  require('neodev').setup({
    override = function(_, options)
      if not options.plugins then
        options.plugins = { 'nvim-treesitter', 'plenary.nvim' }
      end
      return options
    end,
  })

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot. I stumbled upon this plugin a while ago but didn't take a deeper look. Will catch up on this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now I will keep the typehints here in the Telescope plugin. I actually installed the plugin but I'm probably to dumb and too impacient to configure it correctly for plugin development with nvim-orgmode.

Would you mind to provide a correct setup as a hint in the contributor section of the nvim-orgmode documentation?

@lyz-code
Copy link
Collaborator

@seflue the PR is merged, you can now refactor

This feature provides a convenient way to create links to existing
org-files and headlines via telescope.

It leverages the already existing search for headlines.

It relies on an extension of the API of nvim-orgmode, which exposes its
existing feature to insert links. The Telescope feature acts as a
drop-in-replacement to create/select the Link target.
@seflue
Copy link
Collaborator Author

seflue commented May 21, 2024

I rebased the PR and added some documentation.
@lyz-code Can you please merge, because PR #731 in nvim-orgmode also has been merged, so everything should work now.

Copy link
Collaborator

@lyz-code lyz-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again! Can't wait to try it

@lyz-code lyz-code merged commit 02d6876 into nvim-orgmode:main May 22, 2024
@seflue seflue deleted the insert_link branch May 23, 2024 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants