From 71c1bc295f4677922539e86de03fefc49752f508 Mon Sep 17 00:00:00 2001 From: Nicolas Goudry Date: Tue, 4 Jun 2024 20:59:45 +0200 Subject: [PATCH] feat(config): add large buffer handling --- config/largebuf.nix | 25 +++++++++++++++++++++++++ plugins/astrocore/default.nix | 10 +++++++--- 2 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 config/largebuf.nix diff --git a/config/largebuf.nix b/config/largebuf.nix new file mode 100644 index 0000000..11fa1fd --- /dev/null +++ b/config/largebuf.nix @@ -0,0 +1,25 @@ +{ + # Adapted from AstroNvim and Reddit comment + # https://github.com/AstroNvim/astrocore/blob/v1.5.0/lua/astrocore/init.lua#L473-L486 + # https://www.reddit.com/r/neovim/comments/z85s1l/comment/iyfrgvb/ + autoGroups.large_buffer_detector = { }; + autoCmd = [ + { + desc = "Handle large buffers"; + event = "BufRead"; + group = "large_buffer_detector"; + + callback.__raw = '' + function(args) + if vim.b.large_buf then + vim.cmd("syntax off") + vim.cmd(("TSBufDisable %s"):format(args.buf)) + vim.cmd("LspStop") + vim.opt_local.foldmethod = "manual" + vim.opt_local.spell = false + end + end + ''; + } + ]; +} diff --git a/plugins/astrocore/default.nix b/plugins/astrocore/default.nix index 74a391e..e745e02 100644 --- a/plugins/astrocore/default.nix +++ b/plugins/astrocore/default.nix @@ -1,7 +1,11 @@ { lib, pkgs, ... }: { - extra.packages = [ - (import ./package { inherit lib pkgs; }) - ]; + extra = { + packages = [ + (import ./package { inherit lib pkgs; }) + ]; + + config = "require('astrocore').setup({})"; + }; }