Skip to content

Commit

Permalink
perf!: consolidated updates to address performance issues (#868)
Browse files Browse the repository at this point in the history
* perf!: consolidated updates to address performance issues

This fixes #866 and closes #867.

* fixup! perf!: consolidated updates to address performance issues

* revert: `nvim-bufdel` shall always be available (API calls)

* feat(rainbow_delims): line detections for c/cpp

---------

Signed-off-by: Jint-lzxy <50296129+Jint-lzxy@users.noreply.github.com>
Co-authored-by: Layton <caolei6767@google.com>
  • Loading branch information
Jint-lzxy and Layton authored Jul 17, 2023
1 parent bfa6e43 commit 1165861
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lua/modules/configs/completion/lsp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,6 @@ return function()
local final_opts = vim.tbl_deep_extend("keep", _opts, opts)
nvim_lsp.dartls.setup(final_opts)
end

vim.api.nvim_command([[LspStart]]) -- Start LSPs
end
2 changes: 1 addition & 1 deletion lua/modules/configs/completion/lspsaga.lua
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ return function()
in_select = false,
auto_save = false,
keys = {
quit = "<Esc>",
quit = "<C-c>",
select = "x",
exec = "<CR>",
},
Expand Down
20 changes: 19 additions & 1 deletion lua/modules/configs/editor/rainbow_delims.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
return function()
local function init_strategy(check_lines)
return function()
local errors = 200
vim.treesitter.get_parser():for_each_tree(function(lt)
if lt:root():has_error() and errors >= 0 then
errors = errors - 1
end
end)
if errors < 0 then
return nil
end
return (check_lines and vim.fn.line("$") > 450) and require("rainbow-delimiters").strategy["global"]
or require("rainbow-delimiters").strategy["local"]
end
end

vim.g.rainbow_delimiters = {
strategy = {
[""] = require("rainbow-delimiters").strategy["local"],
[""] = init_strategy(false),
c = init_strategy(true),
cpp = init_strategy(true),
},
query = {
[""] = "rainbow-delimiters",
Expand Down
2 changes: 1 addition & 1 deletion lua/modules/plugins/completion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ local completion = {}

completion["neovim/nvim-lspconfig"] = {
lazy = true,
event = { "BufReadPost", "BufAdd", "BufNewFile" },
event = { "CursorHold", "CursorHoldI" },
config = require("completion.lsp"),
dependencies = {
{ "williamboman/mason.nvim" },
Expand Down
6 changes: 3 additions & 3 deletions lua/modules/plugins/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ editor["LunarVim/bigfile.nvim"] = {
}
editor["ojroques/nvim-bufdel"] = {
lazy = true,
event = "BufReadPost",
event = "BufReadPre",
}
editor["rhysd/clever-f.vim"] = {
lazy = true,
event = { "BufReadPost", "BufAdd", "BufNewFile" },
event = { "CursorHold", "CursorHoldI" },
config = require("editor.cleverf"),
}
editor["numToStr/Comment.nvim"] = {
Expand Down Expand Up @@ -87,7 +87,7 @@ editor["nvim-treesitter/nvim-treesitter"] = {
vim.api.nvim_command("TSUpdate")
end
end,
event = "BufReadPre",
event = "BufReadPost",
config = require("editor.treesitter"),
dependencies = {
{ "nvim-treesitter/nvim-treesitter-textobjects" },
Expand Down
4 changes: 2 additions & 2 deletions lua/modules/plugins/tool.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ tool["michaelb/sniprun"] = {
-- You need to cd to `~/.local/share/nvim/site/lazy/sniprun/` and execute `bash ./install.sh`,
-- if you encountered error about no executable sniprun found.
build = "bash ./install.sh",
cmd = { "SnipRun" },
cmd = "SnipRun",
config = require("tool.sniprun"),
}
tool["akinsho/toggleterm.nvim"] = {
Expand Down Expand Up @@ -77,7 +77,7 @@ tool["nvim-telescope/telescope.nvim"] = {
{ "debugloop/telescope-undo.nvim" },
{
"ahmedkhalf/project.nvim",
event = "BufReadPost",
event = { "CursorHold", "CursorHoldI" },
config = require("tool.project"),
},
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },
Expand Down
4 changes: 2 additions & 2 deletions lua/modules/plugins/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ ui["zbirenbaum/neodim"] = {
}
ui["karb94/neoscroll.nvim"] = {
lazy = true,
event = "BufReadPost",
event = { "CursorHold", "CursorHoldI" },
config = require("ui.neoscroll"),
}
ui["shaunsingh/nord.nvim"] = {
Expand All @@ -67,7 +67,7 @@ ui["folke/paint.nvim"] = {
}
ui["dstein64/nvim-scrollview"] = {
lazy = true,
event = "BufReadPost",
event = { "BufReadPost", "BufAdd", "BufNewFile" },
config = require("ui.scrollview"),
}
ui["edluffy/specs.nvim"] = {
Expand Down

0 comments on commit 1165861

Please sign in to comment.