feat: Adding an autocommand to disable features on large files (just

folding for now).

Disabled the autocommand for the telescope folding
workaround.

Re-enabling debugging shortcuts.

Adding webp and png to the telescope ignore patterns.

Cleaning up some commented out old packages.
This commit is contained in:
Finch 2024-10-12 13:28:15 -05:00
parent c90a5a2210
commit 310e3f39d3
4 changed files with 35 additions and 17 deletions

View File

@ -1,6 +1,26 @@
-- Fix for treesitter folds, as folds are not recalculated upon buffer changes (especially when pasting text) -- Fix for treesitter folds, as folds are not recalculated upon buffer changes (especially when pasting text)
vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNew', 'BufWinEnter' }, { -- vim.api.nvim_create_autocmd({ 'BufEnter', 'BufNew', 'BufWinEnter' }, {
-- pattern = '*',
-- group = vim.api.nvim_create_augroup('telescope_fold_workaround', { clear = true }),
-- command = 'set foldexpr=nvim_treesitter#foldexpr()',
-- })
-- Disables syntax, treesitter and folding on larger files
vim.api.nvim_create_autocmd({ 'BufReadPre' }, {
pattern = '*', pattern = '*',
group = vim.api.nvim_create_augroup('telescope_fold_workaround', { clear = true }), group = vim.api.nvim_create_augroup('largefile', { clear = true }),
command = 'set foldexpr=nvim_treesitter#foldexpr()', callback = function(args)
local max_filesize_MiB = 2
local _, stats = pcall(function()
return vim.loop.fs_stat(vim.api.nvim_buf_get_name(args.buf))
end)
local file_size = math.floor(0.5 + (stats.size / (1024 * 1024)))
if file_size > max_filesize_MiB then
-- print(string.format('Big file detected above %sMiB. Disabling syntax, treesitter, and folding.', max_filesize_MiB))
vim.api.nvim_command('set foldmethod=manual')
end
end,
}) })

View File

@ -1,10 +1,5 @@
-- use 'tpope/vim-fugitive' -- Git integration
--
-- -- Experimental
-- use 'mfussenegger/nvim-dap'
-- use 'rcarriga/nvim-dap-ui'
local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim' local lazypath = vim.fn.stdpath('data') .. '/lazy/lazy.nvim'
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
vim.fn.system({ vim.fn.system({
'git', 'git',
@ -15,6 +10,7 @@ if not vim.loop.fs_stat(lazypath) then
lazypath, lazypath,
}) })
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require('lazy').setup({ require('lazy').setup({

View File

@ -29,13 +29,13 @@ return {
vim.keymap.set('n', '<leader><leader>f', function() vim.lsp.buf.format { async = true } end, bufopts) vim.keymap.set('n', '<leader><leader>f', function() vim.lsp.buf.format { async = true } end, bufopts)
-- DAP debug -- DAP debug
-- if dap then if dap then
-- vim.keymap.set('n', '<F5>', function() dap.continue() end, bufopts) vim.keymap.set('n', '<F5>', function() dap.continue() end, bufopts)
-- vim.keymap.set('n', '<F10>', function() dap.step_over() end, bufopts) vim.keymap.set('n', '<F10>', function() dap.step_over() end, bufopts)
-- vim.keymap.set('n', '<F11>', function() dap.step_into() end, bufopts) vim.keymap.set('n', '<F11>', function() dap.step_into() end, bufopts)
-- vim.keymap.set('n', '<F12>', function() dap.step_out() end, bufopts) vim.keymap.set('n', '<F12>', function() dap.step_out() end, bufopts)
-- vim.keymap.set('n', '<leader>b', function() dap.toggle_breakpoint() end, bufopts) vim.keymap.set('n', '<leader>b', function() dap.toggle_breakpoint() end, bufopts)
-- end end
end end
mason_lspconfig.setup { mason_lspconfig.setup {
@ -44,13 +44,13 @@ return {
'ansiblels', 'ansiblels',
'arduino_language_server', 'arduino_language_server',
'clangd', 'clangd',
-- 'emmet_ls',
'intelephense', 'intelephense',
'jdtls', 'jdtls',
'lua_ls', 'lua_ls',
'marksman', 'marksman',
'pylsp', 'pylsp',
'rust_analyzer', 'rust_analyzer',
-- 'r_language_server',
'ts_ls', 'ts_ls',
'yamlls', 'yamlls',
'volar', 'volar',

View File

@ -102,6 +102,8 @@ return {
file_ignore_patterns = { file_ignore_patterns = {
'.git/', '.git/',
'.node_modules/', '.node_modules/',
'.webp',
'.png',
}, },
}) })
end, end,