1
1
mirror of https://github.com/tstack/lnav.git synced 2024-09-11 13:05:51 +03:00

[highlight] turn off nesting for some builtin highlighters

This commit is contained in:
Tim Stack 2022-09-19 20:30:56 -07:00
parent e0ecbdff10
commit f1deeb5b74
5 changed files with 27 additions and 15 deletions

View File

@ -385,12 +385,15 @@ setup_highlights(highlight_map_t& hm)
.with_role(role_t::VCR_FILE);
hm[{highlight_source_t::INTERNAL, "1.stringd"}]
= highlighter(xpcre_compile(R"("(?:\\.|[^"])*")"))
.with_nestable(false)
.with_role(role_t::VCR_STRING);
hm[{highlight_source_t::INTERNAL, "1.strings"}]
= highlighter(xpcre_compile(R"((?<![A-WY-Za-qstv-z])'(?:\\.|[^'])*')"))
.with_nestable(false)
.with_role(role_t::VCR_STRING);
hm[{highlight_source_t::INTERNAL, "1.stringb"}]
= highlighter(xpcre_compile("`(?:\\\\.|[^`])*`"))
.with_nestable(false)
.with_role(role_t::VCR_STRING);
hm[{highlight_source_t::INTERNAL, "diffp"}]
= highlighter(xpcre_compile("^\\+.*")).with_role(role_t::VCR_DIFF_ADD);
@ -403,7 +406,8 @@ setup_highlights(highlight_map_t& hm)
hm[{highlight_source_t::INTERNAL, "0.comment"}]
= highlighter(
xpcre_compile(
R"((?<=[\s;])//.*|/\*.*\*/|\(\*.*\*\)|^#.*|\s+#.*|dnl.*)"))
R"((?<=[\s;])//.*|/\*.*\*/|\(\*.*\*\)|^#\s*(?!include|if|ifndef|elif|else|endif|error|pragma|define|undef).*|\s+#.*|dnl.*)"))
.with_nestable(false)
.with_role(role_t::VCR_COMMENT);
hm[{highlight_source_t::INTERNAL, "javadoc"}]
= highlighter(
@ -435,6 +439,14 @@ setup_highlights(highlight_map_t& hm)
.with_text_format(text_format_t::TF_C_LIKE)
.with_text_format(text_format_t::TF_JAVA)
.with_role(role_t::VCR_SYMBOL);
hm[{highlight_source_t::INTERNAL, "cpp"}]
= highlighter(
xpcre_compile(
R"(^#\s*(?:include|ifdef|ifndef|if|else|elif|error|endif|define|undef|pragma))"))
.with_nestable(false)
.with_text_format(text_format_t::TF_C_LIKE)
.with_text_format(text_format_t::TF_JAVA)
.with_role(role_t::VCR_KEYWORD);
hm[{highlight_source_t::INTERNAL, "num"}]
= highlighter(xpcre_compile(R"(\b-?(?:\d+|0x[a-zA-Z0-9]+)\b)"))
.with_nestable(false)

View File

@ -1,11 +1,11 @@
''
''
{
 "foo bar" : null,
  "array" : [
  1,
  2,
  3
 ],
 "foo bar" : null,
  "array" : [
  1,
  2,
  3
],
"obj" : {
"one" : 1,
"two" : true

View File

@ -4,5 +4,5 @@
 select Id from Account where id = $sfid
 ^
 ERROR at Row:1:Column:34
 line 1:34 no viable alternative at character '$'
""}]}
 line 1:34 no viable alternative at character '$'
""}]}

View File

@ -10,8 +10,8 @@
▌[8] - https://snapcraft.io/lnav
<img
src="https://assets-global.website-files.com/6257adef93867e50d84d30e2/62594fddd654fc29fcc07359_cb48d2a8d4991281d7a6a95d2f58195e.svg"
height="20"/>[1]
src="https://assets-global.website-files.com/6257adef93867e50d84d30e2/62594fddd654fc29fcc07359_cb48d2a8d4991281d7a6a95d2f58195e.svg"
height="20"/>[1]
▌[1] - https://discord.gg/erBPnKwz7R

View File

@ -27,11 +27,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "log_level.hh"
#include "log_level.hh"
#include <ctype.h>
#include <ctype.h>
#include "config.h"
#include "config.h"
const char* level_names[LEVEL__MAX + 1] = {
"unknown",