:sparkels: speed up nvim load with vim.schedule

This commit is contained in:
Léana 江 2023-11-22 23:42:28 +01:00 committed by Léana 江
parent f8ba151d15
commit 1dc1b0b6ed
4 changed files with 272 additions and 272 deletions

View file

@ -1,50 +1,48 @@
vim.defer_fn(function()
require "nvim-treesitter.configs".setup {
require "nvim-treesitter.configs".setup {
ensure_installed = {},
sync_install = false,
auto_install = true,
highlight = { enable = true },
ensure_installed = {},
sync_install = false,
auto_install = true,
highlight = { enable = true },
-- Disable for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
-- Disable for large files
disable = function(lang, buf)
local max_filesize = 100 * 1024 -- 100 KB
local ok, stats = pcall(vim.loop.fs_stat, vim.api.nvim_buf_get_name(buf))
if ok and stats and stats.size > max_filesize then
return true
end
end,
-- Text objets
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
selection_modes = {
["@parameter.outer"] = "v", -- charwise
["@function.outer"] = "V", -- linewise
["@class.outer"] = "<c-v>", -- blockwise
},
include_surrounding_whitespace = true,
-- Text objets
textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
["<leader>A"] = "@parameter.inner",
},
selection_modes = {
["@parameter.outer"] = "v", -- charwise
["@function.outer"] = "V", -- linewise
["@class.outer"] = "<c-v>", -- blockwise
},
include_surrounding_whitespace = true,
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
["<leader>A"] = "@parameter.inner",
},
},
}
end, 0)
},
}
require "treesitter-context".setup {
enable = true, -- Enable this plugin (Can be enabled/disabled later via commands)