Fix pcre2 issue with ripgrep (closes #145) (#148)

* fix(tags): fix rg command if PCRE not available (closes #145)

Some linux distro do not compile ripgrep using the --pcre2 flag.
This commit checks if the --pcre2 flag is available and then tweaks the
ripgrep command accordingly.

At the moment, it will therefore not be possible to filter-out
hexademical color codes from #tags for people that do not have the
--pcre2 flag available. This will be documented in a later commit.

**Important**: the detection of the PCRE availability is done by trying
a simple rg search using _os.execute_. This function interface was
changed in Lua 5.2, which means it will break when Neovim will update to
Lua >5.1. The fix is already there in commented form.

Fixes #145

* refact: cleanup

* doc(tag): add note about rg --pcre2

* doc(tag): add note about rg --pcre2 in vim help
This commit is contained in:
lambtho
2022-06-26 17:49:19 +00:00
committed by GitHub
parent 440033919e
commit 994a44999f
4 changed files with 56 additions and 6 deletions

View File

@@ -157,12 +157,12 @@ telekasten.setup({opts})
Default: '~/zettelkasten'
----------------------
Note to Windows users:
Note to Windows users:
If you must use Windows, avoid using the drive path. You may use it,
If you must use Windows, avoid using the drive path. You may use it,
but telekasten will ignore the drive name and create your main markdown
/ zettelkasten folder in the same drive that neovim executes from. This
is because of how Telescope handles files paths. Windows paths must be
is because of how Telescope handles files paths. Windows paths must be
stripped of the drive name or else the path will not be read correctly.
This is done automatically but is advised that you avoid adding it.
@@ -755,6 +755,17 @@ Note:~
default. This automatically sets the to `telekasten`, and also registers the
syntax with telescope previewers for `.md` files.
Note:
When using the `#tag` notation, telekasten will try to differentiate an
actual tag from an hexadecimal code (e.g. `#FF0000`) to prevent false
matches. This is achieved by using the `--pcre2` flag of `ripgrep`. However,
some linux distribution (mostly the ones based on Debian) do not compile
ripgrep with this flag by default, making it impossible to use. If this is
the case, the tag functions of telekasten will not be able to differentiate
color codes from actual tags and will return everything. A workaround is to
either use the `:tag:` notation or to recompile ripgrep locally with the
appropriate flag (see issues # 115 and #145).
--------------------------------------------------------------------------------
Section 3.3: Templates *telekasten.templates*