A readme explaining how to make neovim work fast
| 1 | # Hygo Vim |
| 2 | |
| 3 | If you use vim style coding in any editor, this will help you instantly |
| 4 | convert to neovim. |
| 5 | |
| 6 | ## Prerequisites |
| 7 | |
| 8 | - If you are using a mac, you need to use iterm2. The default terminal doesn't support true color, so all the colorschemes will look terrible and unreadable. |
| 9 | - Install a [NerdFont Font](https://www.nerdfonts.com/font-downloads) |
| 10 | - [FD-Find](https://github.com/sharkdp/fd) |
| 11 | |
| 12 | ```bash |
| 13 | sudo apt install fd-find |
| 14 | ``` |
| 15 | |
| 16 | - [repgrep](https://github.com/BurntSushi/ripgrep) |
| 17 | |
| 18 | ```bash |
| 19 | sudo apt install ripgrep |
| 20 | ``` |
| 21 | |
| 22 | - Install Neovim |
| 23 | - Download for linux |
| 24 | |
| 25 | ```bash |
| 26 | curl -L -o ~/nvim.appimage https://github.com/neovim/neovim/releases/download/v0.11.0/nvim-linux-x86_64.appimage |
| 27 | ``` |
| 28 | |
| 29 | - Add this to bashrc |
| 30 | |
| 31 | ```bash |
| 32 | alias nvim='~/nvim.appimage' |
| 33 | alias nv=nvim |
| 34 | alias vim=nvim |
| 35 | ``` |
| 36 | |
| 37 | - Set up win32yank for wsl to paste like an absolute gangster |
| 38 | - Note use yanky `<leader>p` to paste if you delete before pasting cuz we use unnamedplus default keyboard |
| 39 | |
| 40 | ```bash |
| 41 | curl -o win32yank.zip https://github.com/equalsraf/win32yank/releases/download/v0.1.1/win32yank-x86.zip -L |
| 42 | unzip win32yank.zip |
| 43 | chmod +x win32yank.exe |
| 44 | sudo mkdir /mnt/c/tools/ |
| 45 | sudo cp win32yank.exe /mnt/c/tools/ |
| 46 | rm win32yank* |
| 47 | ``` |
| 48 | |
| 49 | ## Tmux like a pro |
| 50 | |
| 51 | - Add this to .tmux.conf |
| 52 | |
| 53 | ```conf |
| 54 | source-file ~/.config/nvim/tmux.conf |
| 55 | ``` |
| 56 | |
| 57 | ## Setup toggle term `~/.config/nvim/lua/plugins/toggleterm.lua` |
| 58 | |
| 59 | ```lua |
| 60 | return { |
| 61 | "akinsho/toggleterm.nvim", |
| 62 | keys = { |
| 63 | -- Creates name group for which-key |
| 64 | { |
| 65 | "<leader>t", |
| 66 | desc = "toggleterm", |
| 67 | }, |
| 68 | -- Creates a new floating terminal |
| 69 | { |
| 70 | "<leader>tf", |
| 71 | "<cmd>TermNew direction=float<cr>", |
| 72 | desc = "Create New Floating Terminal", |
| 73 | }, |
| 74 | -- Creates a new tabbed terminal |
| 75 | { |
| 76 | "<leader>tt", |
| 77 | "<cmd>TermNew direction=tab<cr>", |
| 78 | desc = "Create New Tabbed Terminal", |
| 79 | }, |
| 80 | -- Selects a terminal |
| 81 | { |
| 82 | "<leader>ts", |
| 83 | "<cmd>TermSelect<cr>", |
| 84 | desc = "Select Terminal", |
| 85 | }, |
| 86 | }, |
| 87 | opts = { |
| 88 | open_mapping = [[<c-\>]], |
| 89 | }, |
| 90 | } |
| 91 | ``` |
| 92 | |
| 93 | ## Setup autosave `~/.config/nvim/lua/config/autocmds.lua` |
| 94 | |
| 95 | - Add this to autocmd |
| 96 | |
| 97 | ````lua |
| 98 | -- autosave on focus lost and buffer change |
| 99 | local group = vim.api.nvim_create_augroup("autosave_group", { clear = true }) |
| 100 | vim.api.nvim_create_autocmd({ "FocusLost", "BufLeave" }, { |
| 101 | group = group, |
| 102 | callback = function(opts) |
| 103 | if vim.bo.modifiable and not vim.bo.readonly and vim.bo.modified then |
| 104 | local file = vim.fn.expand("%t") |
| 105 | vim.cmd("silent! write") |
| 106 | vim.notify("Autosaved " .. file .. "\nSource " .. opts.event) |
| 107 | end |
| 108 | end, |
| 109 | }) ``` |
| 110 | |
| 111 | ## Vim In Your Browser `~/.config/nvim/lua/plugins/firenvim.lua` |
| 112 | |
| 113 | ```lua |
| 114 | return { |
| 115 | -- enable firenvim |
| 116 | { |
| 117 | "glacambre/firenvim", |
| 118 | build = ":call firenvim#install(0)", |
| 119 | config = function() |
| 120 | if vim.g.started_by_firenvim then |
| 121 | vim.cmd("colorscheme tokyonight-day") |
| 122 | end |
| 123 | vim.g.firenvim_config = { |
| 124 | globalSettings = { alt = "all" }, |
| 125 | localSettings = { |
| 126 | [".*"] = { |
| 127 | takeover = "never", |
| 128 | }, |
| 129 | }, |
| 130 | } |
| 131 | end, |
| 132 | }, |
| 133 | -- disable extnsions based on firenvim |
| 134 | { |
| 135 | "folke/noice.nvim", |
| 136 | enabled = not vim.g.started_by_firenvim, |
| 137 | }, |
| 138 | } |
| 139 | ```` |