Skip to content

Commit

Permalink
perf(plugins): reduce configuration files to shorten startup time
Browse files Browse the repository at this point in the history
  • Loading branch information
liubang committed May 12, 2023
1 parent ecc2e83 commit 73d3cd7
Show file tree
Hide file tree
Showing 4 changed files with 217 additions and 269 deletions.
68 changes: 68 additions & 0 deletions lua/lb/utils/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,74 @@ function M.strip_archive_subpath(path) -- {{{
return path
end -- }}}

function M.file_size_format() -- {{{
local file = vim.fn.expand "%:p"
if file == nil or #file == 0 then
return ""
end
local size = vim.fn.getfsize(file)
if size <= 0 then
return ""
end

local suffixes = { "B", "KB", "MB", "GB" }

local i = 1
while size > 1024 and i < #suffixes do
size = size / 1024
i = i + 1
end

local format = i == 1 and "[%d%s]" or "[%.1f%s]"
return string.format(format, size, suffixes[i])
end -- }}}

function M.lineinfo() -- {{{
local line = vim.fn.line "."
local column = vim.fn.col "."
return string.format("%d:%d %s", line, column, "[%p%%]")
end -- }}}

-- stylua: ignore
local lsp_names = { --{{{
["null-ls"] = "NLS",
["diagnostics_on_open"] = "Diagnostics",
["diagnostics_on_save"] = "Diagnostics",
clangd = "C++",
gopls = "Go",
rust_analyzer = "Rust",
lua_ls = "Lua",
intelephense = "PHP",
pyright = "Python",
bashls = "Bash",
dockerls = "Docker",
tsserver = "TS",
jsonls = "JSON",
sqls = "SQL",
texlab = "LaTeX",
taplo = "TOML",
html = "HTML",
vimls = "Vim",
yamlls = "YAML",
cssls = "CSS",
emmet_ls = "EMMET",
jdtls = "Java",
}
--}}}

function M.lsp_clients_format() -- {{{
local clients = {}
for _, client in pairs(vim.lsp.get_active_clients { bufnr = 0 }) do
local name = lsp_names[client.name] or client.name
clients[#clients + 1] = name
end
return "" .. table.concat(clients, "")
end -- }}}

function M.mode_format() -- {{{
return "\u{e7c5} " .. require("lualine.utils.mode").get_mode()
end -- }}}

return M

-- vim: fdm=marker fdl=0
177 changes: 0 additions & 177 deletions lua/plugins/lualine.lua

This file was deleted.

92 changes: 0 additions & 92 deletions lua/plugins/nvim-navic.lua

This file was deleted.

Loading

0 comments on commit 73d3cd7

Please sign in to comment.