xwmx / nb

CLI and local web plain text note‑taking, bookmarking, and archiving with linking, tagging, filtering, search, Git versioning & syncing, Pandoc conversion, + more, in a single portable script.
https://xwmx.github.io/nb
GNU Affero General Public License v3.0
6.43k stars 181 forks source link

[Feature] Add a variable for Ace editor option "relativeLineNumbers" #236

Closed tkapias closed 1 year ago

tkapias commented 1 year ago

Hi,

Could you add a new variable to customize this option? With a default to false.

"relativeLineNumbers" is useful with vim as an ACE keyboard and the gutter displayed because it gives you the current line number and à relative number for the others. It makes some vim operation with lines easier.

--- nb  2023-02-09 04:00:43.881239652 +0700
+++ /usr/local/bin/nb   2023-02-09 03:53:06.695281859 +0700
@@ -11521,6 +11521,7 @@
       showGutter:               true,
       showInvisibles:           true,
       showLineNumbers:          true,
+      relativeLineNumbers:      false,
       tabSize:                  2,
       useSoftTabs:              true,
       wrap:                     false
@@ -11547,6 +11548,12 @@
       })
     }

+    if ('${NB_ACE_RELATIVE_LINENUMBERS:-0}' === '1') {
+      editor.setOptions({
+        relativeLineNumbers:    true
+      })
+    }
+
     var keyboard = '${NB_ACE_KEYBOARD:-ace}';

     if (['emacs', 'sublime', 'vim', 'vscode'].indexOf(keyboard) !== -1) {
tkapias commented 1 year ago

here is my .nbrc if want to try the same setup:

NB_DIR=$HOME/.nb
NB_NOTEBOOK_PATH=$NB_DIR/home
NBRC_PATH=$HOME/.nbrc

NB_AUDIO_TOOL=mplayer
NB_DATA_TOOL=tidy-viewer
NB_DIRECTORY_TOOL=vifmrun
NB_ENCRYPTION_TOOL=openssl
NB_IMAGE_TOOL='pixterm -d 0 -s 2 -m 2b2b2b'

NB_BROWSER=w3m
NB_EDITOR=vim
NB_GUI_BROWSER=firefox

NB_DEFAULT_EXTENSION=md
NB_AUTO_SYNC=1
NB_BROWSE_COLUMNS=70

NB_COLOR_PRIMARY=69
NB_COLOR_SECONDARY=8
NB_COLOR_THEME=twilight
NB_SYNTAX_THEME=TwoDark

NB_FOOTER=1
NB_HEADER=2
NB_LIMIT=auto

NB_SERVER_HOST=localhost
NB_SERVER_PORT=6789

NB_ACE_ENABLED=1
NB_ACE_KEYBOARD=vim
NB_ACE_MD_GUTTER=1
NB_ACE_RELATIVE_LINENUMBERS=1
NB_ACE_SOFT_TABS=1
NB_ACE_THEME=twilight
xwmx commented 1 year ago

Done! The only tweak I made was the addition of an underscore between LINE and NUMBERS to better reflect the casing in the setting name. Thanks for the detailed information.

tkapias commented 1 year ago

Thank You!