From 3447ed4def7bee1172f8885cba0cc55440d96a5f Mon Sep 17 00:00:00 2001 From: sharkdp Date: Mon, 3 Sep 2018 21:49:08 +0200 Subject: [PATCH] Add CSV syntax, closes #254 --- .gitmodules | 3 ++ assets/syntaxes/CSV | 1 + assets/syntaxes/CSV.sublime-syntax | 46 ++++++++++++++++++++++++++++++ 3 files changed, 50 insertions(+) create mode 160000 assets/syntaxes/CSV create mode 100644 assets/syntaxes/CSV.sublime-syntax diff --git a/.gitmodules b/.gitmodules index 91a88711..b4fc4d7e 100644 --- a/.gitmodules +++ b/.gitmodules @@ -61,3 +61,6 @@ [submodule "assets/syntaxes/Puppet"] path = assets/syntaxes/Puppet url = https://github.com/russCloak/SublimePuppet +[submodule "assets/syntaxes/CSV"] + path = assets/syntaxes/CSV + url = https://github.com/wadetb/Sublime-Text-Advanced-CSV diff --git a/assets/syntaxes/CSV b/assets/syntaxes/CSV new file mode 160000 index 00000000..4786d037 --- /dev/null +++ b/assets/syntaxes/CSV @@ -0,0 +1 @@ +Subproject commit 4786d037a761bc45e516f6b0624a839919ec6d05 diff --git a/assets/syntaxes/CSV.sublime-syntax b/assets/syntaxes/CSV.sublime-syntax new file mode 100644 index 00000000..1bbc5b97 --- /dev/null +++ b/assets/syntaxes/CSV.sublime-syntax @@ -0,0 +1,46 @@ +%YAML 1.2 +--- +# http://www.sublimetext.com/docs/3/syntax.html +name: Advanced CSV +file_extensions: + - csv + - tsv +scope: text.advanced_csv +contexts: + main: + - match: (\") + captures: + 1: string.quoted.double.advanced_csv + push: + - meta_scope: meta.quoted.advanced_csv + - match: (\") + captures: + 1: string.quoted.double.advanced_csv + pop: true + - include: main + - match: '(\[([+-]?\d*)(\:)?([+-]?\d*)(\,)?([+-]?\d*)(\:)?([+-]?\d*)\])?\s*([<>v^])?\s*(=)' + captures: + 1: keyword.operator.advanced_csv + 2: constant.numeric.formula.advanced_csv + 4: constant.numeric.formula.advanced_csv + 6: constant.numeric.formula.advanced_csv + 8: constant.numeric.formula.advanced_csv + 9: keyword.operator.advanced_csv + 10: keyword.operator.advanced_csv + push: + - meta_scope: meta.range.advanced_csv + - match: (?=(\")|$) + pop: true + - include: scope:source.python + - match: '(?<=^|,|\s|\")([0-9.eE+-]+)(?=$|,|\s|\")' + scope: meta.number.advanced_csv + captures: + 1: constant.numeric.advanced_csv + - match: '(?<=^|,|\s|\")([^, \t\"]+)(?=$|,|\s|\")' + scope: meta.nonnumber.advanced_csv + captures: + 1: storage.type.advanced_csv + - match: (\,) + scope: meta.delimiter.advanced_csv + captures: + 1: keyword.operator.advanced_csv