Browse Source

nixpkgs/neovim: fix crash in deeply nested JSX

Thomas Dy 3 months ago
parent
commit
f9fd42ef03

+ 6 - 0
.config/nixpkgs/neovim/plugins/default.nix

@@ -10,6 +10,12 @@ let
     "jose-elias-alvarez/typescript.nvim" = {
       patches = [ ./typescript-nvim-tsserver.patch ];
     };
+
+    "nvim-treesitter/nvim-treesitter" = {
+      # these extra rules causes nvim to crash when looking at a deeply nested
+      # JSX expression
+      patches = [ ./treesitter-jsx.patch ];
+    };
   };
 
   buildPlugin = name: spec:

+ 92 - 0
.config/nixpkgs/neovim/plugins/treesitter-jsx.patch

@@ -0,0 +1,92 @@
+diff --git a/queries/jsx/highlights.scm b/queries/jsx/highlights.scm
+index a53b9533..deb3c159 100644
+--- a/queries/jsx/highlights.scm
++++ b/queries/jsx/highlights.scm
+@@ -65,87 +65,3 @@
+ (jsx_text) @none @spell
+ 
+ (html_character_reference) @character.special
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.heading)
+-  (#eq? @_tag "title"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.heading.1)
+-  (#eq? @_tag "h1"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.heading.2)
+-  (#eq? @_tag "h2"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.heading.3)
+-  (#eq? @_tag "h3"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.heading.4)
+-  (#eq? @_tag "h4"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.heading.5)
+-  (#eq? @_tag "h5"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.heading.6)
+-  (#eq? @_tag "h6"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.strong)
+-  (#any-of? @_tag "strong" "b"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.italic)
+-  (#any-of? @_tag "em" "i"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.strikethrough)
+-  (#any-of? @_tag "s" "del"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.underline)
+-  (#eq? @_tag "u"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.raw)
+-  (#any-of? @_tag "code" "kbd"))
+-
+-((jsx_element
+-  (jsx_opening_element
+-    name: (identifier) @_tag)
+-  (jsx_text) @markup.link.label)
+-  (#eq? @_tag "a"))
+-
+-((jsx_attribute
+-  (property_identifier) @_attr
+-  (string
+-    (string_fragment) @string.special.url))
+-  (#any-of? @_attr "href" "src"))