commit 5e821a4d6155f5f871237d0da1382c97557cf4dc Author: RingOfStorms (Joshua Bell) Date: Mon May 22 21:37:52 2023 -0500 initial commit, working on TODO's diff --git a/autocommands.lua b/autocommands.lua new file mode 100644 index 0000000..b79a80d --- /dev/null +++ b/autocommands.lua @@ -0,0 +1,53 @@ +function is_available(plugin) + local lazy_config_avail, lazy_config = pcall(require, "lazy.core.config") + return lazy_config_avail and lazy_config.plugins[plugin] ~= nil +end + +local augroup = vim.api.nvim_create_augroup +local autocmd = vim.api.nvim_create_autocmd +local cmd = vim.api.nvim_create_user_command +local namespace = vim.api.nvim_create_namespace + +if is_available "alpha-nvim" then + local group_name = augroup("alpha_settings", { clear = true }) + autocmd({ "User", "BufEnter" }, { + desc = "Disable status and tablines for alpha", + group = group_name, + callback = function(event) + if + ( + (event.event == "User" and event.file == "AlphaReady") + or (event.event == "BufEnter" and vim.api.nvim_get_option_value("filetype", { buf = event.buf }) == "alpha") + ) and not vim.g.before_alpha + then + vim.g.before_alpha = { showtabline = vim.opt.showtabline:get(), laststatus = vim.opt.laststatus:get() } + vim.opt.showtabline, vim.opt.laststatus = 0, 0 + elseif + vim.g.before_alpha + and event.event == "BufEnter" + and vim.api.nvim_get_option_value("buftype", { buf = event.buf }) ~= "nofile" + then + vim.opt.laststatus, vim.opt.showtabline = vim.g.before_alpha.laststatus, vim.g.before_alpha.showtabline + vim.g.before_alpha = nil + end + end, + }) + autocmd("VimEnter", { + desc = "Start Alpha when vim is opened with no arguments", + group = group_name, + callback = function() + local should_skip = false + if vim.fn.argc() > 0 or vim.fn.line2byte(vim.fn.line "$") ~= -1 or not vim.o.modifiable then + should_skip = true + else + for _, arg in pairs(vim.v.argv) do + if arg == "-b" or arg == "-c" or vim.startswith(arg, "+") or arg == "-S" then + should_skip = true + break + end + end + end + if not should_skip then require("alpha").start(true, require("alpha").default_config) end + end, + }) +end diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..fb5dca0 --- /dev/null +++ b/init.lua @@ -0,0 +1,26 @@ +require "options" +require "keymaps" + + +local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" +if not vim.loop.fs_stat(lazypath) then + local output = vim.fn.system({ + "git", + "clone", + "--filter=blob:none", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) + if vim.api.nvim_get_vvar "shell_error" ~= 0 then + vim.api.nvim_err_writeln("Error cloning lazy.nvim repository...\n\n" .. output) + end +end +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup("user", {}) + +vim.cmd 'colorscheme material' + +require "autocommands" + diff --git a/keymaps.lua b/keymaps.lua new file mode 100644 index 0000000..59b1fcc --- /dev/null +++ b/keymaps.lua @@ -0,0 +1,169 @@ +-- Shorten function name +local keymap = vim.keymap.set +-- Silent keymap option +local opts = { silent = true } + +--Remap space as leader key +keymap("", "", "", opts) +vim.g.mapleader = " " + +-- Modes +-- normal_mode = "n", +-- insert_mode = "i", +-- visual_mode = "v", +-- visual_block_mode = "x", +-- term_mode = "t", +-- command_mode = "c", + +local scratch = function(extension) + os.execute "mkdir -p ~/dev/scratches/" + local date = os.date "%Y-%m-%dT%H:%M:%S" + local filepath = "~/dev/scratches/scratch_" .. date .. extension + vim.cmd("execute 'edit " .. filepath .. "'") +end + +local mappings = { + n = { + ["w"] = { "w", desc = "Save" }, + ["q"] = { "confirm q", desc = "Quit" }, + ["|"] = { "vsplit", desc = "Vertical Split" }, + ["\\"] = { "split", desc = "Horizontal Split" }, + [""] = { "zz", desc = "Vertical half page down and center cursor" }, + [""] = { "zz", desc = "Vertical half page up and center cursor" }, + ["y"] = { '"*y', desc = "Copy to system clipboard" }, + ["p"] = { '"*p', desc = "Paste from system clipboard" }, + -- TODO L-c to close buffer + + ["gf"] = { ":OpenInGHFile ", desc = "Open in github" }, + + ["fs"] = { + function() + require("telescope.builtin").live_grep { + search_dirs = { "~/dev/scratches/" }, + } + end, + desc = "Find words in scratches", + }, + ["s"] = { name = " Scratch File" }, + ["ss"] = { function() scratch ".txt" end, desc = "New text scratch file" }, + ["sn"] = { function() scratch ".json" end, desc = "New json scratch file" }, + ["sq"] = { function() scratch ".sql" end, desc = "New sql scratch file" }, + ["st"] = { function() scratch ".ts" end, desc = "New ts scratch file" }, + ["sb"] = { function() scratch ".sh" end, desc = "New shell scratch file" }, + ["sj"] = { function() scratch ".js" end, desc = "New js scratch file" }, + ["∆"] = { + ":m .+1==g", + desc = "Move the line up", + }, + ["˚"] = { + ":m .-2==g", + desc = "Move the line down", + }, + ["r"] = { function() require("rest-nvim").run() end, desc = "Send http request" }, + ["Q"] = { ":qa", desc = "Quit all" }, + [","] = { name = " Misc Tools" }, + [",c"] = { name = " Casing" }, + [",cs"] = { ":Snek", desc = "To Snek Case" }, + [",cc"] = { ":Camel", desc = "To Camel Case" }, + [",cp"] = { ":CamelB", desc = "To Pascal Case" }, + [",ck"] = { ":Kebab", desc = "To Kebab Case" }, + [",ce"] = { ":Screm", desc = "To Screm Case" }, + [",j"] = { name = " Jest Tests" }, + [",jr"] = { function() require("jester").run() end, desc = "Run test under cursor" }, + [",jf"] = { function() require("jester").run_file() end, desc = "Run tests for file" }, + [",jl"] = { function() require("jester").run_last() end, desc = "Run last ran test" }, + ["lz"] = { ":LspRestart", desc = "Restart LSP Server" }, + }, + v = { + ["gf"] = { ":OpenInGHFile ", desc = "Open in github" }, + ["y"] = { '"*y', desc = "Copy to system clipboard" }, + ["p"] = { '"*p', desc = "Paste from system clipboard" }, + ["∆"] = { + cmd = ":m '>+1gv=gv", + desc = "Move the selected text up", + }, + ["˚"] = { + cmd = ":m '<-2gv=gv", + desc = "Move the selected text down", + }, + [","] = { name = " Misc Tools" }, + [",c"] = { name = " Casing" }, + [",cs"] = { ":Snek", desc = "To Snek Case" }, + [",cc"] = { ":Camel", desc = "To Camel Case" }, + [",cp"] = { ":CamelB", desc = "To Pascal Case" }, + [",ck"] = { ":Kebab", desc = "To Kebab Case" }, + [",ce"] = { ":Screm", desc = "To Screm Case" }, + }, + x = { + ["∆"] = { + cmd = ":m '>+1gv=gv", + desc = "Move the selected text up", + }, + ["˚"] = { + desc = "Move the selected text down", + cmd = ":m '<-2gv=gv", + }, + }, + i = { + [""] = { "", desc = "Up" }, + [""] = { "", desc = "Down" }, + [""] = { "", desc = "Left" }, + [""] = { "", desc = "Right" }, + }, + c = { + [""] = { "", desc = "Left" }, + [""] = { "", desc = "Down" }, + [""] = { "", desc = "Up" }, + [""] = { "", desc = "Right" }, + }, +} + +local which_key_queue = nil +--- Register queued which-key mappings +function which_key_register() + if which_key_queue then + local wk_avail, wk = pcall(require, "which-key") + if wk_avail then + for mode, registration in pairs(which_key_queue) do + wk.register(registration, { mode = mode }) + end + which_key_queue = nil + end + end +end + +--- Table based API for setting keybindings +---@param map_table table A nested table where the first key is the vim mode, the second key is the key to map, and the value is the function to set the mapping to +---@param base? table A base set of options to set on every keybinding +function set_mappings(map_table, base) + -- iterate over the first keys for each mode + base = base or {} + for mode, maps in pairs(map_table) do + -- iterate over each keybinding set in the current mode + for keymap, options in pairs(maps) do + -- build the options for the command accordingly + if options then + local cmd = options + local keymap_opts = base + if type(options) == "table" then + cmd = options[1] + keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options) + keymap_opts[1] = nil + end + if not cmd or keymap_opts.name then -- if which-key mapping, queue it + if not which_key_queue then which_key_queue = {} end + if not which_key_queue[mode] then which_key_queue[mode] = {} end + which_key_queue[mode][keymap] = keymap_opts + else -- if not which-key mapping, set it + vim.keymap.set(mode, keymap, cmd, keymap_opts) + end + end + end + end + if package.loaded["which-key"] then which_key_register() end -- if which-key is loaded already, register +end + +-- TODO load mappings from user plugins + +set_mappings(mappings); + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..ef34eb5 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,9 @@ +{ + "alpha-nvim": { "branch": "main", "commit": "1838ae926e8d49fe5330d1498ee8289ae2c340bc" }, + "auto-save.nvim": { "branch": "main", "commit": "979b6c82f60cfa80f4cf437d77446d0ded0addf0" }, + "gitsigns.nvim": { "branch": "main", "commit": "c18b7ca0b5b50596722f3a1572eb9b8eb520c0f1" }, + "glow.nvim": { "branch": "advanced_window", "commit": "f1157d4cb7e46e830c72004e7e1adb81a1f9b04c" }, + "lazy.nvim": { "branch": "main", "commit": "6610b15dfd76f7992423916e2b87f031881d7b25" }, + "material.nvim": { "branch": "main", "commit": "0c725897bc3d22c45fbf25a602002ee02f06f619" }, + "which-key.nvim": { "branch": "main", "commit": "e271c28118998c93a14d189af3395812a1aa646c" } +} \ No newline at end of file diff --git a/lua/user/alpha.lua b/lua/user/alpha.lua new file mode 100644 index 0000000..99b51c5 --- /dev/null +++ b/lua/user/alpha.lua @@ -0,0 +1,67 @@ +return { + "goolord/alpha-nvim", + commit = "1838ae926e8d49fe5330d1498ee8289ae2c340bc", -- May 22, 2023 + cmd = "Alpha", + opts = function() + local dashboard = require "alpha.themes.dashboard" + dashboard.section.header.val = { + " ▒▒▒▒▒▒ ", + " ▒▒▓▓▓▓▒▒▒▒▒▒▒▒ ", + " ▓▓▒▒▒▒▒▒▒▒░░ ▓▓ ", + " ▒▒▓▓▓▓▓▓▓▓▓▓▓▓░░░░ ▒▒▒▒▓▓▒▒▒▒ ", + " ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░ ▒▒▓▓▓▓▓▓▒▒▒▒▒▒ ", + " ▓▓▓▓▓▓▓▓▓▓ ██▓▓▓▓▓▓▓▓ ▒▒▒▒ ██ ", + " ██▓▓▓▓ ▓▓████▓▓▓▓ ▒▒▒▒▒▒▒▒▓▓██▓▓ ▒▒▒▒▒▒ ", + " ██ ██ ▒▒▒▒▒▒░░░░ ▒▒▒▒▒▒ ▓▓▓▓▓▓ ▒▒▒▒▓▓▓▓██▓▓▒▒▒▒██▒▒▒▒▒▒▒▒▒▒ ", + " ▒▒▒▒▓▓ ▒▒▒▒▓▓▓▓▓▓▓▓▓▓▒▒░░ ░░▒▒▒▒▒▒▒▒▒▒ ▒▒▒▒ ▒▒▓▓▓▓▓▓▒▒▒▒▒▒▒▒ ██▓▓ ▓▓▓▓▓▓▓▓▒▒▒▒ ▓▓ ▒▒ ", + " ▒▒▓▓▓▓██▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒ ▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ ▒▒▓▓▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░██▓▓ ██▓▓ ▒▒ ▒▒▒▒▓▓▒▒▒▒▓▓ ▒▒ ▒▒ ", + " ▒▒▓▓▓▓▓▓██▓▓▓▓▓▓████▓▓▓▓▓▓▓▓▓▓ ▒▒ ▒▒▒▒▒▒▒▒▒▒ ▓▓▓▓▓▓▓▓▓▓██▓▓▓▓██▓▓▓▓▓▓▓▓ ████▓▓▓▓▓▓▒▒ ██▒▒██▒▒▓▓▓▓▒▒▓▓▓▓▒▒▓▓▓▓██▓▓ ", + " ▓▓▓▓▓▓▓▓██▓▓██ ████ ▓▓▓▓▓▓▓▓ ▒▒▒▒▒▒▒▒▒▒ ▒▒▓▓▒▒ ▒▒▒▒▒▒ ░░██ ▓▓▓▓▓▓▓▓██▓▓ ▓▓██▓▓ ▓▓ ▒▒▒▒▒▒▒▒▒▒▒▒ ██▓▓ ██▓▓▓▓▓▓▓▓▓▓██▓▓▓▓▒▒▓▓▓▓▒▒▓▓", + " ░░▓▓▓▓░░░░████████░░ ░░▓▓▓▓░░ ░░▒▒▒▒▒▒▒▒░░▒▒▓▓▒▒░░▒▒▒▒░░ ░░██ ▓▓░░▓▓░░░░▓▓ ▓▓░░▓▓▒▒▓▓ ▒▒▓▓▓▓▓▓▓▓▒▒▒▒░░▒▒▓▓░░ ██▓▓▓▓▓▓██▓▓██░░██▓▓▓▓▓▓▒▒▓▓", + " ░░░░ ░░██▓▓░░ ░░░░ ░░▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░ ░░██ ▓▓ ▓▓ ▓▓ ░░ ▓▓▓▓░░░░ ░░░░░░░░░░▓▓▓▓▒▒██░░ ░░░░░░ ▒▒░░▓▓▓▓▓▓██░░██▒▒░░▓▓██▓▓▓▓░░", + " ██▓▓ ▒▒ ▒▒▒▒▒▒▒▒ ▓▓▓▓▒▒▒▒▒▒▒▒ ░░ ▓▓ ▓▓ ██ ▓▓▓▓▓▓ ▓▓ ▓▓██▓▓▓▓ ▒▒▒▒▒▒▒▒▒▒ ██░░██ ██▓▓████ ░░ ", + " ██▓▓ ░░ ▒▒░░▓▓░░ ▓▓▒▒░░▒▒░░▒▒ ▓▓ ██ ░░ ▒▒▓▓░░▓▓ ▓▓ ░░░░████▒▒▓▓▓▓▓▓▒▒▒▒░░ ░░ ░░ ██▓▓░░░░ ", + " ██▓▓ ▒▒▒▒▒▒ ▓▓ ██▓▓ ██ ██ ████▓▓██ ▓▓ ▓▓▒▒ ████ ", + " ▓▓▓▓██▓▓▓▓▓▓ ▓▓▒▒ ▓▓▓▓ ██▓▓ ▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓ ", + " ████▓▓██████▓▓▓▓████ ▓▓▓▓▓▓▓▓▓▓▒▒▓▓▓▓██▓▓ ████████▓▓▓▓████████ ██████▓▓████ ██▒▒▓▓▓▓██████▓▓▓▓▒▒██ ", + " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██▓▓▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▓▓▓▓▓▓▓▓ ▓▓▒▒▓▓██████▓▓▓▓▓▓▓▓▒▒██ ▓▓▓▓▓▓▓▓██▓▓▓▓▓▓▓▓▓▓ ▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒██ ", + " ██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▓▓ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▒▒▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒ ▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒ ██▓▓▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒██ ", + " ▓▓▓▓▓▓▓▓▒▒▓▓▓▓▓▓▓▓▒▒▒▒▓▓ ▓▓▒▒▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▓▓ ██▓▓▒▒▒▒▓▓▒▒▒▒▒▒▒▒▓▓▒▒▒▒▒▒██ ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▒▒▒▒▒▒▒▒██ ", + " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ▓▓▒▒▒▒░░░░░░░░░░░░░░░░▓▓ ░░██▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓██ ▓▓▓▓▓▓▒▒▒▒▒▒▓▓▒▒▒▒▓▓ ░░▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ", + " ▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓ ░░████████████████████░░ ██▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░ ░░ ████▓▓▓▓▓▓▓▓▓▓████░░", + "", + " ██╗ ██████╗ ███████╗██╗ ██╗", + " ██║██╔═══██╗██╔════╝██║ ██║", + " ██║██║ ██║███████╗███████║", + " ██ ██║██║ ██║╚════██║██╔══██║", + " ╚█████╔╝╚██████╔╝███████║██║ ██║", + " ╚════╝ ╚═════╝ ╚══════╝╚═╝ ╚═╝", + } + dashboard.section.header.opts.hl = "DashboardHeader" + + dashboard.section.buttons.val = { + } + +dashboard.config.layout[1].val = vim.fn.max { 2, vim.fn.floor(vim.fn.winheight(0) * 0.2) } + dashboard.config.layout[3].val = 5 + dashboard.config.opts.noautocmd = true + + return dashboard + end, + config = function(_, opts) + require("alpha").setup(opts.config) + + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimStarted", + desc = "Add Alpha dashboard footer", + once = true, + callback = function() + local stats = require("lazy").stats() + local ms = math.floor(stats.startuptime * 100 + 0.5) / 100 + opts.section.footer.val = + { " ", " ", " ", "Loaded " .. stats.count .. " plugins  in " .. ms .. "ms" } + pcall(vim.cmd.AlphaRedraw) + end, + }) +end, +} diff --git a/lua/user/auto-save.lua b/lua/user/auto-save.lua new file mode 100644 index 0000000..13c6820 --- /dev/null +++ b/lua/user/auto-save.lua @@ -0,0 +1,5 @@ +return { + "Pocco81/auto-save.nvim", + commit = "979b6c82f60cfa80f4cf437d77446d0ded0addf0", -- May 22, 2023 + event = "User AstroFile", +} diff --git a/lua/user/gitsigns.lua b/lua/user/gitsigns.lua new file mode 100644 index 0000000..82f901c --- /dev/null +++ b/lua/user/gitsigns.lua @@ -0,0 +1,15 @@ +return { + "lewis6991/gitsigns.nvim", + commit = "c18b7ca0b5b50596722f3a1572eb9b8eb520c0f1", + event = "User AstroGitFile", + opts = { + signs = { + add = { text = "▎" }, + change = { text = "▎" }, + delete = { text = "▎" }, + topdelete = { text = "󰐊" }, + changedelete = { text = "▎" }, + untracked = { text = "▎" }, + }, + }, +} diff --git a/lua/user/glow-markdown.lua b/lua/user/glow-markdown.lua new file mode 100644 index 0000000..56dd931 --- /dev/null +++ b/lua/user/glow-markdown.lua @@ -0,0 +1,13 @@ +return { + "lnc3l0t/glow.nvim", + commit = "bbd0473d72a45094495ee5600b5577823543eefe", + branch = "advanced_window", + config = { + default_type = "keep", + }, + cmd = "Glow", + mappings = { + ["m"] = { name = " Markdown" }, + ["mp"] = { ":Glow ", desc = "Markdown preview" }, + } +} diff --git a/lua/user/material.lua b/lua/user/material.lua new file mode 100644 index 0000000..e8ffa10 --- /dev/null +++ b/lua/user/material.lua @@ -0,0 +1,19 @@ +return { + "marko-cerovac/material.nvim", + commit = "0c725897bc3d22c45fbf25a602002ee02f06f619", -- May 22, 2023 + config = function() + vim.g.material_style = "darker" + require("material").setup { + plugins = { + "dashboard", + "gitsigns", + "telescope", + "nvim-tree", + "which-key", + }, + high_visibility = { + darker = true + } + } + end +} diff --git a/lua/user/text-case.lua b/lua/user/text-case.lua new file mode 100644 index 0000000..38a3533 --- /dev/null +++ b/lua/user/text-case.lua @@ -0,0 +1 @@ +return {} -- TODO try out https://github.com/johmsalas/text-case.nvim diff --git a/lua/user/which-key.lua b/lua/user/which-key.lua new file mode 100644 index 0000000..e33f8d0 --- /dev/null +++ b/lua/user/which-key.lua @@ -0,0 +1,16 @@ +return { + "folke/which-key.nvim", + commit = "e271c28118998c93a14d189af3395812a1aa646c", -- May 22, 2023 + event = "VeryLazy", + init = function() + vim.o.timeout = true + vim.o.timeoutlen = 300 + end, + opts = { + icons = { group = vim.g.icons_enabled and "" or "+", separator = "" }, + disable = { filetypes = { "TelescopePrompt" } }, + -- your configuration comes here + -- or leave it empty to use the default settings + -- refer to the configuration section below + } +} diff --git a/options.lua b/options.lua new file mode 100644 index 0000000..e3089ff --- /dev/null +++ b/options.lua @@ -0,0 +1,18 @@ +-- allow use of system keyboard +vim.opt.clipboard = "unnamedplus" +-- allow use of mouse +vim.opt.mouse = 'a' +-- line numbering, relative +vim.opt.number = true +vim.wo.number = true +vim.wo.relativenumber = true +-- Highlights the results of previous search, which is annoying when we are done searching +vim.opt.hlsearch = false +-- Wrap lines in files +vim.opt.wrap = true +-- preseve indentation of virtual wrapped lines +vim.opt.breakindent = true +-- set tab length +vim.opt.tabstop = 2; +vim.opt.shiftwidth = 2; +