Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatically bootstrap Neovim when Neovim is started. #52

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ about though i would just suggest `git log -S`).
* [4a96e645](https://github.com/ThePrimeagen/init.lua/commit/4a96e6457b0a0241ca7361ce62177aa6b9a33a38) fugitive mappings for push and pull
* [a3bad06a](https://github.com/ThePrimeagen/init.lua/commit/a3bad06a4681c322538d609aa1c0bd18880f77c6) disabled eslint. driving me crazy

### Extra credit (only for the fearless!!)
### Automatically bootstrap my configuration with two steps.
1. ./dev
2. nvim

#### 100% Pure Coconut Oil.
The two steps above will completely remove your Neovim endowment and then reload
it. The first Neovim run loads all packages, and the second run causes
Treesitter to install language highlighting.
42 changes: 22 additions & 20 deletions after/plugin/cloak.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
require("cloak").setup({
enabled = true,
cloak_character = "*",
-- The applied highlight group (colors) on the cloaking, see `:h highlight`.
highlight_group = "Comment",
patterns = {
{
-- Match any file starting with ".env".
-- This can be a table to match multiple file patterns.
file_pattern = {
".env*",
"wrangler.toml",
".dev.vars",
},
-- Match an equals sign and any character after it.
-- This can also be a table of patterns to cloak,
-- example: cloak_pattern = { ":.+", "-.+" } for yaml files.
cloak_pattern = "=.+"
local ok, plugin = pcall(require, 'cloak')
if not ok then return end

plugin.setup({
enabled = true,
cloak_character = "*",
-- The applied highlight group (colors) on the cloaking, see `:h highlight`.
highlight_group = "Comment",
patterns = {
{
-- Match any file starting with ".env".
-- This can be a table to match multiple file patterns.
file_pattern = {
".env*",
"wrangler.toml",
".dev.vars",
},
-- Match an equals sign and any character after it.
-- This can also be a table of patterns to cloak,
-- example: cloak_pattern = { ":.+", "-.+" } for yaml files.
cloak_pattern = "=.+"
},
},
},
})

7 changes: 5 additions & 2 deletions after/plugin/colors.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
require('rose-pine').setup({
local ok, plugin = pcall(require, 'rose-pine')
if not ok then return end

plugin.setup({
disable_background = true
})

function ColorMyPencils(color)
function ColorMyPencils(color)
color = color or "rose-pine"
vim.cmd.colorscheme(color)

Expand Down
9 changes: 5 additions & 4 deletions after/plugin/harpoon.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
local mark = require("harpoon.mark")
local ui = require("harpoon.ui")
local mok, mark = pcall(require, 'harpoon.mark')
if not mok then return end

local uok, ui = pcall(require, 'harpoon.ui')
if not uok then return end

vim.keymap.set("n", "<leader>a", mark.add_file)
vim.keymap.set("n", "<C-e>", ui.toggle_quick_menu)
Expand All @@ -8,5 +11,3 @@ vim.keymap.set("n", "<C-h>", function() ui.nav_file(1) end)
vim.keymap.set("n", "<C-t>", function() ui.nav_file(2) end)
vim.keymap.set("n", "<C-n>", function() ui.nav_file(3) end)
vim.keymap.set("n", "<C-s>", function() ui.nav_file(4) end)


8 changes: 6 additions & 2 deletions after/plugin/lsp.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
local lsp = require("lsp-zero")
local lok, lsp = pcall(require, 'lsp-zero')
if not lok then return end

local cok, cmp = pcall(require, 'cmp')
if not cok then return end

lsp.preset("recommended")

lsp.ensure_installed({
'tsserver',
'rust_analyzer',
'lua_ls',
})

-- Fix Undefined global 'vim'
Expand All @@ -19,7 +24,6 @@ lsp.configure('lua-language-server', {
})


local cmp = require('cmp')
local cmp_select = {behavior = cmp.SelectBehavior.Select}
local cmp_mappings = lsp.defaults.cmp_mappings({
['<C-p>'] = cmp.mapping.select_prev_item(cmp_select),
Expand Down
8 changes: 4 additions & 4 deletions after/plugin/refactoring.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require('refactoring').setup({})

vim.api.nvim_set_keymap("v", "<leader>ri", [[ <Esc><Cmd>lua require('refactoring').refactor('Inline Variable')<CR>]], {noremap = true, silent = true, expr = false})

local ok, plugin = pcall(require, 'refactoring')
if not ok then return end

plugin.setup({})
vim.api.nvim_set_keymap("v", "<leader>ri", [[ <Esc><Cmd>lua plugin.refactor('Inline Variable')<CR>]], {noremap = true, silent = true, expr = false})
4 changes: 3 additions & 1 deletion after/plugin/telescope.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
local builtin = require('telescope.builtin')
local ok, builtin = pcall(require, 'telescope.builtin')
if not ok then return end

vim.keymap.set('n', '<leader>pf', builtin.find_files, {})
vim.keymap.set('n', '<C-p>', builtin.git_files, {})
vim.keymap.set('n', '<leader>ps', function()
Expand Down
5 changes: 4 additions & 1 deletion after/plugin/treesitter.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
require'nvim-treesitter.configs'.setup {
local ok, plugin = pcall(require, 'nvim-treesitter.config')
if not ok then return end

plugin.setup {
-- A list of parser names, or "all"
ensure_installed = { "help", "javascript", "typescript", "c", "lua", "rust" },

Expand Down
9 changes: 6 additions & 3 deletions dev
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#!/usr/bin/env bash

rm -rf ~/.config/nvim
ln -s $(pwd) ~/.config/nvim

rm -rfv ~/.cache/nvim
rm -rfv ~/.config/nvim
rm -rfv ~/.local/share/nvim
rm -rfv ~/.local/state/nvim
rm -rfv $(pwd)/plugin
ln -fsv $(pwd) ~/.config/nvim
18 changes: 18 additions & 0 deletions lua/theprimeagen/bootstrap.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
-- Auto install packer.nvim if when needed.

-- Set installation path and clone url.
local path = vim.fn.stdpath('data')..'/site/pack/packer/start/packer.nvim'
local url = 'https://github.com/wbthomason/packer.nvim'

-- TODO: Clone packer if necessary.
if vim.fn.empty(vim.fn.glob(path)) > 0 then
vim.api.nvim_set_hl(0, "NormalFloat", { bg = "#1e222a" })
print('Installing packer.')
vim.fn.system({'git', 'clone', '--depth', '1', url, path})
vim.g.nvim_bootstrapped = 1

-- Add packer.
vim.cmd [[packadd packer.nvim]]
else
vim.g.nvim_bootstrapped = 0
end
19 changes: 16 additions & 3 deletions lua/theprimeagen/init.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,9 +1,22 @@
-- TODO: Add file exists function.
-- https://www.grepper.com/answers/120776/how+to+check+if+file+exists+lua
local function file_exists(name)
local f=io.open(name,'r')
if f ~= nil then io.close() return true else return false end
end

-- TODO: Bootstrap when necessary.
require("theprimeagen.bootstrap")

-- required modules.
require("theprimeagen.packer")
require("theprimeagen.set")
require("theprimeagen.remap")

-- DO NOT INCLUDE THIS
vim.opt.rtp:append("~/personal/streamer-tools")
-- DO NOT INCLUDE THIS
-- TODO: Don't use my streaming tools.
if file_exists("~/personal/streamer-tools") then
vim.opt.rtp:append("~/personal/streamer-tools")
end

local augroup = vim.api.nvim_create_augroup
local ThePrimeagenGroup = augroup('ThePrimeagen', {})
Expand Down
102 changes: 67 additions & 35 deletions lua/theprimeagen/packer.lua
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,24 +1,37 @@
-- This file can be loaded by calling `lua require('plugins')` from your init.vim
-- TODO: Use protected call so we don't error on first use.
local packer_ok, packer = pcall(require, 'packer')
if not packer_ok then return end

-- Only required if you have packer configured as `opt`
vim.cmd.packadd('packer.nvim')
-- TODO: Have packer use a popup window
packer.init {
display = {
open_fn = function()
return require("packer.util").float { border = "rounded" }
end,
},
max_jobs = 50,
}

-- Packer startup function definitions.
--
return packer.startup(function(use)

return require('packer').startup(function(use)
-- Packer can manage itself
use 'wbthomason/packer.nvim'

use {
'nvim-telescope/telescope.nvim', tag = '0.1.0',
-- or , branch = '0.1.x',
requires = { {'nvim-lua/plenary.nvim'} }
'nvim-telescope/telescope.nvim', tag = '0.1.0',
-- or , branch = '0.1.x',
requires = { {'nvim-lua/plenary.nvim'} }
}

use({
'rose-pine/neovim',
as = 'rose-pine',
config = function()
vim.cmd('colorscheme rose-pine')
end
'rose-pine/neovim',
as = 'rose-pine',
config = function()
require("rose-pine").setup()
vim.cmd('colorscheme rose-pine')
end
})

use({
Expand All @@ -34,41 +47,60 @@ return require('packer').startup(function(use)
})


use({"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"})
use("nvim-treesitter/playground")
use{
"nvim-treesitter/nvim-treesitter",
run = function()
pcall(require("nvim-treesitter.install").update{ with_sync = true})
end,
}

use {
"nvim-treesitter/playground",
after = 'nvim-treesitter',
}

use {
"nvim-treesitter/nvim-treesitter-context",
after = 'nvim-treesitter',
}

use("theprimeagen/harpoon")
use("theprimeagen/refactoring.nvim")
use("mbbill/undotree")
use("tpope/vim-fugitive")
use("nvim-treesitter/nvim-treesitter-context");

use {
'VonHeikemen/lsp-zero.nvim',
branch = 'v1.x',
requires = {
-- LSP Support
{'neovim/nvim-lspconfig'},
{'williamboman/mason.nvim'},
{'williamboman/mason-lspconfig.nvim'},

-- Autocompletion
{'hrsh7th/nvim-cmp'},
{'hrsh7th/cmp-buffer'},
{'hrsh7th/cmp-path'},
{'saadparwaiz1/cmp_luasnip'},
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/cmp-nvim-lua'},

-- Snippets
{'L3MON4D3/LuaSnip'},
{'rafamadriz/friendly-snippets'},
}
'VonHeikemen/lsp-zero.nvim',
branch = 'v1.x',
requires = {
-- LSP Support
{'neovim/nvim-lspconfig'},
{'williamboman/mason.nvim'},
{'williamboman/mason-lspconfig.nvim'},

-- Autocompletion
{'hrsh7th/nvim-cmp'},
{'hrsh7th/cmp-buffer'},
{'hrsh7th/cmp-path'},
{'saadparwaiz1/cmp_luasnip'},
{'hrsh7th/cmp-nvim-lsp'},
{'hrsh7th/cmp-nvim-lua'},

-- Snippets
{'L3MON4D3/LuaSnip'},
{'rafamadriz/friendly-snippets'},
}
}

use("folke/zen-mode.nvim")
use("github/copilot.vim")
use("eandrju/cellular-automaton.nvim")
use("laytan/cloak.nvim")

-- TODO: Auto compile and install plugins when packer is bootstrapped.
if vim.g.nvim_bootstrapped == 1 then
packer.sync()
end

end)