Skip to content

Commit

Permalink
refactor(popup, split): remove spinner dependency and redundant filet…
Browse files Browse the repository at this point in the history
…ype settings
  • Loading branch information
jellydn committed Oct 27, 2024
1 parent 27ebe95 commit 1522aab
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
3 changes: 1 addition & 2 deletions lua/hurl/popup.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ local event = require('nui.utils.autocmd').event
local Layout = require('nui.layout')

local utils = require('hurl.utils')
local spinner = require('hurl.spinner')

local M = {}

Expand Down Expand Up @@ -143,7 +142,7 @@ M.clear = function()
-- Clear the buffer and add `Processing...` message with spinner and Hurl command
for _, popup in pairs(popups) do
vim.api.nvim_buf_set_lines(popup.bufnr, 0, -1, false, {
'Processing... ' .. spinner.get_spinner(),
'Processing... ',
_HURL_GLOBAL_CONFIG.last_hurl_command or 'N/A',
})
end
Expand Down
18 changes: 1 addition & 17 deletions lua/hurl/split.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ local split = Split({
relative = 'editor',
position = _HURL_GLOBAL_CONFIG.split_position,
size = _HURL_GLOBAL_CONFIG.split_size,
buf_options = { filetype = 'markdown' },
})

local utils = require('hurl.utils')
local spinner = require('hurl.spinner')

local M = {}

Expand All @@ -25,10 +25,6 @@ M.show = function(data, type)
-- mount/open the component
split:mount()

-- Set a custom filetype for window management, but use markdown for syntax highlighting
vim.api.nvim_buf_set_option(split.bufnr, 'filetype', 'markdown')
vim.api.nvim_buf_set_var(split.bufnr, 'hurl_nvim_buffer', true)

if _HURL_GLOBAL_CONFIG.auto_close then
-- unmount component when buffer is closed
split:on(event.BufLeave, function()
Expand Down Expand Up @@ -93,18 +89,6 @@ M.show = function(data, type)
-- Set content
vim.api.nvim_buf_set_lines(split.bufnr, 0, -1, false, output_lines)

-- Set content to highlight and configure folding
vim.defer_fn(function()
-- Disable TreeSitter-based folding for this buffer
vim.api.nvim_buf_set_option(split.bufnr, 'foldmethod', 'manual')

-- Set filetype to markdown for syntax highlighting
vim.api.nvim_buf_set_option(split.bufnr, 'filetype', 'markdown')

-- Refresh folding
vim.cmd('normal! zx')
end, 0)

split:map('n', _HURL_GLOBAL_CONFIG.mappings.close, function()
quit()
end)
Expand Down

0 comments on commit 1522aab

Please sign in to comment.