remove decoration from netrw previews
This commit is contained in:
parent
6a5e785a9f
commit
44385e1b3d
4 changed files with 33 additions and 9 deletions
|
|
@ -55,6 +55,25 @@ local function close_timer(state, key)
|
|||
state[key] = nil
|
||||
end
|
||||
|
||||
local function indent_guides_enabled(buf)
|
||||
local ok, config = pcall(require, 'ibl.config')
|
||||
if not ok or not config.config then
|
||||
return nil
|
||||
end
|
||||
return config.get_config(buf).enabled
|
||||
end
|
||||
|
||||
local function set_indent_guides(buf, enabled)
|
||||
if enabled == nil then
|
||||
return
|
||||
end
|
||||
|
||||
local ok, ibl = pcall(require, 'ibl')
|
||||
if ok and ibl.initialized then
|
||||
ibl.setup_buffer(buf, { enabled = enabled })
|
||||
end
|
||||
end
|
||||
|
||||
local function restore_preview_buffer(buf, for_editing)
|
||||
local metadata = preview_buffers[buf]
|
||||
if not metadata or not is_valid_buffer(buf) then
|
||||
|
|
@ -66,6 +85,7 @@ local function restore_preview_buffer(buf, for_editing)
|
|||
vim.bo[buf].buflisted = for_editing or metadata.buflisted
|
||||
vim.bo[buf].syntax = metadata.syntax
|
||||
vim.diagnostic.enable(metadata.diagnostics_enabled, { bufnr = buf })
|
||||
set_indent_guides(buf, metadata.indent_guides_enabled)
|
||||
if metadata.treesitter_active then
|
||||
pcall(vim.treesitter.start, buf)
|
||||
end
|
||||
|
|
@ -449,6 +469,7 @@ local function show_native_preview(state, entry)
|
|||
syntax = vim.bo[existing_buf].syntax,
|
||||
treesitter_active = vim.treesitter.highlighter.active[existing_buf] ~= nil,
|
||||
diagnostics_enabled = vim.diagnostic.is_enabled({ bufnr = existing_buf }),
|
||||
indent_guides_enabled = indent_guides_enabled(existing_buf),
|
||||
} or nil
|
||||
|
||||
local ok, shown = pcall(native_preview, entry)
|
||||
|
|
@ -472,6 +493,10 @@ local function show_native_preview(state, entry)
|
|||
and existing.buf == preview_buf
|
||||
and existing.diagnostics_enabled
|
||||
or vim.diagnostic.is_enabled({ bufnr = preview_buf }),
|
||||
indent_guides_enabled = existing ~= nil
|
||||
and existing.buf == preview_buf
|
||||
and existing.indent_guides_enabled
|
||||
or indent_guides_enabled(preview_buf),
|
||||
}
|
||||
|
||||
vim.bo[preview_buf].bufhidden = 'hide'
|
||||
|
|
@ -479,11 +504,8 @@ local function show_native_preview(state, entry)
|
|||
vim.b[preview_buf].netrw_live_preview_buffer = true
|
||||
pcall(vim.treesitter.stop, preview_buf)
|
||||
vim.diagnostic.enable(false, { bufnr = preview_buf })
|
||||
|
||||
local filetype = vim.bo[preview_buf].filetype
|
||||
if filetype ~= '' then
|
||||
vim.bo[preview_buf].syntax = filetype
|
||||
end
|
||||
vim.bo[preview_buf].syntax = ''
|
||||
set_indent_guides(preview_buf, false)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue