|
1 |
| -## Strive |
| 1 | +# Strive: Minimalist Plugin Manager for Neovim |
2 | 2 |
|
3 |
| -Strive: Minimalist Plugin Manager for Neovim |
4 |
| -A lightweight, feature-rich plugin manager with support for lazy loading, |
5 |
| -dependencies, and asynchronous operations. |
| 3 | +Strive is a lightweight, feature-rich plugin manager for Neovim with support for lazy loading, dependencies, and asynchronous operations. |
6 | 4 |
|
7 |
| -most usage see [glepnir/nvim](https://github.com/glepnir/nvim/blob/main/plugin/package.lua) |
| 5 | +## Features |
8 | 6 |
|
9 |
| -## License MIT |
| 7 | +- ✅ Asynchronous installation and updates |
| 8 | +- ✅ Lazy loading based on events, filetypes, commands, and keymaps |
| 9 | +- ✅ Dependency management |
| 10 | +- ✅ Clean and intuitive API |
| 11 | +- ✅ Minimal overhead |
| 12 | +- ✅ Visual progress tracking |
| 13 | + |
| 14 | +## Installation |
| 15 | + |
| 16 | +### Manual Installation |
| 17 | + |
| 18 | +```bash |
| 19 | +git clone https://github.com/nvimdev/strive ~/.local/share/nvim/site/pack/strive/start/strive |
| 20 | +``` |
| 21 | + |
| 22 | +### Bootstrap Installation |
| 23 | + |
| 24 | +```lua |
| 25 | +local strive_path = vim.fn.stdpath('data') .. '/site/pack/strive/start/strive' |
| 26 | +if not vim.uv.fs_stat(strive_path) then |
| 27 | + vim.fn.system({ |
| 28 | + 'git', |
| 29 | + 'clone', |
| 30 | + '--depth=1', |
| 31 | + 'https://github.com/nvimdev/strive', |
| 32 | + strive_path |
| 33 | + }) |
| 34 | + |
| 35 | + vim.o.rtp = strive_path .. ',' .. vim.o.rtp |
| 36 | +end |
| 37 | +``` |
| 38 | + |
| 39 | +## Basic Usage |
| 40 | + |
| 41 | +```lua |
| 42 | +-- Initialize |
| 43 | +local use = require('strive').use |
| 44 | + |
| 45 | +-- Add plugins |
| 46 | +use 'neovim/nvim-lspconfig':ft({'c', 'lua'}) |
| 47 | + |
| 48 | +-- Lazy-load plugins based on events |
| 49 | +use 'lewis6991/gitsigns.nvim' |
| 50 | + :on('BufRead') |
| 51 | + |
| 52 | +-- Lazy-load by commands |
| 53 | +use 'nvim-telescope/telescope.nvim' |
| 54 | + :cmd('Telescope') |
| 55 | + |
| 56 | +-- Colorscheme |
| 57 | +use 'folke/tokyonight.nvim' |
| 58 | + :theme() |
| 59 | +``` |
| 60 | + |
| 61 | +## Commands |
| 62 | + |
| 63 | +Strive provides these commands: |
| 64 | + |
| 65 | +- `:Strive install` - Install all plugins |
| 66 | +- `:Strive update` - Update all plugins |
| 67 | +- `:Strive clean` - Remove unused plugins |
| 68 | + |
| 69 | +## Lazy Loading Methods |
| 70 | + |
| 71 | +### Events |
| 72 | + |
| 73 | +```lua |
| 74 | +-- Load on specific events |
| 75 | +use 'lewis6991/gitsigns.nvim' |
| 76 | + :on('BufRead') |
| 77 | + |
| 78 | +-- Multiple events |
| 79 | +use 'luukvbaal/stabilize.nvim' |
| 80 | + :on({'BufRead', 'BufNewFile'}) |
| 81 | +``` |
| 82 | + |
| 83 | +### Filetypes |
| 84 | + |
| 85 | +```lua |
| 86 | +-- Load for specific filetypes |
| 87 | +use 'fatih/vim-go' |
| 88 | + :ft('go') |
| 89 | + |
| 90 | +-- Multiple filetypes |
| 91 | +use 'plasticboy/vim-markdown' |
| 92 | + :ft({'markdown', 'md'}) |
| 93 | +``` |
| 94 | + |
| 95 | +### Commands |
| 96 | + |
| 97 | +```lua |
| 98 | +-- Load when command is used |
| 99 | +use 'github/copilot.vim' |
| 100 | + :cmd('Copilot') |
| 101 | + |
| 102 | +-- Multiple commands |
| 103 | +use 'nvim-telescope/telescope.nvim' |
| 104 | + :cmd({'Telescope', 'Telescope find_files'}) |
| 105 | +``` |
| 106 | + |
| 107 | +### Keymaps |
| 108 | + |
| 109 | +```lua |
| 110 | +-- Basic keymap in normal mode |
| 111 | +use 'folke/trouble.nvim' |
| 112 | + :keys('<leader>t') |
| 113 | + |
| 114 | +-- Specific mode, key, action and opts |
| 115 | +use 'numToStr/Comment.nvim' |
| 116 | + :keys({ |
| 117 | + {'n', '<leader>c', '<cmd>CommentToggle<CR>', {silent = true}}, |
| 118 | + {'v', '<leader>c', '<cmd>CommentToggle<CR>', {silent = true}} |
| 119 | + }) |
| 120 | +``` |
| 121 | + |
| 122 | +### Conditional Loading |
| 123 | + |
| 124 | +```lua |
| 125 | +-- Load based on a condition |
| 126 | +use 'gpanders/editorconfig.nvim' |
| 127 | + :cond(function() |
| 128 | + return vim.fn.executable('editorconfig') == 1 |
| 129 | + end) |
| 130 | + |
| 131 | +-- Using a Vim expression |
| 132 | +use 'junegunn/fzf.vim' |
| 133 | + :cond('executable("fzf")') |
| 134 | +``` |
| 135 | + |
| 136 | +## Plugin Configuration |
| 137 | + |
| 138 | +### Setup Method |
| 139 | + |
| 140 | +```lua |
| 141 | +-- Call the setup function of a plugin |
| 142 | +use 'nvim-treesitter/nvim-treesitter' |
| 143 | + :setup({ |
| 144 | + ensure_installed = {'lua', 'vim', 'vimdoc'}, |
| 145 | + highlight = {enable = true}, |
| 146 | + indent = {enable = true} |
| 147 | + }) |
| 148 | +``` |
| 149 | + |
| 150 | +### Init vs Config |
| 151 | + |
| 152 | +```lua |
| 153 | +-- Init runs BEFORE the plugin loads |
| 154 | +use 'mbbill/undotree' |
| 155 | + :init(function() |
| 156 | + vim.g.undotree_SetFocusWhenToggle = 1 |
| 157 | + end) |
| 158 | + |
| 159 | +-- Config runs AFTER the plugin loads |
| 160 | +use 'folke/which-key.nvim' |
| 161 | + :config(function() |
| 162 | + require('which-key').setup({ |
| 163 | + plugins = { |
| 164 | + spelling = {enabled = true} |
| 165 | + } |
| 166 | + }) |
| 167 | + end) |
| 168 | +``` |
| 169 | + |
| 170 | +### Build Commands |
| 171 | + |
| 172 | +```lua |
| 173 | +-- Run a command after installing a plugin |
| 174 | +use 'nvim-treesitter/nvim-treesitter' |
| 175 | + :run(':TSUpdate') |
| 176 | +``` |
| 177 | + |
| 178 | +## Local Plugin Development |
| 179 | + |
| 180 | +```lua |
| 181 | +-- Load a local plugin |
| 182 | +use 'username/my-plugin' |
| 183 | + :load_path('~/projects/neovim-plugins') |
| 184 | + |
| 185 | +-- Or set a global development path |
| 186 | +vim.g.strive_dev_path = '~/projects/neovim-plugins' |
| 187 | +use 'my-plugin' |
| 188 | + :load_path() |
| 189 | +``` |
| 190 | + |
| 191 | +## Advanced Configuration |
| 192 | + |
| 193 | +### Custom Settings |
| 194 | + |
| 195 | +```lua |
| 196 | +-- Set custom configuration before loading |
| 197 | +vim.g.strive_auto_install = true -- Auto-install plugins on startup |
| 198 | +vim.g.strive_max_concurrent_tasks = 8 -- Limit concurrent operations |
| 199 | +vim.g.strive_log_level = 'info' -- Set logging level (debug, info, warn, error) |
| 200 | +vim.g.strive_git_timeout = 60000 -- Git operation timeout in ms |
| 201 | +vim.g.strive_git_depth = 1 -- Git clone depth |
| 202 | +vim.g.strive_install_with_retry = false -- Retry failed installations |
| 203 | +``` |
| 204 | + |
| 205 | +## Example Configuration |
| 206 | + |
| 207 | +```lua |
| 208 | +-- Initialize |
| 209 | +local use = require('strive').use |
| 210 | + |
| 211 | +-- UI |
| 212 | +use 'folke/tokyonight.nvim' |
| 213 | + :theme('tokyonight-storm') |
| 214 | + |
| 215 | +use 'nvim-lualine/lualine.nvim' |
| 216 | + :depends('kyazdani42/nvim-web-devicons') |
| 217 | + :config(function() |
| 218 | + require('lualine').setup({ |
| 219 | + options = { |
| 220 | + theme = 'tokyonight' |
| 221 | + } |
| 222 | + }) |
| 223 | + end) |
| 224 | + |
| 225 | +-- Editing |
| 226 | +use 'tpope/vim-surround' |
| 227 | +use 'tpope/vim-commentary' |
| 228 | +use 'windwp/nvim-autopairs' |
| 229 | + :config(function() |
| 230 | + require('nvim-autopairs').setup() |
| 231 | + end) |
| 232 | + |
| 233 | +-- Navigation |
| 234 | +use 'nvim-telescope/telescope.nvim' |
| 235 | + :depends({ |
| 236 | + 'nvim-lua/plenary.nvim', |
| 237 | + 'nvim-telescope/telescope-fzf-native.nvim' |
| 238 | + }) |
| 239 | + :cmd({ |
| 240 | + 'Telescope', |
| 241 | + 'Telescope find_files', |
| 242 | + 'Telescope live_grep' |
| 243 | + }) |
| 244 | + :keys('<leader>f') |
| 245 | + :config(function() |
| 246 | + require('telescope').setup({ |
| 247 | + extensions = { |
| 248 | + fzf = { |
| 249 | + fuzzy = true, |
| 250 | + override_generic_sorter = true, |
| 251 | + override_file_sorter = true, |
| 252 | + case_mode = "smart_case", |
| 253 | + } |
| 254 | + } |
| 255 | + }) |
| 256 | + require('telescope').load_extension('fzf') |
| 257 | + end) |
| 258 | + |
| 259 | +-- LSP & Completion |
| 260 | +use 'neovim/nvim-lspconfig' |
| 261 | + :config(function() |
| 262 | + local lspconfig = require('lspconfig') |
| 263 | + lspconfig.lua_ls.setup({}) |
| 264 | + lspconfig.tsserver.setup({}) |
| 265 | + end) |
| 266 | + |
| 267 | +use 'hrsh7th/nvim-cmp' |
| 268 | + :depends({ |
| 269 | + 'hrsh7th/cmp-nvim-lsp', |
| 270 | + 'hrsh7th/cmp-buffer', |
| 271 | + 'hrsh7th/cmp-path', |
| 272 | + 'L3MON4D3/LuaSnip', |
| 273 | + 'saadparwaiz1/cmp_luasnip' |
| 274 | + }) |
| 275 | + :config(function() |
| 276 | + local cmp = require('cmp') |
| 277 | + local luasnip = require('luasnip') |
| 278 | + |
| 279 | + cmp.setup({ |
| 280 | + snippet = { |
| 281 | + expand = function(args) |
| 282 | + luasnip.lsp_expand(args.body) |
| 283 | + end, |
| 284 | + }, |
| 285 | + mapping = cmp.mapping.preset.insert({ |
| 286 | + ['<C-b>'] = cmp.mapping.scroll_docs(-4), |
| 287 | + ['<C-f>'] = cmp.mapping.scroll_docs(4), |
| 288 | + ['<C-Space>'] = cmp.mapping.complete(), |
| 289 | + ['<C-e>'] = cmp.mapping.abort(), |
| 290 | + ['<CR>'] = cmp.mapping.confirm({ select = true }), |
| 291 | + }), |
| 292 | + sources = cmp.config.sources({ |
| 293 | + { name = 'nvim_lsp' }, |
| 294 | + { name = 'luasnip' }, |
| 295 | + }, { |
| 296 | + { name = 'buffer' }, |
| 297 | + }) |
| 298 | + }) |
| 299 | + end) |
| 300 | + |
| 301 | +-- Git |
| 302 | +use 'lewis6991/gitsigns.nvim' |
| 303 | + :on('BufRead') |
| 304 | + :config(function() |
| 305 | + require('gitsigns').setup() |
| 306 | + end) |
| 307 | +``` |
| 308 | + |
| 309 | +## Best Practices |
| 310 | + |
| 311 | +1. **Group related plugins**: Use dependencies to manage related plugins |
| 312 | +2. **Lazy-load where possible**: This improves startup time |
| 313 | +3. **Use appropriate events**: Choose the right events, filetypes, or commands |
| 314 | +4. **Keep configuration organized**: Group plugins by functionality |
| 315 | +5. **Regular updates**: Run `:Strive update` periodically |
| 316 | +6. **Clean unused plugins**: Run `:Strive clean` to remove unused plugins |
| 317 | + |
| 318 | +## Troubleshooting |
| 319 | + |
| 320 | +If you encounter issues: |
| 321 | + |
| 322 | +1. Check the plugin is available on GitHub |
| 323 | +2. Verify your internet connection |
| 324 | +3. Increase the timeout for Git operations: |
| 325 | + ```lua |
| 326 | + vim.g.strive_git_timeout = 300000 -- 5 minutes |
| 327 | + ``` |
| 328 | +4. Enable debug logging: |
| 329 | + ```lua |
| 330 | + vim.g.strive_log_level = 'debug' |
| 331 | + ``` |
| 332 | +5. Try reinstalling: |
| 333 | + ``` |
| 334 | + :Strive clean |
| 335 | + :Strive install |
| 336 | + ``` |
0 commit comments