Skip to content

Commit 5cfaad2

Browse files
authored
fix: Incorrect TreeSitter language for queries. (#405)
The filetype is not always the same as the parser language type, e.g. "latex" being the language but "tex" being the filetype. Should resolve #404.
1 parent d56752d commit 5cfaad2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lua/nvim-surround/queries.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ M.get_selection = function(capture, type)
4242
local treesitter = require("nvim-surround.treesitter")
4343

4444
local root = treesitter.get_root()
45-
local query = get_query(vim.bo.filetype, type)
45+
local language = vim.treesitter.language.get_lang(vim.bo.filetype) or vim.bo.filetype
46+
local query = get_query(language, type)
4647
if root == nil or query == nil then
4748
return nil
4849
end

0 commit comments

Comments
 (0)