This commit is contained in:
Ray Andrew 2024-08-07 20:28:42 -05:00
parent 8bec478318
commit 5a658d4bb9
No known key found for this signature in database
11 changed files with 461 additions and 164 deletions

View file

@ -1,68 +1,68 @@
{ {
"LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" }, "LuaSnip": { "branch": "master", "commit": "ce0a05ab4e2839e1c48d072c5236cce846a387bc" },
"bufresize.nvim": { "branch": "master", "commit": "3b19527ab936d6910484dcc20fb59bdb12322d8b" }, "bufresize.nvim": { "branch": "master", "commit": "3b19527ab936d6910484dcc20fb59bdb12322d8b" },
"cellular-automaton.nvim": { "branch": "main", "commit": "b7d056dab963b5d3f2c560d92937cb51db61cb5b" }, "chezmoi.nvim": { "branch": "main", "commit": "e5d2b2f534d2a1701ea2f9a8849732b28ea4c8c3" },
"chezmoi.nvim": { "branch": "refactor", "commit": "a0fd6e164493b9d16137ee362c6b2106e5c32fa3" }, "chezmoi.vim": { "branch": "main", "commit": "abf37336437867cbd99ce2f8849b717415391cc3" },
"chezmoi.vim": { "branch": "main", "commit": "a35b426db9d83f8fcf43981f299ad3145d001af2" }, "cloak.nvim": { "branch": "main", "commit": "648aca6d33ec011dc3166e7af3b38820d01a71e4" },
"cloak.nvim": { "branch": "main", "commit": "9abe4e986e924fc54a972c1b0ff52b65a0622624" }, "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" },
"cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, "conform.nvim": { "branch": "master", "commit": "25d48271e3d4404ba017cb92a37d3a681c1ad149" },
"conform.nvim": { "branch": "master", "commit": "34b81e70da83e26c048290204de44268eb59814e" }, "copilot.vim": { "branch": "release", "commit": "25f73977033c597d530c7ab0e211d99b60927d2d" },
"copilot.vim": { "branch": "release", "commit": "57a0115908895f465eb3476f03a0aaa7096e8fe1" }, "everforest": { "branch": "main", "commit": "8fdccd1e45088be3309aaf82072b1f7fec2f6f2c" },
"everforest": { "branch": "main", "commit": "eedb19079c6bf9d162f74a5c48a6d2759f38cc76" },
"focus.nvim": { "branch": "master", "commit": "4135f976afe5d6e1fe66dff121db9d06643f439f" }, "focus.nvim": { "branch": "master", "commit": "4135f976afe5d6e1fe66dff121db9d06643f439f" },
"fzf": { "branch": "master", "commit": "507089d7b235b602f2f400be34c79a895e8c10dc" }, "fzf": { "branch": "master", "commit": "af4917dbb643a7991c50091ec55ec25acb7d28cb" },
"fzf.vim": { "branch": "master", "commit": "8ea9574b3ebdc44fbe3dc6381a13f9ce0c290e2f" }, "fzf.vim": { "branch": "master", "commit": "f7c7b44764a601e621432b98c85709c9a53a7be8" },
"gitsigns.nvim": { "branch": "main", "commit": "2c2463dbd82eddd7dbab881c3a62cfbfbe3c67ae" }, "gitsigns.nvim": { "branch": "main", "commit": "f074844b60f9e151970fbcdbeb8a2cd52b6ef25a" },
"glow.nvim": { "branch": "main", "commit": "238070a686c1da3bccccf1079700eb4b5e19aea4" }, "glow.nvim": { "branch": "main", "commit": "238070a686c1da3bccccf1079700eb4b5e19aea4" },
"gruber-darker.nvim": { "branch": "main", "commit": "1793c0929ca965430410f7ec578272a4af9226ee" },
"harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" }, "harpoon": { "branch": "master", "commit": "ccae1b9bec717ae284906b0bf83d720e59d12b91" },
"image.nvim": { "branch": "master", "commit": "0dd8bdbb8855bc98c534a902c91dc9eddb8155b1" }, "hydra.nvim": { "branch": "master", "commit": "55de54543d673824435930ecf533256eea2e565b" },
"indent-blankline.nvim": { "branch": "master", "commit": "821a7acd88587d966f7e464b0b3031dfe7f5680c" }, "image.nvim": { "branch": "master", "commit": "61c76515cfc3cdac8123ece9e9761b20c3dc1315" },
"lazy.nvim": { "branch": "main", "commit": "28126922c9b54e35a192ac415788f202c3944c9f" }, "indent-blankline.nvim": { "branch": "master", "commit": "65e20ab94a26d0e14acac5049b8641336819dfc7" },
"lsp-zero.nvim": { "branch": "v3.x", "commit": "8cce56f62f3b67a44b71106bc687e13e53ff95b0" }, "lazy.nvim": { "branch": "main", "commit": "077102c5bfc578693f12377846d427f49bc50076" },
"lualine.nvim": { "branch": "master", "commit": "8b56462bfb746760465264de41b4907310f113ec" }, "lsp-zero.nvim": { "branch": "v3.x", "commit": "56db3d5ce5476b183783160e6045f7337ba12b83" },
"mason-lspconfig.nvim": { "branch": "main", "commit": "21d33d69a81f6351e5a5f49078b2e4f0075c8e73" }, "lualine.nvim": { "branch": "master", "commit": "544dd1583f9bb27b393f598475c89809c4d5e86b" },
"mason-tool-installer.nvim": { "branch": "main", "commit": "1212fb6082b7177dde17ea65e429e027835aeb40" }, "markdown-preview.nvim": { "branch": "master", "commit": "a923f5fc5ba36a3b17e289dc35dc17f66d0548ee" },
"mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, "mason-lspconfig.nvim": { "branch": "main", "commit": "ba9c2f0b93deb48d0a99ae0e8d8dd36f7cc286d6" },
"meh": { "branch": "master", "commit": "e2962284bbd53db5cbe2db39efaa3ea74ade0fb1" }, "mason-tool-installer.nvim": { "branch": "main", "commit": "c5e07b8ff54187716334d585db34282e46fa2932" },
"mini.bufremove": { "branch": "main", "commit": "931a3bb514147d9e812767275c4beba6b779b1d3" }, "mason.nvim": { "branch": "main", "commit": "e2f7f9044ec30067bc11800a9e266664b88cda22" },
"mini.comment": { "branch": "main", "commit": "a4b7e46deb9ad2feb8902cc5dbf087eced112ee5" }, "meh": { "branch": "master", "commit": "41dd74e2d5afc6c1e975b01c84512a8951a39569" },
"mini.bufremove": { "branch": "main", "commit": "1ee294a97e091d3cf967974df622c0d887890dc2" },
"mini.comment": { "branch": "main", "commit": "03c13e37318bdb18481311c0ac1adc9ed731caf1" },
"multicursors.nvim": { "branch": "main", "commit": "782820896b1691ed664e4c24f1cd9793dcb33dfb" },
"nabla.nvim": { "branch": "master", "commit": "27a6ea9ed7452bb9e0b19eb0942b5bcf7d051b2f" }, "nabla.nvim": { "branch": "master", "commit": "27a6ea9ed7452bb9e0b19eb0942b5bcf7d051b2f" },
"neo-tree.nvim": { "branch": "v3.x", "commit": "459c60317cc1d251f6eb3b6f010d015d5d24b806" }, "neo-tree.nvim": { "branch": "v3.x", "commit": "29f7c215332ba95e470811c380ddbce2cebe2af4" },
"nui.nvim": { "branch": "main", "commit": "fbb139c6f14896b434d0229099e1acd863ae6bec" }, "nui.nvim": { "branch": "main", "commit": "61574ce6e60c815b0a0c4b5655b8486ba58089a1" },
"nvim-bqf": { "branch": "main", "commit": "b51a37fcd808edafd52511458467c8c9a701ea8d" }, "nvim-bqf": { "branch": "main", "commit": "1b24dc6050c34e8cd377b6b4cd6abe40509e0187" },
"nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, "nvim-cmp": { "branch": "main", "commit": "d818fd0624205b34e14888358037fb6f5dc51234" },
"nvim-lint": { "branch": "master", "commit": "e824adb9bc01647f71e55457353a68f0f37f9931" }, "nvim-lint": { "branch": "master", "commit": "efc6fc83f0772283e064c53a8f9fb5645bde0bc0" },
"nvim-lspconfig": { "branch": "master", "commit": "9ad7021267c6caeb01f839c91ad8f15fb608807e" }, "nvim-lspconfig": { "branch": "master", "commit": "fdc44768a09a65140aa00c92872a5381ad486485" },
"nvim-spectre": { "branch": "master", "commit": "3712ff0cdf4f9f877d9ca708d835a877d9a0abaf" }, "nvim-spectre": { "branch": "master", "commit": "ba7fb777edff6c1fbbeffd343e113af64c04e90a" },
"nvim-surround": { "branch": "main", "commit": "d47001f8ddf9646c24f16d2732d4d0255acd2121" }, "nvim-surround": { "branch": "main", "commit": "ec2dc7671067e0086cdf29c2f5df2dd909d5f71f" },
"nvim-treesitter": { "branch": "master", "commit": "cc6b108ea1251bd361f091b7d5a0dd41c04f8611" }, "nvim-treesitter": { "branch": "master", "commit": "65310b64eee19a6e74e1b6f607a9f46f751290fe" },
"nvim-treesitter-context": { "branch": "master", "commit": "b8b7e52c1517d401d7c519787d5dc4528c41291a" }, "nvim-treesitter-context": { "branch": "master", "commit": "2aba92ceb1479485953007f4d5adf34d0b66917e" },
"nvim-treesitter-textobjects": { "branch": "master", "commit": "b7a0bfa3e93697ca5b61b15df633404bf8f45883" }, "nvim-treesitter-textobjects": { "branch": "master", "commit": "34867c69838078df7d6919b130c0541c0b400c47" },
"nvim-ts-context-commentstring": { "branch": "main", "commit": "7ab799a9792f7cf3883cf28c6a00ad431f3d382a" }, "nvim-ts-context-commentstring": { "branch": "main", "commit": "6b5f95aa4d24f2c629a74f2c935c702b08dbde62" },
"nvim-web-devicons": { "branch": "master", "commit": "4adea17610d140a99c313e3f79a9dc01825d59ae" }, "nvim-web-devicons": { "branch": "master", "commit": "5be6c4e685618b99c3210a69375b38a1202369b4" },
"oil.nvim": { "branch": "master", "commit": "18dfd2458dc741fea683357a17aaa95870b25a3c" }, "oil.nvim": { "branch": "master", "commit": "fcca212c2e966fc3dec1d4baf888e670631d25d1" },
"playground": { "branch": "master", "commit": "ba48c6a62a280eefb7c85725b0915e021a1a0749" }, "plenary.nvim": { "branch": "master", "commit": "a3e3bc82a3f95c5ed0d7201546d5d2c19b20d683" },
"plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, "rasmus": { "branch": "main", "commit": "86d608bd1d12a53b39d9b4b2847cd7c3ea81d473" },
"rasmus": { "branch": "main", "commit": "f824de95d446686e479781c0c2b778c177da528f" },
"readline.nvim": { "branch": "main", "commit": "5cb27349bc01cdcdb3d3494e5337d8b3834aef1a" }, "readline.nvim": { "branch": "main", "commit": "5cb27349bc01cdcdb3d3494e5337d8b3834aef1a" },
"refactoring.nvim": { "branch": "master", "commit": "93d69cce9f0cbee8afae5b2380b296323792645f" }, "rose-pine": { "branch": "main", "commit": "e4b08d74b7272cb21e4e9c71b8b9e0830fd722fe" },
"rose-pine": { "branch": "main", "commit": "a29b09d15a9ef5cd575fbe5ae2a3cfb854876caf" }, "smart-splits.nvim": { "branch": "master", "commit": "209c136a5bee236094245196986ce94920dd3fdf" },
"smart-splits.nvim": { "branch": "master", "commit": "1ae8794e9e7fbdf0ec4074f2d0e056556a834f75" }, "snakemake": { "branch": "main", "commit": "e8735c1477a2a82110757ba86bbd1ccbcaf327ba" },
"snakemake": { "branch": "main", "commit": "2887604ebe8a1e4c9c226780129312f556150dca" },
"symbols-outline.nvim": { "branch": "master", "commit": "564ee65dfc9024bdde73a6621820866987cbb256" }, "symbols-outline.nvim": { "branch": "master", "commit": "564ee65dfc9024bdde73a6621820866987cbb256" },
"telescope-fzf-native.nvim": { "branch": "main", "commit": "9ef21b2e6bb6ebeaf349a0781745549bbb870d27" }, "telescope-fzf-native.nvim": { "branch": "main", "commit": "cf48d4dfce44e0b9a2e19a008d6ec6ea6f01a83b" },
"telescope.nvim": { "branch": "master", "commit": "dc1ea28cc2a02cd1cebb9d80e967807d668f78f8" }, "telescope.nvim": { "branch": "master", "commit": "10b8a82b042caf50b78e619d92caf0910211973d" },
"todo-comments.nvim": { "branch": "main", "commit": "833d8dd8b07eeda37a09e99460f72a02616935cb" }, "todo-comments.nvim": { "branch": "main", "commit": "8f45f353dc3649cb9b44cecda96827ea88128584" },
"tree-sitter-just": { "branch": "main", "commit": "43f2c5efb96e51bbd8e64284662911b60849df00" }, "trouble.nvim": { "branch": "main", "commit": "6efc446226679fda0547c0fd6a7892fd5f5b15d8" },
"trouble.nvim": { "branch": "main", "commit": "f1168feada93c0154ede4d1fe9183bf69bac54ea" }, "undotree": { "branch": "master", "commit": "56c684a805fe948936cda0d1b19505b84ad7e065" },
"undotree": { "branch": "master", "commit": "9dbbf3b7d19dda0d22ceca461818e4739ad8154d" }, "venn.nvim": { "branch": "main", "commit": "b09c2f36ddf70b498281845109bedcf08a7e0de0" },
"venn.nvim": { "branch": "main", "commit": "e4d68341a73dd56c64955058821a58295fb337b1" },
"vim-dispatch": { "branch": "master", "commit": "4c695bc052cad2ae6b980aebbe48d046466e27ae" }, "vim-dispatch": { "branch": "master", "commit": "4c695bc052cad2ae6b980aebbe48d046466e27ae" },
"vim-fugitive": { "branch": "master", "commit": "41beedabc7e948c787ea5696e04c3544c3674e23" }, "vim-fugitive": { "branch": "master", "commit": "0444df68cd1cdabc7453d6bd84099458327e5513" },
"vim-illuminate": { "branch": "master", "commit": "305bf07b919ac526deb5193280379e2f8b599926" }, "vim-illuminate": { "branch": "master", "commit": "5eeb7951fc630682c322e88a9bbdae5c224ff0aa" },
"vim-startuptime": { "branch": "master", "commit": "308b0088a864c4711a96e45b6734cf9294074f65" }, "vim-startuptime": { "branch": "master", "commit": "ac2cccb5be617672add1f4f3c0a55ce99ba34e01" },
"vim-tmux-navigator": { "branch": "master", "commit": "38b1d0402c4600543281dc85b3f51884205674b6" }, "vim-tmux-navigator": { "branch": "master", "commit": "5b3c701686fb4e6629c100ed32e827edf8dad01e" },
"vimtex": { "branch": "master", "commit": "a77d14b2e4391c0d3e860708bb1fd56161ab68eb" }, "vimtex": { "branch": "master", "commit": "5ac62e0315c6f54f53a7d6da7c485cf8e9cf7240" },
"which-key.nvim": { "branch": "main", "commit": "4433e5ec9a507e5097571ed55c02ea9658fb268a" }, "which-key.nvim": { "branch": "main", "commit": "6c1584eb76b55629702716995cca4ae2798a9cca" },
"zen-mode.nvim": { "branch": "main", "commit": "78557d972b4bfbb7488e17b5703d25164ae64e6a" } "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" }
} }

View file

@ -12,6 +12,8 @@ end
vim.opt.rtp:prepend(lazypath) vim.opt.rtp:prepend(lazypath)
require("rayandrew.util").setup()
require("lazy").setup({ require("lazy").setup({
spec = { spec = {
{ import = "rayandrew.plugins" }, { import = "rayandrew.plugins" },

View file

@ -172,7 +172,7 @@ return {
{ {
"xvzc/chezmoi.nvim", "xvzc/chezmoi.nvim",
dependencies = { "nvim-lua/plenary.nvim" }, dependencies = { "nvim-lua/plenary.nvim" },
branch = "refactor", -- branch = "refactor",
opts = { opts = {
edit = { edit = {
watch = true, -- Set true to automatically apply on save. watch = true, -- Set true to automatically apply on save.
@ -222,4 +222,31 @@ return {
vim.opt.rtp:append(plugin.dir .. "/misc/vim") vim.opt.rtp:append(plugin.dir .. "/misc/vim")
end, end,
}, },
{
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
ft = { "markdown" },
build = function()
vim.fn["mkdp#util#install"]()
end,
},
{
"smoka7/multicursors.nvim",
event = "VeryLazy",
dependencies = {
"smoka7/hydra.nvim",
},
opts = {},
cmd = { "MCstart", "MCvisual", "MCclear", "MCpattern", "MCvisualPattern", "MCunderCursor" },
keys = {
{
mode = { "v", "n" },
"<c-d>",
"<cmd>MCstart<cr>",
desc = "Create a selection for selected text or word under the cursor",
},
},
},
} }

View file

@ -40,6 +40,15 @@ return {
}, },
}, },
{
"thimc/gruber-darker.nvim",
lazy = true,
opts = {
transparent = true,
},
},
{ "junegunn/fzf.vim", dependencies = { "junegunn/fzf" } }, { "junegunn/fzf.vim", dependencies = { "junegunn/fzf" } },
-- { -- {

View file

@ -71,7 +71,7 @@ return {
lsp_zero.on_attach(function(client, bufnr) lsp_zero.on_attach(function(client, bufnr)
-- see :help lsp-zero-keybindings -- see :help lsp-zero-keybindings
-- to learn the available actions -- to learn the available actions
lsp_zero.default_keymaps({ buffer = bufnr, preserve_mappings = false }) lsp_zero.default_keymaps({ buffer = bufnr, preserve_mappings = true })
end) end)
require("mason-lspconfig").setup({ require("mason-lspconfig").setup({

View file

@ -1,53 +1,55 @@
local load_textobjects = false
return { return {
------------------------------ ------------------------------
-- TreeSitter -- TreeSitter
------------------------------ ------------------------------
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
version = false, -- last release is way too old and doesn't work on Windows
build = ":TSUpdate", build = ":TSUpdate",
dependencies = { event = { "VeryLazy" },
{ lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline
"nvim-treesitter/nvim-treesitter-textobjects", init = function(plugin)
init = function() -- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") -- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
load_textobjects = true -- no longer trigger the **nvim-treesitter** module to be loaded in time.
end, -- Luckily, the only things that those plugins need are the custom queries, which we make available
}, -- during startup.
require("lazy.core.loader").add_to_rtp(plugin)
{ require("nvim-treesitter.query_predicates")
"IndianBoy42/tree-sitter-just", end,
dependencies = "nvim-treesitter/nvim-treesitter", cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
config = function(_, opts) keys = {
require("tree-sitter-just").setup({}) { "<c-space>", desc = "Increment Selection" },
end, { "<bs>", desc = "Decrement Selection", mode = "x" },
},
}, },
---@type TSConfig
---@diagnostic disable-next-line: missing-fields
opts = { opts = {
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
ensure_installed = { ensure_installed = {
"bash", "bash",
"c", "c",
"diff",
"html", "html",
"javascript", "javascript",
"jsdoc",
"json", "json",
"latex", "jsonc",
"lua", "lua",
"luadoc", "luadoc",
"luap", "luap",
"markdown", "markdown",
"markdown_inline", "markdown_inline",
"nix",
"python", "python",
"query", "query",
"regex", "regex",
"rust", "toml",
"tsx", "tsx",
"typescript", "typescript",
"vim", "vim",
"vimdoc", "vimdoc",
"xml",
"yaml", "yaml",
}, },
incremental_selection = { incremental_selection = {
@ -60,60 +62,17 @@ return {
}, },
}, },
textobjects = { textobjects = {
select = {
enable = true,
lookahead = true,
keymaps = {
["aa"] = "@parameter.outer",
["ia"] = "@parameter.inner",
["af"] = "@function.outer",
["if"] = "@function.inner",
["ac"] = "@class.outer",
["ic"] = "@class.inner",
},
},
move = { move = {
enable = true, enable = true,
set_jumps = true, goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
goto_next_start = { goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
["]k"] = { query = "@block.outer", desc = "Next block start" }, goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
["]f"] = { query = "@function.outer", desc = "Next function start" }, goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
["]a"] = { query = "@parameter.inner", desc = "Next parameter start" },
},
goto_next_end = {
["]K"] = { query = "@block.outer", desc = "Next block end" },
["]F"] = { query = "@function.outer", desc = "Next function end" },
["]A"] = { query = "@parameter.inner", desc = "Next parameter end" },
},
goto_previous_start = {
["[k"] = { query = "@block.outer", desc = "Previous block start" },
["[f"] = { query = "@function.outer", desc = "Previous function start" },
["[a"] = { query = "@parameter.inner", desc = "Previous parameter start" },
},
goto_previous_end = {
["[K"] = { query = "@block.outer", desc = "Previous block end" },
["[F"] = { query = "@function.outer", desc = "Previous function end" },
["[A"] = { query = "@parameter.inner", desc = "Previous parameter end" },
},
},
swap = {
enable = true,
swap_next = {
["<leader>a"] = "@parameter.inner",
},
swap_previous = {
["<leader>A"] = "@parameter.inner",
},
}, },
}, },
}, },
cmd = { "TSUpdateSync" }, ---@param opts TSConfig
keys = {
{ "<c-space>", desc = "Increment selection" },
{ "<bs>", desc = "Decrement selection", mode = "x" },
},
config = function(_, opts) config = function(_, opts)
require("nvim-treesitter.install").compilers = { "gcc", "clang" }
if type(opts.ensure_installed) == "table" then if type(opts.ensure_installed) == "table" then
---@type table<string, boolean> ---@type table<string, boolean>
local added = {} local added = {}
@ -126,28 +85,42 @@ return {
end, opts.ensure_installed) end, opts.ensure_installed)
end end
require("nvim-treesitter.configs").setup(opts) require("nvim-treesitter.configs").setup(opts)
-- vim.schedule(function()
-- require("lazy").load({ plugins = { "nvim-treesitter-textobjects" } })
-- end)
end,
},
if load_textobjects then -- {
-- PERF: no need to load the plugin, if we only need its queries for mini.ai -- "nvim-treesitter/playground",
if opts.textobjects then -- },
for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do {
if opts.textobjects[mod] and opts.textobjects[mod].enable then "nvim-treesitter/nvim-treesitter-textobjects",
local Loader = require("lazy.core.loader") lazy = true,
Loader.disabled_rtp_plugins["nvim-treesitter-textobjects"] = nil config = function()
local plugin = require("lazy.core.config").plugins["nvim-treesitter-textobjects"] -- When in diff mode, we want to use the default
require("lazy.core.loader").source_runtime(plugin.dir, "plugin") -- vim text objects c & C instead of the treesitter ones.
break local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
local configs = require("nvim-treesitter.configs")
for name, fn in pairs(move) do
if name:find("goto") == 1 then
move[name] = function(q, ...)
if vim.wo.diff then
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
for key, query in pairs(config or {}) do
if q == query and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key)
return
end
end
end end
return fn(q, ...)
end end
end end
end end
end, end,
}, },
{
"nvim-treesitter/playground",
},
{ {
"nvim-treesitter/nvim-treesitter-context", "nvim-treesitter/nvim-treesitter-context",
opts = { opts = {

View file

@ -225,10 +225,6 @@ return {
}, },
}, },
{
"theprimeagen/refactoring.nvim",
},
{ {
"github/copilot.vim", "github/copilot.vim",
init = function() init = function()
@ -242,12 +238,9 @@ return {
end, end,
}, },
{
"eandrju/cellular-automaton.nvim",
},
{ {
"mbbill/undotree", "mbbill/undotree",
cmd = { "UndotreeToggle" },
}, },
{ {

205
lua/rayandrew/root.lua Normal file
View file

@ -0,0 +1,205 @@
local lazy_util = require("lazy.util")
---@class lazyvim.util.root
---@overload fun(): string
local M = setmetatable({}, {
__call = function(m)
return m.get()
end,
})
---@class LazyRoot
---@field paths string[]
---@field spec LazyRootSpec
---@alias LazyRootFn fun(buf: number): (string|string[])
---@alias LazyRootSpec string|string[]|LazyRootFn
---@type LazyRootSpec[]
M.spec = { "lsp", { ".git", "lua" }, "cwd" }
M.detectors = {}
function M.detectors.cwd()
return { vim.uv.cwd() }
end
function M.detectors.lsp(buf)
local bufpath = M.bufpath(buf)
if not bufpath then
return {}
end
local roots = {} ---@type string[]
for _, client in pairs(LazyVim.lsp.get_clients({ bufnr = buf })) do
-- only check workspace folders, since we're not interested in clients
-- running in single file mode
local workspace = client.config.workspace_folders
for _, ws in pairs(workspace or {}) do
roots[#roots + 1] = vim.uri_to_fname(ws.uri)
end
end
return vim.tbl_filter(function(path)
path = lazy_util.norm(path)
return path and bufpath:find(path, 1, true) == 1
end, roots)
end
---@param patterns string[]|string
function M.detectors.pattern(buf, patterns)
patterns = type(patterns) == "string" and { patterns } or patterns
local path = M.bufpath(buf) or vim.uv.cwd()
local pattern = vim.fs.find(function(name)
for _, p in ipairs(patterns) do
if name == p then
return true
end
if p:sub(1, 1) == "*" and name:find(p:sub(2) .. "$") then
return true
end
end
return false
end, { path = path, upward = true })[1]
return pattern and { vim.fs.dirname(pattern) } or {}
end
function M.bufpath(buf)
return M.realpath(vim.api.nvim_buf_get_name(assert(buf)))
end
function M.cwd()
return M.realpath(vim.uv.cwd()) or ""
end
function M.realpath(path)
if path == "" or path == nil then
return nil
end
path = vim.uv.fs_realpath(path) or path
return lazy_util.norm(path)
end
---@param spec LazyRootSpec
---@return LazyRootFn
function M.resolve(spec)
if M.detectors[spec] then
return M.detectors[spec]
elseif type(spec) == "function" then
return spec
end
return function(buf)
return M.detectors.pattern(buf, spec)
end
end
---@param opts? { buf?: number, spec?: LazyRootSpec[], all?: boolean }
function M.detect(opts)
opts = opts or {}
opts.spec = opts.spec or type(vim.g.root_spec) == "table" and vim.g.root_spec or M.spec
opts.buf = (opts.buf == nil or opts.buf == 0) and vim.api.nvim_get_current_buf() or opts.buf
local ret = {} ---@type LazyRoot[]
for _, spec in ipairs(opts.spec) do
local paths = M.resolve(spec)(opts.buf)
paths = paths or {}
paths = type(paths) == "table" and paths or { paths }
local roots = {} ---@type string[]
for _, p in ipairs(paths) do
local pp = M.realpath(p)
if pp and not vim.tbl_contains(roots, pp) then
roots[#roots + 1] = pp
end
end
table.sort(roots, function(a, b)
return #a > #b
end)
if #roots > 0 then
ret[#ret + 1] = { spec = spec, paths = roots }
if opts.all == false then
break
end
end
end
return ret
end
function M.info()
local spec = type(vim.g.root_spec) == "table" and vim.g.root_spec or M.spec
local roots = M.detect({ all = true })
local lines = {} ---@type string[]
local first = true
for _, root in ipairs(roots) do
for _, path in ipairs(root.paths) do
lines[#lines + 1] = ("- [%s] `%s` **(%s)**"):format(
first and "x" or " ",
path,
type(root.spec) == "table" and table.concat(root.spec, ", ") or root.spec
)
first = false
end
end
lines[#lines + 1] = "```lua"
lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec)
lines[#lines + 1] = "```"
LazyVim.info(lines, { title = "LazyVim Roots" })
return roots[1] and roots[1].paths[1] or vim.uv.cwd()
end
---@type table<number, string>
M.cache = {}
function M.setup()
vim.api.nvim_create_user_command("LazyRoot", function()
LazyVim.root.info()
end, { desc = "LazyVim roots for the current buffer" })
-- FIX: doesn't properly clear cache in neo-tree `set_root` (which should happen presumably on `DirChanged`),
-- probably because the event is triggered in the neo-tree buffer, therefore add `BufEnter`
-- Maybe this is too frequent on `BufEnter` and something else should be done instead??
vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged", "BufEnter" }, {
group = vim.api.nvim_create_augroup("lazyvim_root_cache", { clear = true }),
callback = function(event)
M.cache[event.buf] = nil
end,
})
end
-- returns the root directory based on:
-- * lsp workspace folders
-- * lsp root_dir
-- * root pattern of filename of the current buffer
-- * root pattern of cwd
---@param opts? {normalize?:boolean}
---@return string
function M.get(opts)
local buf = vim.api.nvim_get_current_buf()
local ret = M.cache[buf]
if not ret then
local roots = M.detect({ all = false })
ret = roots[1] and roots[1].paths[1] or vim.uv.cwd()
M.cache[buf] = ret
end
if opts and opts.normalize then
return ret
end
return M.is_win() and ret:gsub("/", "\\") or ret
end
function M.is_win()
return vim.uv.os_uname().sysname:find("Windows") ~= nil
end
function M.git()
local root = M.get()
local git_root = vim.fs.find(".git", { path = root, upward = true })[1]
local ret = git_root and vim.fn.fnamemodify(git_root, ":h") or root
return ret
end
---@param opts? {hl_last?: string}
function M.pretty_path(opts)
return ""
end
return M

View file

@ -3,7 +3,8 @@ local M = {}
-- M.colorscheme = "rose-pine" -- M.colorscheme = "rose-pine"
-- M.colorscheme = "meh" -- M.colorscheme = "meh"
-- M.colorscheme = "rasmus" -- M.colorscheme = "rasmus"
M.colorscheme = "everforest" -- M.colorscheme = "everforest"
M.colorscheme = "gruber-darker"
M.background = "dark" M.background = "dark"
-- M.colorscheme = "" -- M.colorscheme = ""

View file

@ -3,6 +3,7 @@ local M = {}
local lsps = { local lsps = {
lua = { "lua-language-server" }, lua = { "lua-language-server" },
python = { "pyright" }, python = { "pyright" },
rust = { "rust_analyzer" },
} }
-- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234 -- https://github.com/chrisgrieser/.config/blob/7dc36c350976010b32ece078edd581687634811a/nvim/lua/plugins/linter-formatter.lua#L214-L234
@ -40,6 +41,7 @@ M.formatters = {
nix = { "alejandra" }, nix = { "alejandra" },
yaml = { "prettier" }, yaml = { "prettier" },
html = { "prettier" }, html = { "prettier" },
rust = { "rustfmt" },
markdown = { markdown = {
"markdown-toc", "markdown-toc",
"markdownlint", "markdownlint",

View file

@ -1,3 +1,5 @@
local root = require("rayandrew.root")
-- shamelessly copied from -- shamelessly copied from
-- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/util/init.lua -- https://github.com/LazyVim/LazyVim/blob/main/lua/lazyvim/util/init.lua
@ -88,30 +90,76 @@ function M.get_root()
return root return root
end end
-- function M.telescope(builtin, opts)
-- local params = { builtin = builtin, opts = opts }
-- return function()
-- builtin = params.builtin
-- opts = params.opts
-- opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {})
-- if builtin == "files" then
-- if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then
-- opts.show_untracked = true
-- builtin = "git_files"
-- else
-- builtin = "find_files"
-- end
-- end
-- if opts.cwd and opts.cwd ~= vim.loop.cwd() then
-- opts.attach_mappings = function(_, map)
-- map("i", "<a-c>", function()
-- local action_state = require("telescope.actions.state")
-- local line = action_state.get_current_line()
-- M.telescope(
-- params.builtin,
-- vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line })
-- )()
-- end)
-- return true
-- end
-- end
--
-- require("telescope.builtin")[builtin](opts)
-- end
-- end
-- this will return a function that calls telescope.
-- cwd will default to lazyvim.util.get_root
-- for `files`, git_files or find_files will be chosen depending on .git
---@param builtin string
---@param opts? lazyvim.util.telescope.opts
function M.telescope(builtin, opts) function M.telescope(builtin, opts)
local params = { builtin = builtin, opts = opts } local params = { builtin = builtin, opts = opts }
return function() return function()
builtin = params.builtin builtin = params.builtin
opts = params.opts opts = params.opts
opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}) opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {}) --[[@as lazyvim.util.telescope.opts]]
if builtin == "files" then if builtin == "files" then
if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then if
opts.show_untracked = true vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.git")
and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.ignore")
and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.rgignore")
then
if opts.show_untracked == nil then
opts.show_untracked = true
end
builtin = "git_files" builtin = "git_files"
else else
builtin = "find_files" builtin = "find_files"
end end
end end
if opts.cwd and opts.cwd ~= vim.loop.cwd() then if opts.cwd and opts.cwd ~= vim.uv.cwd() then
local function open_cwd_dir()
local action_state = require("telescope.actions.state")
local line = action_state.get_current_line()
M.telescope(
params.builtin,
vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line })
)()
end
---@diagnostic disable-next-line: inject-field
opts.attach_mappings = function(_, map) opts.attach_mappings = function(_, map)
map("i", "<a-c>", function() -- opts.desc is overridden by telescope, until it's changed there is this fix
local action_state = require("telescope.actions.state") map("i", "<a-c>", open_cwd_dir, { desc = "Open cwd Directory" })
local line = action_state.get_current_line()
M.telescope(
params.builtin,
vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line })
)()
end)
return true return true
end end
end end
@ -177,4 +225,41 @@ function M.on_very_lazy(fn)
}) })
end end
function M.lazy_file()
-- This autocmd will only trigger when a file was loaded from the cmdline.
-- It will render the file as quickly as possible.
vim.api.nvim_create_autocmd("BufReadPost", {
once = true,
callback = function(event)
-- Skip if we already entered vim
if vim.v.vim_did_enter == 1 then
return
end
-- Try to guess the filetype (may change later on during Neovim startup)
local ft = vim.filetype.match({ buf = event.buf })
if ft then
-- Add treesitter highlights and fallback to syntax
local lang = vim.treesitter.language.get_lang(ft)
if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then
vim.bo[event.buf].syntax = ft
end
-- Trigger early redraw
vim.cmd([[redraw]])
end
end,
})
-- Add support for the LazyFile event
local Event = require("lazy.core.handler.event")
Event.mappings.LazyFile = { id = "LazyFile", event = M.lazy_file_events }
Event.mappings["User LazyFile"] = Event.mappings.LazyFile
end
function M.setup()
-- M.lazy_file()
end
return M return M