From 99280dd226225c1b638bd00dc2b53f9633ce00e2 Mon Sep 17 00:00:00 2001 From: tdback Date: Mon, 11 Nov 2024 22:17:41 -0500 Subject: [PATCH] moved config to personal forge --- after/ftplugin/go.lua | 3 ++ after/ftplugin/html.lua | 3 ++ after/ftplugin/lua.lua | 3 ++ after/ftplugin/markdown.lua | 2 ++ after/ftplugin/nix.lua | 3 ++ after/ftplugin/sh.lua | 3 ++ after/ftplugin/text.lua | 2 ++ init.lua | 1 + lazy-lock.json | 20 +++++++++++++ lua/custom/lazy.lua | 20 +++++++++++++ lua/custom/plugins/cmp.lua | 46 ++++++++++++++++++++++++++++++ lua/custom/plugins/colorscheme.lua | 15 ++++++++++ lua/custom/plugins/lsp.lua | 34 ++++++++++++++++++++++ lua/custom/plugins/mini.lua | 7 +++++ lua/custom/plugins/oil.lua | 15 ++++++++++ lua/custom/plugins/pairs.lua | 7 +++++ lua/custom/plugins/telescope.lua | 17 +++++++++++ lua/custom/plugins/treesitter.lua | 17 +++++++++++ lua/custom/plugins/undotree.lua | 6 ++++ lua/custom/plugins/zenmode.lua | 30 +++++++++++++++++++ plugin/autocmd.lua | 13 +++++++++ plugin/keymaps.lua | 19 ++++++++++++ plugin/options.lua | 37 ++++++++++++++++++++++++ 23 files changed, 323 insertions(+) create mode 100644 after/ftplugin/go.lua create mode 100644 after/ftplugin/html.lua create mode 100644 after/ftplugin/lua.lua create mode 100644 after/ftplugin/markdown.lua create mode 100644 after/ftplugin/nix.lua create mode 100644 after/ftplugin/sh.lua create mode 100644 after/ftplugin/text.lua create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/custom/lazy.lua create mode 100644 lua/custom/plugins/cmp.lua create mode 100644 lua/custom/plugins/colorscheme.lua create mode 100644 lua/custom/plugins/lsp.lua create mode 100644 lua/custom/plugins/mini.lua create mode 100644 lua/custom/plugins/oil.lua create mode 100644 lua/custom/plugins/pairs.lua create mode 100644 lua/custom/plugins/telescope.lua create mode 100644 lua/custom/plugins/treesitter.lua create mode 100644 lua/custom/plugins/undotree.lua create mode 100644 lua/custom/plugins/zenmode.lua create mode 100644 plugin/autocmd.lua create mode 100644 plugin/keymaps.lua create mode 100644 plugin/options.lua diff --git a/after/ftplugin/go.lua b/after/ftplugin/go.lua new file mode 100644 index 0000000..753f08f --- /dev/null +++ b/after/ftplugin/go.lua @@ -0,0 +1,3 @@ +vim.opt_local.shiftwidth = 4 +vim.opt_local.tabstop = 4 +vim.opt_local.expandtab = false diff --git a/after/ftplugin/html.lua b/after/ftplugin/html.lua new file mode 100644 index 0000000..78c5eeb --- /dev/null +++ b/after/ftplugin/html.lua @@ -0,0 +1,3 @@ +vim.opt_local.shiftwidth = 2 +vim.opt_local.tabstop = 2 +vim.opt_local.expandtab = true diff --git a/after/ftplugin/lua.lua b/after/ftplugin/lua.lua new file mode 100644 index 0000000..78c5eeb --- /dev/null +++ b/after/ftplugin/lua.lua @@ -0,0 +1,3 @@ +vim.opt_local.shiftwidth = 2 +vim.opt_local.tabstop = 2 +vim.opt_local.expandtab = true diff --git a/after/ftplugin/markdown.lua b/after/ftplugin/markdown.lua new file mode 100644 index 0000000..9e5828c --- /dev/null +++ b/after/ftplugin/markdown.lua @@ -0,0 +1,2 @@ +vim.opt_local.spell = true +vim.opt_local.textwidth = 79 diff --git a/after/ftplugin/nix.lua b/after/ftplugin/nix.lua new file mode 100644 index 0000000..78c5eeb --- /dev/null +++ b/after/ftplugin/nix.lua @@ -0,0 +1,3 @@ +vim.opt_local.shiftwidth = 2 +vim.opt_local.tabstop = 2 +vim.opt_local.expandtab = true diff --git a/after/ftplugin/sh.lua b/after/ftplugin/sh.lua new file mode 100644 index 0000000..78c5eeb --- /dev/null +++ b/after/ftplugin/sh.lua @@ -0,0 +1,3 @@ +vim.opt_local.shiftwidth = 2 +vim.opt_local.tabstop = 2 +vim.opt_local.expandtab = true diff --git a/after/ftplugin/text.lua b/after/ftplugin/text.lua new file mode 100644 index 0000000..9e5828c --- /dev/null +++ b/after/ftplugin/text.lua @@ -0,0 +1,2 @@ +vim.opt_local.spell = true +vim.opt_local.textwidth = 79 diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..6027699 --- /dev/null +++ b/init.lua @@ -0,0 +1 @@ +require("custom.lazy") diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..f29e101 --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,20 @@ +{ + "LuaSnip": { "branch": "master", "commit": "787dee55ca364cc9119787165418fe93b74c1842" }, + "cmp-buffer": { "branch": "main", "commit": "3022dbc9166796b644a841a02de8dd1cc1d311fa" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "39e2eda76828d88b773cc27a3f61d2ad782c922d" }, + "cmp-path": { "branch": "main", "commit": "91ff86cd9c29299a64f968ebb45846c485725f23" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "lazy.nvim": { "branch": "main", "commit": "cf8ecc2c5e4332760431a33534240b0cbc6680ab" }, + "mini.nvim": { "branch": "main", "commit": "77533e69cc4fadb7f4c25f23255ae0890a058818" }, + "neovim": { "branch": "main", "commit": "07a887a7bef4aacea8c7caebaf8cbf808cdc7a8e" }, + "nvim-autopairs": { "branch": "master", "commit": "ee297f215e95a60b01fde33275cc3c820eddeebe" }, + "nvim-cmp": { "branch": "main", "commit": "29fb4854573355792df9e156cb779f0d31308796" }, + "nvim-lspconfig": { "branch": "master", "commit": "28b205ebe73a18f401e040585106f9bafd8ff21f" }, + "nvim-treesitter": { "branch": "master", "commit": "48fc5d1dfe3dded8028826dfee7526e26212c73b" }, + "nvim-web-devicons": { "branch": "master", "commit": "19d257cf889f79f4022163c3fbb5e08639077bd8" }, + "oil.nvim": { "branch": "master", "commit": "cca1631d5ea450c09ba72f3951a9e28105a3632c" }, + "plenary.nvim": { "branch": "master", "commit": "2d9b06177a975543726ce5c73fca176cedbffe9d" }, + "telescope.nvim": { "branch": "master", "commit": "a0bbec21143c7bc5f8bb02e0005fa0b982edc026" }, + "undotree": { "branch": "master", "commit": "78b5241191852ffa9bb5da5ff2ee033160798c3b" }, + "zen-mode.nvim": { "branch": "main", "commit": "29b292bdc58b76a6c8f294c961a8bf92c5a6ebd6" } +} diff --git a/lua/custom/lazy.lua b/lua/custom/lazy.lua new file mode 100644 index 0000000..2bab63c --- /dev/null +++ b/lua/custom/lazy.lua @@ -0,0 +1,20 @@ +vim.g.mapleader = " " +vim.g.maplocalleader = " " + +local lazypath = vim.fn.stdpath "data" .. "/lazy/lazy.nvim" +if not vim.uv.fs_stat(lazypath) then + vim.fn.system { + "git", + "clone", + "--filter=blob:none", + "--branch=stable", + "https://github.com/folke/lazy.nvim.git", + lazypath, + } +end + +vim.opt.rtp:prepend(lazypath) + +require("lazy").setup({ import = "custom/plugins" }, { + change_detection = { notify = false }, +}) diff --git a/lua/custom/plugins/cmp.lua b/lua/custom/plugins/cmp.lua new file mode 100644 index 0000000..de114fc --- /dev/null +++ b/lua/custom/plugins/cmp.lua @@ -0,0 +1,46 @@ +return { + "hrsh7th/nvim-cmp", + dependencies = { + "hrsh7th/cmp-nvim-lsp", + "hrsh7th/cmp-buffer", + "hrsh7th/cmp-path", + "L3MON4D3/LuaSnip", + "saadparwaiz1/cmp_luasnip", + }, + lazy = false, + config = function() + vim.opt.completeopt = { "menu", "menuone", "noselect" } + vim.opt.shortmess:append("c") + + local cmp = require("cmp") + + cmp.setup({ + preselect = cmp.PreselectMode.Item, + + sources = { + { name = "nvim_lsp" }, + { name = "luasnip" }, + { name = "path" }, + { name = "buffer" }, + }, + + mapping = { + [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), + [""] = cmp.mapping.confirm({ + behavior = cmp.SelectBehavior.Insert, + select = true, + }), + [""] = nil, + [""] = nil, + [""] = nil, + }, + + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + }) + end, +} diff --git a/lua/custom/plugins/colorscheme.lua b/lua/custom/plugins/colorscheme.lua new file mode 100644 index 0000000..f8ed0db --- /dev/null +++ b/lua/custom/plugins/colorscheme.lua @@ -0,0 +1,15 @@ +return { + "rose-pine/neovim", + config = function() + require("rose-pine").setup({ + dim_inactive_windows = true, + styles = { + bold = true, + italic = false, + transparency = true, + }, + }) + + vim.cmd("colorscheme rose-pine") + end, +} diff --git a/lua/custom/plugins/lsp.lua b/lua/custom/plugins/lsp.lua new file mode 100644 index 0000000..aceeb41 --- /dev/null +++ b/lua/custom/plugins/lsp.lua @@ -0,0 +1,34 @@ +return { + "neovim/nvim-lspconfig", + config = function() + local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities()) + + local on_attach = function(client, bufnr) + local opts = { buffer = bufnr, noremap = true, silent = true } + + if client.server_capabilities.inlayHintProvider then + vim.lsp.inlay_hint.enable(true) + end + + vim.diagnostic.config({ virtual_text = true }) + + vim.keymap.set("n", "gd", function() vim.lsp.buf.definition() end, opts) + vim.keymap.set("n", "[d", function() vim.diagnostic.goto_next() end, opts) + vim.keymap.set("n", "]d", function() vim.diagnostic.goto_prev() end, opts) + end + + local lspc = require("lspconfig") + local servers = { + "nixd", + "pylsp", + "clangd", + "gopls", + "rust_analyzer", + "ocamllsp", + } + + for _, s in ipairs(servers) do + lspc[s].setup({ on_attach = on_attach, capabilities = capabilities }) + end + end, +} diff --git a/lua/custom/plugins/mini.lua b/lua/custom/plugins/mini.lua new file mode 100644 index 0000000..084cb02 --- /dev/null +++ b/lua/custom/plugins/mini.lua @@ -0,0 +1,7 @@ +return { + "echasnovski/mini.nvim", + config = function() + require("mini.ai").setup() + require("mini.surround").setup() + end, +} diff --git a/lua/custom/plugins/oil.lua b/lua/custom/plugins/oil.lua new file mode 100644 index 0000000..d5144bf --- /dev/null +++ b/lua/custom/plugins/oil.lua @@ -0,0 +1,15 @@ +return { + 'stevearc/oil.nvim', + dependencies = { "nvim-tree/nvim-web-devicons" }, + config = function() + require("oil").setup({ + default_file_explorer = true, + skip_confirm_for_simple_edits = true, + view_options = { + show_hidden = true, + }, + }) + + vim.keymap.set("n", "-", "Oil", { desc = "Open parent directory" }) + end, +} diff --git a/lua/custom/plugins/pairs.lua b/lua/custom/plugins/pairs.lua new file mode 100644 index 0000000..637b524 --- /dev/null +++ b/lua/custom/plugins/pairs.lua @@ -0,0 +1,7 @@ +return { + "windwp/nvim-autopairs", + event = "InsertEnter", + config = function() + require("nvim-autopairs").setup({ map_c_h = true }) + end, +} diff --git a/lua/custom/plugins/telescope.lua b/lua/custom/plugins/telescope.lua new file mode 100644 index 0000000..8593110 --- /dev/null +++ b/lua/custom/plugins/telescope.lua @@ -0,0 +1,17 @@ +return { + "nvim-telescope/telescope.nvim", + tag = "0.1.8", + dependencies = { + "nvim-lua/plenary.nvim", + }, + config = function() + require("telescope").setup({}) + + local builtin = require("telescope.builtin") + vim.keymap.set("n", "sf", builtin.find_files, { desc = "[s]earch [f]iles" }) + vim.keymap.set("n", "sg", builtin.live_grep, { desc = "[s]earch by [g]rep" }) + vim.keymap.set("n", "sw", builtin.grep_string, { desc = "[s]earch current [w]ord" }) + vim.keymap.set("n", "sb", builtin.buffers, { desc = "[s]earch [b]uffers" }) + vim.keymap.set("n", "sh", builtin.help_tags, { desc = "[s]earch [h]elp" }) + end, +} diff --git a/lua/custom/plugins/treesitter.lua b/lua/custom/plugins/treesitter.lua new file mode 100644 index 0000000..3de7c04 --- /dev/null +++ b/lua/custom/plugins/treesitter.lua @@ -0,0 +1,17 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + lazy = false, + config = function() + require("nvim-treesitter.configs").setup({ + ensure_installed = { "nix", "lua", "bash" }, + auto_install = true, + sync_install = false, + indent = { enable = true }, + highlight = { + enable = true, + additional_vim_regex_highlighting = false, + }, + }) + end, +} diff --git a/lua/custom/plugins/undotree.lua b/lua/custom/plugins/undotree.lua new file mode 100644 index 0000000..fe71c5a --- /dev/null +++ b/lua/custom/plugins/undotree.lua @@ -0,0 +1,6 @@ +return { + "mbbill/undotree", + config = function() + vim.keymap.set("n", "u", vim.cmd.UndotreeToggle) + end, +} diff --git a/lua/custom/plugins/zenmode.lua b/lua/custom/plugins/zenmode.lua new file mode 100644 index 0000000..7f4cc88 --- /dev/null +++ b/lua/custom/plugins/zenmode.lua @@ -0,0 +1,30 @@ +return { + "folke/zen-mode.nvim", + config = function() + vim.keymap.set("n", "zz", function() + require("zen-mode").setup({ + window = { + width = 80, + options = { + signcolumn = "no", + number = false, + relativenumber = false, + wrap = true, + linebreak = true, + cursorline = false, + colorcolumn = "0", + }, + }, + plugins = { + gitsigns = { enabled = false }, + options = { + enabled = true, + ruler = false, + showcmd = false, + }, + }, + }) + require("zen-mode").toggle() + end) + end, +} diff --git a/plugin/autocmd.lua b/plugin/autocmd.lua new file mode 100644 index 0000000..21b5f9f --- /dev/null +++ b/plugin/autocmd.lua @@ -0,0 +1,13 @@ +local autocmd = vim.api.nvim_create_autocmd + +autocmd({ "TextYankPost" }, { + pattern = "*", + callback = function() + vim.highlight.on_yank({ + higroup = "IncSearch", + timeout = 50, + }) + end, +}) + +autocmd({ "BufWritePre" }, { pattern = "*", command = [[%s/\s\+$//e]] }) diff --git a/plugin/keymaps.lua b/plugin/keymaps.lua new file mode 100644 index 0000000..62b6051 --- /dev/null +++ b/plugin/keymaps.lua @@ -0,0 +1,19 @@ +vim.keymap.set("n", "n", "nzzzv") +vim.keymap.set("n", "N", "Nzzzv") +vim.keymap.set("n", "J", "mzJ`z") +vim.keymap.set("v", "J", ":m '>+1gv=gv") +vim.keymap.set("v", "K", ":m '>-2gv=gv") +vim.keymap.set("n", "", "zz") +vim.keymap.set("n", "", "zz") +vim.keymap.set({ "n", "v" }, "d", [["_d]]) +vim.keymap.set("n", "f", vim.lsp.buf.format) +vim.keymap.set("x", "p", [["_dP]]) +vim.keymap.set("n", "hh", ":help") +vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) +vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) +vim.keymap.set({ "n", "v" }, "y", [["+y]]) +vim.keymap.set("n", "Y", [["+Y]]) +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") +vim.keymap.set("n", "", "") diff --git a/plugin/options.lua b/plugin/options.lua new file mode 100644 index 0000000..c349c3a --- /dev/null +++ b/plugin/options.lua @@ -0,0 +1,37 @@ +vim.opt.showcmd = true +vim.opt.scrolloff = 8 +vim.opt.updatetime = 50 + +vim.opt.number = true +vim.opt.relativenumber = true + +vim.opt.shiftwidth = 4 +vim.opt.tabstop = 4 +vim.opt.expandtab = true +vim.opt.smartindent = true + +vim.opt.wrap = false +vim.opt.linebreak = false + +vim.opt.smartcase = true +vim.opt.ignorecase = true +vim.opt.hlsearch = false +vim.opt.incsearch = true + +vim.opt.foldmethod = "syntax" +vim.opt.foldlevel = 99 + +vim.opt.signcolumn = "yes" +vim.opt.colorcolumn = "80" +vim.opt.cursorline = true +vim.opt.cursorlineopt = "number" + +vim.opt.termguicolors = true +vim.opt.isfname:append("@-@") + +vim.opt.swapfile = false +vim.opt.backup = false +vim.opt.undofile = true +vim.opt.undodir = os.getenv("HOME") .. "/.vim/undodir" + +vim.opt.mouse = "va"