Skip to content

Commit

Permalink
fix(hurl): fold not work if set foldexpr to `vim.treesitter.foldexpr(…
Browse files Browse the repository at this point in the history
…)` (#162)

set filetype to `hurl-nvim` by default make `vim.treesitter.foldexpr()` not work, causes zc zo to fail. this commit check if edgy.nvim exists and then set filetype to hurl-nvim, otherwise just set filetype to input param type.
  • Loading branch information
wenjinnn authored May 28, 2024
1 parent e833f9b commit 356194e
Showing 1 changed file with 9 additions and 6 deletions.
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)

vim.api.nvim_buf_set_name(split.bufnr, 'hurl-response')

Expand Down Expand Up @@ -61,9 +67,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

0 comments on commit 356194e

Please sign in to comment.