Add theme-set/switching logic, and minor nvim, tmux, obsidian changes
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
local defaultColorScheme = "tokyodark"
|
||||
|
||||
function SetColorSchemeWrapper(scheme)
|
||||
scheme = scheme or defaultColorScheme
|
||||
vim.cmd.colorscheme(scheme)
|
||||
end
|
||||
|
||||
SetColorSchemeWrapper(defaultColorScheme)
|
||||
--
|
||||
-- SetColorSchemeWrapper("tokyodark")
|
||||
-- SetColorSchemeWrapper("tokyonight-night")
|
||||
-- SetColorSchemeWrapper("bamboo-vulgaris")
|
||||
-- SetColorSchemeWrapper("rose-pine-main")
|
||||
-- SetColorSchemeWrapper("gruvbox")
|
||||
-- SetColorSchemeWrapper("slate")
|
||||
-- SetColorSchemeWrapper("sorbet")
|
||||
|
||||
@@ -34,18 +34,15 @@ vim.keymap.set("n", "<leader>p", [["+p]])
|
||||
|
||||
-- search-and-replace shortcuts
|
||||
vim.keymap.set("n", "<leader>rw", [[:%s/\<<C-r><C-w>\>/<C-r><C-w>/gI<Left><Left><Left>]])
|
||||
vim.keymap.set("n", "<leader>ra", [[:%s//g<Left><Left>]])
|
||||
vim.keymap.set("n", "<leader>ra", [[:%s//gc<Left><Left><Left>]])
|
||||
|
||||
-- toggle expandtab and show message
|
||||
vim.keymap.set("n", "<leader>tab", function()
|
||||
if vim.opt.expandtab:get() then
|
||||
vim.opt.expandtab = false
|
||||
print("using actual tabs")
|
||||
else
|
||||
vim.opt.expandtab = true
|
||||
print("using spaces in place of tabs")
|
||||
end
|
||||
end)
|
||||
vim.keymap.set("n", "<leader>tab", function() ToggleTabsSpaces() end)
|
||||
|
||||
-- open scratch/tmp buffers which won't prompt for file-save
|
||||
vim.keymap.set("n", "<leader>ss", function() TmpBuff("enew") end)
|
||||
vim.keymap.set("n", "<leader>sl", function() TmpBuff("vnew") end)
|
||||
vim.keymap.set("n", "<leader>sj", function() TmpBuff("new") end)
|
||||
|
||||
-- quicker switching between panes/splits
|
||||
vim.keymap.set("n", "<C-h>", [[<C-w>h]])
|
||||
@@ -64,12 +61,16 @@ kmgAutocmd('FileType', {
|
||||
})
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
-- quickfix TODO: learn about quickfix (:help quickfix), then set mappings
|
||||
-- quickfix and location lists
|
||||
-- ref: :h quickfix or :h location-list
|
||||
-- NOTE: look at :h setqflist and :h vim.diagnostic.setqflist()
|
||||
|
||||
-- vim.keymap.set("n", "<C-k>", "<cmd>cnext<CR>zz")
|
||||
-- vim.keymap.set("n", "<C-j>", "<cmd>cprev<CR>zz")
|
||||
-- vim.keymap.set("n", "<leader>k", "<cmd>lnext<CR>zz")
|
||||
-- vim.keymap.set("n", "<leader>j", "<cmd>lprev<CR>zz")
|
||||
vim.keymap.set("n", "<leader>qo", "<cmd>copen<CR>")
|
||||
vim.keymap.set("n", "<leader>qc", "<cmd>cclose<CR>")
|
||||
vim.keymap.set("n", "<leader>qn", "<cmd>cnext<CR>")
|
||||
vim.keymap.set("n", "<leader>qp", "<cmd>cprev<CR>")
|
||||
vim.keymap.set("n", "<leader>ln", "<cmd>lnext<CR>")
|
||||
vim.keymap.set("n", "<leader>lp", "<cmd>lprev<CR>")
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
-- debugger and debugging ui
|
||||
@@ -112,18 +113,29 @@ kmgAutocmd('LspAttach', {
|
||||
callback = function(e)
|
||||
local opts = { buffer = e.buf }
|
||||
vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts)
|
||||
vim.keymap.set("n", "K", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("n", "<leader>h", function() vim.lsp.buf.hover() end, opts)
|
||||
vim.keymap.set("i", "<C-h>", function() vim.lsp.buf.signature_help() end, opts)
|
||||
vim.keymap.set("n", "<leader>vdv", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "<leader>vdn", function() vim.diagnostic.goto_next() end, opts)
|
||||
vim.keymap.set("n", "<leader>vdp", function() vim.diagnostic.goto_prev() end, opts)
|
||||
vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrl", function() vim.lsp.buf.references() end, opts)
|
||||
vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
vim.keymap.set("n", "<leader>lv", function() vim.diagnostic.open_float() end, opts)
|
||||
vim.keymap.set("n", "<leader>lq", function() vim.diagnostic.setqflist() end, opts)
|
||||
-- TODO: learn what the below commands are and if i want to set keymaps for them
|
||||
-- vim.keymap.set("n", "<leader>vws", function() vim.lsp.buf.workspace_symbol() end, opts)
|
||||
-- vim.keymap.set("n", "<leader>vca", function() vim.lsp.buf.code_action() end, opts)
|
||||
-- vim.keymap.set("n", "<leader>vrl", function() vim.lsp.buf.references() end, opts)
|
||||
-- vim.keymap.set("n", "<leader>vrn", function() vim.lsp.buf.rename() end, opts)
|
||||
end
|
||||
})
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
-- git stuff
|
||||
|
||||
vim.keymap.set("n", "<leader>ga", function() vim.cmd("silent !git add %") end)
|
||||
vim.keymap.set("n", "<leader>gs", function() TmpBuff("new"); ReadShellCmd('git status') end)
|
||||
vim.keymap.set("n", "<leader>gl", function() TmpBuff("vnew"); ReadShellCmd('git log') end)
|
||||
vim.keymap.set("n", "<leader>gg", function()
|
||||
TmpBuff()
|
||||
ReadShellCmd('git ' .. vim.fn.input('git '))
|
||||
end)
|
||||
|
||||
------------------------------------------------------------------------------------------
|
||||
-- plugins
|
||||
|
||||
@@ -138,6 +150,10 @@ vim.keymap.set('n', '<leader>ff', tscBuiltin.find_files, { desc = 'tscope find f
|
||||
vim.keymap.set('n', '<leader>fg', tscBuiltin.git_files, { desc = 'tscope find git-tracked files' })
|
||||
vim.keymap.set('n', '<leader>fb', tscBuiltin.buffers, { desc = 'tscope buffers' })
|
||||
vim.keymap.set('n', '<leader>fh', tscBuiltin.help_tags, { desc = 'tscope help tags' })
|
||||
-- TODO: maybe add commands:
|
||||
-- - find files including git-ignored (have a yes and no option)
|
||||
-- - grep files including git-ignored (have a yes and no option)
|
||||
-- - grep which supports fuzzy-find, unless performance is horrendous
|
||||
|
||||
-- harpoon
|
||||
local harpoon = require("harpoon")
|
||||
@@ -146,18 +162,10 @@ vim.keymap.set("n", "<leader>ha", function() harpoon:list():add() end)
|
||||
vim.keymap.set("n", "<leader>hA", function() harpoon:list():prepend() end)
|
||||
vim.keymap.set("n", "<leader>hn", function() harpoon:list():next() end)
|
||||
vim.keymap.set("n", "<leader>hp", function() harpoon:list():prev() end)
|
||||
|
||||
vim.keymap.set("n", "<leader>hz", function() harpoon:list():select(1) end)
|
||||
vim.keymap.set("n", "<leader>hx", function() harpoon:list():select(2) end)
|
||||
vim.keymap.set("n", "<leader>hc", function() harpoon:list():select(3) end)
|
||||
vim.keymap.set("n", "<leader>hv", function() harpoon:list():select(4) end)
|
||||
vim.keymap.set("n", "<leader>hb", function() harpoon:list():select(5) end)
|
||||
|
||||
vim.keymap.set("n", "<leader>hZ", function() harpoon:list():replace_at(1) end)
|
||||
vim.keymap.set("n", "<leader>hX", function() harpoon:list():replace_at(2) end)
|
||||
vim.keymap.set("n", "<leader>hC", function() harpoon:list():replace_at(3) end)
|
||||
vim.keymap.set("n", "<leader>hV", function() harpoon:list():replace_at(4) end)
|
||||
vim.keymap.set("n", "<leader>hB", function() harpoon:list():replace_at(5) end)
|
||||
for i = 1, 10, 1 do
|
||||
vim.keymap.set("n", "<leader>" .. (i % 10), function() harpoon:list():select(i) end)
|
||||
vim.keymap.set("n", "<leader>h" .. (i % 10), function() harpoon:list():replace_at(i) end)
|
||||
end
|
||||
|
||||
-- undotree
|
||||
vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||
@@ -165,13 +173,6 @@ vim.keymap.set("n", "<leader>u", vim.cmd.UndotreeToggle)
|
||||
-- treesitter and treesitter-context
|
||||
vim.keymap.set("n", "<leader>tc", function() vim.cmd.TSContext({ "toggle" }) end)
|
||||
|
||||
-- fugitive (git integration)
|
||||
vim.keymap.set("n", "<leader>gG", vim.cmd.Git)
|
||||
vim.keymap.set("n", "<leader>gg", ":Git ") -- shortcut, arbitrary git commands
|
||||
vim.keymap.set("n", "<leader>ga", function() vim.cmd.Git({ "add %"}) end)
|
||||
vim.keymap.set("n", "<leader>gs", function() vim.cmd.Git({ "-p status" }) end)
|
||||
vim.keymap.set("n", "<leader>gc", function() vim.cmd.Git({ "commit -a" }) end)
|
||||
|
||||
-- conform (formatter)
|
||||
vim.keymap.set("n", "<leader>fmt", function()
|
||||
require("conform").format({ bufnr = 0 })
|
||||
|
||||
@@ -4,8 +4,12 @@ return {
|
||||
branch = "harpoon2", -- https://github.com/ThePrimeagen/harpoon/tree/harpoon2
|
||||
dependencies = { "nvim-lua/plenary.nvim" },
|
||||
config = function()
|
||||
local harpoon = require("harpoon")
|
||||
harpoon:setup()
|
||||
require("harpoon"):setup({
|
||||
settings = {
|
||||
save_on_toggle = true,
|
||||
sync_on_ui_close = true,
|
||||
}
|
||||
})
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -70,8 +70,4 @@ return {
|
||||
require('bamboo').load()
|
||||
end,
|
||||
},
|
||||
{
|
||||
dir = os.getenv('DIR_GIT_PROJECTS') .. "/other/omarchy-pina-theme/pina.nvim",
|
||||
name = "pina",
|
||||
},
|
||||
}
|
||||
30
src_files/.config/nvim/lua/theme_transparency.lua
Normal file
30
src_files/.config/nvim/lua/theme_transparency.lua
Normal file
@@ -0,0 +1,30 @@
|
||||
vim.api.nvim_set_hl(0, "Normal", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "FloatBorder", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "Pmenu", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "Terminal", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "EndOfBuffer", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "FoldColumn", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "Folded", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "SignColumn", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NormalNC", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "WhichKeyFloat", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "TelescopeBorder", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "TelescopeNormal", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptBorder", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "TelescopePromptTitle", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyINFOBody", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyERRORBody", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyWARNBody", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyTRACEBody", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyDEBUGBody", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyINFOTitle", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyERRORTitle", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyWARNTitle", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyTRACETitle", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyDEBUGTitle", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyINFOBorder", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyERRORBorder", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyWARNBorder", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyTRACEBorder", { bg = "none" })
|
||||
vim.api.nvim_set_hl(0, "NotifyDEBUGBorder", { bg = "none" })
|
||||
34
src_files/.config/nvim/lua/util_functions.lua
Normal file
34
src_files/.config/nvim/lua/util_functions.lua
Normal file
@@ -0,0 +1,34 @@
|
||||
function ThemeUpdate()
|
||||
local scheme_name = "tokyodark" -- default if unable to parse from file
|
||||
local current_theme_file = vim.fn.stdpath("config") .. "/current-theme"
|
||||
local ok, theme = pcall(dofile, current_theme_file)
|
||||
if ok then
|
||||
scheme_name = theme.colorscheme_name
|
||||
end
|
||||
vim.cmd.colorscheme(scheme_name)
|
||||
pcall(dofile, vim.fn.stdpath('config') .. '/lua/theme_transparency.lua')
|
||||
end
|
||||
|
||||
function TmpBuff(split_opt)
|
||||
local new_cmd = split_opt or "enew"
|
||||
vim.cmd(new_cmd)
|
||||
vim.opt_local.buftype = "nofile"
|
||||
vim.opt_local.bufhidden = "hide"
|
||||
vim.opt_local.swapfile = false
|
||||
vim.cmd("file tmp_" .. os.date("%Y%m%d_%H%M%S"))
|
||||
end
|
||||
|
||||
function ReadShellCmd(command)
|
||||
vim.cmd("read !" .. command)
|
||||
end
|
||||
|
||||
function ToggleTabsSpaces()
|
||||
if vim.opt.expandtab:get() then
|
||||
vim.opt.expandtab = false
|
||||
print("using actual tabs")
|
||||
else
|
||||
vim.opt.expandtab = true
|
||||
print("using spaces in place of tabs")
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user