diff --git a/init.lua b/init.lua index 839a36b..d81d753 100644 --- a/init.lua +++ b/init.lua @@ -1,16 +1,9 @@ -local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim" -if not vim.loop.fs_stat(lazypath) then - vim.fn.system({ - "git", - "clone", - "--filter=blob:none", - "--single-branch", - "https://github.com/folke/lazy.nvim.git", - lazypath, - }) -end vim.g.mapleader = "," -vim.opt.runtimepath:prepend(lazypath) + +local github = function(repo) + return "https://github.com/" .. repo +end + vim.opt.winborder = "rounded" vim.opt.relativenumber = true vim.opt.number = true @@ -41,7 +34,143 @@ vim.o.clipboard = "unnamedplus" -- Persistent undos vim.opt.undofile = true vim.filetype.add({ extension = { mdx = "mdx", service = "systemd", templ = "templ" } }) -require("lazy").setup("plugins") +vim.opt.packpath:prepend(vim.fn.stdpath("data") .. "/site") + +vim.pack.add({ + github("neovim/nvim-lspconfig"), + { src = github("mrcjkb/rustaceanvim"), version = vim.version.range("^9") }, + github("nvim-lua/plenary.nvim"), + github("Saecki/crates.nvim"), + github("ziglang/zig.vim"), + { src = github("saghen/blink.cmp"), version = vim.version.range("1.*") }, + github("EdenEast/nightfox.nvim"), + github("ethanholz/nvim-lastplace"), + github("folke/which-key.nvim"), + github("folke/snacks.nvim"), + github("echasnovski/mini.icons"), + github("folke/lsp-trouble.nvim"), + github("stevearc/conform.nvim"), + github("nvim-lualine/lualine.nvim"), + github("nvim-treesitter/nvim-treesitter"), + github("nvim-treesitter/nvim-treesitter-context"), +}, { confirm = false, load = true }) + +local nts = require("nvim-treesitter") +local ts_parsers = { + "astro", + "bash", + "c", + "dockerfile", + "gitcommit", + "go", + "gomod", + "lua", + "python", + "query", + "rust", + "toml", + "yaml", + "just", +} +nts.setup({ + install_dir = vim.fn.stdpath("data") .. "/site", +}) +nts.install(ts_parsers) +vim.api.nvim_create_autocmd("PackChanged", { + callback = function(event) + if + event.data.spec.name == "nvim-treesitter" + and (event.data.kind == "install" or event.data.kind == "update") + then + nts.update() + end + end, +}) +vim.api.nvim_create_autocmd("FileType", { + pattern = ts_parsers, + callback = function() + pcall(vim.treesitter.start) + end, +}) + +require("snacks").setup({ + input = {}, + picker = { + sources = { + files = { + exclude = { "*.lock" }, + }, + grep = { + exclude = { "*.lock" }, + }, + }, + }, + indent = { + animate = { + enabled = false, + }, + }, + explorer = {}, + notifier = {}, +}) + +require("mini.icons").setup() +require("trouble").setup() + +require("blink.cmp").setup({ + completion = { + documentation = { + auto_show = true, + auto_show_delay_ms = 500, + }, + }, + keymap = { + preset = "default", + [""] = { "select_next", "fallback" }, + [""] = { "select_prev", "fallback" }, + }, +}) +require("crates").setup({ + lsp = { + enabled = true, + actions = true, + completion = true, + hover = true, + }, +}) +require("nvim-lastplace").setup() +require("which-key").setup() +vim.opt.cmdheight = 1 +vim.opt.laststatus = 3 +require("lualine").setup({ + options = { + component_separators = { left = "|", right = "|" }, + section_separators = "", + }, +}) +vim.cmd.colorscheme("carbonfox") + +local conform_folder = "/Users/ethan/Documents/work/openfe/openfe" +local cwd = vim.fs.normalize(vim.loop.cwd() or "") +conform_folder = vim.fs.normalize(conform_folder) +if cwd:sub(1, #conform_folder) ~= conform_folder then + require("conform").setup({ + formatters_by_ft = { + lua = { "stylua" }, + python = { "ruff_format" }, + terraform = { "tofu_fmt" }, + astro = { "prettierd", "prettier", stop_after_first = true }, + svelte = { "prettierd", "prettier", stop_after_first = true }, + typescript = { "prettierd", "prettier", stop_after_first = true }, + javascript = { "prettierd", "prettier", stop_after_first = true }, + }, + format_on_save = { + timeout_ms = 500, + lsp_fallback = true, + }, + }) +end + require("mappings") require("lsp") diff --git a/lazy-lock.json b/lazy-lock.json deleted file mode 100644 index 03898f5..0000000 --- a/lazy-lock.json +++ /dev/null @@ -1,22 +0,0 @@ -{ - "blink.cmp": { "branch": "main", "commit": "78336bc89ee5365633bcf754d93df01678b5c08f" }, - "conform.nvim": { "branch": "master", "commit": "619363c30309d29ffa631e67c8183f2a72caa373" }, - "crates.nvim": { "branch": "main", "commit": "694357861ec9ebf12475ddcdd04ea45a0923c32d" }, - "gitsigns.nvim": { "branch": "main", "commit": "dd3f588bacbeb041be6facf1742e42097f62165d" }, - "harpoon": { "branch": "master", "commit": "1bc17e3e42ea3c46b33c0bbad6a880792692a1b3" }, - "lazy.nvim": { "branch": "main", "commit": "306a05526ada86a7b30af95c5cc81ffba93fef97" }, - "lsp-trouble.nvim": { "branch": "main", "commit": "bd67efe408d4816e25e8491cc5ad4088e708a69a" }, - "lualine.nvim": { "branch": "master", "commit": "221ce6b2d999187044529f49da6554a92f740a96" }, - "mini.icons": { "branch": "main", "commit": "520995f1d75da0e4cc901ee95080b1ff2bc46b94" }, - "nightfox.nvim": { "branch": "main", "commit": "26b61b1f856ec37cae3cb64f5690adb955f246a1" }, - "nvim-lastplace": { "branch": "main", "commit": "0bb6103c506315044872e0f84b1f736c4172bb20" }, - "nvim-lspconfig": { "branch": "master", "commit": "9573948c38bfabeec353ae7dd7d3ffec4c506a6b" }, - "nvim-treesitter": { "branch": "main", "commit": "4916d6592ede8c07973490d9322f187e07dfefac" }, - "nvim-treesitter-context": { "branch": "master", "commit": "b311b30818951d01f7b4bf650521b868b3fece16" }, - "plenary.nvim": { "branch": "master", "commit": "74b06c6c75e4eeb3108ec01852001636d85a932b" }, - "rustaceanvim": { "branch": "master", "commit": "a60811ae6054ba981cb4693aaecd715dea783327" }, - "snacks.nvim": { "branch": "main", "commit": "882c996cf28183f4d63640de0b4c02ec886d01f2" }, - "vim-fugitive": { "branch": "master", "commit": "3b753cf8c6a4dcde6edee8827d464ba9b8c4a6f0" }, - "which-key.nvim": { "branch": "main", "commit": "3aab2147e74890957785941f0c1ad87d0a44c15a" }, - "zig.vim": { "branch": "master", "commit": "1a1112eec20e28c832a06ddb1d0060f6ce652372" } -} diff --git a/lua/mappings.lua b/lua/mappings.lua index 6625100..872774b 100644 --- a/lua/mappings.lua +++ b/lua/mappings.lua @@ -14,6 +14,30 @@ map({ "n", "v" }, "p", '"+p', { desc = "Paste from clipboard" }) map({ "n", "v" }, "y", '"+y', { desc = "Yank to clipboard" }) map("t", "", "", { desc = "Exit terminal" }) map("n", "zz", "ZenMode", { desc = "Toggle ZendMode" }) +map("n", "ff", function() + Snacks.picker.files() +end, { desc = "Find files" }) +map("n", "fg", function() + Snacks.picker.grep() +end, { desc = "Grep" }) +map("n", "fb", function() + Snacks.picker.buffers() +end, { desc = "Buffers" }) +map("n", "s", function() + Snacks.picker.spelling() +end, { desc = "Spelling" }) +map("n", "gr", function() + Snacks.picker.lsp_references() +end, { desc = "References" }) +map("n", "gi", function() + Snacks.picker.lsp_implementations() +end, { desc = "Implementations" }) +map("n", "e", function() + Snacks.explorer.open() +end, { desc = "File Explorer" }) +map("n", "xx", "Trouble diagnostics toggle", { + desc = "Diagnostics (Trouble)", +}) -- Register LSP mappings vim.api.nvim_create_autocmd("LspAttach", { diff --git a/lua/plugins/conform.lua b/lua/plugins/conform.lua deleted file mode 100644 index 57ad824..0000000 --- a/lua/plugins/conform.lua +++ /dev/null @@ -1,33 +0,0 @@ -return { - { - "stevearc/conform.nvim", - cond = function() - local folder = "/Users/ethan/Documents/work/openfe/openfe" - local cwd = vim.loop.cwd() -- current working directory - -- Normalize both paths - local function normalize(path) - return vim.fs.normalize(path or "") - end - cwd = normalize(cwd) - folder = normalize(folder) - - -- Check if cwd starts with folder path - return cwd:sub(1, #folder) ~= folder - end, - opts = { - formatters_by_ft = { - lua = { "stylua" }, - python = { "ruff_format" }, - terraform = { "tofu_fmt" }, - astro = { "prettierd", "prettier", stop_after_first = true }, - svelte = { "prettierd", "prettier", stop_after_first = true }, - typescript = { "prettierd", "prettier", stop_after_first = true }, - javascript = { "prettierd", "prettier", stop_after_first = true }, - }, - format_on_save = { - timeout_ms = 500, - lsp_fallback = true, - }, - }, - }, -} diff --git a/lua/plugins/git.lua b/lua/plugins/git.lua deleted file mode 100644 index 9316246..0000000 --- a/lua/plugins/git.lua +++ /dev/null @@ -1,43 +0,0 @@ -return { - -- Git - { - "tpope/vim-fugitive", - cmd = "Git", - keys = { - { "gg", vim.cmd.Git, desc = "Open vim-fugitive" }, - }, - }, - { - "lewis6991/gitsigns.nvim", - lazy = true, - event = "BufReadPre", - opts = { - on_attach = function(bufnr) - local signs = require("gitsigns") - local function map(mode, l, r, opts) - opts = opts or {} - opts.buffer = bufnr - if type(mode) == "table" then - for _, m in ipairs(mode) do - vim.keymap.set(m, l, r, opts) - end - else - vim.keymap.set(mode, l, r, opts) - end - end - map({ "v", "n" }, "gsh", function() - signs.stage_hunk({ vim.fn.line("."), vim.fn.line("v") }) - end, { desc = "Stage hunk" }) - map("n", "gsb", signs.stage_buffer, { desc = "Stage buffer" }) - map({ "v", "n" }, "gsr", function() - require("gitsigns").reset_hunk({ vim.fn.line("."), vim.fn.line("v") }) - end, { desc = "Reset hunk" }) - map("n", "gb", signs.blame_line, { desc = "Blame Line" }) - end, - current_line_blame = true, - current_line_blame_opts = { - delay = "250", - }, - }, - }, -} diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua deleted file mode 100644 index 16d9526..0000000 --- a/lua/plugins/harpoon.lua +++ /dev/null @@ -1,62 +0,0 @@ -return { - { - "ThePrimeagen/harpoon", - opts = { - tabline = true, - }, - dependencies = { - { "nvim-lua/plenary.nvim" }, - }, - keys = { - { - "m", - function() - require("harpoon.mark").add_file() - end, - desc = "Harpoon Mark", - }, - { - "q", - function() - require("harpoon.ui").toggle_quick_menu() - end, - desc = "Harpoon Quick Menu", - }, - { - "1", - function() - require("harpoon.ui").nav_file(1) - end, - desc = "Harpoon 1", - }, - { - "2", - function() - require("harpoon.ui").nav_file(2) - end, - desc = "Harpoon 2", - }, - { - "3", - function() - require("harpoon.ui").nav_file(3) - end, - desc = "Harpoon 3", - }, - { - "4", - function() - require("harpoon.ui").nav_file(4) - end, - desc = "Harpoon 4", - }, - { - "5", - function() - require("harpoon.ui").nav_file(5) - end, - desc = "Harpoon 5", - }, - }, - }, -} diff --git a/lua/plugins/init.lua b/lua/plugins/init.lua deleted file mode 100644 index 8c8ac6e..0000000 --- a/lua/plugins/init.lua +++ /dev/null @@ -1,58 +0,0 @@ -return { - { "neovim/nvim-lspconfig" }, - { - "mrcjkb/rustaceanvim", - version = "^9", - lazy = false, - ft = { "rust" }, - }, - -- Filetype plugins - { - "Saecki/crates.nvim", - event = "BufRead Cargo.toml", - dependencies = { "nvim-lua/plenary.nvim" }, - opts = { - lsp = { - enabled = true, - actions = true, - completion = true, - hover = true, - }, - }, - }, - "ziglang/zig.vim", - - { - "saghen/blink.cmp", - version = "1.*", - opts = { - completion = { - documentation = { - auto_show = true, - auto_show_delay_ms = 500, - }, - }, - keymap = { - preset = "default", - [""] = { "select_next", "fallback" }, - [""] = { "select_prev", "fallback" }, - }, - }, - }, - -- UI - { - "EdenEast/nightfox.nvim", - config = function() - -- NOTE: you do not need to call setup if you don't want to. - vim.cmd.colorscheme("carbonfox") - end, - }, - { - "ethanholz/nvim-lastplace", - config = true, - }, - { - "folke/which-key.nvim", - config = true, - }, -} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua deleted file mode 100644 index 4d360a4..0000000 --- a/lua/plugins/lualine.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - { - "nvim-lualine/lualine.nvim", - config = function() - vim.opt.cmdheight = 1 - vim.opt.laststatus = 3 - require("lualine").setup({ - options = { - component_separators = { left = "|", right = "|" }, - section_separators = "", - }, - }) - end, - }, -} diff --git a/lua/plugins/snacks.lua b/lua/plugins/snacks.lua deleted file mode 100644 index 60103bb..0000000 --- a/lua/plugins/snacks.lua +++ /dev/null @@ -1,76 +0,0 @@ -return { - { - "folke/snacks.nvim", - opts = { - input = {}, - picker = { - sources = { - files = { - exclude = { "*.lock" }, - }, - grep = { - exclude = { "*.lock" }, - }, - }, - }, - indent = { - animate = { - enabled = false, - }, - }, - explorer = {}, - notifier = {}, - }, - keys = { - { - "ff", - function() - Snacks.picker.files() - end, - desc = "Find files", - }, - { - "fg", - function() - Snacks.picker.grep() - end, - desc = "Grep", - }, - { - "fb", - function() - Snacks.picker.buffers() - end, - desc = "Buffers", - }, - { - "s", - function() - Snacks.picker.spelling() - end, - desc = "Spelling", - }, - { - "gr", - function() - Snacks.picker.lsp_references() - end, - desc = "References", - }, - { - "gi", - function() - Snacks.picker.lsp_implementations() - end, - desc = "Implementations", - }, - { - "e", - function() - Snacks.explorer.open() - end, - desc = "File Explorer", - }, - }, - }, -} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua deleted file mode 100644 index 61a0674..0000000 --- a/lua/plugins/treesitter.lua +++ /dev/null @@ -1,53 +0,0 @@ -return { - "nvim-treesitter/nvim-treesitter", - build = ":TSUpdate", - branch = "main", - lazy = false, - config = function() - require("nvim-treesitter.configs").setup({ - ensure_installed = { - "astro", - "bash", - "c", - "dockerfile", - "gitcommit", - "go", - "gomod", - "lua", - "python", - "query", - "rust", - "toml", - "yaml", - "just", - }, - highlight = { - enable = true, - }, - playground = { - enable = true, - }, - -- Potentially remove, this is not really in my roation yet - incremental_selection = { - enable = true, - keymaps = { - init_selection = "", - node_incremental = "", - scope_incremental = "", - node_decremental = "", - }, - }, - sync_install = false, - auto_install = false, - ignore_install = {}, - modules = {}, - }) - end, - - { - "nvim-treesitter/nvim-treesitter-context", - event = "VeryLazy", - }, - - -- Treesitter Consistent Syntax Highlighting and indent -} diff --git a/lua/plugins/trouble.lua b/lua/plugins/trouble.lua deleted file mode 100644 index 4c750d0..0000000 --- a/lua/plugins/trouble.lua +++ /dev/null @@ -1,15 +0,0 @@ -return { - { - "folke/lsp-trouble.nvim", - config = true, - cmd = "Trouble", - keys = { - { - "xx", - "Trouble diagnostics toggle", - desc = "Diagnostics (Trouble)", - }, - }, - dependencies = { "echasnovski/mini.icons" }, - }, -} diff --git a/nvim-pack-lock.json b/nvim-pack-lock.json new file mode 100644 index 0000000..0045481 --- /dev/null +++ b/nvim-pack-lock.json @@ -0,0 +1,70 @@ +{ + "plugins": { + "blink.cmp": { + "rev": "78336bc89ee5365633bcf754d93df01678b5c08f", + "src": "https://github.com/saghen/blink.cmp", + "version": "1.0.0 - 2.0.0" + }, + "conform.nvim": { + "rev": "619363c30309d29ffa631e67c8183f2a72caa373", + "src": "https://github.com/stevearc/conform.nvim" + }, + "crates.nvim": { + "rev": "694357861ec9ebf12475ddcdd04ea45a0923c32d", + "src": "https://github.com/Saecki/crates.nvim" + }, + "lsp-trouble.nvim": { + "rev": "bd67efe408d4816e25e8491cc5ad4088e708a69a", + "src": "https://github.com/folke/lsp-trouble.nvim" + }, + "lualine.nvim": { + "rev": "221ce6b2d999187044529f49da6554a92f740a96", + "src": "https://github.com/nvim-lualine/lualine.nvim" + }, + "mini.icons": { + "rev": "98faae31e9be1cc054ae63485e58ceb185efcad0", + "src": "https://github.com/echasnovski/mini.icons" + }, + "nightfox.nvim": { + "rev": "4dacd3f0185a2227bdf3b6c0975a8f0bf87cac9a", + "src": "https://github.com/EdenEast/nightfox.nvim" + }, + "nvim-lastplace": { + "rev": "0bb6103c506315044872e0f84b1f736c4172bb20", + "src": "https://github.com/ethanholz/nvim-lastplace" + }, + "nvim-lspconfig": { + "rev": "b7b920947f21339ee41fbb38c79d6445e12900aa", + "src": "https://github.com/neovim/nvim-lspconfig" + }, + "nvim-treesitter": { + "rev": "61df84986b4b4ec469ee745a182e433d49f8c27e", + "src": "https://github.com/nvim-treesitter/nvim-treesitter" + }, + "nvim-treesitter-context": { + "rev": "b311b30818951d01f7b4bf650521b868b3fece16", + "src": "https://github.com/nvim-treesitter/nvim-treesitter-context" + }, + "plenary.nvim": { + "rev": "74b06c6c75e4eeb3108ec01852001636d85a932b", + "src": "https://github.com/nvim-lua/plenary.nvim" + }, + "rustaceanvim": { + "rev": "5a3a4158857ee1f7ec839b6ddd87cc0083a19c5f", + "src": "https://github.com/mrcjkb/rustaceanvim", + "version": "9.0.0 - 10.0.0" + }, + "snacks.nvim": { + "rev": "882c996cf28183f4d63640de0b4c02ec886d01f2", + "src": "https://github.com/folke/snacks.nvim" + }, + "which-key.nvim": { + "rev": "3aab2147e74890957785941f0c1ad87d0a44c15a", + "src": "https://github.com/folke/which-key.nvim" + }, + "zig.vim": { + "rev": "1a1112eec20e28c832a06ddb1d0060f6ce652372", + "src": "https://github.com/ziglang/zig.vim" + } + } +}