From 914f9ea7671afee938b6df9e800c0710edbeb83e Mon Sep 17 00:00:00 2001 From: Dan Chadwick Date: Sun, 3 Mar 2024 18:01:30 -0500 Subject: [PATCH] Initial commit. --- .luarc.json | 5 +++ init.lua | 16 ++++++++ lazy-lock.json | 23 +++++++++++ lua/dan/core.lua | 15 ++++++++ lua/plugins.lua | 2 + lua/plugins/alpha.lua | 76 +++++++++++++++++++++++++++++++++++++ lua/plugins/completions.lua | 44 +++++++++++++++++++++ lua/plugins/harpoon.lua | 38 +++++++++++++++++++ lua/plugins/lazygit.lua | 6 +++ lua/plugins/lsp-config.lua | 33 ++++++++++++++++ lua/plugins/lualine.lua | 13 +++++++ lua/plugins/neotree.lua | 12 ++++++ lua/plugins/rose-pine.lua | 73 +++++++++++++++++++++++++++++++++++ lua/plugins/telescope.lua | 33 ++++++++++++++++ lua/plugins/treesitter.lua | 14 +++++++ 15 files changed, 403 insertions(+) create mode 100644 .luarc.json create mode 100644 init.lua create mode 100644 lazy-lock.json create mode 100644 lua/dan/core.lua create mode 100644 lua/plugins.lua create mode 100644 lua/plugins/alpha.lua create mode 100644 lua/plugins/completions.lua create mode 100644 lua/plugins/harpoon.lua create mode 100644 lua/plugins/lazygit.lua create mode 100644 lua/plugins/lsp-config.lua create mode 100644 lua/plugins/lualine.lua create mode 100644 lua/plugins/neotree.lua create mode 100644 lua/plugins/rose-pine.lua create mode 100644 lua/plugins/telescope.lua create mode 100644 lua/plugins/treesitter.lua diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..1e1765c --- /dev/null +++ b/.luarc.json @@ -0,0 +1,5 @@ +{ + "diagnostics.globals": [ + "vim" + ] +} \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..6a1833d --- /dev/null +++ b/init.lua @@ -0,0 +1,16 @@ +require("dan.core") +-- Lazy VIM -- +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", + "https://github.com/folke/lazy.nvim.git", + "--branch=stable", -- latest stable release + lazypath, + }) +end +vim.opt.rtp:prepend(lazypath) +require("lazy").setup("plugins") + diff --git a/lazy-lock.json b/lazy-lock.json new file mode 100644 index 0000000..40816fd --- /dev/null +++ b/lazy-lock.json @@ -0,0 +1,23 @@ +{ + "LuaSnip": { "branch": "master", "commit": "a7a4b4682c4b3e2ba82b82a4e6e5f5a0e79dec32" }, + "alpha-nvim": { "branch": "main", "commit": "41283fb402713fc8b327e60907f74e46166f4cfd" }, + "cmp-nvim-lsp": { "branch": "main", "commit": "5af77f54de1b16c34b23cba810150689a3a90312" }, + "cmp_luasnip": { "branch": "master", "commit": "05a9ab28b53f71d1aece421ef32fee2cb857a843" }, + "friendly-snippets": { "branch": "main", "commit": "dcd4a586439a1c81357d5b9d26319ae218cc9479" }, + "harpoon": { "branch": "harpoon2", "commit": "a38be6e0dd4c6db66997deab71fc4453ace97f9c" }, + "lazy.nvim": { "branch": "main", "commit": "aedcd79811d491b60d0a6577a9c1701063c2a609" }, + "lazygit.nvim": { "branch": "main", "commit": "10a5f30536dc2d4abe36d410d83149272ea457fa" }, + "lualine.nvim": { "branch": "master", "commit": "7d131a8d3ba5016229e8a1d08bf8782acea98852" }, + "mason-lspconfig.nvim": { "branch": "main", "commit": "21d33d69a81f6351e5a5f49078b2e4f0075c8e73" }, + "mason.nvim": { "branch": "main", "commit": "3b5068f0fc565f337d67a2d315d935f574848ee7" }, + "neo-tree.nvim": { "branch": "v3.x", "commit": "f3941c57ec85d7bdb44fa53fd858fd80f159018f" }, + "nui.nvim": { "branch": "main", "commit": "b81333d12f824dbed5eb231c8a4409a290fdd848" }, + "nvim-cmp": { "branch": "main", "commit": "04e0ca376d6abdbfc8b52180f8ea236cbfddf782" }, + "nvim-lspconfig": { "branch": "master", "commit": "c932a56bf25167b1e88d2a1ebe35bb774b41019a" }, + "nvim-treesitter": { "branch": "master", "commit": "6e2b56cbe75ddf18e6efecee44bc3936d70b0b3e" }, + "nvim-web-devicons": { "branch": "master", "commit": "4adea17610d140a99c313e3f79a9dc01825d59ae" }, + "plenary.nvim": { "branch": "master", "commit": "4f71c0c4a196ceb656c824a70792f3df3ce6bb6d" }, + "rose-pine": { "branch": "main", "commit": "f977eeba34b030b37f93ece2fbd792477606203b" }, + "telescope-ui-select.nvim": { "branch": "master", "commit": "6e51d7da30bd139a6950adf2a47fda6df9fa06d2" }, + "telescope.nvim": { "branch": "master", "commit": "d90956833d7c27e73c621a61f20b29fdb7122709" } +} \ No newline at end of file diff --git a/lua/dan/core.lua b/lua/dan/core.lua new file mode 100644 index 0000000..a93c9c0 --- /dev/null +++ b/lua/dan/core.lua @@ -0,0 +1,15 @@ +vim.g.mapleader = " " +vim.keymap.set("n", "pv", vim.cmd.Ex) +vim.keymap.set("n", "gg", vim.cmd.LazyGit) +vim.cmd("set expandtab") +vim.cmd("set tabstop=2") +vim.cmd("set softtabstop=2") +vim.cmd("set shiftwidth=2") +vim.cmd("set syntax=on") +vim.cmd("set number") +vim.cmd("set nu") +vim.cmd("set relativenumber") +vim.cmd("set rnu") +vim.cmd("set number relativenumber") +vim.cmd("set nu rnu") +vim.api.nvim_set_option("clipboard","unnamed") diff --git a/lua/plugins.lua b/lua/plugins.lua new file mode 100644 index 0000000..97aeadd --- /dev/null +++ b/lua/plugins.lua @@ -0,0 +1,2 @@ +return { +} diff --git a/lua/plugins/alpha.lua b/lua/plugins/alpha.lua new file mode 100644 index 0000000..148d4fc --- /dev/null +++ b/lua/plugins/alpha.lua @@ -0,0 +1,76 @@ +return { + "goolord/alpha-nvim", + event = "VimEnter", -- load plugin after all configuration is set + dependencies = { + "nvim-tree/nvim-web-devicons", + }, + + config = function() + local alpha = require("alpha") + local dashboard = require("alpha.themes.dashboard") + + dashboard.section.header.val = { + [[ ]], + [[ ]], + [[ ]], + [[ ]], + [[ ]], + [[ ]], + [[ ]], + [[  ]], + [[ ████ ██████ █████ ██ ]], + [[ ███████████ █████  ]], + [[ █████████ ███████████████████ ███ ███████████ ]], + [[ █████████ ███ █████████████ █████ ██████████████ ]], + [[ █████████ ██████████ █████████ █████ █████ ████ █████ ]], + [[ ███████████ ███ ███ █████████ █████ █████ ████ █████ ]], + [[ ██████ █████████████████████ ████ █████ █████ ████ ██████ ]], + [[ ]], + [[ ]], + [[ ]], + } + + _Gopts = { + position = "center", + hl = "Type", + -- wrap = "overflow"; + } + + -- Set menu + dashboard.section.buttons.val = { + -- dashboard.button("SPC j", "󰈚 Restore Session", ":SessionRestore"), + dashboard.button("e", " New file", ":ene startinsert "), + dashboard.button("f", " Find file", ":cd $HOME/dotfiles/.config | Telescope find_files"), + dashboard.button("g", "󰱼 Find word", ":Telescope live_grep"), + dashboard.button("r", " Recent", ":Telescope oldfiles"), + dashboard.button("c", " Config", ":e $MYVIMRC "), + dashboard.button("m", "󱌣 Mason", ":Mason"), + dashboard.button("l", "󰒲 Lazy", ":Lazy"), + dashboard.button("u", "󰂖 Update plugins", "lua require('lazy').sync()"), + dashboard.button("q", " Quit NVIM", ":qa"), + } + + --local function footer() + --return "Mohammed Babiker Babai" + --end + + --dashboard.section.footer.val = footer() + + dashboard.opts.opts.noautocmd = true + alpha.setup(dashboard.opts) + + require("alpha").setup(dashboard.opts) + + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimStarted", + callback = function() + local stats = require("lazy").stats() + local count = (math.floor(stats.startuptime * 100) / 100) + dashboard.section.footer.val = { + "󱐌 " .. stats.count .. " plugins loaded in " .. count .. " ms" + } + pcall(vim.cmd.AlphaRedraw) + end, + }) + end, +} diff --git a/lua/plugins/completions.lua b/lua/plugins/completions.lua new file mode 100644 index 0000000..1124107 --- /dev/null +++ b/lua/plugins/completions.lua @@ -0,0 +1,44 @@ +return { + { + "hrsh7th/cmp-nvim-lsp" + }, + { + "L3MON4D3/LuaSnip", + dependencies = { + "saadparwaiz1/cmp_luasnip", + "rafamadriz/friendly-snippets" + } + }, + { + "hrsh7th/nvim-cmp", + config = function() + local cmp = require("cmp") + require("luasnip.loaders.from_vscode").lazy_load() + cmp.setup({ + snippet = { + expand = function(args) + require('luasnip').lsp_expand(args.body) -- For `luasnip` users. + end, + }, + window = { + completion = cmp.config.window.bordered(), + documentation = cmp.config.window.bordered(), + }, + mapping = cmp.mapping.preset.insert({ + [''] = cmp.mapping.scroll_docs(-4), + [''] = cmp.mapping.scroll_docs(4), + [''] = cmp.mapping.complete(), + [''] = cmp.mapping.abort(), + [''] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + }), + sources = cmp.config.sources({ + -- { name = 'nvim_lsp' }, + -- { name = 'vsnip' }, -- For vsnip users. + { name = 'luasnip' }, -- For luasnip users. + }, { + { name = 'buffer' }, + }) + }) + end + }, +} diff --git a/lua/plugins/harpoon.lua b/lua/plugins/harpoon.lua new file mode 100644 index 0000000..afe7ac1 --- /dev/null +++ b/lua/plugins/harpoon.lua @@ -0,0 +1,38 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + dependencies = { + "nvim-lua/plenary.nvim" + }, + config = function() + local harpoon = require("harpoon") + -- REQUIRED + harpoon:setup() + -- REQUIRED + -- basic telescope configuration + local conf = require("telescope.config").values + local function toggle_telescope(harpoon_files) + local file_paths = {} + for _, item in ipairs(harpoon_files.items) do + table.insert(file_paths, item.value) + end + + require("telescope.pickers").new({}, { + prompt_title = "Harpoon", + finder = require("telescope.finders").new_table({ + results = file_paths, + }), + previewer = conf.file_previewer({}), + sorter = conf.generic_sorter({}), + }):find() + end + vim.keymap.set("n", "", function() toggle_telescope(harpoon:list()) end, { desc = "Open harpoon window" }) + vim.keymap.set("n", "a", function() harpoon:list():append() end) + vim.keymap.set("n", "c", function() harpoon:list():clear() end) + vim.keymap.set("n", "r", function() harpoon:list():remove() end) + -- vim.keymap.set("n", "", function() harpoon.ui:toggle_quick_menu(harpoon:list()) end) + -- Toggle previous & next buffers stored within Harpoon list + -- vim.keymap.set("n", "", function() harpoon:list():prev() end) + -- vim.keymap.set("n", "", function() harpoon:list():next() end) + end +} diff --git a/lua/plugins/lazygit.lua b/lua/plugins/lazygit.lua new file mode 100644 index 0000000..348facd --- /dev/null +++ b/lua/plugins/lazygit.lua @@ -0,0 +1,6 @@ +return { + "kdheepak/lazygit.nvim", + dependencies = { + "nvim-lua/plenary.nvim", + } +} diff --git a/lua/plugins/lsp-config.lua b/lua/plugins/lsp-config.lua new file mode 100644 index 0000000..833c92a --- /dev/null +++ b/lua/plugins/lsp-config.lua @@ -0,0 +1,33 @@ +return { + { + "williamboman/mason.nvim", + config = function() + require("mason").setup() + end + }, + { + "williamboman/mason-lspconfig.nvim", + config = function() + require("mason-lspconfig").setup({ + ensure_installed = { "lua_ls", "phpactor" } + }) + end + }, + { + "neovim/nvim-lspconfig", + config = function() + local capabilities = require('cmp_nvim_lsp').default_capabilities() + local lspconfig = require("lspconfig") + lspconfig.lua_ls.setup({ + capabilities = capabilities + }) + lspconfig.phpactor.setup({ + capabilities = capabilities + }) + vim.keymap.set("n", 'K', vim.lsp.buf.hover, {}) + vim.keymap.set('n', 'gd', vim.lsp.buf.definition, {}) + vim.keymap.set({ 'n' }, 'ca', vim.lsp.buf.code_action, {}) + + end + } +} diff --git a/lua/plugins/lualine.lua b/lua/plugins/lualine.lua new file mode 100644 index 0000000..3514c18 --- /dev/null +++ b/lua/plugins/lualine.lua @@ -0,0 +1,13 @@ +return { + 'nvim-lualine/lualine.nvim', + dependencies = { + 'nvim-tree/nvim-web-devicons' + }, + config = function() + require('lualine'). setup({ + options= { + theme = 'dracula' + } + }) + end +} diff --git a/lua/plugins/neotree.lua b/lua/plugins/neotree.lua new file mode 100644 index 0000000..a8e320a --- /dev/null +++ b/lua/plugins/neotree.lua @@ -0,0 +1,12 @@ +return { + "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-tree/nvim-web-devicons", + "MunifTanjim/nui.nvim", + }, + config = function() + vim.keymap.set("n", "", ':Neotree filesystem reveal left', {}) + end +} diff --git a/lua/plugins/rose-pine.lua b/lua/plugins/rose-pine.lua new file mode 100644 index 0000000..de19451 --- /dev/null +++ b/lua/plugins/rose-pine.lua @@ -0,0 +1,73 @@ + return { + 'rose-pine/neovim', + name = 'rose-pine', + config = function() + require("rose-pine").setup({ + variant = "moon", -- auto, main, moon, or dawn + dark_variant = "main", -- main, moon, or dawn + dim_inactive_windows = false, + extend_background_behind_borders = true, + + enable = { + terminal = true, + legacy_highlights = true, -- Improve compatibility for previous versions of Neovim + migrations = true, -- Handle deprecated options automatically + }, + + styles = { + bold = false, + italic = false, + transparency = false, + }, + + groups = { + border = "muted", + link = "iris", + panel = "surface", + + error = "love", + hint = "iris", + info = "foam", + note = "pine", + todo = "rose", + warn = "gold", + + git_add = "foam", + git_change = "rose", + git_delete = "love", + git_dirty = "rose", + git_ignore = "muted", + git_merge = "iris", + git_rename = "pine", + git_stage = "iris", + git_text = "rose", + git_untracked = "subtle", + + h1 = "iris", + h2 = "foam", + h3 = "rose", + h4 = "gold", + h5 = "pine", + h6 = "foam", + }, + + highlight_groups = { + -- Comment = { fg = "foam" }, + -- VertSplit = { fg = "muted", bg = "muted" }, + }, + + before_highlight = function(group, highlight, palette) + -- Disable all undercurls + -- if highlight.undercurl then + -- highlight.undercurl = false + -- end + -- + -- Change palette colour -- if highlight.fg == palette.pine then + -- highlight.fg = palette.foam + -- end + end, + }) + vim.cmd("colorscheme rose-pine") + end + } + diff --git a/lua/plugins/telescope.lua b/lua/plugins/telescope.lua new file mode 100644 index 0000000..05a7568 --- /dev/null +++ b/lua/plugins/telescope.lua @@ -0,0 +1,33 @@ +return { + { + 'nvim-telescope/telescope.nvim', + tag = '0.1.5', + dependencies = { + 'nvim-lua/plenary.nvim' + }, + config = function() + local builtin = require('telescope.builtin') + vim.keymap.set('n', 'ff', builtin.find_files, {}) + vim.keymap.set('n', 'fg', builtin.live_grep, {}) + vim.keymap.set('n', 'fb', builtin.buffers, {}) + vim.keymap.set('n', 'fh', builtin.help_tags, {}) + end + }, + { + "nvim-telescope/telescope-ui-select.nvim", + config = function() + -- This is your opts table + require("telescope").setup { + extensions = { + ["ui-select"] = { + require("telescope.themes").get_dropdown { + } + } + } + } + -- To get ui-select loaded and working with telescope, you need to call + -- load_extension, somewhere after setup function: + require("telescope").load_extension("ui-select") + end + } +} diff --git a/lua/plugins/treesitter.lua b/lua/plugins/treesitter.lua new file mode 100644 index 0000000..da75628 --- /dev/null +++ b/lua/plugins/treesitter.lua @@ -0,0 +1,14 @@ +return { + "nvim-treesitter/nvim-treesitter", + build = ":TSUpdate", + config = function() + local configs = require("nvim-treesitter.configs") + configs.setup({ + ensure_installed = { "php", "lua", "vim", "javascript", "html", "yaml" }, + sync_install = false, + highlight = { enable = true }, + indent = { enable = true }, + }) + end +} +