From dbb9af29d56e0894688637c805c3fdccac5067cd Mon Sep 17 00:00:00 2001 From: Ian Griffin Date: Mon, 18 Aug 2025 11:07:22 +0800 Subject: minor updates --- lua/binds.lua | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'lua/binds.lua') diff --git a/lua/binds.lua b/lua/binds.lua index beef6fb..291bfb8 100644 --- a/lua/binds.lua +++ b/lua/binds.lua @@ -29,6 +29,51 @@ ct.map('n', 'wq', 'wbd') -- netrw ct.map('n', 'e', 'Explore') +-- +-- LSP +-- +local lsp_buf = vim.lsp.buf + +-- Function to convert snake_case to PascalCase +local function snake_to_pascal(name) + return name:gsub('_', ''):gsub("(%a)(%w*)", function(first, rest) + return first:upper() .. rest:lower() + end) +end + +for func_name, _ in pairs(lsp_buf) do + if type(lsp_buf[func_name]) == "function" then -- Check if the value is a function + local command_name = 'LspBuf' .. snake_to_pascal(func_name) + vim.api.nvim_create_user_command( + command_name, + function() + lsp_buf[func_name]() -- Call the function from the table + end, + {desc = "Run LSP Buffer Function: " .. func_name} + ) + end +end + +function toggle_background() + local bg = vim.o.background + + if bg == "dark" then + vim.cmd("set background=light") + else + vim.cmd("set background=dark") + end + + -- Query the current colorscheme + --[[ local colorscheme = vim.fn.executable('colorscheme') or "" + -- colorscheme = colorscheme:match("^%s*(.-)%s*$") + + -- Reload the colorscheme if it was set + if colorscheme ~= "" then + vim.cmd("colorscheme " .. colorscheme) + end ]]-- +end + +ct.map('n', 'b', 'lua toggle_background()') -- -- Commands -- -- cgit v1.3