joplin-plugin-cm-linenumbers
joplin-plugin-cm-linenumbers copied to clipboard
Make line numbers relative
This makes the displayed line numbers relative to current line. The current line number will also be displayed. This is the same behavior as Vim hybrid line numbers (:set number relativenumber).
I find this the most useful when using Vim. We could also add a build option to let the user choose between absolute and relative.
reference for implementation: https://github.com/codemirror/CodeMirror/issues/4116
Awesome work, @jannes 👍 It works perfectly. Could you please see if you could add the option to choose between absolute and relative. If you'd like to do that as a separate PR, that's ok too (Let me know if that's the case).
I'll have a look, so you think just having to different npm commands to build one or the other would be good?
E.g npm run dist-absolute
, npm run dist-relative
I was thinking of more like adding a setting using joplin.settings
API that users could flip on/off. But in case it looks time consuming to do, different npm commands is ok to do for now and I can add the settings myself once I get a breather from work.
No, I agree that would be the nicest, but are you sure that this is already possible with the current plugin system? If so, I would have a look at this the coming days
Edit: I don't think it is possible yet to have subsettings for plugins. But we can add an extra menu item 'Toggle absolute/relative linenumbers' in the 'View' menu. What do you think?
But we can add an extra menu item 'Toggle absolute/relative linenumbers' in the 'View' menu.
Yes, this should be good.
Still haven't found the time to implement the setting.
But I notice that the relative line numbers do not work consistently, after some time of having Joplin open it stops working and just uses the absolute numbering. Can you confirm this behavior?
It seems like the event handler for 'cursorActivity' is overriden/removed somehow, can not explain this otherwise.
Hmm, I haven't seen that behavior. My instance has been open for many days but it's still showing relative numbers. Will keep an eye out for it.