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)
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 = '*',
group = vim.api.nvim_create_augroup('telescope_fold_workaround', { clear = true }),
command = 'set foldexpr=nvim_treesitter#foldexpr()',
group = vim.api.nvim_create_augroup('largefile', { clear = true }),
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'
if not vim.loop.fs_stat(lazypath) then
vim.fn.system({
'git',
@ -15,6 +10,7 @@ if not vim.loop.fs_stat(lazypath) then
lazypath,
})
end
vim.opt.rtp:prepend(lazypath)
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)
-- DAP debug
-- if dap then
-- 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', '<F11>', function() dap.step_into() 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)
-- end
if dap then
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', '<F11>', function() dap.step_into() 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)
end
end
mason_lspconfig.setup {
@ -44,13 +44,13 @@ return {
'ansiblels',
'arduino_language_server',
'clangd',
-- 'emmet_ls',
'intelephense',
'jdtls',
'lua_ls',
'marksman',
'pylsp',
'rust_analyzer',
-- 'r_language_server',
'ts_ls',
'yamlls',
'volar',

View File

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