I'm trying to change the foldmethod option for httpResult buffer with different strategies:
Creating a file in stdpath("config")/ftplugin/httpResult.vim (or after/ftplugin/httpResult.vim) with setlocal foldmethod=indent (and verifying that is executed, with :scriptnames)
Adding an autocommand with autocmd FileType httpResult set foldmethod=indent
The only way I could make it happen was modifying the plugin source code:
diff --git lua/rest-nvim/curl/init.lua lua/rest-nvim/curl/init.lua
index 7de0b9c..10fb302 100644
--- lua/rest-nvim/curl/init.lua
+++ lua/rest-nvim/curl/init.lua
@@ -36,6 +36,7 @@ M.get_or_create_buf = function()
vim.api.nvim_buf_set_name(new_bufnr, tmp_name)
vim.api.nvim_buf_set_option(new_bufnr, "ft", "httpResult")
vim.api.nvim_buf_set_option(new_bufnr, "buftype", "nofile")
+ vim.api.nvim_set_option("foldlevelstart", 1)
return new_bufnr
end
@@ -98,6 +99,7 @@ local function create_callback(method, url)
vim.cmd(cmd_split .. res_bufnr)
-- Set unmodifiable state
vim.api.nvim_buf_set_option(res_bufnr, "modifiable", false)
+ vim.api.nvim_win_set_option(vim.fn.bufwinid(res_bufnr), "foldmethod", "indent")
end
-- Send cursor in response buffer to start
Any ideas how this could work?
Even better would be if I could use json treesitter highlighting and folding in the httpResult buffer, but I guess it would be more difficult (making a httpResult treesitter parser and inject the json parser).
Hi, nice plugin!
I'm trying to change the
foldmethod
option forhttpResult
buffer with different strategies:Creating a file in
stdpath("config")/ftplugin/httpResult.vim
(orafter/ftplugin/httpResult.vim
) withsetlocal foldmethod=indent
(and verifying that is executed, with:scriptnames
)Adding an autocommand with
autocmd FileType httpResult set foldmethod=indent
The only way I could make it happen was modifying the plugin source code:
Any ideas how this could work?
Even better would be if I could use json treesitter highlighting and folding in the httpResult buffer, but I guess it would be more difficult (making a httpResult treesitter parser and inject the json parser).
Thank you.