From a4b2fd5ba5ec3cdd9c3c7a5f6868b6c52eea0313 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikael=20Elki=C3=A6r?= <2102306+MikaelElkiaer@users.noreply.github.com> Date: Wed, 4 May 2022 14:09:20 +0200 Subject: [PATCH] Adds generic mapping of filetype to ts parser name (#89) * Revert "Rename cs.lua to c_sharp.lua" This reverts commit 32adfde9b0fe65cd8084ec943a191ee641e7fd4b. * Adds generic mapping of filetype to ts parser name --- lua/neogen/configurations/{c_sharp.lua => cs.lua} | 0 lua/neogen/generator.lua | 4 +++- 2 files changed, 3 insertions(+), 1 deletion(-) rename lua/neogen/configurations/{c_sharp.lua => cs.lua} (100%) diff --git a/lua/neogen/configurations/c_sharp.lua b/lua/neogen/configurations/cs.lua similarity index 100% rename from lua/neogen/configurations/c_sharp.lua rename to lua/neogen/configurations/cs.lua diff --git a/lua/neogen/generator.lua b/lua/neogen/generator.lua index b762176..bd25bf1 100644 --- a/lua/neogen/generator.lua +++ b/lua/neogen/generator.lua @@ -6,6 +6,7 @@ if not ok then notify("neogen requires nvim-treesitter to operate :(", vim.log.levels.ERROR) return function(_, _) end end +local ts_parsers = require("nvim-treesitter.parsers") local conf = require("neogen.config").get() local granulator = require("neogen.granulator") @@ -38,7 +39,8 @@ local function todo_text(type) end local function get_parent_node(filetype, typ, language) - local parser = vim.treesitter.get_parser(0, filetype) + local parser_name = ts_parsers.ft_to_lang(filetype) + local parser = vim.treesitter.get_parser(0, parser_name) local tstree = parser:parse()[1] local tree = tstree:root()