Skip to content
This repository has been archived by the owner on Jan 14, 2024. It is now read-only.

Title IDs #10

Closed
srid opened this issue Sep 18, 2020 · 9 comments
Closed

Title IDs #10

srid opened this issue Sep 18, 2020 · 9 comments

Comments

@srid
Copy link

srid commented Sep 18, 2020

[[Some note, with puctuation]] is now a valid link in neuron.

cf.

@fiatjaf
Copy link
Owner

fiatjaf commented Sep 19, 2020

This affects gzo. Must change it to use yi] to select text inside [] and then use that to get match against the zettel cache.

@srid
Copy link
Author

srid commented Oct 10, 2020

@flyinggrizzly
Copy link

flyinggrizzly commented Oct 14, 2020

I’m finding myself always renaming files with UID file names to something that reflects the note’s topic, usual skewer-cased. Realistically this means I don’t use gzN and instead just :vsp filename.md, but then I lose both the utility of the plugin and the guaranteed uniqueness provided by the UID.

Would a config option to use skewer-case suffixed with a UID be possible?

Something like “and then, an aeroplane” would generate and-then-an-aeroplane-97ghj76.md

@fiatjaf
Copy link
Owner

fiatjaf commented Oct 14, 2020

Yes, that is possible, but what happens if someone else comes here tomorrow and ask for a different algorithm? Maybe I should allow you to specify your own name function on your .vimrc?

@flyinggrizzly
Copy link

That would definitely work for me—it seems like a good balance for the project too.

@flyinggrizzly
Copy link

I’m happy to attempt this, but I haven’t worked with Vimscript before, so it may not be fast or the cleanest code.

Would you like me to try, or would you prefer to handle this yourself?

@fiatjaf
Copy link
Owner

fiatjaf commented Oct 15, 2020

I ended up doing it.

This was quite weird. I also have no experience with VimScript and had never seen any Vim plugin expose a function like that. Maybe there is something wrong with it but it seems to work fine.

I added a note here with some brief usage information: https://github.com/fiatjaf/neuron.vim#customization

Please let me know how that works for you.

@flyinggrizzly
Copy link

flyinggrizzly commented Oct 16, 2020

Thanks for that--I'm testing it out, and it's working great.

The only issue is that on loading vim, I get errors about duplicated bareword definitions, when I'm overriding the function. (I'm running Neovim 0.4.3 if it matters)

Would you be open to a PR that changed the GenerateNeuronID function to something like this?

function! g:GenerateNeuronID(title)
  if exists('*g:CustomNeuronIDGenerator')
    return g:CustomNeuronIDGenerator(title)
  else
    # existing default implementation
endfunction

(PR would also update documentation)

It seems like it'd be safer for the project if people aren't overriding a probably important function, and the plugin is in control of when (and whether, in case something big changes) the custom generator is called. It also makes things cleaner for users, without the errors.


Edit:

Looking closer at the code, seems like we might be able to get away with just updating the assignment to g:NeuronGenerateID on line 27 of plugin/neuron.vim to target a different customization function name to avoid the clash.

@fiatjaf
Copy link
Owner

fiatjaf commented Oct 16, 2020

Yes, I think your suggested changes make sense.
If you want to open a PR please do it. Otherwise in some days I may take a look at it again.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants