From e381847ea289d60dec43e500ca8362f298c8e33f Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Mon, 13 May 2024 18:38:38 +0200 Subject: [PATCH] fix: don't use tree-sitter to get module name for `mod` snippet --- CHANGELOG.md | 2 ++ lua/haskell-snippets/module.lua | 5 +---- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 542dc56..c0e5537 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 tree-sitter-haskell v0.21.0 rewrite. Because there are not many queries, this plugin maintains backward compatibility with the previous tree-sitter-haskell implementation for now. +- Don't use tree-sitter to get the module name for the `mod` snippet, + as this is most likely not set. Instead, use `:t:r`. ## [1.4.3] - 2023-12-15 diff --git a/lua/haskell-snippets/module.lua b/lua/haskell-snippets/module.lua index 525e0c2..8f3e178 100644 --- a/lua/haskell-snippets/module.lua +++ b/lua/haskell-snippets/module.lua @@ -62,10 +62,7 @@ end ---@return string | nil local function get_buf_module_name(_) - local buf_content = table.concat(vim.api.nvim_buf_get_lines(0, 0, -1, false), '\n') - return treesitter_module_name(function(mod) - return mod - end, buf_content, '(haskell (header module: (module) @mod))', '(haskell module: (module) @mod)') + return vim.fn.fnamemodify(vim.api.nvim_buf_get_name(0), ':t:r') end local function get_module_name_node()