Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: don't use tree-sitter to get module name for mod snippet #28

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `<filename>:t:r`.

## [1.4.3] - 2023-12-15

Expand Down
5 changes: 1 addition & 4 deletions lua/haskell-snippets/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading