From cf1e2e38ed2db450220f553edf05fc9570423952 Mon Sep 17 00:00:00 2001 From: Petr Hrdina Date: Wed, 14 Jan 2026 21:45:20 +0100 Subject: [PATCH] Add more colorscheme and ability to switch --- lazy-lock.json | 2 ++ lua/config/keymaps.lua | 21 ++++++++++++------- lua/config/lazy.lua | 4 ++-- lua/config/options.lua | 40 +++++++++++++++++++----------------- lua/plugins/colorschemes.lua | 22 ++++++++++++++++++++ lua/utils/colorscheme.lua | 21 +++++++++++++++++++ 6 files changed, 82 insertions(+), 28 deletions(-) create mode 100644 lua/plugins/colorschemes.lua create mode 100644 lua/utils/colorscheme.lua diff --git a/lazy-lock.json b/lazy-lock.json index 3050f39..d4d1cbf 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,4 +1,6 @@ { + "catppuccin": { "branch": "main", "commit": "beaf41a30c26fd7d6c386d383155cbd65dd554cd" }, + "gruvbox.nvim": { "branch": "main", "commit": "a472496e1a4465a2dd574389dcf6cdb29af9bf1b" }, "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, "nvim-treesitter": { "branch": "main", "commit": "5a7e5638e7d220575b1c22c8a2e099b52231886e" }, "plenary.nvim": { "branch": "master", "commit": "b9fd5226c2f76c951fc8ed5923d85e4de065e509" }, diff --git a/lua/config/keymaps.lua b/lua/config/keymaps.lua index dd10d17..32693d0 100644 --- a/lua/config/keymaps.lua +++ b/lua/config/keymaps.lua @@ -1,12 +1,19 @@ +local keymap = vim.keymap + -- Save & quit -vim.keymap.set("n", "w", ":w") -vim.keymap.set("n", "q", ":q") +keymap.set("n", "w", ":w") +keymap.set("n", "q", ":q") -- Clear search highlight -vim.keymap.set("n", "h", ":nohlsearch") +keymap.set("n", "h", ":nohlsearch") -- Better window navigation -vim.keymap.set("n", "", "h") -vim.keymap.set("n", "", "j") -vim.keymap.set("n", "", "k") -vim.keymap.set("n", "", "l") +keymap.set("n", "", "h") +keymap.set("n", "", "j") +keymap.set("n", "", "k") +keymap.set("n", "", "l") + +-- Colorscheme +local utils = require("utils.colorscheme") + +keymap.set("n", "cs", utils.pick, { desc = "Pick colorscheme" }) diff --git a/lua/config/lazy.lua b/lua/config/lazy.lua index 45380c8..b24d5d5 100644 --- a/lua/config/lazy.lua +++ b/lua/config/lazy.lua @@ -18,9 +18,9 @@ vim.opt.rtp:prepend(lazypath) -- Initialize lazy.nvim local plugins = { - require("plugins.tokyonight"), -- theme - require("plugins.treesitter"), -- syntax tree + require("plugins.colorschemes"), -- theme require("plugins.telescope"), -- fuzzy finder + require("plugins.treesitter"), -- syntax tree } require("lazy").setup(plugins) diff --git a/lua/config/options.lua b/lua/config/options.lua index 3e176b0..62039e4 100644 --- a/lua/config/options.lua +++ b/lua/config/options.lua @@ -1,30 +1,32 @@ +local opt = vim.opt + -- Line numbers -vim.opt.number = true -vim.opt.relativenumber = true +opt.number = true +opt.relativenumber = true -- Tabs & indentation -vim.opt.tabstop = 4 -- number of spaces a tab counts for -vim.opt.shiftwidth = 4 -- spaces for each indent -vim.opt.expandtab = true -- convert tabs to spaces -vim.opt.smartindent = true +opt.tabstop = 4 -- number of spaces a tab counts for +opt.shiftwidth = 4 -- spaces for each indent +opt.expandtab = true -- convert tabs to spaces +opt.smartindent = true -- Searching -vim.opt.ignorecase = true -- case-insensitive search... -vim.opt.smartcase = true -- ...unless you use capitals -vim.opt.hlsearch = true -vim.opt.incsearch = true +opt.ignorecase = true -- case-insensitive search... +opt.smartcase = true -- ...unless you use capitals +opt.hlsearch = true +opt.incsearch = true -- UI / UX -vim.opt.termguicolors = true -vim.opt.cursorline = true -vim.opt.signcolumn = "yes" -- avoid text shifting -vim.opt.wrap = false -- no line wrapping +opt.termguicolors = true +opt.cursorline = true +opt.signcolumn = "yes" -- avoid text shifting +opt.wrap = false -- no line wrapping -- Behavior -vim.opt.scrolloff = 8 -- keep lines above/below cursor -vim.opt.sidescrolloff = 8 -vim.opt.updatetime = 300 -- faster diagnostics -vim.opt.timeoutlen = 500 -- faster key sequences +opt.scrolloff = 8 -- keep lines above/below cursor +opt.sidescrolloff = 8 +opt.updatetime = 300 -- faster diagnostics +opt.timeoutlen = 500 -- faster key sequences -- Clipboard (use system clipboard) -vim.opt.clipboard = "unnamedplus" +opt.clipboard = "unnamedplus" diff --git a/lua/plugins/colorschemes.lua b/lua/plugins/colorschemes.lua new file mode 100644 index 0000000..d76ada7 --- /dev/null +++ b/lua/plugins/colorschemes.lua @@ -0,0 +1,22 @@ +return { + -- Tokyo Night + { + "folke/tokyonight.nvim", + lazy = true, + }, + -- Catppuccin + { + "catppuccin/nvim", + name = "catppuccin", + lazy = false, -- loads immediately + priority = 1000, -- ensure it loads before other plugins + config = function() + vim.cmd.colorscheme("catppuccin") + end, + }, + -- Gruvbox + { + "ellisonleao/gruvbox.nvim", + lazy = true, + }, +} diff --git a/lua/utils/colorscheme.lua b/lua/utils/colorscheme.lua new file mode 100644 index 0000000..5f7d8ec --- /dev/null +++ b/lua/utils/colorscheme.lua @@ -0,0 +1,21 @@ +local M = {} + +-- List of installed colorschemes +M.themes = { "tokyonight", "catppuccin", "gruvbox" } + +-- Picker function +function M.pick() + vim.ui.select(M.themes, { + prompt = "Choose Colorscheme:", + }, function(choice) + if choice then + -- Load lazy plugin if needed + pcall(require, choice) + + -- Apply the colorscheme + vim.cmd.colorscheme(choice) + end + end) +end + +return M