refactor: move icons to settings and add setup method for configs extending LazyVim (like my own dots)

This commit is contained in:
Folke Lemaitre 2023-01-03 21:04:35 +01:00
parent ff777b5efd
commit 7a49913cf2
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
8 changed files with 57 additions and 40 deletions

View file

@ -1,4 +1,4 @@
require("lazyvim.config.options") vim.g.mapleader = " "
require("lazyvim.config.lazy") vim.g.maplocalleader = " "
require("lazyvim.config.autocmds")
require("lazyvim.config.keymaps") require("lazyvim").setup()

View file

@ -1,30 +0,0 @@
return {
diagnostics = {
Error = "",
Warn = "",
Hint = "",
Info = "",
},
kinds = {
Class = "",
Color = "",
Constant = "",
Constructor = "",
Enum = "",
EnumMember = "",
Field = "",
File = "",
Folder = "",
Function = "",
Interface = "",
Keyword = "",
Method = "ƒ ",
Property = "",
Snippet = "",
Struct = "",
Text = "",
Unit = "",
Value = "",
Variable = "",
},
}

View file

@ -1,6 +1,3 @@
vim.g.mapleader = " "
vim.g.maplocalleader = " "
vim.opt.autowrite = true -- enable auto write vim.opt.autowrite = true -- enable auto write
vim.opt.clipboard = "unnamedplus" -- sync with system clipboard vim.opt.clipboard = "unnamedplus" -- sync with system clipboard
vim.opt.cmdheight = 1 vim.opt.cmdheight = 1

View file

@ -0,0 +1,35 @@
---@class LazyVimSettings
local settings = {
icons = {
diagnostics = {
Error = "",
Warn = "",
Hint = "",
Info = "",
},
kinds = {
Class = "",
Color = "",
Constant = "",
Constructor = "",
Enum = "",
EnumMember = "",
Field = "",
File = "",
Folder = "",
Function = "",
Interface = "",
Keyword = "",
Method = "ƒ ",
Property = "",
Snippet = "",
Struct = "",
Text = "",
Unit = "",
Value = "",
Variable = "",
},
},
}
return settings

15
lua/lazyvim/init.lua Normal file
View file

@ -0,0 +1,15 @@
local M = {}
---@param opts? LazyVimSettings
function M.setup(opts)
if not package.loaded.lazy then
require("lazyvim.config.lazy")
end
local settings = require("lazyvim.config.settings")
package.loaded["lazyvim.config.settings"] = vim.tbl_deep_extend("force", settings, opts or {})
require("lazyvim.config.options")
require("lazyvim.config.autocmds")
require("lazyvim.config.keymaps")
end
return M

View file

@ -59,7 +59,7 @@ return {
}), }),
formatting = { formatting = {
format = function(_, item) format = function(_, item)
local icons = require("lazyvim.config.icons").kinds local icons = require("lazyvim.config.settings").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

View file

@ -20,7 +20,7 @@ return {
end) end)
-- diagnostics -- diagnostics
for name, icon in pairs(require("lazyvim.config.icons").diagnostics) do for name, icon in pairs(require("lazyvim.config.settings").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

View file

@ -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.icons").diagnostics local icons = require("lazyvim.config.settings").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)