cleaned up some code
This commit is contained in:
@@ -50,13 +50,13 @@ local keymap = {
|
|||||||
|
|
||||||
local TAB_WIDTH = 4
|
local TAB_WIDTH = 4
|
||||||
|
|
||||||
---@type { [string]: 'gruvbox'|'vscode'|false }
|
---@type installed_themes
|
||||||
local color_scheme_settings = {
|
local default_theme = 'gruvbox'
|
||||||
default = 'gruvbox',
|
|
||||||
|
---@type { [string]: installed_themes}
|
||||||
|
local file_specific_themes = {
|
||||||
markdown = 'vscode',
|
markdown = 'vscode',
|
||||||
}
|
}
|
||||||
assert(color_scheme_settings.default ~= nil, 'The default color scheme must be either false or a valid string.')
|
|
||||||
--> set color to false for ugly default colors
|
|
||||||
|
|
||||||
vim.g.mapleader = keymap.leader_key
|
vim.g.mapleader = keymap.leader_key
|
||||||
vim.g.maplocalleader = keymap.leader_key
|
vim.g.maplocalleader = keymap.leader_key
|
||||||
@@ -156,24 +156,9 @@ local function packer_startup(use)
|
|||||||
{'BufEnter'},
|
{'BufEnter'},
|
||||||
{
|
{
|
||||||
callback = function(_)
|
callback = function(_)
|
||||||
---@type string
|
local theme = file_specific_themes[vim.api.nvim_buf_get_option(0, "filetype")] or default_theme
|
||||||
local filetype = vim.api.nvim_buf_get_option(0, "filetype")
|
vim.o.termguicolors = theme ~= 'default'
|
||||||
|
|
||||||
---@type string|false
|
|
||||||
local theme
|
|
||||||
if color_scheme_settings[filetype] ~= nil then
|
|
||||||
theme = color_scheme_settings[filetype]
|
|
||||||
else
|
|
||||||
theme = color_scheme_settings.default
|
|
||||||
end
|
|
||||||
|
|
||||||
if theme then
|
|
||||||
vim.o.termguicolors = true
|
|
||||||
vim.cmd(" colorscheme " .. theme .. " ")
|
vim.cmd(" colorscheme " .. theme .. " ")
|
||||||
else
|
|
||||||
vim.o.termguicolors = false
|
|
||||||
vim.cmd(" colorscheme default ")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
@@ -482,3 +467,9 @@ vim.keymap.set(
|
|||||||
)
|
)
|
||||||
|
|
||||||
return require('packer').startup(packer_startup)
|
return require('packer').startup(packer_startup)
|
||||||
|
|
||||||
|
|
||||||
|
---@alias installed_themes
|
||||||
|
---| 'default'
|
||||||
|
---| 'gruvbox'
|
||||||
|
---| 'vscode'
|
||||||
|
|||||||
Reference in New Issue
Block a user