From a56cb9a0a2b4ae1671b52b2bbf706e47b0473b70 Mon Sep 17 00:00:00 2001 From: Ray Andrew <4437323+rayandrew@users.noreply.github.com> Date: Tue, 1 Aug 2023 22:47:08 -0500 Subject: [PATCH] change style --- lazy-lock.json | 12 +-- lua/rayandrew/autocmds.lua | 7 +- lua/rayandrew/plugins.lua | 211 ++++++++++++++++++++----------------- lua/rayandrew/remap.lua | 129 ++++------------------- lua/rayandrew/util.lua | 10 +- stylua.toml | 2 +- 6 files changed, 146 insertions(+), 225 deletions(-) diff --git a/lazy-lock.json b/lazy-lock.json index 4662398..9cdd03f 100644 --- a/lazy-lock.json +++ b/lazy-lock.json @@ -1,11 +1,11 @@ { "LuaSnip": { "branch": "master", "commit": "e81cbe6004051c390721d8570a4a0541ceb0df10" }, + "asyncrun.vim": { "branch": "master", "commit": "7191d0c30dd105e5d7f897b9a6ee19cabe734466" }, "bufferline.nvim": { "branch": "main", "commit": "99f0932365b34e22549ff58e1bea388465d15e99" }, "cellular-automaton.nvim": { "branch": "main", "commit": "679943b8e1e5ef79aaeeaf4b00782c52eb4e928f" }, "cloak.nvim": { "branch": "main", "commit": "c6a92e2fbc6b931bc9ed0d07e80931c2324e05cb" }, "cmp-nvim-lsp": { "branch": "main", "commit": "44b16d11215dce86f253ce0c30949813c0a90765" }, - "copilot-cmp": { "branch": "master", "commit": "c2cdb3c0f5078b0619055af192295830a7987790" }, - "copilot.lua": { "branch": "master", "commit": "e48bd7020a98be217d85c006a298656294fd6210" }, + "copilot.vim": { "branch": "release", "commit": "a4a6d6b3f9e284e7f5c849619e06cd228cad8abd" }, "dressing.nvim": { "branch": "master", "commit": "829bc80400651aea31b03d8fc9a99135512fe67a" }, "flash.nvim": { "branch": "main", "commit": "967117690bd677cb7b6a87f0bc0077d2c0be3a27" }, "harpoon": { "branch": "master", "commit": "21f4c47c6803d64ddb934a5b314dcb1b8e7365dc" }, @@ -24,10 +24,10 @@ "nui.nvim": { "branch": "main", "commit": "9e3916e784660f55f47daa6f26053ad044db5d6a" }, "null-ls.nvim": { "branch": "main", "commit": "db09b6c691def0038c456551e4e2772186449f35" }, "nvim-cmp": { "branch": "main", "commit": "c4e491a87eeacf0408902c32f031d802c7eafce8" }, - "nvim-lspconfig": { "branch": "master", "commit": "b6091272422bb0fbd729f7f5d17a56d37499c54f" }, + "nvim-lspconfig": { "branch": "master", "commit": "a59d74e12340242c0735666fb2e91afdbe6f2496" }, "nvim-navic": { "branch": "master", "commit": "9c89730da6a05acfeb6a197e212dfadf5aa60ca0" }, "nvim-spectre": { "branch": "master", "commit": "3ba6edeea1390457caaf73e96ab9c086ff6f90e9" }, - "nvim-treesitter": { "branch": "master", "commit": "1c79da3300951e934f635eaf8703480b57644e7e" }, + "nvim-treesitter": { "branch": "master", "commit": "4c4d586a05e236d8199ab6faab8cb733a9b5bd24" }, "nvim-treesitter-context": { "branch": "master", "commit": "6f8f788738b968f24a108ee599c5be0031f94f06" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "9e519b6146512c8e2e702faf8ac48420f4f5deec" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "e9062e2dfb9854e6a927370f2d720de354c88524" }, @@ -37,12 +37,12 @@ "readline.nvim": { "branch": "master", "commit": "cab666cbd026dea9c817182e22255ecb3b3419b1" }, "refactoring.nvim": { "branch": "master", "commit": "5359e74291164fcaeaaecdea9ba753ad54eb53d0" }, "rose-pine": { "branch": "main", "commit": "e29002cbee4854a9c8c4b148d8a52fae3176070f" }, - "telescope.nvim": { "branch": "master", "commit": "b6fccfb0f7589a87587875206786daccba62acc3" }, + "telescope.nvim": { "branch": "master", "commit": "d2e17ba18a6840b7e7079764b282616c3188e0de" }, "todo-comments.nvim": { "branch": "main", "commit": "3094ead8edfa9040de2421deddec55d3762f64d1" }, "trouble.nvim": { "branch": "main", "commit": "40aad004f53ae1d1ba91bcc5c29d59f07c5f01d3" }, "undotree": { "branch": "master", "commit": "0e11ba7325efbbb3f3bebe06213afa3e7ec75131" }, "vim-fugitive": { "branch": "master", "commit": "b3b838d690f315a503ec4af8c634bdff3b200aaf" }, - "vim-illuminate": { "branch": "master", "commit": "a2907275a6899c570d16e95b9db5fd921c167502" }, + "vim-illuminate": { "branch": "master", "commit": "5ed17582a8e97bf0a0c617c3cf762e98f87b9859" }, "vim-startuptime": { "branch": "master", "commit": "454b3de856b7bd298700de33d79774ca9b9e3875" }, "vim-tmux-navigator": { "branch": "master", "commit": "cdd66d6a37d991bba7997d593586fc51a5b37aa8" }, "which-key.nvim": { "branch": "main", "commit": "7ccf476ebe0445a741b64e36c78a682c1c6118b7" }, diff --git a/lua/rayandrew/autocmds.lua b/lua/rayandrew/autocmds.lua index 8a13f41..d5ecc83 100644 --- a/lua/rayandrew/autocmds.lua +++ b/lua/rayandrew/autocmds.lua @@ -64,12 +64,7 @@ vim.api.nvim_create_autocmd("FileType", { }, callback = function(event) vim.bo[event.buf].buflisted = false - vim.keymap.set( - "n", - "q", - "close", - { buffer = event.buf, silent = true } - ) + vim.keymap.set("n", "q", "close", { buffer = event.buf, silent = true }) end, }) diff --git a/lua/rayandrew/plugins.lua b/lua/rayandrew/plugins.lua index f12c03d..80ab546 100644 --- a/lua/rayandrew/plugins.lua +++ b/lua/rayandrew/plugins.lua @@ -8,7 +8,8 @@ return { "dstein64/vim-startuptime", -- lazy-load on a command cmd = "StartupTime", - -- init is called during startup. Configuration for vim plugins typically should be set in an init function + -- init is called during startup. + -- Configuration for vim plugins typically should be set in an init function init = function() vim.g.startuptime_tries = 10 end, @@ -71,15 +72,15 @@ return { end, desc = "Find Files (cwd)", }, - { - "", - function() - local Util = require("rayandrew.util") - local fun = Util.telescope("git_files") - fun() - end, - desc = "Find Git Files", - }, + -- { + -- "", + -- function() + -- local Util = require("rayandrew.util") + -- local fun = Util.telescope("git_files") + -- fun() + -- end, + -- desc = "Find Git Files", + -- }, { "sm", function() @@ -114,9 +115,7 @@ return { -- disable rtp plugin, as we only need its queries for mini.ai -- In case other textobject modules are enabled, we will load them -- once nvim-treesitter is loaded - require("lazy.core.loader").disable_rtp_plugin( - "nvim-treesitter-textobjects" - ) + require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") load_textobjects = true end, }, @@ -181,8 +180,7 @@ return { if opts.textobjects[mod] and opts.textobjects[mod].enable then local Loader = require("lazy.core.loader") Loader.disabled_rtp_plugins["nvim-treesitter-textobjects"] = nil - local plugin = - require("lazy.core.config").plugins["nvim-treesitter-textobjects"] + local plugin = require("lazy.core.config").plugins["nvim-treesitter-textobjects"] require("lazy.core.loader").source_runtime(plugin.dir, "plugin") break end @@ -461,6 +459,13 @@ return { "notify", "toggleterm", "lazyterm", + "qf", + }, + buftype_exclude = { + "terminal", + "nofile", + "quickfix", + "prompt", }, show_trailing_blankline_indent = false, show_current_context = false, @@ -629,19 +634,19 @@ return { }, -- Copilot - { - "zbirenbaum/copilot.lua", - cmd = "Copilot", - build = ":Copilot auth", - opts = { - suggestion = { enabled = false }, - panel = { enabled = false }, - filetypes = { - markdown = true, - help = true, - }, - }, - }, + -- { + -- "zbirenbaum/copilot.lua", + -- cmd = "Copilot", + -- build = ":Copilot auth", + -- opts = { + -- suggestion = { enabled = false }, + -- panel = { enabled = false }, + -- filetypes = { + -- markdown = true, + -- help = true, + -- }, + -- }, + -- }, -- Autocompletion { @@ -649,23 +654,24 @@ return { event = "InsertEnter", dependencies = { { "L3MON4D3/LuaSnip", build = "make install_jsregexp" }, - { - "zbirenbaum/copilot-cmp", - dependencies = "copilot.lua", - opts = {}, - config = function(_, opts) - local Util = require("rayandrew.util") - local copilot_cmp = require("copilot_cmp") - copilot_cmp.setup(opts) - -- attach cmp source whenever copilot attaches - -- fixes lazy-loading issues with the copilot cmp source - Util.on_attach(function(client) - if client.name == "copilot" then - copilot_cmp._on_insert_enter({}) - end - end) - end, - }, + -- { + -- "zbirenbaum/copilot-cmp", + -- dependencies = "copilot.lua", + -- enabled = false, + -- opts = {}, + -- config = function(_, opts) + -- local Util = require("rayandrew.util") + -- local copilot_cmp = require("copilot_cmp") + -- copilot_cmp.setup(opts) + -- -- attach cmp source whenever copilot attaches + -- -- fixes lazy-loading issues with the copilot cmp source + -- Util.on_attach(function(client) + -- if client.name == "copilot" then + -- copilot_cmp._on_insert_enter({}) + -- end + -- end) + -- end, + -- }, }, config = function() require("lsp-zero.cmp").extend() @@ -677,7 +683,7 @@ return { cmp.setup({ sources = { - { name = "copilot", group_index = 2 }, + -- { name = "copilot", group_index = 2 }, { name = "nvim_lsp", group_index = 2 }, { name = "path", group_index = 2 }, { name = "luasnip", group_index = 2 }, @@ -844,12 +850,7 @@ return { config = function(_, opts) local nls = require("null-ls") nls.setup({ - root_dir = require("null-ls.utils").root_pattern( - ".null-ls-root", - ".neoconf.json", - "Makefile", - ".git" - ), + root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"), sources = { nls.builtins.completion.spell, nls.builtins.code_actions.gitsigns, @@ -862,8 +863,7 @@ return { -- js/ts linter -- only enable eslint if root has .eslintrc.js (not in youtube nvim video) condition = function(utils) - return utils.root_has_file(".eslintrc.js") - or utils.root_has_file(".eslintrc.cjs") + return utils.root_has_file(".eslintrc.js") or utils.root_has_file(".eslintrc.cjs") end, filetypes = { "javascript", @@ -966,8 +966,7 @@ return { opts = { options = { custom_commentstring = function() - return require("ts_context_commentstring.internal").calculate_commentstring() - or vim.bo.commentstring + return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring end, }, }, @@ -1125,9 +1124,9 @@ return { { "theprimeagen/refactoring.nvim", }, - -- { - -- "github/copilot.vim", - -- }, + { + "github/copilot.vim", + }, { "eandrju/cellular-automaton.nvim", }, @@ -1137,6 +1136,26 @@ return { { "mbbill/undotree", }, + { + "skywind3000/asyncrun.vim", + cmd = { "AsyncRun", "AsyncStop" }, + keys = { + { + "cc", + function() + local input = vim.fn.input("Command: ") + vim.cmd("AsyncRun " .. input) + -- vim.cmd("sleep 1") + -- vim.cmd("copen") + end, + desc = "AsyncRun", + }, + { "ck", desc = "AsyncStop" }, + }, + config = function() + vim.g.asyncrun_open = 6 + end, + }, -- Folke { @@ -1308,16 +1327,12 @@ return { mode = "search", exclude = { function(win) - return vim.bo[vim.api.nvim_win_get_buf(win)].filetype - ~= "TelescopeResults" + return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= "TelescopeResults" end, }, }, action = function(match) - local picker = - require("telescope.actions.state").get_current_picker( - prompt_bufnr - ) + local picker = require("telescope.actions.state").get_current_picker(prompt_bufnr) picker:set_selection(match.pos[1] - 1) end, }) @@ -1341,37 +1356,37 @@ return { }, -- Copilot Lualine - { - "nvim-lualine/lualine.nvim", - -- optional = true, - event = "VeryLazy", - opts = function(_, opts) - local Util = require("rayandrew.util") - local colors = { - [""] = Util.fg("Special"), - ["Normal"] = Util.fg("Special"), - ["Warning"] = Util.fg("DiagnosticError"), - ["InProgress"] = Util.fg("DiagnosticWarn"), - } - table.insert(opts.sections.lualine_x, 2, { - function() - local icon = require("rayandrew.themes").icons.kinds.Copilot - local status = require("copilot.api").status.data - return icon .. (status.message or "") - end, - cond = function() - local ok, clients = - pcall(vim.lsp.get_active_clients, { name = "copilot", bufnr = 0 }) - return ok and #clients > 0 - end, - color = function() - if not package.loaded["copilot"] then - return - end - local status = require("copilot.api").status.data - return colors[status.status] or colors[""] - end, - }) - end, - }, + -- { + -- "nvim-lualine/lualine.nvim", + -- -- optional = true, + -- event = "VeryLazy", + -- opts = function(_, opts) + -- local Util = require("rayandrew.util") + -- local colors = { + -- [""] = Util.fg("Special"), + -- ["Normal"] = Util.fg("Special"), + -- ["Warning"] = Util.fg("DiagnosticError"), + -- ["InProgress"] = Util.fg("DiagnosticWarn"), + -- } + -- table.insert(opts.sections.lualine_x, 2, { + -- function() + -- local icon = require("rayandrew.themes").icons.kinds.Copilot + -- local status = require("copilot.api").status.data + -- return icon .. (status.message or "") + -- end, + -- cond = function() + -- local ok, clients = + -- pcall(vim.lsp.get_active_clients, { name = "copilot", bufnr = 0 }) + -- return ok and #clients > 0 + -- end, + -- color = function() + -- if not package.loaded["copilot"] then + -- return + -- end + -- local status = require("copilot.api").status.data + -- return colors[status.status] or colors[""] + -- end, + -- }) + -- end, + -- }, } diff --git a/lua/rayandrew/remap.lua b/lua/rayandrew/remap.lua index e853c69..fddc561 100644 --- a/lua/rayandrew/remap.lua +++ b/lua/rayandrew/remap.lua @@ -6,118 +6,43 @@ local Util = require("rayandrew.util") Util.map("n", "fs", "w", { desc = "Save file" }) -Util.map( - { "i", "v", "n", "s" }, - "", - "w", - { desc = "Save file" } -) +Util.map({ "i", "v", "n", "s" }, "", "w", { desc = "Save file" }) -- Move Lines -Util.map("n", "", "m .+1==", { desc = "Move down" }) -Util.map("n", "", "m .-2==", { desc = "Move up" }) -Util.map("i", "", "m .+1==gi", { desc = "Move down" }) -Util.map("i", "", "m .-2==gi", { desc = "Move up" }) -Util.map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) -Util.map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) +Util.map("n", "", "m .+1==", { desc = "Move down" }) +Util.map("n", "", "m .-2==", { desc = "Move up" }) +Util.map("i", "", "m .+1==gi", { desc = "Move down" }) +Util.map("i", "", "m .-2==gi", { desc = "Move up" }) +Util.map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) +Util.map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) ------------------------------ -- Windowing + Navigation ------------------------------ -- better up/down -Util.map( - { "n", "x" }, - "j", - "v:count == 0 ? 'gj' : 'j'", - { expr = true, silent = true } -) -Util.map( - { "n", "x" }, - "k", - "v:count == 0 ? 'gk' : 'k'", - { expr = true, silent = true } -) +Util.map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +Util.map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -- resize -Util.map( - "n", - "", - "resize +2", - { desc = "Increase window height" } -) -Util.map( - "n", - "", - "resize -2", - { desc = "Decrease window height" } -) -Util.map( - "n", - "", - "vertical resize -2", - { desc = "Decrease window width" } -) -Util.map( - "n", - "", - "vertical resize +2", - { desc = "Increase window width" } -) +Util.map("n", "", "resize +2", { desc = "Increase window height" }) +Util.map("n", "", "resize -2", { desc = "Decrease window height" }) +Util.map("n", "", "vertical resize -2", { desc = "Decrease window width" }) +Util.map("n", "", "vertical resize +2", { desc = "Increase window width" }) -- split -Util.map( - "n", - "ws", - "split", - { desc = "[W]indow Horizontal [S]plit" } -) -- split horizontal -Util.map( - "n", - "wv", - "vsplit", - { desc = "[W]indow [V]ertical Split" } -) -- split vertical +Util.map("n", "ws", "split", { desc = "[W]indow Horizontal [S]plit" }) -- split horizontal +Util.map("n", "wv", "vsplit", { desc = "[W]indow [V]ertical Split" }) -- split vertical -- move -Util.map( - "n", - "wh", - "TmuxNavigateLeft", - { desc = "Go to Left [W]indow" } -) -Util.map( - "n", - "wj", - "TmuxNavigateDown", - { desc = "Go to [W]indow Below" } -) -Util.map( - "n", - "wk", - "TmuxNavigateUp", - { desc = "Go to Top [W]indow" } -) -Util.map( - "n", - "wl", - "TmuxNavigateRight", - { desc = "Go to Right [W]indow" } -) +Util.map("n", "wh", "TmuxNavigateLeft", { desc = "Go to Left [W]indow" }) +Util.map("n", "wj", "TmuxNavigateDown", { desc = "Go to [W]indow Below" }) +Util.map("n", "wk", "TmuxNavigateUp", { desc = "Go to Top [W]indow" }) +Util.map("n", "wl", "TmuxNavigateRight", { desc = "Go to Right [W]indow" }) if Util.has("bufferline.nvim") then - Util.map( - "n", - "", - "BufferLineCyclePrev", - { desc = "Prev buffer" } - ) - Util.map( - "n", - "", - "BufferLineCycleNext", - { desc = "Next buffer" } - ) + Util.map("n", "", "BufferLineCyclePrev", { desc = "Prev buffer" }) + Util.map("n", "", "BufferLineCycleNext", { desc = "Next buffer" }) Util.map("n", "[b", "BufferLineCyclePrev", { desc = "Prev buffer" }) Util.map("n", "]b", "BufferLineCycleNext", { desc = "Next buffer" }) else @@ -133,12 +58,7 @@ Util.map("n", "f", "tabfirst", { desc = "First Tab" }) Util.map("n", "", "tabnew", { desc = "New Tab" }) Util.map("n", "]", "tabnext", { desc = "Next Tab" }) Util.map("n", "d", "tabclose", { desc = "Close Tab" }) -Util.map( - "n", - "[", - "tabprevious", - { desc = "Previous Tab" } -) +Util.map("n", "[", "tabprevious", { desc = "Previous Tab" }) -- close Util.map("n", "wq", "q", { desc = "[W]indow [Q]uit" }) -- quit @@ -179,10 +99,7 @@ Util.map("n", "mr", "CellularAutomaton make_it_rain") -- lazygit Util.map("n", "gg", function() - Util.float_term( - { "lazygit" }, - { cwd = Util.get_root(), esc_esc = false, ctrl_hjkl = false } - ) + Util.float_term({ "lazygit" }, { cwd = Util.get_root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) Util.map("n", "gG", function() Util.float_term({ "lazygit" }, { esc_esc = false, ctrl_hjkl = false }) diff --git a/lua/rayandrew/util.lua b/lua/rayandrew/util.lua index 1eb0938..61f8bb5 100644 --- a/lua/rayandrew/util.lua +++ b/lua/rayandrew/util.lua @@ -16,8 +16,7 @@ end function M.fg(name) ---@type {foreground?:number}? - local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) - or vim.api.nvim_get_hl_by_name(name, true) + local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true) local fg = hl and hl.fg or hl.foreground return fg and { fg = string.format("#%06x", fg) } end @@ -106,12 +105,7 @@ function M.telescope(builtin, opts) local line = action_state.get_current_line() M.telescope( params.builtin, - vim.tbl_deep_extend( - "force", - {}, - params.opts or {}, - { cwd = false, default_text = line } - ) + vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line }) )() end) return true diff --git a/stylua.toml b/stylua.toml index 421c3d9..0f90030 100644 --- a/stylua.toml +++ b/stylua.toml @@ -1,3 +1,3 @@ indent_type = "Spaces" indent_width = 2 -column_width = 80 +column_width = 120