faerryn / user.nvim

Since the advent of vim and neovim, countless package managers have appeared and dissappeared. Well, here's another to the list.
MIT License
32 stars 2 forks source link

Supports hooks and branches selection ? #2

Closed basilgood closed 2 years ago

basilgood commented 3 years ago

Has this plugin support to clone a plugin from a different branch or maybe from a commit ? Has support to add hooks after a plugin is installed ? {'do': ':TSUpdate'} Has support to clone to start folder and not to opt ?

faerryn commented 3 years ago

using the start folder instead of opt would compromise reproducibility, so I won't support it unless absolutely necessary for popular plugins.

basilgood commented 3 years ago

using the start folder instead of opt would compromise reproducibility

I don't understand how. You can detail a little ? How is related to reproducibility opt and start folders ? straight.el has a lockfile where it stores hashes. But here if I move my init.lua to other machine I haven' the same packages like in the initial machine. user.nvim will clone repos to other hashes.

basilgood commented 3 years ago
  • [x] Custom branch

Thank you

faerryn commented 3 years ago

How is related to reproducibility opt and start folders ?

packages in /start/ are sourced no matter what, so if you remove that package in your vimrc, they will still start. Also, why do you want to put things in /start/ instead of /opt/?

basilgood commented 3 years ago

packages in /start/ are sourced no matter what, so if you remove that package in your vimrc, they will still start.

Oh I see now what you are after... It's ok for me. lua require'user'.clean() I think this can be done automatically at startup exactly as the installation does. But now this plugin manager can't handle popular plugins like: https://github.com/joshdick/onedark.vim https://github.com/dracula/vim etc... because this packs have additional folders like autoload and after even if they not respect all the vim principles. Nor https://github.com/svermeulen/vimpeccable which is not really popular but useful and it's a lua plugin doesn't work. Look at dracula colorscheme. It has an after folder where it does the highlighting for the main syntax plugins. It's a pity because your plugin it's very good.

Test this simple init.lua and convince yourself:

local user_install_path = vim.fn.stdpath("data").."/site/pack/user/opt/faerryn/user.nvim"
if vim.fn.empty(vim.fn.glob(user_install_path)) > 0 then
  os.execute([[git clone --depth 1 https://github.com/faerryn/user.nvim.git ']]..user_install_path..[[']])
end
vim.api.nvim_command("packadd faerryn/user.nvim")
local user = require"user"
user.setup()
local use = user.use
use "faerryn/user.nvim"
use 'joshdick/onedark.vim'
vim.cmd 'colorscheme onedark'

I want to put everything in opt folder but it doesn't work that way and it's not recomended. Many syntax plugins has after folders because it's needed and they will not loaded. (until your last commit)

faerryn commented 3 years ago
use {
    "joshdick/onedark.vim",
    config = function()
        vim.api.nvim_command("colorscheme onedark")
    end,
}

works perfectly for me. always put code that requires plugins inside of config()

basilgood commented 3 years ago

It really works perfectly that way.

basilgood commented 3 years ago

And vimpeccable works that way:

use{
  "svermeulen/vimpeccable",
  config = function()
    vimp.nnoremap('<leader>n', function()
      vim.wo.number = not vim.wo.number
    end)
  end
}

I need to put all my mappings in this config. It's not bad at all. It's very good instead :)

faerryn commented 3 years ago

:smiley:

basilgood commented 3 years ago

Wow !!! works modularized: I have a file packs.lua with:

local user = require"user"
user.setup()
local use = user.use

use "faerryn/user.nvim"
require'completion' -- here I source completion.lua

use {
  'tpope/vim-vinegar',
  init = function()
    vim.g.netrw_altfile = 1
    vim.g.netrw_altv = 1
    vim.g.netrw_preview = 1
    vim.g.netrw_alto = 0
    vim.g.netrw_use_errorwindow = 0
    cmd 'autocmd FileType netrw nmap <buffer><silent> <right> <cr>'
    cmd 'autocmd FileType netrw nmap <buffer><silent> <left> -'
    cmd 'autocmd FileType netrw nmap <buffer> <TAB> mf'
    cmd 'autocmd FileType netrw nmap <buffer> <S-TAB> mF'
    cmd 'autocmd FileType netrw nmap <buffer> <c-x> mfmx'
  end
}
...

and an other file completion.lua:

local user = require"user"
local use = user.use

use{
  'hrsh7th/nvim-compe',
  config = function()
    require'compe'.setup {
      enabled = true,
      debug = false,
      min_length = 2,
      preselect = 'disable',
      allow_prefix_unmatch = false,
      throttle_time  = 120,
      source_timeout = 200,
      incomplete_delay = 400,
      source = {
        path = true,
        buffer = true,
        nvim_lsp = true
      }
    }
    exec([[
    inoremap <silent><expr> <cr> compe#confirm('<cr>')
    inoremap <silent><expr> <tab> pumvisible() ? '<c-n>' : '<tab>'
    inoremap <silent><expr> <s-tab> pumvisible() ? '<c-p>' : '<s-tab>'
    ]], false)
  end
}
faerryn commented 3 years ago

don't call user.setup() more than once!

faerryn commented 2 years ago

I have finally gone around to implement pinning commits!

basilgood commented 2 years ago

I just tested and it works out of the box. I really like this plugin manager because it's simple, plugins are lazy loaded by default and keeps the configuration well arranged and easy to find for each plugin. A single config page is now easy to view, debug and modify as desired. Very good job!!!

faerryn commented 2 years ago

Well, user.nvim doesn't lazy load. However, most good vim plugins are already lazy-loaded (see autoload).

But I appreciate the comment! Thanks!