initial commit, working on TODO's

This commit is contained in:
RingOfStorms (Joshua Bell) 2023-05-22 21:37:52 -05:00
commit 5e821a4d61
12 changed files with 411 additions and 0 deletions

53
autocommands.lua Normal file
View file

@ -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

26
init.lua Normal file
View file

@ -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"

169
keymaps.lua Normal file
View file

@ -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("", "<Space>", "<Nop>", 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 = {
["<leader>w"] = { "<cmd>w<cr>", desc = "Save" },
["<leader>q"] = { "<cmd>confirm q<cr>", desc = "Quit" },
["|"] = { "<cmd>vsplit<cr>", desc = "Vertical Split" },
["\\"] = { "<cmd>split<cr>", desc = "Horizontal Split" },
["<C-d>"] = { "<C-d>zz", desc = "Vertical half page down and center cursor" },
["<C-u>"] = { "<C-u>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
["<leader>gf"] = { ":OpenInGHFile <CR>", desc = "Open in github" },
["<leader>fs"] = {
function()
require("telescope.builtin").live_grep {
search_dirs = { "~/dev/scratches/" },
}
end,
desc = "Find words in scratches",
},
["<leader>s"] = { name = " Scratch File" },
["<leader>ss"] = { function() scratch ".txt" end, desc = "New text scratch file" },
["<leader>sn"] = { function() scratch ".json" end, desc = "New json scratch file" },
["<leader>sq"] = { function() scratch ".sql" end, desc = "New sql scratch file" },
["<leader>st"] = { function() scratch ".ts" end, desc = "New ts scratch file" },
["<leader>sb"] = { function() scratch ".sh" end, desc = "New shell scratch file" },
["<leader>sj"] = { function() scratch ".js" end, desc = "New js scratch file" },
[""] = {
"<Esc>:m .+1<CR>==g",
desc = "Move the line up",
},
["˚"] = {
"<Esc>:m .-2<CR>==g",
desc = "Move the line down",
},
["<leader>r"] = { function() require("rest-nvim").run() end, desc = "Send http request" },
["<leader>Q"] = { ":qa<CR>", desc = "Quit all" },
["<leader>,"] = { name = " Misc Tools" },
["<leader>,c"] = { name = " Casing" },
["<leader>,cs"] = { ":Snek<CR>", desc = "To Snek Case" },
["<leader>,cc"] = { ":Camel<CR>", desc = "To Camel Case" },
["<leader>,cp"] = { ":CamelB<CR>", desc = "To Pascal Case" },
["<leader>,ck"] = { ":Kebab<CR>", desc = "To Kebab Case" },
["<leader>,ce"] = { ":Screm<CR>", desc = "To Screm Case" },
["<leader>,j"] = { name = " Jest Tests" },
["<leader>,jr"] = { function() require("jester").run() end, desc = "Run test under cursor" },
["<leader>,jf"] = { function() require("jester").run_file() end, desc = "Run tests for file" },
["<leader>,jl"] = { function() require("jester").run_last() end, desc = "Run last ran test" },
["<leader>lz"] = { ":LspRestart<CR>", desc = "Restart LSP Server" },
},
v = {
["<leader>gf"] = { ":OpenInGHFile <CR>", desc = "Open in github" },
["y"] = { '"*y', desc = "Copy to system clipboard" },
["p"] = { '"*p', desc = "Paste from system clipboard" },
[""] = {
cmd = ":m '>+1<CR>gv=gv",
desc = "Move the selected text up",
},
["˚"] = {
cmd = ":m '<-2<CR>gv=gv",
desc = "Move the selected text down",
},
["<leader>,"] = { name = " Misc Tools" },
["<leader>,c"] = { name = " Casing" },
["<leader>,cs"] = { ":Snek<CR>", desc = "To Snek Case" },
["<leader>,cc"] = { ":Camel<CR>", desc = "To Camel Case" },
["<leader>,cp"] = { ":CamelB<CR>", desc = "To Pascal Case" },
["<leader>,ck"] = { ":Kebab<CR>", desc = "To Kebab Case" },
["<leader>,ce"] = { ":Screm<CR>", desc = "To Screm Case" },
},
x = {
[""] = {
cmd = ":m '>+1<CR>gv=gv",
desc = "Move the selected text up",
},
["˚"] = {
desc = "Move the selected text down",
cmd = ":m '<-2<CR>gv=gv",
},
},
i = {
["<C-k>"] = { "<Up>", desc = "Up" },
["<C-j>"] = { "<Down>", desc = "Down" },
["<C-h>"] = { "<Left>", desc = "Left" },
["<C-l>"] = { "<Right>", desc = "Right" },
},
c = {
["<C-h>"] = { "<Left>", desc = "Left" },
["<C-j>"] = { "<Down>", desc = "Down" },
["<C-k>"] = { "<Up>", desc = "Up" },
["<C-l>"] = { "<Right>", 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);

9
lazy-lock.json Normal file
View file

@ -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" }
}

67
lua/user/alpha.lua Normal file
View file

@ -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,
}

5
lua/user/auto-save.lua Normal file
View file

@ -0,0 +1,5 @@
return {
"Pocco81/auto-save.nvim",
commit = "979b6c82f60cfa80f4cf437d77446d0ded0addf0", -- May 22, 2023
event = "User AstroFile",
}

15
lua/user/gitsigns.lua Normal file
View file

@ -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 = "" },
},
},
}

View file

@ -0,0 +1,13 @@
return {
"lnc3l0t/glow.nvim",
commit = "bbd0473d72a45094495ee5600b5577823543eefe",
branch = "advanced_window",
config = {
default_type = "keep",
},
cmd = "Glow",
mappings = {
["<leader>m"] = { name = " Markdown" },
["<leader>mp"] = { ":Glow <CR>", desc = "Markdown preview" },
}
}

19
lua/user/material.lua Normal file
View file

@ -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
}

1
lua/user/text-case.lua Normal file
View file

@ -0,0 +1 @@
return {} -- TODO try out https://github.com/johmsalas/text-case.nvim

16
lua/user/which-key.lua Normal file
View file

@ -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
}
}

18
options.lua Normal file
View file

@ -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;