From 90a99a41f639f76f6a6712d51578de461d8ff6cf Mon Sep 17 00:00:00 2001 From: Lambtho Date: Wed, 27 Apr 2022 21:25:00 +0200 Subject: [PATCH] fix: hex colors no longer tags (closes #115) --- lua/taglinks/tagutils.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/taglinks/tagutils.lua b/lua/taglinks/tagutils.lua index 3abe3cc..a5b0df3 100644 --- a/lua/taglinks/tagutils.lua +++ b/lua/taglinks/tagutils.lua @@ -1,7 +1,8 @@ local Job = require("plenary.job") local M = {} -local hashtag_re = "(^|\\s|'|\")#[a-zA-ZÀ-ÿ]+[a-zA-ZÀ-ÿ0-9/\\-_]*" +local hashtag_re = + "(^|\\s|'|\")((?!(#[a-fA-F0-9]{3})(\\W|$)|(#[a-fA-F0-9]{6})(\\W|$))#[a-zA-ZÀ-ÿ]+[a-zA-ZÀ-ÿ0-9/\\-_]*)" local colon_re = "(^|\\s):[a-zA-ZÀ-ÿ]+[a-zA-ZÀ-ÿ0-9/\\-_]*:" local yaml_re = "(^|\\s)tags:\\s*\\[([a-zA-ZÀ-ÿ]+[a-zA-ZÀ-ÿ0-9/\\-_]*(,\\s)*)*]" @@ -19,7 +20,7 @@ local function command_find_all_tags(opts) re = yaml_re end - return "rg", { "--vimgrep", "-o", re, "--", opts.cwd } + return "rg", { "--vimgrep", "--pcre2", "-o", re, "--", opts.cwd } end -- strips away leading ' or " , then trims whitespace @@ -108,7 +109,7 @@ end M.do_find_all_tags = function(opts) local cmd, args = command_find_all_tags(opts) - -- print(cmd .. " " .. vim.inspect(args)) + --print(cmd .. " " .. vim.inspect(args)) local ret = {} local _ = Job :new({