improve performance

This commit is contained in:
xfy
2024-09-10 17:42:16 +08:00
parent a15a417dbd
commit c0fc1aa12a
10 changed files with 90 additions and 81 deletions

View File

@ -33,7 +33,7 @@
"nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" },
"nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-tree.lua": { "branch": "master", "commit": "d41b4ca013ed89e41b9c0ecbdae5f1633e42f7fa" },
"nvim-treesitter": { "branch": "master", "commit": "f8bbb820a8a2bdb3c3408fa1110b5323e8bbe4bd" },
"nvim-treesitter": { "branch": "master", "commit": "c436d45eeeeb78e5482cb28b59de1d7a77c93d86" },
"nvim-ts-autotag": { "branch": "main", "commit": "e239a560f338be31337e7abc3ee42515daf23f5e" },
"nvim-web-devicons": { "branch": "master", "commit": "9793801f974bba70e4ac5d7eae6c4f5659993d8e" },
"oil.nvim": { "branch": "master", "commit": "1fe476daf0b3c108cb8ee1fc1226cc282fa2c9c1" },

View File

@ -1,5 +1,6 @@
return {
"akinsho/bufferline.nvim",
event = "VeryLazy",
dependencies = { "nvim-tree/nvim-web-devicons" },
version = "*",
opts = {

View File

@ -1,6 +1,7 @@
return {
"phaazon/hop.nvim",
branch = "v2",
event = "BufRead",
config = function()
local hop = require("hop")
hop.setup({ keys = "etovxqpdygfblzhckisuran" })

View File

@ -1,5 +1,4 @@
return {
"nvim-lua/plenary.nvim", -- lua functions that many plugins use
"christoomey/vim-tmux-navigator", -- tmux & split window navigation
"b0o/schemastore.nvim", -- json schema store
{ "christoomey/vim-tmux-navigator", event = "VeryLazy" }, -- tmux & split window navigation
}

View File

@ -1,99 +1,102 @@
return {
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
"hrsh7th/cmp-nvim-lsp",
{ "antosha417/nvim-lsp-file-operations", config = true },
{ "folke/neodev.nvim", opts = {} },
},
opts = { document_highlight = { enabled = false } },
config = function()
local lspconfig = require("lspconfig")
local mason_lspconfig = require("mason-lspconfig")
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local map = vim.keymap.set -- for conciseness
{ "b0o/schemastore.nvim", lazy = true }, -- json schema store
{
"neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" },
dependencies = {
{ "hrsh7th/cmp-nvim-lsp", lazy = true },
{ "antosha417/nvim-lsp-file-operations", config = true, lazy = true },
{ "folke/neodev.nvim", opts = {}, lazy = true },
},
opts = { document_highlight = { enabled = false } },
config = function()
local lspconfig = require("lspconfig")
local mason_lspconfig = require("mason-lspconfig")
local cmp_nvim_lsp = require("cmp_nvim_lsp")
local map = vim.keymap.set -- for conciseness
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
local opts = { buffer = ev.buf, silent = true }
vim.api.nvim_create_autocmd("LspAttach", {
group = vim.api.nvim_create_augroup("UserLspConfig", {}),
callback = function(ev)
local opts = { buffer = ev.buf, silent = true }
opts.desc = "Show LSP references"
map("n", "gr", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
opts.desc = "Show LSP references"
map("n", "gr", "<cmd>Telescope lsp_references<CR>", opts) -- show definition, references
opts.desc = "Go to declaration"
map("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
opts.desc = "Go to declaration"
map("n", "gD", vim.lsp.buf.declaration, opts) -- go to declaration
opts.desc = "Show LSP definitions"
map("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
opts.desc = "Show LSP definitions"
map("n", "gd", "<cmd>Telescope lsp_definitions<CR>", opts) -- show lsp definitions
opts.desc = "Show LSP implementations"
map("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
opts.desc = "Show LSP implementations"
map("n", "gi", "<cmd>Telescope lsp_implementations<CR>", opts) -- show lsp implementations
opts.desc = "Show LSP type definitions"
map("n", "<leader>gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
opts.desc = "Show LSP type definitions"
map("n", "<leader>gt", "<cmd>Telescope lsp_type_definitions<CR>", opts) -- show lsp type definitions
opts.desc = "See available code actions"
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
opts.desc = "See available code actions"
map({ "n", "v" }, "<leader>ca", vim.lsp.buf.code_action, opts) -- see available code actions, in visual mode will apply to selection
opts.desc = "Smart rename"
map("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
opts.desc = "Smart rename"
map("n", "<leader>rn", vim.lsp.buf.rename, opts) -- smart rename
opts.desc = "Show buffer diagnostics"
map("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
opts.desc = "Show buffer diagnostics"
map("n", "<leader>D", "<cmd>Telescope diagnostics bufnr=0<CR>", opts) -- show diagnostics for file
opts.desc = "Show line diagnostics"
map("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
opts.desc = "Show line diagnostics"
map("n", "<leader>d", vim.diagnostic.open_float, opts) -- show diagnostics for line
opts.desc = "Go to previous diagnostic"
map("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
opts.desc = "Go to previous diagnostic"
map("n", "[d", vim.diagnostic.goto_prev, opts) -- jump to previous diagnostic in buffer
opts.desc = "Go to next diagnostic"
map("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
opts.desc = "Go to next diagnostic"
map("n", "]d", vim.diagnostic.goto_next, opts) -- jump to next diagnostic in buffer
opts.desc = "Show documentation for what is under cursor"
opts.silent = true
map("n", "gh", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
opts.desc = "Show documentation for what is under cursor"
opts.silent = true
map("n", "gh", vim.lsp.buf.hover, opts) -- show documentation for what is under cursor
opts.desc = "Restart LSP"
map("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
end,
})
opts.desc = "Restart LSP"
map("n", "<leader>rs", ":LspRestart<CR>", opts) -- mapping to restart lsp if necessary
end,
})
local capabilities = cmp_nvim_lsp.default_capabilities()
local capabilities = cmp_nvim_lsp.default_capabilities()
local signs = { Error = "", Warn = "", Hint = "󰠠 ", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
local signs = { Error = "", Warn = "", Hint = "󰠠 ", Info = "" }
for type, icon in pairs(signs) do
local hl = "DiagnosticSign" .. type
vim.fn.sign_define(hl, { text = icon, texthl = hl, numhl = "" })
end
mason_lspconfig.setup_handlers({
-- default handler for installed servers
function(server_name)
lspconfig[server_name].setup({
capabilities = capabilities,
})
end,
["vtsls"] = function()
lspconfig["vtsls"].setup(require("rua.config.vtsls"))
map("n", "<leader>co", "<cmd> OrganizeImports <CR>", { desc = "Organize imports" })
end,
["lua_ls"] = function()
lspconfig["lua_ls"].setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
completion = {
callSnippet = "Replace",
mason_lspconfig.setup_handlers({
-- default handler for installed servers
function(server_name)
lspconfig[server_name].setup({
capabilities = capabilities,
})
end,
["vtsls"] = function()
lspconfig["vtsls"].setup(require("rua.config.vtsls"))
map("n", "<leader>co", "<cmd> OrganizeImports <CR>", { desc = "Organize imports" })
end,
["lua_ls"] = function()
lspconfig["lua_ls"].setup({
capabilities = capabilities,
settings = {
Lua = {
diagnostics = {
globals = { "vim" },
},
completion = {
callSnippet = "Replace",
},
},
},
},
})
end,
})
end,
})
end,
})
end,
},
}

View File

@ -4,6 +4,7 @@ return {
"williamboman/mason-lspconfig.nvim",
"WhoIsSethDaniel/mason-tool-installer.nvim",
},
event = "VeryLazy",
config = function()
local mason = require("mason")
local mason_lspconfig = require("mason-lspconfig")

View File

@ -1,6 +1,7 @@
return {
"nvim-lualine/lualine.nvim",
dependencies = { "nvim-tree/nvim-web-devicons" },
event = "VeryLazy",
config = function()
local lualine = require("lualine")
-- local lazy_status = require("lazy.status") -- to configure lazy pending updates count

View File

@ -1,6 +1,7 @@
return {
"nvim-tree/nvim-tree.lua",
dependencies = "nvim-tree/nvim-web-devicons",
event = "VeryLazy",
config = function()
local nvimtree = require("nvim-tree")

View File

@ -1,6 +1,7 @@
return {
"nvim-telescope/telescope.nvim",
branch = "0.1.x",
event = "VeryLazy",
dependencies = {
"nvim-lua/plenary.nvim",
{ "nvim-telescope/telescope-fzf-native.nvim", build = "make" },

View File

@ -88,6 +88,7 @@ return {
},
{
"NvChad/nvim-colorizer.lua",
event = "BufRead",
opts = {
user_default_options = {
tailwind = true,