Skip to content

Commit

Permalink
feat: add disable_max_size option (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
stevearc committed Mar 31, 2022
1 parent 8681b03 commit defa94d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lua/aerial/backends/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ M.is_supported = function(bufnr, name)
if max_lines and max_lines > 0 and vim.api.nvim_buf_line_count(bufnr) > max_lines then
return false, "File exceeds disable_max_lines size"
end
local max_size = config.disable_max_size
if max_size and max_size > 0 then
local size = vim.fn.getfsize(vim.api.nvim_buf_get_name(bufnr))
-- size will be -2 if it doesn't fit into a number
if size > max_size or size == -2 then
return false, "File exceeds disable_max_size"
end
end
local backend = M.get_backend_by_name(name)
if backend then
local supported, err = backend.is_supported(bufnr)
Expand Down
3 changes: 3 additions & 0 deletions lua/aerial/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ local default_options = {
-- Disable aerial on files with this many lines
disable_max_lines = 10000,

-- Disable aerial on files this size or larger (in bytes)
disable_max_size = 10000000,

-- A list of all symbols to display. Set to false to display all symbols.
-- This can be a filetype map (see :help aerial-filetype-map)
-- To see all available values, see :help SymbolKind
Expand Down

0 comments on commit defa94d

Please sign in to comment.