mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-23 09:18:51 +02:00
refactor: LazyVim.config
This commit is contained in:
parent
57ef349910
commit
05e45e0d35
15 changed files with 32 additions and 42 deletions
|
@ -27,7 +27,7 @@ return {
|
||||||
}
|
}
|
||||||
table.insert(opts.sections.lualine_x, 2, {
|
table.insert(opts.sections.lualine_x, 2, {
|
||||||
function()
|
function()
|
||||||
local icon = require("lazyvim.config").icons.kinds.Copilot
|
local icon = LazyVim.config.icons.kinds.Copilot
|
||||||
local status = require("copilot.api").status.data
|
local status = require("copilot.api").status.data
|
||||||
return icon .. (status.message or "")
|
return icon .. (status.message or "")
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -42,7 +42,7 @@ return {
|
||||||
optional = true,
|
optional = true,
|
||||||
event = "VeryLazy",
|
event = "VeryLazy",
|
||||||
opts = function(_, opts)
|
opts = function(_, opts)
|
||||||
local icon = require("lazyvim.config").icons.kinds.TabNine
|
local icon = LazyVim.config.icons.kinds.TabNine
|
||||||
table.insert(opts.sections.lualine_x, 2, LazyVim.lualine.cmp_source("cmp_tabnine", icon))
|
table.insert(opts.sections.lualine_x, 2, LazyVim.lualine.cmp_source("cmp_tabnine", icon))
|
||||||
end,
|
end,
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,12 +1,10 @@
|
||||||
local Config = require("lazyvim.config")
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
desc = "Aerial Symbol Browser",
|
desc = "Aerial Symbol Browser",
|
||||||
{
|
{
|
||||||
"stevearc/aerial.nvim",
|
"stevearc/aerial.nvim",
|
||||||
event = "LazyFile",
|
event = "LazyFile",
|
||||||
opts = function()
|
opts = function()
|
||||||
local icons = vim.deepcopy(Config.icons.kinds)
|
local icons = vim.deepcopy(LazyVim.config.icons.kinds)
|
||||||
|
|
||||||
-- HACK: fix lua's weird choice for `Package` for control
|
-- HACK: fix lua's weird choice for `Package` for control
|
||||||
-- structures like if/else/for/etc.
|
-- structures like if/else/for/etc.
|
||||||
|
@ -14,8 +12,8 @@ return {
|
||||||
|
|
||||||
---@type table<string, string[]>|false
|
---@type table<string, string[]>|false
|
||||||
local filter_kind = false
|
local filter_kind = false
|
||||||
if Config.kind_filter then
|
if LazyVim.config.kind_filter then
|
||||||
filter_kind = assert(vim.deepcopy(Config.kind_filter))
|
filter_kind = assert(vim.deepcopy(LazyVim.config.kind_filter))
|
||||||
filter_kind._ = filter_kind.default
|
filter_kind._ = filter_kind.default
|
||||||
filter_kind.default = nil
|
filter_kind.default = nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -30,7 +30,7 @@ end
|
||||||
|
|
||||||
local function symbols_filter(entry, ctx)
|
local function symbols_filter(entry, ctx)
|
||||||
if ctx.symbols_filter == nil then
|
if ctx.symbols_filter == nil then
|
||||||
ctx.symbols_filter = require("lazyvim.config").get_kind_filter(ctx.bufnr) or false
|
ctx.symbols_filter = LazyVim.config.get_kind_filter(ctx.bufnr) or false
|
||||||
end
|
end
|
||||||
if ctx.symbols_filter == false then
|
if ctx.symbols_filter == false then
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -18,7 +18,7 @@ return {
|
||||||
separator = " ",
|
separator = " ",
|
||||||
highlight = true,
|
highlight = true,
|
||||||
depth_limit = 5,
|
depth_limit = 5,
|
||||||
icons = require("lazyvim.config").icons.kinds,
|
icons = LazyVim.config.icons.kinds,
|
||||||
lazy_update_context = true,
|
lazy_update_context = true,
|
||||||
}
|
}
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -12,7 +12,6 @@ return {
|
||||||
keys = { { "<leader>cs", "<cmd>Outline<cr>", desc = "Toggle Outline" } },
|
keys = { { "<leader>cs", "<cmd>Outline<cr>", desc = "Toggle Outline" } },
|
||||||
cmd = "Outline",
|
cmd = "Outline",
|
||||||
opts = function()
|
opts = function()
|
||||||
local Config = require("lazyvim.config")
|
|
||||||
local defaults = require("outline.config").defaults
|
local defaults = require("outline.config").defaults
|
||||||
local opts = {
|
local opts = {
|
||||||
symbols = {},
|
symbols = {},
|
||||||
|
@ -22,14 +21,14 @@ return {
|
||||||
down_and_jump = "<down>",
|
down_and_jump = "<down>",
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
local filter = Config.kind_filter
|
local filter = LazyVim.config.kind_filter
|
||||||
|
|
||||||
if type(filter) == "table" then
|
if type(filter) == "table" then
|
||||||
filter = filter.default
|
filter = filter.default
|
||||||
if type(filter) == "table" then
|
if type(filter) == "table" then
|
||||||
for kind, symbol in pairs(defaults.symbols) do
|
for kind, symbol in pairs(defaults.symbols) do
|
||||||
opts.symbols[kind] = {
|
opts.symbols[kind] = {
|
||||||
icon = Config.icons.kinds[kind] or symbol.icon,
|
icon = LazyVim.config.icons.kinds[kind] or symbol.icon,
|
||||||
hl = symbol.hl,
|
hl = symbol.hl,
|
||||||
}
|
}
|
||||||
if not vim.tbl_contains(filter, kind) then
|
if not vim.tbl_contains(filter, kind) then
|
||||||
|
|
|
@ -133,7 +133,7 @@ return {
|
||||||
"<leader>ss",
|
"<leader>ss",
|
||||||
function()
|
function()
|
||||||
require("telescope.builtin").lsp_document_symbols({
|
require("telescope.builtin").lsp_document_symbols({
|
||||||
symbols = require("lazyvim.config").get_kind_filter(),
|
symbols = LazyVim.config.get_kind_filter(),
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
desc = "Goto Symbol",
|
desc = "Goto Symbol",
|
||||||
|
@ -142,7 +142,7 @@ return {
|
||||||
"<leader>sS",
|
"<leader>sS",
|
||||||
function()
|
function()
|
||||||
require("telescope.builtin").lsp_dynamic_workspace_symbols({
|
require("telescope.builtin").lsp_dynamic_workspace_symbols({
|
||||||
symbols = require("lazyvim.config").get_kind_filter(),
|
symbols = LazyVim.config.get_kind_filter(),
|
||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
desc = "Goto Symbol (Workspace)",
|
desc = "Goto Symbol (Workspace)",
|
||||||
|
|
|
@ -170,7 +170,7 @@ return {
|
||||||
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
|
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
|
||||||
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●"
|
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●"
|
||||||
or function(diagnostic)
|
or function(diagnostic)
|
||||||
local icons = require("lazyvim.config").icons.diagnostics
|
local icons = LazyVim.config.icons.diagnostics
|
||||||
for d, icon in pairs(icons) do
|
for d, icon in pairs(icons) do
|
||||||
if diagnostic.severity == vim.diagnostic.severity[d:upper()] then
|
if diagnostic.severity == vim.diagnostic.severity[d:upper()] then
|
||||||
return icon
|
return icon
|
||||||
|
|
|
@ -61,7 +61,7 @@ return {
|
||||||
diagnostics = "nvim_lsp",
|
diagnostics = "nvim_lsp",
|
||||||
always_show_bufferline = false,
|
always_show_bufferline = false,
|
||||||
diagnostics_indicator = function(_, _, diag)
|
diagnostics_indicator = function(_, _, diag)
|
||||||
local icons = require("lazyvim.config").icons.diagnostics
|
local icons = LazyVim.config.icons.diagnostics
|
||||||
local ret = (diag.error and icons.Error .. diag.error .. " " or "")
|
local ret = (diag.error and icons.Error .. diag.error .. " " or "")
|
||||||
.. (diag.warning and icons.Warn .. diag.warning or "")
|
.. (diag.warning and icons.Warn .. diag.warning or "")
|
||||||
return vim.trim(ret)
|
return vim.trim(ret)
|
||||||
|
@ -112,7 +112,7 @@ return {
|
||||||
local lualine_require = require("lualine_require")
|
local lualine_require = require("lualine_require")
|
||||||
lualine_require.require = require
|
lualine_require.require = require
|
||||||
|
|
||||||
local icons = require("lazyvim.config").icons
|
local icons = LazyVim.config.icons
|
||||||
|
|
||||||
vim.o.laststatus = vim.g.lualine_laststatus
|
vim.o.laststatus = vim.g.lualine_laststatus
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
local Config = require("lazyvim.config")
|
|
||||||
|
|
||||||
-- Some extras need to be loaded before others
|
-- Some extras need to be loaded before others
|
||||||
local prios = {
|
local prios = {
|
||||||
["lazyvim.plugins.extras.test.core"] = 1,
|
["lazyvim.plugins.extras.test.core"] = 1,
|
||||||
|
@ -13,7 +11,7 @@ local prios = {
|
||||||
}
|
}
|
||||||
|
|
||||||
---@type string[]
|
---@type string[]
|
||||||
local extras = LazyVim.dedup(Config.json.data.extras)
|
local extras = LazyVim.dedup(LazyVim.config.json.data.extras)
|
||||||
|
|
||||||
local version = vim.version()
|
local version = vim.version()
|
||||||
local v = version.major .. "_" .. version.minor
|
local v = version.major .. "_" .. version.minor
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
local Config = require("lazyvim.config")
|
|
||||||
local Float = require("lazy.view.float")
|
local Float = require("lazy.view.float")
|
||||||
local LazyConfig = require("lazy.core.config")
|
local LazyConfig = require("lazy.core.config")
|
||||||
local Plugin = require("lazy.core.plugin")
|
local Plugin = require("lazy.core.plugin")
|
||||||
|
@ -124,7 +123,7 @@ function M.get_extra(source, modname)
|
||||||
imports = imports,
|
imports = imports,
|
||||||
desc = require(modname).desc,
|
desc = require(modname).desc,
|
||||||
recommended = recommended,
|
recommended = recommended,
|
||||||
managed = vim.tbl_contains(Config.json.data.extras, modname) or not enabled,
|
managed = vim.tbl_contains(LazyVim.config.json.data.extras, modname) or not enabled,
|
||||||
plugins = plugins,
|
plugins = plugins,
|
||||||
optional = optional,
|
optional = optional,
|
||||||
}
|
}
|
||||||
|
@ -169,17 +168,17 @@ function X:toggle()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
extra.enabled = not extra.enabled
|
extra.enabled = not extra.enabled
|
||||||
Config.json.data.extras = vim.tbl_filter(function(name)
|
LazyVim.config.json.data.extras = vim.tbl_filter(function(name)
|
||||||
return name ~= extra.module
|
return name ~= extra.module
|
||||||
end, Config.json.data.extras)
|
end, LazyVim.config.json.data.extras)
|
||||||
M.state = vim.tbl_filter(function(name)
|
M.state = vim.tbl_filter(function(name)
|
||||||
return name ~= extra.module
|
return name ~= extra.module
|
||||||
end, M.state)
|
end, M.state)
|
||||||
if extra.enabled then
|
if extra.enabled then
|
||||||
table.insert(Config.json.data.extras, extra.module)
|
table.insert(LazyVim.config.json.data.extras, extra.module)
|
||||||
M.state[#M.state + 1] = extra.module
|
M.state[#M.state + 1] = extra.module
|
||||||
end
|
end
|
||||||
table.sort(Config.json.data.extras)
|
table.sort(LazyVim.config.json.data.extras)
|
||||||
LazyVim.json.save()
|
LazyVim.json.save()
|
||||||
LazyVim.info(
|
LazyVim.info(
|
||||||
"`"
|
"`"
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
local Config = require("lazyvim.config")
|
|
||||||
|
|
||||||
---@class lazyvim.util.json
|
---@class lazyvim.util.json
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
@ -46,18 +44,18 @@ function M.encode(value)
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.save()
|
function M.save()
|
||||||
Config.json.data.version = Config.json.version
|
LazyVim.config.json.data.version = LazyVim.config.json.version
|
||||||
local path = vim.fn.stdpath("config") .. "/lazyvim.json"
|
local path = vim.fn.stdpath("config") .. "/lazyvim.json"
|
||||||
local f = io.open(path, "w")
|
local f = io.open(path, "w")
|
||||||
if f then
|
if f then
|
||||||
f:write(LazyVim.json.encode(Config.json.data))
|
f:write(LazyVim.json.encode(LazyVim.config.json.data))
|
||||||
f:close()
|
f:close()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function M.migrate()
|
function M.migrate()
|
||||||
LazyVim.info("Migrating `lazyvim.json` to version `" .. Config.json.version .. "`")
|
LazyVim.info("Migrating `lazyvim.json` to version `" .. LazyVim.config.json.version .. "`")
|
||||||
local json = Config.json
|
local json = LazyVim.config.json
|
||||||
|
|
||||||
-- v0
|
-- v0
|
||||||
if not json.data.version then
|
if not json.data.version then
|
||||||
|
|
|
@ -30,7 +30,7 @@ function M.cmp_source(name, icon)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
function()
|
function()
|
||||||
return icon or require("lazyvim.config").icons.kinds[name:sub(1, 1):upper() .. name:sub(2)]
|
return icon or LazyVim.config.icons.kinds[name:sub(1, 1):upper() .. name:sub(2)]
|
||||||
end,
|
end,
|
||||||
cond = function()
|
cond = function()
|
||||||
return status() ~= nil
|
return status() ~= nil
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
local Config = require("lazyvim.config")
|
|
||||||
|
|
||||||
---@class lazyvim.util.news
|
---@class lazyvim.util.news
|
||||||
local M = {}
|
local M = {}
|
||||||
|
|
||||||
|
@ -13,13 +11,13 @@ end
|
||||||
|
|
||||||
function M.setup()
|
function M.setup()
|
||||||
vim.schedule(function()
|
vim.schedule(function()
|
||||||
if Config.news.lazyvim then
|
if LazyVim.config.news.lazyvim then
|
||||||
if not Config.json.data.news["NEWS.md"] then
|
if not LazyVim.config.json.data.news["NEWS.md"] then
|
||||||
M.welcome()
|
M.welcome()
|
||||||
end
|
end
|
||||||
M.lazyvim(true)
|
M.lazyvim(true)
|
||||||
end
|
end
|
||||||
if Config.news.neovim then
|
if LazyVim.config.news.neovim then
|
||||||
M.neovim(true)
|
M.neovim(true)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -61,12 +59,12 @@ function M.open(file, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
if opts.when_changed then
|
if opts.when_changed then
|
||||||
local is_new = not Config.json.data.news[ref]
|
local is_new = not LazyVim.config.json.data.news[ref]
|
||||||
local hash = M.hash(file)
|
local hash = M.hash(file)
|
||||||
if hash == Config.json.data.news[ref] then
|
if hash == LazyVim.config.json.data.news[ref] then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
Config.json.data.news[ref] = hash
|
LazyVim.config.json.data.news[ref] = hash
|
||||||
LazyVim.json.save()
|
LazyVim.json.save()
|
||||||
-- don't open if file has never been opened
|
-- don't open if file has never been opened
|
||||||
if is_new then
|
if is_new then
|
||||||
|
|
|
@ -78,7 +78,7 @@ function M.foldtext()
|
||||||
if not ret or type(ret) == "string" then
|
if not ret or type(ret) == "string" then
|
||||||
ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } }
|
ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } }
|
||||||
end
|
end
|
||||||
table.insert(ret, { " " .. require("lazyvim.config").icons.misc.dots })
|
table.insert(ret, { " " .. LazyVim.config.icons.misc.dots })
|
||||||
|
|
||||||
if not vim.treesitter.foldtext then
|
if not vim.treesitter.foldtext then
|
||||||
return table.concat(
|
return table.concat(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue