Resaltado de Parser Personalizado en nvim-treesitter: Causas y Solución con after/

Descubre por qué un parser personalizado en nvim-treesitter compila pero no resalta y cómo solucionarlo con after/queries para extender los highlights sin modificarlos. Guía y servicios de Q2BSTUDIO.

20 sept 2025 • 3 min read • Q2BSTUDIO Team

Inteligencia-Artificial-

Resaltado de Parser Personalizado en nvim-treesitter Causas y Solución con after/ Por Q2BSTUDIO, empresa de desarrollo de software y aplicaciones a medida, especialistas en inteligencia artificial, ciberseguridad y servicios cloud aws y azure

Si has creado un parser personalizado para tree sitter y en Neovim ves que el parser funciona pero el resaltado no se aplica, este artículo explica la causa habitual y la solución práctica. En Q2BSTUDIO ofrecemos servicios de software a medida y asesoría técnica para integrar herramientas avanzadas como tree sitter en flujos de trabajo profesionales, incluyendo soluciones de ia para empresas y agentes IA.

El problema resumido Es común que al registrar un parser personalizado en nvim-treesitter el compilador del parser se instale correctamente y nodos específicos se reconozcan en el árbol sintáctico, pero que ningúna regla de resaltado se aplique en el buffer. Comandos como TSPlaygroundToggle muestran nodos nuevos y TSCaptureUnderCursor puede confirmar la presencia de esos nodos, sin embargo no aparecen grupos de highlight. La razón es una especificidad de nvim-treesitter: las consultas o queries para resaltado se buscan en la carpeta queries del propio nvim-treesitter y no dentro del repositorio del parser especificado en install_info.

La causa detallada nvim-treesitter construye y usa el parser desde la URL indicada en install_info pero ignora archivos de query dentro de ese repo. En la práctica esto significa que un archivo queries/cpp/highlights.scm en tu repositorio del parser será pasado por alto y no surtirá efecto.

La solución práctica Usar la carpeta after para extender las queries. Neovim carga las rutas runtime en orden y cualquier archivo dentro de after se procesa tras las definiciones por defecto. Paso 1 crear en tu repositorio personalizado la ruta after/queries/cpp/highlights.scm y añadir solo las reglas que amplían el resaltado de C++, p. ej. macros específicas de Unreal Engine. Ejemplo sencillo de contenido que puedes poner dentro de ese archivo dentro de tu repo: ;; extends ; Unreal Engine macros (uclass_macro UCLASS @attribute) (uproperty_macro UPROPERTY @attribute) Paso 2 asegurarte de que Neovim conoce la carpeta after añadiendo el repositorio del parser como plugin en tu gestor de plugins. Si usas lazy.nvim agrega el repositorio taku25/tree-sitter-unreal-cpp como plugin independiente; de ese modo su carpeta after se añade al runtimepath y al arrancar Neovim se cargarán las rules adicionales.

Por qué funciona El flujo de carga de Neovim lee primero las consultas estándar de C++, y después carga cualquier after/queries/cpp/highlights.scm encontrado en los plugins o en el runtimepath. Así no reemplazas ni rompes los highlights existentes, solo extiendes el conjunto con tus reglas específicas.

Recomendaciones prácticas Verifica primero con TSPlaygroundToggle y TSCaptureUnderCursor que el parser reconoce los nodos que esperas. Mantén las definiciones de highlights en after/queries/{filetype}/ y evita duplicar reglas ya proporcionadas por nvim-treesitter. Si distribuyes el parser como plugin, documenta la ruta after para que otros desarrolladores la encuentren fácilmente.

Servicios Q2BSTUDIO Si necesitas ayuda para integrar parsers personalizados, automatizar despliegues, o desarrollar aplicaciones complejas, nuestro equipo en Q2BSTUDIO ofrece desarrollo de software a medida y aplicaciones a medida, además de soluciones avanzadas en inteligencia artificial, agentes IA y consultoría para ia para empresas. También trabajamos en ciberseguridad, pentesting, servicios cloud aws y azure, servicios inteligencia de negocio y power bi para mejorar la observabilidad y decisión basada en datos.

Conclusión Si tu parser personalizado se compila pero no se resaltan las reglas, muy probablemente nvim-treesitter está ignorando las queries en tu repo. La forma segura y efectiva de solucionarlo es colocar tus queries en after/queries/{filetype}/ y distribuir el parser como plugin para que su carpeta after se añada al runtimepath. En Q2BSTUDIO podemos ayudarte a implementar esta solución y a optimizar tu stack de desarrollo para proyectos con necesidades de alto valor técnico.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Artificial intelligence

AI agents, chatbots, and intelligent assistants that automate tasks and serve your customers 24/7 to improve the efficiency of your business.

More info

Software Development

Web, mobile, and desktop applications, intranets, e-commerce, SaaS, and management platforms designed for your company's specific needs.

More info

Cloud services

Migration, infrastructure, managed hosting, high availability, and security on Microsoft Azure and Amazon Web Services to help your business scale without limits.

More info

Cybersecurity and pentesting

Security audits, penetration testing and protection of applications, data and infrastructure on-premise and cloud, with ethical hacking and regulatory compliance.

More info

Business Intelligence

Dashboards and data analysis with Power BI: we integrate your sources, design dashboards and KPIs and turn your data into decisions.

More info

Process automation

We automate repetitive tasks and connect your applications with n8n, Power Automate, Make, and RPA, eliminating manual work and increasing productivity.

More info

Training for Companies

We train your teams in technology with criteria: web development, databases, Git, best practices and security, automation with n8n, artificial intelligence for companies and creation of AI solutions with Azure AI Foundry.

More info

Code Auditing

We audit the code that you, your team or an AI create: we tell you what is good and what to improve, we secure it and make it ready for production, web or app.

More info

AI Image Generation

We create for you the images that your business needs with artificial intelligence: product, networks, advertising, illustration and avatars. You tell us what you want and we deliver it ready to use.

More info

AI Video Generation

We create videos with artificial intelligence for you: promotional, networking, virtual presenters, dubbing and animations. You tell us the idea and we will deliver it assembled and ready to publish.

More info

AI Conversational Avatars

We create conversational avatars with AI – digital humans with a face and voice – that serve your customers and teams with the knowledge of your company, on your website, interactive monitors, WhatsApp or Teams.

More info

Online Marketing and AI

Google Ads, Meta Ads, LinkedIn Ads and AI Engine Positioning (GEO/AEO): we attract customers and make your brand appear where they search for you, also on ChatGPT, Gemini and Perplexity.

More info

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.