format all files

This commit is contained in:
RingOfStorms (Joshua Bell) 2023-11-03 00:57:32 -05:00
parent 7adc3a8bf9
commit 0a17321086
26 changed files with 331 additions and 331 deletions

View file

@ -3,27 +3,26 @@ require("keymaps")
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then if not vim.loop.fs_stat(lazypath) then
local output = vim.fn.system({ local output = vim.fn.system({
"git", "git",
"clone", "clone",
"--filter=blob:none", "--filter=blob:none",
"https://github.com/folke/lazy.nvim.git", "https://github.com/folke/lazy.nvim.git",
"--branch=stable", -- latest stable release "--branch=stable", -- latest stable release
lazypath, lazypath,
}) })
if vim.api.nvim_get_vvar("shell_error") ~= 0 then if vim.api.nvim_get_vvar("shell_error") ~= 0 then
vim.api.nvim_err_writeln("Error cloning lazy.nvim repository...\n\n" .. output) vim.api.nvim_err_writeln("Error cloning lazy.nvim repository...\n\n" .. output)
end end
end end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("lazy").setup("plugins", { require("lazy").setup("plugins", {
change_detection = { change_detection = {
enabled = false, enabled = false,
}, },
}) })
vim.cmd("colorscheme material") vim.cmd("colorscheme material")
require("tools") require("tools")
require("autocommands") require("autocommands")

View file

@ -105,7 +105,6 @@ require("util").keymaps({
["<C-r>"] = { '"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection" }, ["<C-r>"] = { '"hy:%s/<C-r>h//g<left><left>', desc = "Replace current selection" },
[">"] = { "> gv", desc = "Indent selection" }, [">"] = { "> gv", desc = "Indent selection" },
["<"] = { "< gv", desc = "Outdent selection" }, ["<"] = { "< gv", desc = "Outdent selection" },
}, },
i = { i = {
["<C-k>"] = { "<Up>", desc = "Up" }, ["<C-k>"] = { "<Up>", desc = "Up" },

View file

@ -1,18 +1,18 @@
return { return {
"Pocco81/auto-save.nvim", "Pocco81/auto-save.nvim",
event = "BufEnter", event = "BufEnter",
opts = { opts = {
trigger_events = { "InsertLeave", "TextChanged", "TextChangedI", "BufLeave" }, trigger_events = { "InsertLeave", "TextChanged", "TextChangedI", "BufLeave" },
condition = function(buf) condition = function(buf)
local disallowed_filetypes = { "TelescopePrompt" } local disallowed_filetypes = { "TelescopePrompt" }
local utils = require("auto-save.utils.data") local utils = require("auto-save.utils.data")
if if
vim.fn.getbufvar(buf, "&modifiable") == 1 vim.fn.getbufvar(buf, "&modifiable") == 1
and utils.not_in(vim.fn.getbufvar(buf, "&filetype"), disallowed_filetypes) and utils.not_in(vim.fn.getbufvar(buf, "&filetype"), disallowed_filetypes)
then then
return true return true
end end
return false return false
end, end,
}, },
} }

View file

@ -1,4 +1,4 @@
vim.o.sessionoptions="blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions" vim.o.sessionoptions = "blank,buffers,curdir,folds,help,tabpages,winsize,winpos,terminal,localoptions"
return { return {
"rmagatti/auto-session", "rmagatti/auto-session",

View file

@ -1,7 +1,7 @@
return { return {
"uga-rosa/ccc.nvim", "uga-rosa/ccc.nvim",
event = "BufRead", event = "BufRead",
keys = { keys = {
{ "<leader>,cp", ":CccPick <CR>", desc = "Color Picker" }, { "<leader>,cp", ":CccPick <CR>", desc = "Color Picker" },
}, },
} }

View file

@ -1,17 +1,17 @@
vim.g.NERDCreateDefaultMappings = 0 vim.g.NERDCreateDefaultMappings = 0
vim.g.NERDDefaultAlign = 'both' vim.g.NERDDefaultAlign = "both"
vim.g.NERDSpaceDelims = 1 vim.g.NERDSpaceDelims = 1
vim.cmd("filetype plugin on") vim.cmd("filetype plugin on")
return { return {
"preservim/nerdcommenter", "preservim/nerdcommenter",
keys = { keys = {
{ "<leader>/", ':call nerdcommenter#Comment(0, "toggle")<CR>', desc = "Toggle comments on selection" }, { "<leader>/", ':call nerdcommenter#Comment(0, "toggle")<CR>', desc = "Toggle comments on selection" },
{ {
"<leader>/", "<leader>/",
':call nerdcommenter#Comment(0, "toggle")<CR>', ':call nerdcommenter#Comment(0, "toggle")<CR>',
desc = "Toggle comments on selection", desc = "Toggle comments on selection",
mode = "v", mode = "v",
}, },
}, },
} }

View file

@ -6,9 +6,9 @@ return {
"<leader>xx", "<leader>xx",
"<cmd>:'<,'>FloatermNew --autoclose=2<cr>", "<cmd>:'<,'>FloatermNew --autoclose=2<cr>",
desc = "Run selected as command in float terminal", desc = "Run selected as command in float terminal",
mode = "v" mode = "v",
}, },
{ "<C-x>", "<cmd>FloatermToggle Terminal<cr>", desc = "Toggle float terminal" }, { "<C-x>", "<cmd>FloatermToggle Terminal<cr>", desc = "Toggle float terminal" },
{ "<C-z>", "<cmd>FloatermNew --disposable<cr>", desc = "Toggle disposable float terminal", mode = { "v", "n" }} { "<C-z>", "<cmd>FloatermNew --disposable<cr>", desc = "Toggle disposable float terminal", mode = { "v", "n" } },
}, },
} }

View file

@ -1,4 +1,4 @@
local highlight = require('util').highlight local highlight = require("util").highlight
-- Dull Version -- Dull Version
highlight("GitGutterUntracked", { fg = "#688066", gui = "nocombine" }) highlight("GitGutterUntracked", { fg = "#688066", gui = "nocombine" })
@ -8,7 +8,7 @@ return {
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
opts = { opts = {
watch_gitdir = { watch_gitdir = {
interval = 100 interval = 100,
}, },
signs = { signs = {
add = { hl = "GitGutterAdd" }, add = { hl = "GitGutterAdd" },
@ -20,7 +20,7 @@ return {
}, },
current_line_blame_opts = { current_line_blame_opts = {
virt_text = true, virt_text = true,
virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align'
delay = 0, delay = 0,
ignore_whitespace = false, ignore_whitespace = false,
}, },
@ -28,8 +28,8 @@ return {
vim.keymap.set("n", "<leader>gb", function() vim.keymap.set("n", "<leader>gb", function()
package.loaded.gitsigns.toggle_current_line_blame() package.loaded.gitsigns.toggle_current_line_blame()
end, { desc = "Toggle git blame on current line" }) end, { desc = "Toggle git blame on current line" })
end end,
} },
}, },
{ {
"Neogitorg/neogit", "Neogitorg/neogit",
@ -38,17 +38,20 @@ return {
}, },
opts = { opts = {
integrations = { integrations = {
diffview = true diffview = true,
}, },
sections = { sections = {
recent = false recent = false,
} },
}, },
keys = { keys = {
{ "<leader>gs", function() {
require('neogit').open({ kind = "vsplit" }) "<leader>gs",
end } function()
} require("neogit").open({ kind = "vsplit" })
end,
},
},
}, },
{ {
@ -92,7 +95,7 @@ return {
multi_file = { multi_file = {
diff_merges = "first-parent", diff_merges = "first-parent",
}, },
} },
}, },
win_config = { win_config = {
position = "bottom", position = "bottom",
@ -103,5 +106,5 @@ return {
keys = { keys = {
{ "<leader>gd", "<cmd>DiffviewOpen<cr>", desc = "Opens git diff view." }, { "<leader>gd", "<cmd>DiffviewOpen<cr>", desc = "Opens git diff view." },
}, },
} },
} }

View file

@ -1,17 +1,17 @@
return { return {
"rest-nvim/rest.nvim", "rest-nvim/rest.nvim",
event = "BufEnter *.http", event = "BufEnter *.http",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
opts = { opts = {
encode_url = false, encode_url = false,
}, },
keys = { keys = {
{ {
"<leader>r", "<leader>r",
function() function()
require("rest-nvim").run() require("rest-nvim").run()
end, end,
desc = "Send selected http request", desc = "Send selected http request",
}, },
}, },
} }

View file

@ -1,10 +1,10 @@
vim.opt.list = true vim.opt.list = true
-- vim.opt.listchars = '' -- vim.opt.listchars = ''
-- vim.opt.listchars:append "space:⋅" -- vim.opt.listchars:append "space:⋅"
vim.opt.listchars:append "eol:↴" vim.opt.listchars:append("eol:↴")
vim.opt.listchars:append "tab: >" vim.opt.listchars:append("tab: >")
local highlight = require('util').highlight local highlight = require("util").highlight
highlight("NonText", { fg = "#303030", gui = "nocombine" }) highlight("NonText", { fg = "#303030", gui = "nocombine" })
return { return {
@ -20,7 +20,7 @@ return {
-- char = '.', -- char = '.',
-- char = '¦', -- char = '¦',
use_treesitter = true, use_treesitter = true,
scope = { scope = {
enabled = true, enabled = true,
char = "", char = "",
show_start = false, show_start = false,
@ -31,10 +31,10 @@ return {
"IndentBlanklineScope3", "IndentBlanklineScope3",
"IndentBlanklineScope4", "IndentBlanklineScope4",
"IndentBlanklineScope5", "IndentBlanklineScope5",
} },
}, },
indent = { indent = {
char = '', char = "",
highlight = { highlight = {
"IndentBlanklineIndent1", "IndentBlanklineIndent1",
"IndentBlanklineIndent2", "IndentBlanklineIndent2",
@ -42,10 +42,10 @@ return {
"IndentBlanklineIndent4", "IndentBlanklineIndent4",
"IndentBlanklineIndent5", "IndentBlanklineIndent5",
}, },
} },
}, },
config = function(_, opts) config = function(_, opts)
local hooks = require "ibl.hooks" local hooks = require("ibl.hooks")
hooks.register(hooks.type.HIGHLIGHT_SETUP, function() hooks.register(hooks.type.HIGHLIGHT_SETUP, function()
vim.api.nvim_set_hl(0, "IndentBlanklineIndent1", { fg = "#915053" }) vim.api.nvim_set_hl(0, "IndentBlanklineIndent1", { fg = "#915053" })
vim.api.nvim_set_hl(0, "IndentBlanklineIndent2", { fg = "#A27F3E" }) vim.api.nvim_set_hl(0, "IndentBlanklineIndent2", { fg = "#A27F3E" })
@ -60,6 +60,6 @@ return {
vim.api.nvim_set_hl(0, "IndentBlanklineScope5", { fg = "#917DC0" }) vim.api.nvim_set_hl(0, "IndentBlanklineScope5", { fg = "#917DC0" })
end) end)
require('ibl').setup(opts) require("ibl").setup(opts)
end end,
} }

View file

@ -1,30 +1,30 @@
local function prereqs() local function prereqs()
local output = vim.fn.system({ local output = vim.fn.system({
"which", "which",
"lazygit", "lazygit",
}) })
if output == nil or output == "" then if output == nil or output == "" then
print("Installing lazygit with rtx") print("Installing lazygit with rtx")
-- if v:shell_error != 0 then -- if v:shell_error != 0 then
vim.fn.system({ vim.fn.system({
"rtx", "rtx",
"global", "global",
"lazygit@latest", "lazygit@latest",
}) })
vim.fn.system({ vim.fn.system({
"rtx", "rtx",
"install", "install",
}) })
end end
end end
return { return {
"kdheepak/lazygit.nvim", "kdheepak/lazygit.nvim",
dependencies = { dependencies = {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
}, },
build = prereqs, build = prereqs,
keys = { keys = {
{ "<leader>gg", "<cmd>LazyGit<cr>", desc = "Open lazy git ui" }, { "<leader>gg", "<cmd>LazyGit<cr>", desc = "Open lazy git ui" },
}, },
} }

View file

@ -184,7 +184,7 @@ return {
build = ":MasonUpdate", build = ":MasonUpdate",
opts = {}, opts = {},
}, },
{ "folke/neodev.nvim", opts = {} }, -- lua stuff { "folke/neodev.nvim", opts = {} }, -- lua stuff
{ {
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
}, },
@ -276,8 +276,8 @@ return {
end, end,
}, },
{ name = "nvim_lsp", priority = 9 }, { name = "nvim_lsp", priority = 9 },
{ nane = "buffer", priority = 7 }, { nane = "buffer", priority = 7 },
{ name = "luasnip", priority = 6 }, { name = "luasnip", priority = 6 },
{ name = "path" }, { name = "path" },
{ name = "crates" }, { name = "crates" },
}, },

View file

@ -15,7 +15,7 @@ local function langs()
if client.name == "pyright" then if client.name == "pyright" then
out = vim.fn.system({ "python", "-V" }) out = vim.fn.system({ "python", "-V" })
elseif client.name == "tsserver" then elseif client.name == "tsserver" then
out = 'node ' .. vim.fn.system({ "node", "--version" }) out = "node " .. vim.fn.system({ "node", "--version" })
end end
if out ~= nil and out ~= "" then if out ~= nil and out ~= "" then
langs[#langs + 1] = vim.trim(out) langs[#langs + 1] = vim.trim(out)
@ -58,8 +58,8 @@ return {
}, },
}, },
lualine_b = { lualine_b = {
"mode" "mode",
} },
}, },
inactive_winbar = { inactive_winbar = {
lualine_a = { lualine_a = {

View file

@ -1,12 +1,12 @@
return { return {
"lnc3l0t/glow.nvim", "lnc3l0t/glow.nvim",
branch = "advanced_window", branch = "advanced_window",
opts = { opts = {
default_type = "keep", default_type = "keep",
}, },
cmd = "Glow", cmd = "Glow",
keys = { keys = {
{ "<leader>m", "<Nop>", desc = " Markdown" }, { "<leader>m", "<Nop>", desc = " Markdown" },
{ "<leader>mp", ":Glow <CR>", desc = "Markdown preview" }, { "<leader>mp", ":Glow <CR>", desc = "Markdown preview" },
}, },
} }

View file

@ -1,51 +1,51 @@
return { return {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons" }, dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons" },
cmd = "Neotree", cmd = "Neotree",
init = function() init = function()
vim.g.neo_tree_remove_legacy_commands = true vim.g.neo_tree_remove_legacy_commands = true
end, end,
pin = true, pin = true,
tag = "2.56", tag = "2.56",
opts = { opts = {
window = { window = {
position = "float", position = "float",
}, },
auto_clean_after_session_restore = true, auto_clean_after_session_restore = true,
close_if_last_window = true, close_if_last_window = true,
sources = { "filesystem" }, sources = { "filesystem" },
filesystem = { filesystem = {
follow_current_file = false, follow_current_file = false,
group_empty_dirs = true, group_empty_dirs = true,
filtered_items = { filtered_items = {
visible = true, visible = true,
hide_dotfiles = false, hide_dotfiles = false,
hide_gitignored = false, hide_gitignored = false,
never_show = { never_show = {
".DS_Store", ".DS_Store",
}, },
}, },
}, },
use_libuv_file_watcher = true, use_libuv_file_watcher = true,
nesting_rules = { nesting_rules = {
["ts"] = { ".cjs", ".cjs.map", ".d.ts", ".d.ts.map", ".js", ".js.map", ".mjs", ".mjs.map", ".test.ts" }, ["ts"] = { ".cjs", ".cjs.map", ".d.ts", ".d.ts.map", ".js", ".js.map", ".mjs", ".mjs.map", ".test.ts" },
["js"] = { ".cjs", ".cjs.map", ".d.js", ".d.js.map", ".js", ".js.map", ".mjs", ".mjs.map", ".test.js" }, ["js"] = { ".cjs", ".cjs.map", ".d.js", ".d.js.map", ".js", ".js.map", ".mjs", ".mjs.map", ".test.js" },
["tsx"] = { ".d.ts", ".d.ts.map", ".js;", ".js.map;", ".jsx;", ".jsx.map;", ".module.scss;", ".svg" }, ["tsx"] = { ".d.ts", ".d.ts.map", ".js;", ".js.map;", ".jsx;", ".jsx.map;", ".module.scss;", ".svg" },
["scss"] = { ".css", ".css.map" }, ["scss"] = { ".css", ".css.map" },
}, },
}, },
keys = { keys = {
{ "<leader>e", "<cmd>Neotree toggle<CR>", desc = "Toggle Explorer" }, { "<leader>e", "<cmd>Neotree toggle<CR>", desc = "Toggle Explorer" },
{ {
"<leader>o", "<leader>o",
function() function()
if vim.bo.filetype == "neo-tree" then if vim.bo.filetype == "neo-tree" then
vim.cmd.wincmd("p") vim.cmd.wincmd("p")
else else
vim.cmd.Neotree("reveal") vim.cmd.Neotree("reveal")
end end
end, end,
desc = "Toggle Explorer Focus", desc = "Toggle Explorer Focus",
}, },
}, },
} }

View file

@ -74,7 +74,7 @@ return {
null_ls.builtins.formatting.prettier, -- typescript/javascript null_ls.builtins.formatting.prettier, -- typescript/javascript
null_ls.builtins.formatting.stylua.with({ null_ls.builtins.formatting.stylua.with({
extra_args = { "--indent-type", "spaces", "--indent-width", "2" }, extra_args = { "--indent-type", "spaces", "--indent-width", "2" },
}), -- lua }), -- lua
--null_ls.builtins.formatting.rustfmt, -- rust --null_ls.builtins.formatting.rustfmt, -- rust
rust_formatter_genemichaels, -- order matters, run genemichaels first then rustfmt rust_formatter_genemichaels, -- order matters, run genemichaels first then rustfmt
rust_formatter_rustfmt, rust_formatter_rustfmt,

View file

@ -2,7 +2,7 @@ return {
"Almo7aya/openingh.nvim", "Almo7aya/openingh.nvim",
event = "BufEnter", event = "BufEnter",
keys = { keys = {
{ "<leader>gf", "<cmd>OpenInGHFile<CR>", desc = "Open in git" }, { "<leader>gf", "<cmd>OpenInGHFile<CR>", desc = "Open in git" },
{ "<leader>gf", "<cmd>OpenInGHFileLines<CR>", desc = "Open in git", mode = { "v" } }, { "<leader>gf", "<cmd>OpenInGHFileLines<CR>", desc = "Open in git", mode = { "v" } },
}, },
} }

View file

@ -7,6 +7,6 @@ return {
require("telescope").load_extension("textcase") require("telescope").load_extension("textcase")
end, end,
keys = { keys = {
{ "<leader>,c", "<cmd>TextCaseOpenTelescope<cr>", desc = "Change case of selection", mode = {"n", "v"} }, { "<leader>,c", "<cmd>TextCaseOpenTelescope<cr>", desc = "Change case of selection", mode = { "n", "v" } },
}, },
} }

View file

@ -1,18 +1,18 @@
return { return {
"marko-cerovac/material.nvim", "marko-cerovac/material.nvim",
config = function() config = function()
vim.g.material_style = "darker" vim.g.material_style = "darker"
require("material").setup({ require("material").setup({
plugins = { plugins = {
"dashboard", "dashboard",
"gitsigns", "gitsigns",
"telescope", "telescope",
"nvim-tree", "nvim-tree",
"which-key", "which-key",
}, },
high_visibility = { high_visibility = {
darker = true, darker = true,
}, },
}) })
end, end,
} }

View file

@ -1,7 +1,7 @@
return { return {
"mbbill/undotree", "mbbill/undotree",
event = "BufEnter", event = "BufEnter",
keys = { keys = {
{ "<leader>u", vim.cmd.UndotreeToggle, desc = "Undo Tree Toggle" }, { "<leader>u", vim.cmd.UndotreeToggle, desc = "Undo Tree Toggle" },
}, },
} }

View file

@ -1,3 +1,3 @@
return { return {
"nvim-lua/plenary.nvim", "nvim-lua/plenary.nvim",
} }

View file

@ -1,15 +1,15 @@
return { return {
"rcarriga/nvim-notify", "rcarriga/nvim-notify",
event = "VeryLazy", event = "VeryLazy",
opts = { opts = {
top_down = false, top_down = false,
}, },
config = function(_, opts) config = function(_, opts)
require("notify").setup(opts) require("notify").setup(opts)
vim.notify = require("notify") vim.notify = require("notify")
end, end,
keys = { keys = {
{ "<leader>fn", "<cmd>Telescope notify<cr>", desc = "Telescope search notifications", mode ={"n", "v", "x"} }, { "<leader>fn", "<cmd>Telescope notify<cr>", desc = "Telescope search notifications", mode = { "n", "v", "x" } },
}, },
} }

View file

@ -1,3 +1,3 @@
return { return {
"tpope/vim-sleuth", "tpope/vim-sleuth",
} }

View file

@ -1,7 +1,7 @@
-- Autoload all files in this tools dir, minus this init again -- Autoload all files in this tools dir, minus this init again
for _, file in ipairs(vim.fn.readdir(vim.fn.stdpath("config") .. "/lua/tools", [[v:val =~ '\.lua$']])) do for _, file in ipairs(vim.fn.readdir(vim.fn.stdpath("config") .. "/lua/tools", [[v:val =~ '\.lua$']])) do
if file ~= "init.lua" then if file ~= "init.lua" then
local tool = string.sub(file, 0, -5) local tool = string.sub(file, 0, -5)
require("tools." .. tool) require("tools." .. tool)
end end
end end

View file

@ -1,77 +1,77 @@
-- Scratch files -- Scratch files
local scratch = function(extension) local scratch = function(extension)
os.execute("mkdir -p ~/dev/scratches/") os.execute("mkdir -p ~/dev/scratches/")
local date = os.date("%Y-%m-%dT%H:%M:%S") local date = os.date("%Y-%m-%dT%H:%M:%S")
local filepath = "~/dev/scratches/scratch_" .. date .. extension local filepath = "~/dev/scratches/scratch_" .. date .. extension
vim.cmd("execute 'edit " .. filepath .. "'") vim.cmd("execute 'edit " .. filepath .. "'")
end end
require("util").keymaps({ require("util").keymaps({
n = { n = {
["<leader>fsw"] = { ["<leader>fsw"] = {
function() function()
require("telescope.builtin").live_grep({ require("telescope.builtin").live_grep({
search_dirs = { "~/dev/scratches/" }, search_dirs = { "~/dev/scratches/" },
}) })
end, end,
desc = "Find Words in Scratches", desc = "Find Words in Scratches",
}, },
["<leader>fsf"] = { ["<leader>fsf"] = {
function() function()
require("telescope.builtin").find_files({ require("telescope.builtin").find_files({
search_dirs = { "~/dev/scratches/" }, search_dirs = { "~/dev/scratches/" },
}) })
end, end,
desc = "Find Scratches", desc = "Find Scratches",
}, },
["<leader>s"] = { "<Nop>", desc = "Scratch File" }, ["<leader>s"] = { "<Nop>", desc = "Scratch File" },
["<leader>ss"] = { ["<leader>ss"] = {
function() function()
scratch(".txt") scratch(".txt")
end, end,
desc = "New [t]e[xt] scratch file", desc = "New [t]e[xt] scratch file",
}, },
["<leader>sn"] = { ["<leader>sn"] = {
function() function()
scratch(".json") scratch(".json")
end, end,
desc = "New json scratch file", desc = "New json scratch file",
}, },
["<leader>sm"] = { ["<leader>sm"] = {
function() function()
scratch(".md") scratch(".md")
end, end,
desc = "New [m]ark[d]own scratch file", desc = "New [m]ark[d]own scratch file",
}, },
["<leader>sq"] = { ["<leader>sq"] = {
function() function()
scratch(".sql") scratch(".sql")
end, end,
desc = "New sql scratch file", desc = "New sql scratch file",
}, },
["<leader>st"] = { ["<leader>st"] = {
function() function()
scratch(".ts") scratch(".ts")
end, end,
desc = "New [t]ype[s]cript scratch file", desc = "New [t]ype[s]cript scratch file",
}, },
["<leader>sb"] = { ["<leader>sb"] = {
function() function()
scratch(".sh") scratch(".sh")
end, end,
desc = "New [sh]ell scratch file", desc = "New [sh]ell scratch file",
}, },
["<leader>sj"] = { ["<leader>sj"] = {
function() function()
scratch(".js") scratch(".js")
end, end,
desc = "New [j]ava[s]cript scratch file", desc = "New [j]ava[s]cript scratch file",
}, },
["<leader>sr"] = { ["<leader>sr"] = {
function() function()
scratch(".rs") scratch(".rs")
end, end,
desc = "New [r]u[s]t scratch file", desc = "New [r]u[s]t scratch file",
}, },
}, },
}) })

View file

@ -1,61 +1,60 @@
local M = {} local M = {}
function M.keymaps(mappings) function M.keymaps(mappings)
for mode, maps in pairs(mappings) do for mode, maps in pairs(mappings) do
for keymap, options in pairs(maps) do for keymap, options in pairs(maps) do
if options then if options then
local cmd = options local cmd = options
local keymap_opts = {} local keymap_opts = {}
if type(options) == "table" then if type(options) == "table" then
cmd = options[1] cmd = options[1]
keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options) keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options)
keymap_opts[1] = nil keymap_opts[1] = nil
end end
if mode and keymap and cmd and keymap_opts then if mode and keymap and cmd and keymap_opts then
vim.keymap.set(mode, keymap, cmd, keymap_opts) vim.keymap.set(mode, keymap, cmd, keymap_opts)
end end
end end
end end
end end
end end
function M.spread(template) function M.spread(template)
local result = {} local result = {}
for key, value in pairs(template) do for key, value in pairs(template) do
result[key] = value result[key] = value
end end
return function(table) return function(table)
for key, value in pairs(table) do for key, value in pairs(table) do
result[key] = value result[key] = value
end end
return result return result
end end
end end
-- From https://github.com/lukas-reineke/onedark.nvim/blob/master/lua/onedark.lua -- From https://github.com/lukas-reineke/onedark.nvim/blob/master/lua/onedark.lua
function M.highlight(group, options) function M.highlight(group, options)
local guifg = options.fg or "NONE" local guifg = options.fg or "NONE"
local guibg = options.bg or "NONE" local guibg = options.bg or "NONE"
local guisp = options.sp or "NONE" local guisp = options.sp or "NONE"
local gui = options.gui or "NONE" local gui = options.gui or "NONE"
local blend = options.blend or 0 local blend = options.blend or 0
local ctermfg = options.ctermfg or "NONE" local ctermfg = options.ctermfg or "NONE"
vim.cmd( vim.cmd(
string.format( string.format(
"highlight %s guifg=%s ctermfg=%s guibg=%s guisp=%s gui=%s blend=%d", "highlight %s guifg=%s ctermfg=%s guibg=%s guisp=%s gui=%s blend=%d",
group, group,
guifg, guifg,
ctermfg, ctermfg,
guibg, guibg,
guisp, guisp,
gui, gui,
blend blend
)
) )
)
end end
return M return M