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(hurl): fold not work if set foldexpr to vim.treesitter.foldexpr() #162

Merged
merged 1 commit into from
May 28, 2024
Merged
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
15 changes: 9 additions & 6 deletions lua/hurl/split.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ local split = Split({
relative = 'editor',
position = _HURL_GLOBAL_CONFIG.split_position,
size = _HURL_GLOBAL_CONFIG.split_size,
-- Create a custom filetype so that we can use https://github.com/folke/edgy.nvim to manage the window
-- E.g: { title = "Hurl Nvim", ft = "hurl-nvim" },
buf_options = { filetype = 'hurl-nvim' },
})

local utils = require('hurl.utils')
Expand All @@ -22,6 +19,15 @@ local M = {}
M.show = function(data, type)
-- mount/open the component
split:mount()
-- If have edgy.nvim
if pcall(require, 'edgy') then
-- Create a custom filetype so that we can use https://github.com/folke/edgy.nvim to manage the window
-- E.g: { title = "Hurl Nvim", ft = "hurl-nvim" },
vim.api.nvim_buf_set_option(split.bufnr, 'filetype', 'hurl-nvim')
end

-- Set content to highlight, refer https://github.com/MunifTanjim/nui.nvim/issues/76#issuecomment-1001358770
vim.api.nvim_buf_set_option(split.bufnr, 'filetype', type)
Comment on lines +23 to +30
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Potential issue: The filetype is set twice when edgy.nvim is available.

The current logic sets the filetype to 'hurl-nvim' if edgy.nvim is available (line 26), but then it immediately sets it again to the type parameter (line 30). This could lead to unexpected behavior or override settings intended for 'hurl-nvim'. Consider restructuring the logic to ensure the filetype is set only once based on the conditions.


if _HURL_GLOBAL_CONFIG.auto_close then
-- unmount component when buffer is closed
Expand Down Expand Up @@ -57,9 +63,6 @@ M.show = function(data, type)
split:map('n', 'q', function()
quit()
end)

-- Set content to highlight, refer https://github.com/MunifTanjim/nui.nvim/issues/76#issuecomment-1001358770
vim.api.nvim_buf_set_option(split.bufnr, 'filetype', type)
end

M.clear = function()
Expand Down