diff --git a/README.md b/README.md index aa3823b8..10af542f 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,71 @@ -### ThePrimeagen's init.lua -Prerequisite: install [ripgrep](https://github.com/BurntSushi/ripgrep). +# ThePrimeagen's init.lua -[The full video of me setting up this repo](https://www.youtube.com/watch?v=w7i4amO_zaE) + +## Getting Started +### Install the following: +* **[ripgrep](https://github.com/BurntSushi/ripgrep)** (It's in the Debian repos) + ```sh + sudo apt install ripgrep + ``` +* **[Use the latest version of Zsh](https://zsh.sourceforge.io/Arc/source.html)** <-- Link +* You will need a recent version of **NeoVim** too, the ones in the apt repos are too old. +* The most compatable version of NeoVim for this config, is **[NVIM v0.9.4](https://github.com/neovim/neovim/releases)** +* Use these commands to install it, and u must have Packer installed alongside this `init.lua` repo too -For anyone that is interested in my vimrc, i will have a commit log below -documenting each one of my commits (easy to C-f the change you want to know + +**- Then you can git clone this repo in your home directory, and run the dev bash script to clean out your current nvim files** +```bash +#!/usr/bin/env bash + +# To start with a clean slate, you will need to delete and remove your current/previous neovim files and dirs. +rm -rf ~/.config/nvim +ln -s $(pwd) ~/.config/nvim +``` +**- Then install NVIM v0.9.4, and Packer** +```bash +wget https://github.com/neovim/neovim/releases/download/stable/nvim.appimage +chmod +x nvim.appimage +sudo mv nvim.appimage /usr/local/bin/nvim + +# git clone packer +git clone --depth 1 https://github.com/wbthomason/packer.nvim\\n ~/.local/share/nvim/site/pack/packer/start/packer.nvim +``` + +## Installation Video walkthrough by ThePrimeagen: +**How to create this init.lua from scratch: https://youtu.be/w7i4amO_zaE** + + +- I have since installed Tabnine +- **[How to install Tabnine in NeoVim: Detailed instructions. Click here.](https://github.com/LinuxUser255/BashAndLinux/blob/main/Tabnine_Install.md)** +- What the file structure looks like: + +![init lua](https://user-images.githubusercontent.com/46334926/230166494-c42825b4-7a2e-4d62-b89a-b7bde9c62326.png) +--- + +**[Click here for NeoVim documentation on netrw:](https://neovim.io/doc/user/pi_netrw.html#:~:text=Netrw%20makes%20reading%20files%2C%20writing,plugin%20on%20%22%20plugins%20are%20enabled)** + +### How to use netrw. The basics. +- Enter netrw from the terminal: `nvim . ` +- Runtimepath: `:h rtp` +- Create a new file: enter netrw: `nvim .` press the percent sign `%` then name it. +- Create a directory, enter netrw `nvim .` then press d, then name it. +- To source a file use the command `:so` +- Scroll using `j and k`, (up and down) +- Select / open a file or dir with `Enter` +- Close a file `leader pv` *the leader key is the spacebar* +- Fuzzy find while in netrw `leader pf` +- Open the fuzzy finder from within a neovim file (accessed via netrw): `Ctrl + p` +- Scroll up and down within the fuzzy finder using `up and down arrow keys` and typing the file name +- Open up the file tree without closing the file you are in. use the cmd `:Vex` vertical explore. (split window). +- Hop left-right between windows: enter *window mode* `ctrl + w` then `l` to go right & `ctrl + w` + `h` go left. +- Return to the original file, (close all window splits), `ctrl + w` + `o` + +--- +For anyone that is interested in Prime's vimrc, he will have a commit log below +documenting each commits (easy to C-f the change you want to know about though i would just suggest `git log -S`). -### Change Log +### Change Log (as of the date of me forking this repo: 04/05/2023 * [33eee9ad](https://github.com/ThePrimeagen/init.lua/commit/33eee9ad0c035a92137d99dae06a2396be4c892e) initial commits * [cb210006](https://github.com/ThePrimeagen/init.lua/commit/cb210006356b4b613b71c345cb2b02eefa961fc0) netrw, autogroups for yank highlighting, and auto remove whitespace * [c8c0bf4a](https://github.com/ThePrimeagen/init.lua/commit/c8c0bf4aeacd0bd77136d9c5ee490680515a106b) zenmode. i really like this plugin diff --git a/after/plugin/colors.lua b/after/plugin/colors.lua index fe97b1bb..51ba27f6 100644 --- a/after/plugin/colors.lua +++ b/after/plugin/colors.lua @@ -12,3 +12,4 @@ function ColorMyPencils(color) end ColorMyPencils() + diff --git a/after/plugin/lsp.lua b/after/plugin/lsp.lua index ca85cbec..346a7ee5 100644 --- a/after/plugin/lsp.lua +++ b/after/plugin/lsp.lua @@ -8,15 +8,7 @@ lsp.ensure_installed({ }) -- Fix Undefined global 'vim' -lsp.configure('lua-language-server', { - settings = { - Lua = { - diagnostics = { - globals = { 'vim' } - } - } - } -}) +lsp.nvim_workspace() local cmp = require('cmp') diff --git a/after/plugin/tabnine.lua b/after/plugin/tabnine.lua new file mode 100644 index 00000000..a90f0af9 --- /dev/null +++ b/after/plugin/tabnine.lua @@ -0,0 +1,18 @@ +local config = require("tabnine.config") +local auto_commands = require("tabnine.auto_commands") +local user_commands = require("tabnine.user_commands") +local keymaps = require("tabnine.keymaps") + +local M = {} + +function M.setup(o) + config.set_config(o) + + keymaps.setup() + + user_commands.setup() + + auto_commands.setup() +end + +return M diff --git a/dev b/dev index 6f51fbc7..1fbc34b4 100755 --- a/dev +++ b/dev @@ -1,5 +1,6 @@ #!/usr/bin/env bash +# To start with a clean slate, you will need to delete and remove your current/previous neovim files and dirs. rm -rf ~/.config/nvim ln -s $(pwd) ~/.config/nvim diff --git a/init.lua b/init.lua index a39d9f18..113fafaa 100644 --- a/init.lua +++ b/init.lua @@ -1,2 +1,14 @@ require("theprimeagen") +-- run the comannd :TabnineHub after all tabnine code has been saved and sourced + +require('tabnine').setup({ + disable_auto_comment=true, + accept_keymap="", + dismiss_keymap = "", + debounce_ms = 800, + suggestion_color = {gui = "#808080", cterm = 244}, + exclude_filetypes = {"TelescopePrompt"} +}) + + diff --git a/lua/theprimeagen/packer.lua b/lua/theprimeagen/packer.lua index cd886f38..996919b3 100644 --- a/lua/theprimeagen/packer.lua +++ b/lua/theprimeagen/packer.lua @@ -33,10 +33,15 @@ return require('packer').startup(function(use) end }) - - use({"nvim-treesitter/nvim-treesitter", run = ":TSUpdate"}) + use { + 'nvim-treesitter/nvim-treesitter', + run = function() + local ts_update = require('nvim-treesitter.install').update({ with_sync = true }) + ts_update() + end,} use("nvim-treesitter/playground") use("theprimeagen/harpoon") + use("ThePrimeagen/vim-be-good") use("theprimeagen/refactoring.nvim") use("mbbill/undotree") use("tpope/vim-fugitive") @@ -66,9 +71,10 @@ return require('packer').startup(function(use) } use("folke/zen-mode.nvim") - use("github/copilot.vim") + -- use("github/copilot.vim") + -- TabNine + use('codota/tabnine-nvim') use("eandrju/cellular-automaton.nvim") use("laytan/cloak.nvim") end) - diff --git a/lua/theprimeagen/remap.lua b/lua/theprimeagen/remap.lua index e165d1ab..d9beac31 100644 --- a/lua/theprimeagen/remap.lua +++ b/lua/theprimeagen/remap.lua @@ -1,51 +1,93 @@ +-- This keymaps file needs to be "required" in /nvim/config/init.lua -vim.g.mapleader = " " +-- [[ NetRW cmds Project view & vertical window split ]] vim.keymap.set("n", "pv", vim.cmd.Ex) +vim.keymap.set("n", "ve", vim.cmd.Vex) +--[ ! Move an entite line or lines up or down. ]] +-- when highlighting a line, press shift + j or k vim.keymap.set("v", "J", ":m '>+1gv=gv") +-- J takes the line below and appends it to your current line with a space +-- And this one keeps your cursor in one place dispite movving other lines vim.keymap.set("v", "K", ":m '<-2gv=gv") - vim.keymap.set("n", "J", "mzJ`z") +-- The two below keeps the cursor in the middle when scrolling with ctrl + d & u +-- Makes searching the file less disorienting. vim.keymap.set("n", "", "zz") vim.keymap.set("n", "", "zz") + +-- Make search terms stay in the middle when searching the file for characters, text, etc.. vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "N", "Nzzzv") -vim.keymap.set("n", "vwm", function() - require("vim-with-me").StartVimWithMe() -end) -vim.keymap.set("n", "svwm", function() - require("vim-with-me").StopVimWithMe() -end) +-- Pasting highlighted text over a pre-selected highligted text +-- Deletes highlighted word into the 'void' register and then paste it over. +vim.keymap.set("x", "p", [["_dP]]) +-- normal mode, then visual line mode, then spacebar shift -- greatest remap ever +-- Pasting highlighted text over a pre-selected highligted text +-- Deletes highlighted word into the 'void' register and then paste it over. vim.keymap.set("x", "p", [["_dP]]) --- next greatest remap ever : asbjornHaland +-- YANK TEXT TO THE SYSTEM CLIPBOARD +-- Normal mode, then leader yy +-- yanks text to the system clipboard enabling you to pate elsewhere vim.keymap.set({"n", "v"}, "y", [["+y]]) vim.keymap.set("n", "Y", [["+Y]]) vim.keymap.set({"n", "v"}, "d", [["_d]]) --- This is going to get me cancelled -vim.keymap.set("i", "", "") - -vim.keymap.set("n", "Q", "") +-- When using Tmux: ctrl + f and now fuzzy find in another terminal session vim.keymap.set("n", "", "silent !tmux neww tmux-sessionizer") vim.keymap.set("n", "f", vim.lsp.buf.format) +-- Quick-fix navigation list vim.keymap.set("n", "", "cnextzz") vim.keymap.set("n", "", "cprevzz") vim.keymap.set("n", "k", "lnextzz") vim.keymap.set("n", "j", "lprevzz") +-- ! Extremely useful: space + s opens a menu and begin replacing the word on which your cursor lies. vim.keymap.set("n", "s", [[:%s/\<\>//gI]]) + +-- Make the file executable without having to exit and chmoding it manually. vim.keymap.set("n", "x", "!chmod +x %", { silent = true }) -vim.keymap.set("n", "vpp", "e ~/.dotfiles/nvim/.config/nvim/lua/theprimeagen/packer.lua"); -vim.keymap.set("n", "mr", "CellularAutomaton make_it_rain"); +-- Diagnostic keymaps +vim.keymap.set('n', '[d', vim.diagnostic.goto_prev, { desc = 'Go to previous diagnostic message' }) +vim.keymap.set('n', ']d', vim.diagnostic.goto_next, { desc = 'Go to next diagnostic message' }) +vim.keymap.set('n', 'e', vim.diagnostic.open_float, { desc = 'Open floating diagnostic message' }) +vim.keymap.set('n', 'q', vim.diagnostic.setloclist, { desc = 'Open diagnostics list' }) + +-- ThePrimeagen's Flashy Highlight on yank +local augroup = vim.api.nvim_create_augroup +local ThePrimeagenGroup = augroup('ThePrimeagen', {}) + +local autocmd = vim.api.nvim_create_autocmd +local yank_group = augroup('HighlightYank', {}) + +function R(name) + require("plenary.reload").reload_module(name) +end + +autocmd('TextYankPost', { + group = yank_group, + pattern = '*', + callback = function() + vim.highlight.on_yank({ + higroup = 'IncSearch', + timeout = 40, + }) + end, +}) -vim.keymap.set("n", "", function() - vim.cmd("so") -end) +autocmd({"BufWritePre"}, { + group = ThePrimeagenGroup, + pattern = "*", + command = [[%s/\s\+$//e]], +}) +-- attempt opaque background: It worked! +vim.api.nvim_set_hl(0, "Normal", { bg = "none" }) +vim.api.nvim_set_hl(0, "NormalFloat", { bg = "none" })