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,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
return {
|
||||
-- TODO: decide which of these i won't be using, then remove from this file
|
||||
{
|
||||
"ellisonleao/gruvbox.nvim",
|
||||
name = "gruvbox",
|
||||
-- lazy = false,
|
||||
-- priority = 1000,
|
||||
opts = {
|
||||
terminal_colors = true, -- add neovim terminal colors
|
||||
undercurl = true,
|
||||
@@ -30,13 +27,13 @@ return {
|
||||
},
|
||||
},
|
||||
{
|
||||
-- TODO: decide if i want rose-pine, remove from file if not
|
||||
"rose-pine/neovim",
|
||||
name = "rose-pine",
|
||||
},
|
||||
{
|
||||
-- TODO: decide if i want tokyonight, remove from file if not
|
||||
"folke/tokyonight.nvim",
|
||||
lazy = false,
|
||||
priority = 1000,
|
||||
opts = {
|
||||
style = "night", -- "night", "storm", "moon", "day"
|
||||
styles = {
|
||||
@@ -70,8 +67,4 @@ return {
|
||||
require('bamboo').load()
|
||||
end,
|
||||
},
|
||||
{
|
||||
dir = os.getenv('DIR_GIT_PROJECTS') .. "/other/omarchy-pina-theme/pina.nvim",
|
||||
name = "pina",
|
||||
},
|
||||
}
|
||||
@@ -40,7 +40,7 @@ return {
|
||||
},
|
||||
})
|
||||
|
||||
-- TODO: decide if needed/wanted
|
||||
-- TODO: decide if needed/wanted
|
||||
-- local treesitter_parser_config = require("nvim-treesitter.parsers").get_parser_configs()
|
||||
-- treesitter_parser_config.templ = {
|
||||
-- install_info = {
|
||||
@@ -53,21 +53,22 @@ return {
|
||||
-- vim.treesitter.language.register("templ", "templ")
|
||||
end
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter-context",
|
||||
after = "nvim-treesitter",
|
||||
opts = {
|
||||
enable = false, -- can enable/disable via manual command
|
||||
multiwindow = false,
|
||||
max_lines = 0, -- lines the window should span; x <= 0 means no limit
|
||||
min_window_height = 10, -- min window height to enable; x <= 0 means no limit
|
||||
line_numbers = true,
|
||||
multiline_threshold = 40, -- max lines to show for a single context
|
||||
trim_scope = 'outer', -- 'inner', 'outer'; discard lines if max_lines exceeded
|
||||
mode = 'cursor', -- 'cursor', 'topline'; line used to calculate context
|
||||
separator = "-", -- 1 char, like '-'; only shown when >= 2 lines above
|
||||
zindex = 20, -- z-index of the context window
|
||||
on_attach = nil, -- (fun(buf: integer): boolean); return false to disable attaching
|
||||
},
|
||||
},
|
||||
-- {
|
||||
-- -- TODO: decide if needed/wanted
|
||||
-- "nvim-treesitter/nvim-treesitter-context",
|
||||
-- after = "nvim-treesitter",
|
||||
-- opts = {
|
||||
-- enable = false, -- can enable/disable via manual command
|
||||
-- multiwindow = false,
|
||||
-- max_lines = 0, -- lines the window should span; x <= 0 means no limit
|
||||
-- min_window_height = 10, -- min window height to enable; x <= 0 means no limit
|
||||
-- line_numbers = true,
|
||||
-- multiline_threshold = 40, -- max lines to show for a single context
|
||||
-- trim_scope = 'outer', -- 'inner', 'outer'; discard lines if max_lines exceeded
|
||||
-- mode = 'cursor', -- 'cursor', 'topline'; line used to calculate context
|
||||
-- separator = "-", -- 1 char, like '-'; only shown when >= 2 lines above
|
||||
-- zindex = 20, -- z-index of the context window
|
||||
-- on_attach = nil, -- (fun(buf: integer): boolean); return false to disable attaching
|
||||
-- },
|
||||
-- },
|
||||
}
|
||||
|
||||
14
src_files/.config/nvim/lua/theme_transparency.lua
Normal file
14
src_files/.config/nvim/lua/theme_transparency.lua
Normal file
@@ -0,0 +1,14 @@
|
||||
local hl_properties = {
|
||||
"Normal", "NormalFloat", "FloatBorder", "Pmenu", "Terminal", "EndOfBuffer",
|
||||
"FoldColumn", "Folded", "SignColumn", "NormalNC", "WhichKeyFloat", "TelescopeBorder",
|
||||
"TelescopeNormal", "TelescopePromptBorder", "TelescopePromptTitle", "NotifyINFOBody",
|
||||
"NotifyERRORBody", "NotifyWARNBody", "NotifyTRACEBody", "NotifyDEBUGBody",
|
||||
"NotifyINFOTitle", "NotifyERRORTitle", "NotifyWARNTitle", "NotifyTRACETitle",
|
||||
"NotifyDEBUGTitle", "NotifyINFOBorder", "NotifyERRORBorder", "NotifyWARNBorder",
|
||||
"NotifyTRACEBorder", "NotifyDEBUGBorder",
|
||||
}
|
||||
|
||||
for _, v in ipairs(hl_properties) do
|
||||
vim.api.nvim_set_hl(0, v, { bg = "none" })
|
||||
end
|
||||
|
||||
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