Improve startuptime | remove un-needed plugins | lazy load plugin highlights too

removed nvim-gps as nvim-navic or winbar.nvim will be added when v0.8 neovim releases. Removed lsp signature as I was able to emulate showing args with the default signature help() window
This commit is contained in:
siduck 2022-06-14 17:36:27 +05:30
parent d42ffe1ac7
commit 0bde81a074
21 changed files with 463 additions and 391 deletions

View file

@ -4,6 +4,8 @@ if not present then
return
end
require("base46").load_highlight "alpha"
local function button(sc, txt, keybind)
local sc_ = sc:gsub("%s", ""):gsub("SPC", "<leader>")

View file

@ -4,6 +4,8 @@ if not present then
return
end
require("base46").load_highlight "bufferline"
vim.cmd [[
function! Toggle_theme(a,b,c,d)
lua require('base46').toggle_theme()

View file

@ -4,6 +4,8 @@ if not present then
return
end
require("base46").load_highlight "cmp"
vim.opt.completeopt = "menuone,noselect"
local function border(hl_name)
@ -45,9 +47,8 @@ local options = {
},
formatting = {
format = function(_, vim_item)
local icons = require "plugins.configs.lspkind_icons"
local icons = require("ui.icons").lspkind
vim_item.kind = string.format("%s %s", icons[vim_item.kind], vim_item.kind)
return vim_item
end,
},

View file

@ -1,39 +0,0 @@
local present, gps = pcall(require, "nvim-gps")
if not present then
return
end
local icons = require "plugins.configs.lspkind_icons"
local options = {
depth = 5,
icons = {
["class-name"] = "%#GpsItemKindClass#" .. icons.Class .. "%*" .. " ",
["function-name"] = "%#GpsItemKindFunction#" .. icons.Function .. "%*" .. " ",
["method-name"] = "%#GpsItemKindMethod#" .. icons.Method .. "%*" .. " ",
["container-name"] = "%#GpsItemKindProperty#" .. icons.Object .. "%*" .. " ",
["tag-name"] = "%#GpsItemKindKeyword#" .. icons.Tag .. "%*" .. " ",
["mapping-name"] = "%#GpsItemKindProperty#" .. icons.Object .. "%*" .. " ",
["sequence-name"] = "%GpsItemKindProperty#" .. icons.Array .. "%*" .. " ",
["null-name"] = "%GpsItemKindField#" .. icons.Field .. "%*" .. " ",
["boolean-name"] = "%GpsItemKindValue#" .. icons.Boolean .. "%*" .. " ",
["integer-name"] = "%GpsItemKindValue#" .. icons.Number .. "%*" .. " ",
["float-name"] = "%GpsItemKindValue#" .. icons.Number .. "%*" .. " ",
["string-name"] = "%GpsItemKindValue#" .. icons.String .. "%*" .. " ",
["array-name"] = "%GpsItemKindProperty#" .. icons.Array .. "%*" .. " ",
["object-name"] = "%GpsItemKindProperty#" .. icons.Object .. "%*" .. " ",
["number-name"] = "%GpsItemKindValue#" .. icons.Number .. "%*" .. " ",
["table-name"] = "%GpsItemKindProperty#" .. icons.Table .. "%*" .. " ",
["date-name"] = "%GpsItemKindValue#" .. icons.Calendar .. "%*" .. " ",
["date-time-name"] = "%GpsItemKindValue#" .. icons.Table .. "%*" .. " ",
["inline-table-name"] = "%GpsItemKindProperty#" .. icons.Calendar .. "%*" .. " ",
["time-name"] = "%GpsItemKindValue#" .. icons.Watch .. "%*" .. " ",
["module-name"] = "%GpsItemKindModule#" .. icons.Module .. "%*" .. " ",
},
}
options = require("core.utils").load_override(options, "SmiteshP/nvim-gps")
gps.setup(options)

View file

@ -1,128 +0,0 @@
local present, devicons = pcall(require, "nvim-web-devicons")
if not present then
return
end
local options = {
override = {
default_icon = {
icon = "",
name = "Default",
},
c = {
icon = "",
name = "c",
},
css = {
icon = "",
name = "css",
},
deb = {
icon = "",
name = "deb",
},
Dockerfile = {
icon = "",
name = "Dockerfile",
},
html = {
icon = "",
name = "html",
},
jpeg = {
icon = "",
name = "jpeg",
},
jpg = {
icon = "",
name = "jpg",
},
js = {
icon = "",
name = "js",
},
kt = {
icon = "󱈙",
name = "kt",
},
lock = {
icon = "",
name = "lock",
},
lua = {
icon = "",
name = "lua",
},
mp3 = {
icon = "",
name = "mp3",
},
mp4 = {
icon = "",
name = "mp4",
},
out = {
icon = "",
name = "out",
},
png = {
icon = "",
name = "png",
},
py = {
icon = "",
name = "py",
},
["robots.txt"] = {
icon = "",
name = "robots",
},
toml = {
icon = "",
name = "toml",
},
ts = {
icon = "",
name = "ts",
},
ttf = {
icon = "",
name = "TrueTypeFont",
},
rb = {
icon = "",
name = "rb",
},
rpm = {
icon = "",
name = "rpm",
},
vue = {
icon = "",
name = "vue",
},
woff = {
icon = "",
name = "WebOpenFontFormat",
},
woff2 = {
icon = "",
name = "WebOpenFontFormat2",
},
xz = {
icon = "",
name = "xz",
},
zip = {
icon = "",
name = "zip",
},
},
}
-- check for any override
options = require("core.utils").load_override(options, "kyazdani42/nvim-web-devicons")
devicons.setup(options)

View file

@ -4,20 +4,12 @@ if not present then
return
end
require("base46").load_highlight "lsp"
local M = {}
local utils = require "core.utils"
require("plugins.configs.others").lsp_handlers()
-- Borders for LspInfo winodw
local win = require "lspconfig.ui.windows"
local _default_opts = win.default_opts
win.default_opts = function(options)
local opts = _default_opts(options)
opts.border = "single"
return opts
end
require "ui.lsp"
M.on_attach = function(client, bufnr)
client.resolved_capabilities.document_formatting = false
@ -25,6 +17,16 @@ M.on_attach = function(client, bufnr)
local lsp_mappings = utils.load_config().mappings.lspconfig
utils.load_mappings({ lsp_mappings }, { buffer = bufnr })
if client.supports_method "textDocument/signatureHelp" then
vim.api.nvim_create_autocmd({ "CursorHoldI" }, {
pattern = "*",
group = vim.api.nvim_create_augroup("LspSignature", {}),
callback = function()
vim.lsp.buf.signature_help()
end,
})
end
end
local capabilities = vim.lsp.protocol.make_client_capabilities()

View file

@ -1,36 +0,0 @@
return {
Text = "",
Method = "",
Function = "",
Constructor = "",
Field = "",
Variable = "",
Class = "",
Interface = "",
Module = "",
Property = "",
Unit = "",
Value = "",
Enum = "",
Keyword = "",
Snippet = "",
Color = "",
File = "",
Reference = "",
Folder = "",
EnumMember = "",
Constant = "",
Struct = "",
Event = "",
Operator = "",
TypeParameter = "",
Table = "",
Object = "",
Tag = "",
Array = "",
Boolean = "",
Number = "",
String = "",
Calendar = "",
Watch = "",
}

View file

@ -4,6 +4,8 @@ if not present then
return
end
require("base46").load_highlight "nvimtree"
local options = {
filters = {
dotfiles = false,

View file

@ -4,6 +4,8 @@ if not present then
return
end
require "base46.term"
local options = {
terminals = {
list = {},

View file

@ -19,28 +19,9 @@ M.autopairs = function()
autopairs.setup(options)
local cmp_autopairs = require "nvim-autopairs.completion.cmp"
cmp.event:on("confirm_done", cmp_autopairs.on_confirm_done())
end
M.better_escape = function()
local present, escape = pcall(require, "better_escape")
if not present then
return
end
local options = {
mapping = { "jk" }, -- a table with mappings to use
timeout = vim.o.timeoutlen,
clear_empty_lines = false, -- clear line after escaping if there is only whitespace
keys = "<Esc>",
}
options = load_override(options, "max397574/better-escape.nvim")
escape.setup(options)
end
M.blankline = function()
local present, blankline = pcall(require, "indent_blankline")
@ -48,6 +29,8 @@ M.blankline = function()
return
end
require("base46").load_highlight "blankline"
local options = {
indentLine_enabled = 1,
char = "",
@ -59,7 +42,6 @@ M.blankline = function()
"lspinfo",
"TelescopePrompt",
"TelescopeResults",
"nvchad_cheatsheet",
"lsp-installer",
"",
},
@ -99,9 +81,9 @@ M.colorizer = function()
}
options = load_override(options, "NvChad/nvim-colorizer.lua")
colorizer.setup(options["filetypes"], options["user_default_options"])
vim.cmd "ColorizerReloadAllBuffers"
vim.cmd "ColorizerAttachToBuffer"
end
M.comment = function()
@ -130,79 +112,9 @@ M.luasnip = function()
options = load_override(options, "L3MON4D3/LuaSnip")
luasnip.config.set_config(options)
require("luasnip.loaders.from_vscode").lazy_load()
end
M.signature = function()
local present, lsp_signature = pcall(require, "lsp_signature")
if not present then
return
end
local options = {
bind = true,
doc_lines = 0,
floating_window = true,
fix_pos = true,
hint_enable = true,
hint_prefix = "",
hint_scheme = "String",
hi_parameter = "Search",
max_height = 22,
max_width = 120, -- max_width of signature floating_window, line will be wrapped if exceed max_width
handler_opts = {
border = "single", -- double, single, shadow, none
},
zindex = 200, -- by default it will be on top of all floating windows, set to 50 send it to bottom
padding = "", -- character to pad on left and right of signature can be ' ', or '|' etc
}
options = load_override(options, "ray-x/lsp_signature.nvim")
lsp_signature.setup(options)
end
M.lsp_handlers = function()
local function lspSymbol(name, icon)
local hl = "DiagnosticSign" .. name
vim.fn.sign_define(hl, { text = icon, numhl = hl, texthl = hl })
end
lspSymbol("Error", "")
lspSymbol("Info", "")
lspSymbol("Hint", "")
lspSymbol("Warn", "")
vim.diagnostic.config {
virtual_text = {
prefix = "",
},
signs = true,
underline = true,
update_in_insert = false,
}
vim.lsp.handlers["textDocument/hover"] = vim.lsp.with(vim.lsp.handlers.hover, {
border = "single",
})
vim.lsp.handlers["textDocument/signatureHelp"] = vim.lsp.with(vim.lsp.handlers.signature_help, {
border = "single",
})
-- suppress error messages from lang servers
vim.notify = function(msg, log_level)
if msg:match "exit code" then
return
end
if log_level == vim.log.levels.ERROR then
vim.api.nvim_err_writeln(msg)
else
vim.api.nvim_echo({ { msg } }, true, {})
end
end
end
M.gitsigns = function()
local present, gitsigns = pcall(require, "gitsigns")
@ -210,6 +122,8 @@ M.gitsigns = function()
return
end
require("base46").load_highlight "git"
local options = {
signs = {
add = { hl = "DiffAdd", text = "", numhl = "GitSignsAddNr" },
@ -219,9 +133,21 @@ M.gitsigns = function()
changedelete = { hl = "DiffChangeDelete", text = "~", numhl = "GitSignsChangeNr" },
},
}
options = load_override(options, "lewis6991/gitsigns.nvim")
options = load_override(options, "lewis6991/gitsigns.nvim")
gitsigns.setup(options)
end
M.devicons = function()
local present, devicons = pcall(require, "nvim-web-devicons")
if present then
require("base46").load_highlight "devicons"
local options = { override = require("ui.icons").devicons }
options = require("core.utils").load_override(options, "kyazdani42/nvim-web-devicons")
devicons.setup(options)
end
end
return M

View file

@ -4,6 +4,10 @@ if not present then
return
end
vim.g.theme_switcher_loaded = true
require("base46").load_highlight "telescope"
local options = {
defaults = {
vimgrep_arguments = {

View file

@ -4,6 +4,9 @@ if not present then
return
end
require("base46").load_highlight "syntax"
require("base46").load_highlight "treesitter"
local options = {
ensure_installed = {
"lua",

View file

@ -4,6 +4,8 @@ if not present then
return
end
require("base46").load_highlight "whichkey"
local options = {
icons = {

View file

@ -1,9 +1,12 @@
vim.cmd "packadd packer.nvim"
local lazy_load = require "core.lazy_load"
local plugins = {
["nvim-lua/plenary.nvim"] = {},
["lewis6991/impatient.nvim"] = {},
["wbthomason/packer.nvim"] = {},
["NvChad/extensions"] = {},
["NvChad/extensions"] = { module = "nvchad", cmd = "Telescope" },
["NvChad/base46"] = {
after = "plenary.nvim",
@ -24,43 +27,40 @@ local plugins = {
},
["kyazdani42/nvim-web-devicons"] = {
after = "base46",
module = "nvim-web-devicons",
config = function()
require "plugins.configs.icons"
end,
},
["SmiteshP/nvim-gps"] = {
event = "CursorMoved",
config = function()
require "plugins.configs.gps"
require("plugins.configs.others").devicons()
end,
},
["akinsho/bufferline.nvim"] = {
tag = "v2.*",
after = "nvim-web-devicons",
opt = true,
setup = lazy_load.bufferline(),
config = function()
require "plugins.configs.bufferline"
end,
},
["lukas-reineke/indent-blankline.nvim"] = {
event = "BufRead",
opt = true,
config = function()
require("plugins.configs.others").blankline()
end,
},
["NvChad/nvim-colorizer.lua"] = {
event = "BufRead",
opt = true,
setup = lazy_load.colorizer(),
config = function()
require("plugins.configs.others").colorizer()
end,
},
["nvim-treesitter/nvim-treesitter"] = {
event = { "BufRead", "BufNewFile" },
module = "nvim-treesitter",
cmd = { "TSInstall", "TSUninstall" },
setup = lazy_load.treesitter(),
run = ":TSUpdate",
config = function()
require "plugins.configs.treesitter"
@ -70,25 +70,17 @@ local plugins = {
-- git stuff
["lewis6991/gitsigns.nvim"] = {
opt = true,
setup = lazy_load.gitsigns(),
config = function()
require("plugins.configs.others").gitsigns()
end,
setup = function()
require("core.utils").packer_lazy_load "gitsigns.nvim"
end,
},
-- lsp stuff
["williamboman/nvim-lsp-installer"] = {
opt = true,
setup = function()
require("core.utils").packer_lazy_load "nvim-lsp-installer"
-- reload the current file so lsp actually starts for it
vim.defer_fn(function()
vim.cmd 'if &ft == "packer" | echo "" | else | silent! e %'
end, 0)
end,
setup = lazy_load.on_file_open(),
},
["neovim/nvim-lspconfig"] = {
@ -100,15 +92,6 @@ local plugins = {
end,
},
["ray-x/lsp_signature.nvim"] = {
after = "nvim-lspconfig",
config = function()
require("plugins.configs.others").signature()
end,
},
-- load luasnips + cmp related in insert mode only
["rafamadriz/friendly-snippets"] = {
@ -190,11 +173,9 @@ local plugins = {
end,
},
-- Only load whichkey after all the gui
["folke/which-key.nvim"] = {
opt = true,
setup = function()
require("core.utils").packer_lazy_load "which-key.nvim"
end,
module = "which-key",
config = function()
require "plugins.configs.whichkey"
end,