diff --git a/init.lua b/init.lua index f446842..f12d732 100644 --- a/init.lua +++ b/init.lua @@ -3,27 +3,26 @@ 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 + 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("plugins", { - change_detection = { - enabled = false, - }, + change_detection = { + enabled = false, + }, }) vim.cmd("colorscheme material") require("tools") require("autocommands") - diff --git a/lua/keymaps.lua b/lua/keymaps.lua index c9ff609..e146c40 100644 --- a/lua/keymaps.lua +++ b/lua/keymaps.lua @@ -105,7 +105,6 @@ require("util").keymaps({ [""] = { '"hy:%s/h//g', desc = "Replace current selection" }, [">"] = { "> gv", desc = "Indent selection" }, ["<"] = { "< gv", desc = "Outdent selection" }, - }, i = { [""] = { "", desc = "Up" }, diff --git a/lua/plugins/auto-save.lua b/lua/plugins/auto-save.lua index a9f3ccb..dc8589b 100644 --- a/lua/plugins/auto-save.lua +++ b/lua/plugins/auto-save.lua @@ -1,18 +1,18 @@ return { - "Pocco81/auto-save.nvim", - event = "BufEnter", - opts = { - trigger_events = { "InsertLeave", "TextChanged", "TextChangedI", "BufLeave" }, - condition = function(buf) - local disallowed_filetypes = { "TelescopePrompt" } - local utils = require("auto-save.utils.data") - if - vim.fn.getbufvar(buf, "&modifiable") == 1 - and utils.not_in(vim.fn.getbufvar(buf, "&filetype"), disallowed_filetypes) - then - return true - end - return false - end, - }, + "Pocco81/auto-save.nvim", + event = "BufEnter", + opts = { + trigger_events = { "InsertLeave", "TextChanged", "TextChangedI", "BufLeave" }, + condition = function(buf) + local disallowed_filetypes = { "TelescopePrompt" } + local utils = require("auto-save.utils.data") + if + vim.fn.getbufvar(buf, "&modifiable") == 1 + and utils.not_in(vim.fn.getbufvar(buf, "&filetype"), disallowed_filetypes) + then + return true + end + return false + end, + }, } diff --git a/lua/plugins/auto-session.lua b/lua/plugins/auto-session.lua index 8eaaeff..5eca509 100644 --- a/lua/plugins/auto-session.lua +++ b/lua/plugins/auto-session.lua @@ -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 { "rmagatti/auto-session", diff --git a/lua/plugins/colorpicker_ccc.lua b/lua/plugins/colorpicker_ccc.lua index da64cb4..6835b68 100644 --- a/lua/plugins/colorpicker_ccc.lua +++ b/lua/plugins/colorpicker_ccc.lua @@ -1,7 +1,7 @@ return { - "uga-rosa/ccc.nvim", - event = "BufRead", - keys = { - { ",cp", ":CccPick ", desc = "Color Picker" }, - }, + "uga-rosa/ccc.nvim", + event = "BufRead", + keys = { + { ",cp", ":CccPick ", desc = "Color Picker" }, + }, } diff --git a/lua/plugins/comments.lua b/lua/plugins/comments.lua index b3ed384..bb4145d 100644 --- a/lua/plugins/comments.lua +++ b/lua/plugins/comments.lua @@ -1,17 +1,17 @@ vim.g.NERDCreateDefaultMappings = 0 -vim.g.NERDDefaultAlign = 'both' +vim.g.NERDDefaultAlign = "both" vim.g.NERDSpaceDelims = 1 vim.cmd("filetype plugin on") return { - "preservim/nerdcommenter", - keys = { - { "/", ':call nerdcommenter#Comment(0, "toggle")', desc = "Toggle comments on selection" }, - { - "/", - ':call nerdcommenter#Comment(0, "toggle")', - desc = "Toggle comments on selection", - mode = "v", - }, - }, + "preservim/nerdcommenter", + keys = { + { "/", ':call nerdcommenter#Comment(0, "toggle")', desc = "Toggle comments on selection" }, + { + "/", + ':call nerdcommenter#Comment(0, "toggle")', + desc = "Toggle comments on selection", + mode = "v", + }, + }, } diff --git a/lua/plugins/floatterm.lua b/lua/plugins/floatterm.lua index 0812230..329d6ed 100644 --- a/lua/plugins/floatterm.lua +++ b/lua/plugins/floatterm.lua @@ -6,9 +6,9 @@ return { "xx", ":'<,'>FloatermNew --autoclose=2", desc = "Run selected as command in float terminal", - mode = "v" + mode = "v", }, { "", "FloatermToggle Terminal", desc = "Toggle float terminal" }, - { "", "FloatermNew --disposable", desc = "Toggle disposable float terminal", mode = { "v", "n" }} + { "", "FloatermNew --disposable", desc = "Toggle disposable float terminal", mode = { "v", "n" } }, }, } diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua index acacd65..d2cd97c 100644 --- a/lua/plugins/git.lua +++ b/lua/plugins/git.lua @@ -1,4 +1,4 @@ -local highlight = require('util').highlight +local highlight = require("util").highlight -- Dull Version highlight("GitGutterUntracked", { fg = "#688066", gui = "nocombine" }) @@ -8,7 +8,7 @@ return { dependencies = { "nvim-lua/plenary.nvim" }, opts = { watch_gitdir = { - interval = 100 + interval = 100, }, signs = { add = { hl = "GitGutterAdd" }, @@ -20,7 +20,7 @@ return { }, current_line_blame_opts = { virt_text = true, - virt_text_pos = 'eol', -- 'eol' | 'overlay' | 'right_align' + virt_text_pos = "eol", -- 'eol' | 'overlay' | 'right_align' delay = 0, ignore_whitespace = false, }, @@ -28,8 +28,8 @@ return { vim.keymap.set("n", "gb", function() package.loaded.gitsigns.toggle_current_line_blame() end, { desc = "Toggle git blame on current line" }) - end - } + end, + }, }, { "Neogitorg/neogit", @@ -38,17 +38,20 @@ return { }, opts = { integrations = { - diffview = true + diffview = true, }, sections = { - recent = false - } + recent = false, + }, }, keys = { - { "gs", function() - require('neogit').open({ kind = "vsplit" }) - end } - } + { + "gs", + function() + require("neogit").open({ kind = "vsplit" }) + end, + }, + }, }, { @@ -92,7 +95,7 @@ return { multi_file = { diff_merges = "first-parent", }, - } + }, }, win_config = { position = "bottom", @@ -103,5 +106,5 @@ return { keys = { { "gd", "DiffviewOpen", desc = "Opens git diff view." }, }, - } + }, } diff --git a/lua/plugins/http_rest.lua b/lua/plugins/http_rest.lua index 26cc4c7..c0c5685 100644 --- a/lua/plugins/http_rest.lua +++ b/lua/plugins/http_rest.lua @@ -1,17 +1,17 @@ return { - "rest-nvim/rest.nvim", - event = "BufEnter *.http", - dependencies = { "nvim-lua/plenary.nvim" }, + "rest-nvim/rest.nvim", + event = "BufEnter *.http", + dependencies = { "nvim-lua/plenary.nvim" }, opts = { encode_url = false, }, - keys = { - { - "r", - function() - require("rest-nvim").run() - end, - desc = "Send selected http request", - }, - }, + keys = { + { + "r", + function() + require("rest-nvim").run() + end, + desc = "Send selected http request", + }, + }, } diff --git a/lua/plugins/indent-blankline.lua b/lua/plugins/indent-blankline.lua index dfdbd82..45675b4 100644 --- a/lua/plugins/indent-blankline.lua +++ b/lua/plugins/indent-blankline.lua @@ -1,10 +1,10 @@ vim.opt.list = true -- vim.opt.listchars = '' -- vim.opt.listchars:append "space:⋅" -vim.opt.listchars:append "eol:↴" -vim.opt.listchars:append "tab: >" +vim.opt.listchars:append("eol:↴") +vim.opt.listchars:append("tab: >") -local highlight = require('util').highlight +local highlight = require("util").highlight highlight("NonText", { fg = "#303030", gui = "nocombine" }) return { @@ -20,7 +20,7 @@ return { -- char = '.', -- char = '¦', use_treesitter = true, - scope = { + scope = { enabled = true, char = "┊", show_start = false, @@ -31,10 +31,10 @@ return { "IndentBlanklineScope3", "IndentBlanklineScope4", "IndentBlanklineScope5", - } + }, }, - indent = { - char = '│', + indent = { + char = "│", highlight = { "IndentBlanklineIndent1", "IndentBlanklineIndent2", @@ -42,10 +42,10 @@ return { "IndentBlanklineIndent4", "IndentBlanklineIndent5", }, - } + }, }, config = function(_, opts) - local hooks = require "ibl.hooks" + local hooks = require("ibl.hooks") hooks.register(hooks.type.HIGHLIGHT_SETUP, function() vim.api.nvim_set_hl(0, "IndentBlanklineIndent1", { fg = "#915053" }) vim.api.nvim_set_hl(0, "IndentBlanklineIndent2", { fg = "#A27F3E" }) @@ -60,6 +60,6 @@ return { vim.api.nvim_set_hl(0, "IndentBlanklineScope5", { fg = "#917DC0" }) end) - require('ibl').setup(opts) - end + require("ibl").setup(opts) + end, } diff --git a/lua/plugins/lazygit.lua b/lua/plugins/lazygit.lua index 4ee0284..c151c08 100644 --- a/lua/plugins/lazygit.lua +++ b/lua/plugins/lazygit.lua @@ -1,30 +1,30 @@ local function prereqs() - local output = vim.fn.system({ - "which", - "lazygit", - }) - if output == nil or output == "" then - print("Installing lazygit with rtx") - -- if v:shell_error != 0 then - vim.fn.system({ - "rtx", - "global", - "lazygit@latest", - }) - vim.fn.system({ - "rtx", - "install", - }) - end + local output = vim.fn.system({ + "which", + "lazygit", + }) + if output == nil or output == "" then + print("Installing lazygit with rtx") + -- if v:shell_error != 0 then + vim.fn.system({ + "rtx", + "global", + "lazygit@latest", + }) + vim.fn.system({ + "rtx", + "install", + }) + end end return { - "kdheepak/lazygit.nvim", - dependencies = { - "nvim-lua/plenary.nvim", - }, - build = prereqs, - keys = { - { "gg", "LazyGit", desc = "Open lazy git ui" }, - }, + "kdheepak/lazygit.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + }, + build = prereqs, + keys = { + { "gg", "LazyGit", desc = "Open lazy git ui" }, + }, } diff --git a/lua/plugins/lsp.lua b/lua/plugins/lsp.lua index 0a0e34f..ddd86ec 100644 --- a/lua/plugins/lsp.lua +++ b/lua/plugins/lsp.lua @@ -184,7 +184,7 @@ return { build = ":MasonUpdate", opts = {}, }, - { "folke/neodev.nvim", opts = {} }, -- lua stuff + { "folke/neodev.nvim", opts = {} }, -- lua stuff { "williamboman/mason-lspconfig.nvim", }, @@ -276,8 +276,8 @@ return { end, }, { name = "nvim_lsp", priority = 9 }, - { nane = "buffer", priority = 7 }, - { name = "luasnip", priority = 6 }, + { nane = "buffer", priority = 7 }, + { name = "luasnip", priority = 6 }, { name = "path" }, { name = "crates" }, }, diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua index dcfe172..7e0b324 100644 --- a/lua/plugins/lualine.lua +++ b/lua/plugins/lualine.lua @@ -15,7 +15,7 @@ local function langs() if client.name == "pyright" then out = vim.fn.system({ "python", "-V" }) elseif client.name == "tsserver" then - out = 'node ' .. vim.fn.system({ "node", "--version" }) + out = "node " .. vim.fn.system({ "node", "--version" }) end if out ~= nil and out ~= "" then langs[#langs + 1] = vim.trim(out) @@ -58,8 +58,8 @@ return { }, }, lualine_b = { - "mode" - } + "mode", + }, }, inactive_winbar = { lualine_a = { diff --git a/lua/plugins/markdown_glow.lua b/lua/plugins/markdown_glow.lua index dba754c..63c2888 100644 --- a/lua/plugins/markdown_glow.lua +++ b/lua/plugins/markdown_glow.lua @@ -1,12 +1,12 @@ return { - "lnc3l0t/glow.nvim", - branch = "advanced_window", - opts = { - default_type = "keep", - }, - cmd = "Glow", - keys = { - { "m", "", desc = " Markdown" }, - { "mp", ":Glow ", desc = "Markdown preview" }, - }, + "lnc3l0t/glow.nvim", + branch = "advanced_window", + opts = { + default_type = "keep", + }, + cmd = "Glow", + keys = { + { "m", "", desc = " Markdown" }, + { "mp", ":Glow ", desc = "Markdown preview" }, + }, } diff --git a/lua/plugins/neo-tree.lua b/lua/plugins/neo-tree.lua index 152d850..349208c 100644 --- a/lua/plugins/neo-tree.lua +++ b/lua/plugins/neo-tree.lua @@ -1,51 +1,51 @@ return { - "nvim-neo-tree/neo-tree.nvim", - dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons" }, - cmd = "Neotree", - init = function() - vim.g.neo_tree_remove_legacy_commands = true - end, - pin = true, - tag = "2.56", - opts = { + "nvim-neo-tree/neo-tree.nvim", + dependencies = { "MunifTanjim/nui.nvim", "nvim-lua/plenary.nvim", "nvim-tree/nvim-web-devicons" }, + cmd = "Neotree", + init = function() + vim.g.neo_tree_remove_legacy_commands = true + end, + pin = true, + tag = "2.56", + opts = { window = { position = "float", }, - auto_clean_after_session_restore = true, - close_if_last_window = true, - sources = { "filesystem" }, - filesystem = { - follow_current_file = false, - group_empty_dirs = true, - filtered_items = { - visible = true, - hide_dotfiles = false, - hide_gitignored = false, - never_show = { - ".DS_Store", - }, - }, - }, - use_libuv_file_watcher = true, - nesting_rules = { - ["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" }, - ["tsx"] = { ".d.ts", ".d.ts.map", ".js;", ".js.map;", ".jsx;", ".jsx.map;", ".module.scss;", ".svg" }, - ["scss"] = { ".css", ".css.map" }, - }, - }, - keys = { - { "e", "Neotree toggle", desc = "Toggle Explorer" }, - { - "o", - function() - if vim.bo.filetype == "neo-tree" then - vim.cmd.wincmd("p") - else - vim.cmd.Neotree("reveal") - end - end, - desc = "Toggle Explorer Focus", - }, - }, + auto_clean_after_session_restore = true, + close_if_last_window = true, + sources = { "filesystem" }, + filesystem = { + follow_current_file = false, + group_empty_dirs = true, + filtered_items = { + visible = true, + hide_dotfiles = false, + hide_gitignored = false, + never_show = { + ".DS_Store", + }, + }, + }, + use_libuv_file_watcher = true, + nesting_rules = { + ["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" }, + ["tsx"] = { ".d.ts", ".d.ts.map", ".js;", ".js.map;", ".jsx;", ".jsx.map;", ".module.scss;", ".svg" }, + ["scss"] = { ".css", ".css.map" }, + }, + }, + keys = { + { "e", "Neotree toggle", desc = "Toggle Explorer" }, + { + "o", + function() + if vim.bo.filetype == "neo-tree" then + vim.cmd.wincmd("p") + else + vim.cmd.Neotree("reveal") + end + end, + desc = "Toggle Explorer Focus", + }, + }, } diff --git a/lua/plugins/null-ls.lua b/lua/plugins/null-ls.lua index e6ebf3e..ec6e005 100644 --- a/lua/plugins/null-ls.lua +++ b/lua/plugins/null-ls.lua @@ -74,7 +74,7 @@ return { null_ls.builtins.formatting.prettier, -- typescript/javascript null_ls.builtins.formatting.stylua.with({ extra_args = { "--indent-type", "spaces", "--indent-width", "2" }, - }), -- lua + }), -- lua --null_ls.builtins.formatting.rustfmt, -- rust rust_formatter_genemichaels, -- order matters, run genemichaels first then rustfmt rust_formatter_rustfmt, diff --git a/lua/plugins/open-github.lua b/lua/plugins/open-github.lua index 427cd22..553ce77 100644 --- a/lua/plugins/open-github.lua +++ b/lua/plugins/open-github.lua @@ -2,7 +2,7 @@ return { "Almo7aya/openingh.nvim", event = "BufEnter", keys = { - { "gf", "OpenInGHFile", desc = "Open in git" }, + { "gf", "OpenInGHFile", desc = "Open in git" }, { "gf", "OpenInGHFileLines", desc = "Open in git", mode = { "v" } }, }, } diff --git a/lua/plugins/text-case.lua b/lua/plugins/text-case.lua index ca133ad..9c10837 100644 --- a/lua/plugins/text-case.lua +++ b/lua/plugins/text-case.lua @@ -7,6 +7,6 @@ return { require("telescope").load_extension("textcase") end, keys = { - { ",c", "TextCaseOpenTelescope", desc = "Change case of selection", mode = {"n", "v"} }, + { ",c", "TextCaseOpenTelescope", desc = "Change case of selection", mode = { "n", "v" } }, }, } diff --git a/lua/plugins/theme_material.lua b/lua/plugins/theme_material.lua index 374232a..4cae0d9 100644 --- a/lua/plugins/theme_material.lua +++ b/lua/plugins/theme_material.lua @@ -1,18 +1,18 @@ return { - "marko-cerovac/material.nvim", - config = function() - vim.g.material_style = "darker" - require("material").setup({ - plugins = { - "dashboard", - "gitsigns", - "telescope", - "nvim-tree", - "which-key", - }, - high_visibility = { - darker = true, - }, - }) - end, + "marko-cerovac/material.nvim", + 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/plugins/undotree.lua b/lua/plugins/undotree.lua index c23e75c..6701e57 100644 --- a/lua/plugins/undotree.lua +++ b/lua/plugins/undotree.lua @@ -1,7 +1,7 @@ return { - "mbbill/undotree", - event = "BufEnter", - keys = { - { "u", vim.cmd.UndotreeToggle, desc = "Undo Tree Toggle" }, - }, + "mbbill/undotree", + event = "BufEnter", + keys = { + { "u", vim.cmd.UndotreeToggle, desc = "Undo Tree Toggle" }, + }, } diff --git a/lua/plugins/util_plenary.lua b/lua/plugins/util_plenary.lua index dfc4697..fa493d2 100644 --- a/lua/plugins/util_plenary.lua +++ b/lua/plugins/util_plenary.lua @@ -1,3 +1,3 @@ return { - "nvim-lua/plenary.nvim", + "nvim-lua/plenary.nvim", } diff --git a/lua/plugins/vim-notify.lua b/lua/plugins/vim-notify.lua index a21f405..6b60b51 100644 --- a/lua/plugins/vim-notify.lua +++ b/lua/plugins/vim-notify.lua @@ -1,15 +1,15 @@ return { - "rcarriga/nvim-notify", + "rcarriga/nvim-notify", event = "VeryLazy", - opts = { - top_down = false, - }, - config = function(_, opts) - require("notify").setup(opts) + opts = { + top_down = false, + }, + config = function(_, opts) + require("notify").setup(opts) - vim.notify = require("notify") - end, - keys = { - { "fn", "Telescope notify", desc = "Telescope search notifications", mode ={"n", "v", "x"} }, - }, + vim.notify = require("notify") + end, + keys = { + { "fn", "Telescope notify", desc = "Telescope search notifications", mode = { "n", "v", "x" } }, + }, } diff --git a/lua/plugins_disabled/tabstops_sleuth.lua b/lua/plugins_disabled/tabstops_sleuth.lua index fddd2af..e386ac4 100644 --- a/lua/plugins_disabled/tabstops_sleuth.lua +++ b/lua/plugins_disabled/tabstops_sleuth.lua @@ -1,3 +1,3 @@ return { - "tpope/vim-sleuth", + "tpope/vim-sleuth", } diff --git a/lua/tools/init.lua b/lua/tools/init.lua index 9ffdb1f..16ca696 100644 --- a/lua/tools/init.lua +++ b/lua/tools/init.lua @@ -1,7 +1,7 @@ -- 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 - if file ~= "init.lua" then - local tool = string.sub(file, 0, -5) - require("tools." .. tool) - end + if file ~= "init.lua" then + local tool = string.sub(file, 0, -5) + require("tools." .. tool) + end end diff --git a/lua/tools/scratch-files.lua b/lua/tools/scratch-files.lua index 95a13f9..196344a 100644 --- a/lua/tools/scratch-files.lua +++ b/lua/tools/scratch-files.lua @@ -1,77 +1,77 @@ -- Scratch files 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 .. "'") + 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 require("util").keymaps({ - n = { - ["fsw"] = { - function() - require("telescope.builtin").live_grep({ - search_dirs = { "~/dev/scratches/" }, - }) - end, - desc = "Find Words in Scratches", - }, - ["fsf"] = { - function() - require("telescope.builtin").find_files({ - search_dirs = { "~/dev/scratches/" }, - }) - end, - desc = "Find Scratches", - }, - ["s"] = { "", desc = "Scratch File" }, - ["ss"] = { - function() - scratch(".txt") - end, - desc = "New [t]e[xt] scratch file", - }, - ["sn"] = { - function() - scratch(".json") - end, - desc = "New json scratch file", - }, - ["sm"] = { - function() - scratch(".md") - end, - desc = "New [m]ark[d]own scratch file", - }, - ["sq"] = { - function() - scratch(".sql") - end, - desc = "New sql scratch file", - }, - ["st"] = { - function() - scratch(".ts") - end, - desc = "New [t]ype[s]cript scratch file", - }, - ["sb"] = { - function() - scratch(".sh") - end, - desc = "New [sh]ell scratch file", - }, - ["sj"] = { - function() - scratch(".js") - end, - desc = "New [j]ava[s]cript scratch file", - }, - ["sr"] = { - function() - scratch(".rs") - end, - desc = "New [r]u[s]t scratch file", - }, - }, + n = { + ["fsw"] = { + function() + require("telescope.builtin").live_grep({ + search_dirs = { "~/dev/scratches/" }, + }) + end, + desc = "Find Words in Scratches", + }, + ["fsf"] = { + function() + require("telescope.builtin").find_files({ + search_dirs = { "~/dev/scratches/" }, + }) + end, + desc = "Find Scratches", + }, + ["s"] = { "", desc = "Scratch File" }, + ["ss"] = { + function() + scratch(".txt") + end, + desc = "New [t]e[xt] scratch file", + }, + ["sn"] = { + function() + scratch(".json") + end, + desc = "New json scratch file", + }, + ["sm"] = { + function() + scratch(".md") + end, + desc = "New [m]ark[d]own scratch file", + }, + ["sq"] = { + function() + scratch(".sql") + end, + desc = "New sql scratch file", + }, + ["st"] = { + function() + scratch(".ts") + end, + desc = "New [t]ype[s]cript scratch file", + }, + ["sb"] = { + function() + scratch(".sh") + end, + desc = "New [sh]ell scratch file", + }, + ["sj"] = { + function() + scratch(".js") + end, + desc = "New [j]ava[s]cript scratch file", + }, + ["sr"] = { + function() + scratch(".rs") + end, + desc = "New [r]u[s]t scratch file", + }, + }, }) diff --git a/lua/util.lua b/lua/util.lua index 01ba8a9..814642c 100644 --- a/lua/util.lua +++ b/lua/util.lua @@ -1,61 +1,60 @@ local M = {} function M.keymaps(mappings) - for mode, maps in pairs(mappings) do - for keymap, options in pairs(maps) do - if options then - local cmd = options - local keymap_opts = {} - if type(options) == "table" then - cmd = options[1] - keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options) - keymap_opts[1] = nil - end + for mode, maps in pairs(mappings) do + for keymap, options in pairs(maps) do + if options then + local cmd = options + local keymap_opts = {} + if type(options) == "table" then + cmd = options[1] + keymap_opts = vim.tbl_deep_extend("force", keymap_opts, options) + keymap_opts[1] = nil + end - if mode and keymap and cmd and keymap_opts then - vim.keymap.set(mode, keymap, cmd, keymap_opts) - end - end - end - end - + if mode and keymap and cmd and keymap_opts then + vim.keymap.set(mode, keymap, cmd, keymap_opts) + end + end + end + end end function M.spread(template) - local result = {} - for key, value in pairs(template) do - result[key] = value - end + local result = {} + for key, value in pairs(template) do + result[key] = value + end - return function(table) - for key, value in pairs(table) do - result[key] = value - end - return result - end + return function(table) + for key, value in pairs(table) do + result[key] = value + end + return result + end end -- From https://github.com/lukas-reineke/onedark.nvim/blob/master/lua/onedark.lua function M.highlight(group, options) - local guifg = options.fg or "NONE" - local guibg = options.bg or "NONE" - local guisp = options.sp or "NONE" - local gui = options.gui or "NONE" - local blend = options.blend or 0 - local ctermfg = options.ctermfg or "NONE" + local guifg = options.fg or "NONE" + local guibg = options.bg or "NONE" + local guisp = options.sp or "NONE" + local gui = options.gui or "NONE" + local blend = options.blend or 0 + local ctermfg = options.ctermfg or "NONE" - vim.cmd( - string.format( - "highlight %s guifg=%s ctermfg=%s guibg=%s guisp=%s gui=%s blend=%d", - group, - guifg, - ctermfg, - guibg, - guisp, - gui, - blend - ) + vim.cmd( + string.format( + "highlight %s guifg=%s ctermfg=%s guibg=%s guisp=%s gui=%s blend=%d", + group, + guifg, + ctermfg, + guibg, + guisp, + gui, + blend ) + ) end return M