diff --git a/nvim/lua/autocmds.lua b/nvim/lua/autocmds.lua index 03e53e1..f4ee473 100644 --- a/nvim/lua/autocmds.lua +++ b/nvim/lua/autocmds.lua @@ -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, }) diff --git a/nvim/lua/plugins.lua b/nvim/lua/plugins.lua index bf5bee7..23bc997 100644 --- a/nvim/lua/plugins.lua +++ b/nvim/lua/plugins.lua @@ -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({ diff --git a/nvim/lua/plugins/mason.lua b/nvim/lua/plugins/mason.lua index fbdb223..baed217 100644 --- a/nvim/lua/plugins/mason.lua +++ b/nvim/lua/plugins/mason.lua @@ -29,13 +29,13 @@ return { vim.keymap.set('n', 'f', function() vim.lsp.buf.format { async = true } end, bufopts) -- DAP debug - -- if dap then - -- vim.keymap.set('n', '', function() dap.continue() end, bufopts) - -- vim.keymap.set('n', '', function() dap.step_over() end, bufopts) - -- vim.keymap.set('n', '', function() dap.step_into() end, bufopts) - -- vim.keymap.set('n', '', function() dap.step_out() end, bufopts) - -- vim.keymap.set('n', 'b', function() dap.toggle_breakpoint() end, bufopts) - -- end + if dap then + vim.keymap.set('n', '', function() dap.continue() end, bufopts) + vim.keymap.set('n', '', function() dap.step_over() end, bufopts) + vim.keymap.set('n', '', function() dap.step_into() end, bufopts) + vim.keymap.set('n', '', function() dap.step_out() end, bufopts) + vim.keymap.set('n', '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', diff --git a/nvim/lua/plugins/telescope.lua b/nvim/lua/plugins/telescope.lua index f52f3a0..9c714e6 100644 --- a/nvim/lua/plugins/telescope.lua +++ b/nvim/lua/plugins/telescope.lua @@ -102,6 +102,8 @@ return { file_ignore_patterns = { '.git/', '.node_modules/', + '.webp', + '.png', }, }) end,