Browse Source

extended theme toggling

imac
Juni Kim 2 years ago
parent
commit
b33adedd66
  1. 2
      lua/junikim/options.lua
  2. 23
      lua/junikim/remap.lua
  3. 20
      lua/junikim/theme.lua

2
lua/junikim/options.lua

@ -79,7 +79,7 @@ vim.api.nvim_create_autocmd("FileType", {
})
vim.api.nvim_create_autocmd("BufWritePre", {
pattern = { "*.go", "*.py", "*.lua", "*.ts", "*.tsx", "*.js", "*.md", "*.json" },
pattern = { "*.go", "*.py", "*.lua", "*.ts", "*.tsx", "*.js", "*.md", "*.json", "*.rs" },
callback = function(args)
vim.lsp.buf.formatting_sync()
end

23
lua/junikim/remap.lua

@ -26,11 +26,22 @@ map("n", "<F12>", ":w|:!texbld run compile<CR>")
map("n", "<F5>", ":w|:!./test.sh<CR>")
-- hacks
vim.keymap.set("v", "J", ":m '>+1<CR>gv=gv")
vim.keymap.set("v", "K", ":m '<-2<CR>gv=gv")
vim.keymap.set("n", "J", "mzJ`z")
vim.keymap.set("n", "<C-d>", "<C-d>zz")
vim.keymap.set("n", "<C-u>", "<C-u>zz")
vim.keymap.set("n", "n", "nzzzv")
vim.keymap.set("n", "N", "Nzzzv")
vim.keymap.set("x", "<leader>p", [["_dP]])
vim.keymap.set({ "n", "v" }, "<leader>y", [["+y]])
vim.keymap.set("n", "<leader>Y", [["+Y]])
vim.keymap.set("n", "<leader>x", "<cmd>!chmod +x %<CR>", { silent = true })
vim.keymap.set("n", "<leader>X", "<cmd>!chmod -x %<CR>", { silent = true })
-- execute file
vim.keymap.set("n", "<leader>e", "<cmd>!%:p<CR>", { silent = true })
@ -41,4 +52,14 @@ vim.keymap.set("n", "<leader>fmt", function()
vim.lsp.buf.formatting_sync()
end)
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmuxs<CR>")
if os.getenv("TMUX") ~= nil then
vim.keymap.set("n", "<C-f>", "<cmd>silent !tmux neww tmuxs<CR>")
vim.keymap.set("n", "<C-n>", "<cmd>silent !tmux neww ncmpcpp<CR>")
else
local function unavailable()
print("Not in a tmux session")
end
vim.keymap.set("n", "<C-f>", unavailable)
vim.keymap.set("n", "<C-n>", unavailable)
end

20
lua/junikim/theme.lua

@ -1,9 +1,25 @@
local day = 9
local night = 19
local hour = os.date("*t").hour
print("hour" .. hour)
local themes = { "catppuccin-latte", "catppuccin-mocha" }
local theme = 1
if day <= hour and hour < night then
vim.cmd([[ colorscheme catppuccin-latte ]])
theme = 1
else
vim.cmd([[ colorscheme catppuccin-mocha ]])
theme = 2
end
vim.cmd.colorscheme(themes[theme])
local function toggletheme()
if theme == 1 then
theme = 2
else
theme = 1
end
vim.cmd.colorscheme(themes[theme])
end
vim.api.nvim_create_user_command("ToggleTheme", toggletheme, {})
Loading…
Cancel
Save