mirror of
https://github.com/LazyVim/LazyVim.git
synced 2025-06-23 09:18:51 +02:00
feat(config)!: LazyVim can now be configured like any other plugin with {"LazyVim/LazyVim", opts = ... }. config.settings
is deprecated
This commit is contained in:
parent
aafc033927
commit
36c84f47c9
7 changed files with 113 additions and 57 deletions
79
lua/lazyvim/config/init.lua
Normal file
79
lua/lazyvim/config/init.lua
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
---@type LazyVimConfig
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
---@class LazyVimConfig
|
||||||
|
local defaults = {
|
||||||
|
icons = {
|
||||||
|
diagnostics = {
|
||||||
|
Error = " ",
|
||||||
|
Warn = " ",
|
||||||
|
Hint = " ",
|
||||||
|
Info = " ",
|
||||||
|
},
|
||||||
|
git = {
|
||||||
|
added = " ",
|
||||||
|
modified = " ",
|
||||||
|
removed = " ",
|
||||||
|
},
|
||||||
|
kinds = {
|
||||||
|
Array = " ",
|
||||||
|
Boolean = " ",
|
||||||
|
Class = " ",
|
||||||
|
Color = " ",
|
||||||
|
Constant = " ",
|
||||||
|
Constructor = " ",
|
||||||
|
Enum = " ",
|
||||||
|
EnumMember = " ",
|
||||||
|
Event = " ",
|
||||||
|
Field = " ",
|
||||||
|
File = " ",
|
||||||
|
Folder = " ",
|
||||||
|
Function = " ",
|
||||||
|
Interface = " ",
|
||||||
|
Key = " ",
|
||||||
|
Keyword = " ",
|
||||||
|
Method = " ",
|
||||||
|
Module = " ",
|
||||||
|
Namespace = " ",
|
||||||
|
Null = "ﳠ ",
|
||||||
|
Number = " ",
|
||||||
|
Object = " ",
|
||||||
|
Operator = " ",
|
||||||
|
Package = " ",
|
||||||
|
Property = " ",
|
||||||
|
Reference = " ",
|
||||||
|
Snippet = " ",
|
||||||
|
String = " ",
|
||||||
|
Struct = " ",
|
||||||
|
Text = " ",
|
||||||
|
TypeParameter = " ",
|
||||||
|
Unit = " ",
|
||||||
|
Value = " ",
|
||||||
|
Variable = " ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
---@type LazyVimConfig
|
||||||
|
local options
|
||||||
|
|
||||||
|
---@param opts? LazyVimConfig
|
||||||
|
function M.setup(opts)
|
||||||
|
options = vim.tbl_deep_extend("force", defaults, opts or {})
|
||||||
|
---@param range? string
|
||||||
|
function M.has(range)
|
||||||
|
local Semver = require("lazy.manage.semver")
|
||||||
|
return Semver.range(range or M.lazy_version):matches(require("lazy.core.config").version or "0.0.0")
|
||||||
|
end
|
||||||
|
|
||||||
|
setmetatable(M, {
|
||||||
|
__index = function(_, key)
|
||||||
|
if options == nil then
|
||||||
|
M.setup()
|
||||||
|
end
|
||||||
|
---@cast options LazyVimConfig
|
||||||
|
return options[key]
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
|
||||||
|
return M
|
|
@ -1,54 +1,16 @@
|
||||||
---@class LazyVimSettings
|
require("lazy.core.util").warn(
|
||||||
local settings = {
|
[[`config.settings` is deprecated.
|
||||||
icons = {
|
|
||||||
diagnostics = {
|
Please configure LazyVim as a plugin:
|
||||||
Error = " ",
|
```lua
|
||||||
Warn = " ",
|
{
|
||||||
Hint = " ",
|
"LazyVim/LazyVim",
|
||||||
Info = " ",
|
opts = {
|
||||||
},
|
-- your config comes here
|
||||||
git = {
|
|
||||||
added = " ",
|
|
||||||
modified = " ",
|
|
||||||
removed = " ",
|
|
||||||
},
|
|
||||||
kinds = {
|
|
||||||
Array = " ",
|
|
||||||
Boolean = " ",
|
|
||||||
Class = " ",
|
|
||||||
Color = " ",
|
|
||||||
Constant = " ",
|
|
||||||
Constructor = " ",
|
|
||||||
Enum = " ",
|
|
||||||
EnumMember = " ",
|
|
||||||
Event = " ",
|
|
||||||
Field = " ",
|
|
||||||
File = " ",
|
|
||||||
Folder = " ",
|
|
||||||
Function = " ",
|
|
||||||
Interface = " ",
|
|
||||||
Key = " ",
|
|
||||||
Keyword = " ",
|
|
||||||
Method = " ",
|
|
||||||
Module = " ",
|
|
||||||
Namespace = " ",
|
|
||||||
Null = "ﳠ ",
|
|
||||||
Number = " ",
|
|
||||||
Object = " ",
|
|
||||||
Operator = " ",
|
|
||||||
Package = " ",
|
|
||||||
Property = " ",
|
|
||||||
Reference = " ",
|
|
||||||
Snippet = " ",
|
|
||||||
String = " ",
|
|
||||||
Struct = " ",
|
|
||||||
Text = " ",
|
|
||||||
TypeParameter = " ",
|
|
||||||
Unit = " ",
|
|
||||||
Value = " ",
|
|
||||||
Variable = " ",
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
```
|
||||||
return settings
|
]],
|
||||||
|
{ title = "LazyVim" }
|
||||||
|
)
|
||||||
|
return require("lazyvim.config")
|
||||||
|
|
8
lua/lazyvim/init.lua
Normal file
8
lua/lazyvim/init.lua
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
local M = {}
|
||||||
|
|
||||||
|
---@param opts? LazyVimConfig
|
||||||
|
function M.setup(opts)
|
||||||
|
require("lazyvim.config").setup(opts)
|
||||||
|
end
|
||||||
|
|
||||||
|
return M
|
|
@ -63,7 +63,7 @@ return {
|
||||||
}),
|
}),
|
||||||
formatting = {
|
formatting = {
|
||||||
format = function(_, item)
|
format = function(_, item)
|
||||||
local icons = require("lazyvim.config.settings").icons.kinds
|
local icons = require("lazyvim.config").icons.kinds
|
||||||
if icons[item.kind] then
|
if icons[item.kind] then
|
||||||
item.kind = icons[item.kind] .. item.kind
|
item.kind = icons[item.kind] .. item.kind
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,11 @@
|
||||||
return {
|
local specs = {
|
||||||
-- set to HEAD for now. I'm sill making too many changes for this repo related to lazy itself
|
-- set to HEAD for now. I'm sill making too many changes for this repo related to lazy itself
|
||||||
{ "folke/lazy.nvim", version = false },
|
{ "folke/lazy.nvim", version = false },
|
||||||
}
|
}
|
||||||
|
|
||||||
|
-- only add for >=9.0.1, since there's an endless loop in earlier versions
|
||||||
|
if require("lazyvim.config").has(">=9.1.0") then
|
||||||
|
specs[#specs + 1] = { "LazyVim/LazyVim", priority = 10000, lazy = true }
|
||||||
|
end
|
||||||
|
|
||||||
|
return specs
|
||||||
|
|
|
@ -57,7 +57,7 @@ return {
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- diagnostics
|
-- diagnostics
|
||||||
for name, icon in pairs(require("lazyvim.config.settings").icons.diagnostics) do
|
for name, icon in pairs(require("lazyvim.config").icons.diagnostics) do
|
||||||
name = "DiagnosticSign" .. name
|
name = "DiagnosticSign" .. name
|
||||||
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||||
end
|
end
|
||||||
|
|
|
@ -48,7 +48,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.settings").icons.diagnostics
|
local icons = require("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)
|
||||||
|
@ -74,7 +74,7 @@ return {
|
||||||
require("lazyvim.util").deprecate("lualine.override", "lualine.opts")
|
require("lazyvim.util").deprecate("lualine.override", "lualine.opts")
|
||||||
end
|
end
|
||||||
|
|
||||||
local icons = require("lazyvim.config.settings").icons
|
local icons = require("lazyvim.config").icons
|
||||||
|
|
||||||
local function fg(name)
|
local function fg(name)
|
||||||
return function()
|
return function()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue