From eb53aba5af5c572a5679606937fabca1ac03db5d Mon Sep 17 00:00:00 2001 From: Riley Bruins Date: Sun, 14 Jul 2024 08:10:19 -0700 Subject: [PATCH] fix(treesitter): recognize aliased parsers in omnifunc, query linter **Problem:** A query file for something like `html_tags` will not be given html node completion **Solution:** Check for parser aliases before offering completions Co-authored-by: Lewis Russell (cherry picked from commit 05dcda8f9b0583505327692570a2cfd0225124dc) --- runtime/lua/vim/treesitter/_query_linter.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/runtime/lua/vim/treesitter/_query_linter.lua b/runtime/lua/vim/treesitter/_query_linter.lua index 12b4cbc7b9..6b8c3a17f2 100644 --- a/runtime/lua/vim/treesitter/_query_linter.lua +++ b/runtime/lua/vim/treesitter/_query_linter.lua @@ -40,7 +40,8 @@ end local function guess_query_lang(buf) local filename = api.nvim_buf_get_name(buf) if filename ~= '' then - return vim.F.npcall(vim.fn.fnamemodify, filename, ':p:h:t') + local resolved_filename = vim.F.npcall(vim.fn.fnamemodify, filename, ':p:h:t') + return resolved_filename and vim.treesitter.language.get_lang(resolved_filename) or nil end end