diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..c327093 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,21 @@ +# Contributing + +Paq is small because my own needs as a Nvim user are pretty simple, +but that doesn't mean I'm against adding features. If you have suggestions, +write an issue! Try to be specific. When writing the titles, make the intent clear; +and for the body of the issue, the more detailed the description the better. + +For bugs, write the title as an statement: +`Paq isn't doing foo` or `Paq does bar instead of foo`. +In the body, be sure to include the steps necessary to reproduce the issue, +and a minimal working example. + +For feature requests, write the title as an imperative: +`Do foo instead of bar` or `Add foo`. +This makes it easier to match them to their (possible) corresponding PR. +In the body, try to nail down the scope of the feature, what it should do +and what it shouldn't do. Also include if you're interested in adding the +feature yourself. + +For questions, there are no restrictions. Ask away. Just write the title a +question: `Can Paq do foo?` diff --git a/README.md b/README.md index 1925390..78d4559 100644 --- a/README.md +++ b/README.md @@ -76,14 +76,3 @@ To generate helptags after installing a plugin, just run `:helptags ALL`. The [docs](https://github.com/savq/paq-nvim/tree/master/doc/paq-nvim.txt) include a section on moving from Vim-plug or Minpac to Paq. - - -## Contributing - -Paq is small because my own needs as a Neovim user are pretty simple, -but that doesn't mean I'm against adding features. -If you find a bug, have questions or suggestions, write an issue! - -You can read the [docs](https://github.com/savq/paq-nvim/tree/master/doc/paq-nvim.txt) -section on contributing for more information. - diff --git a/doc/paq-nvim.txt b/doc/paq-nvim.txt index 80912d4..ee11dd0 100644 --- a/doc/paq-nvim.txt +++ b/doc/paq-nvim.txt @@ -15,7 +15,6 @@ CONTENTS *paq-contents* Commands |paq-commands| Paq directory |paq-directory| Moving from other package managers |paq-moving| - Contributing |paq-contributing| ============================================================================== @@ -238,53 +237,5 @@ Would be written in Lua like: paq {'lervag/vimtex', opt=true} < - -============================================================================== -CONTRIBUTING *paq-contributing* - -Paq is small because my own needs as a Nvim user are pretty simple, -but that doesn't mean I'm against adding features. If you have suggestions, -write an issue! - -All development for this package happens on GitHub. When posting an issue -always try to be specific. When writing the titles, make the intent clear; -and for the body of the issue, the more detailed the description the better. - -Also keep in mind the following: - -Bugs~ - -Write the title as an statement: -`Paq isn't doing foo` or `Paq does bar instead of foo` - -In the body, be sure to include the steps necessary to reproduce the issue, -and a minimal working example. - - -Feature requests~ - -For feature requests, write the title as an imperative: -`Do foo instead of bar` or `Add foo` - -This makes it easier to match them to their (possible) corresponding PR. - -In the body, try to nail down the scope of the feature, what it should do -and what it shouldn't do. Also include if you're interested in adding the -feature yourself. - - -Questions~ - -For questions, there are no restrictions. Ask away. Just write the title a -question: `Can Paq do foo?` - - -Showcase~ - -Nvim's Lua support is still a novel thing. If you are using Paq in your Lua -configuration, I'd be interested to see it. Post an issue, or write me an -email. - - ============================================================================== vim:tw=78:ts=8:noet:ft=help:norl: diff --git a/lua/paq-nvim.lua b/lua/paq-nvim.lua index ec3c766..9304cad 100644 --- a/lua/paq-nvim.lua +++ b/lua/paq-nvim.lua @@ -1,30 +1,21 @@ -local loop = vim.loop -- Constants -local PATH = vim.fn.stdpath('data') .. '/site/pack/paqs/' -local GITHUB = 'https://github.com/' -local REPO_RE = '^[%w-]+/([%w-_.]+)$' --is this regex correct? +local PATH = vim.fn.stdpath('data') .. '/site/pack/paqs/' +local GITHUB = 'https://github.com/' +local REPO_RE = '^[%w-]+/([%w-_.]+)$' --- Table of 'name':{options} pairs -local packages = {} - -local function get_dir(name, opt) - return PATH .. (opt and 'opt/' or 'start/') .. name -end - -local function is_pkg_dir(dir) - return vim.fn.isdirectory(dir) ~= 0 -end +local uv = vim.loop -- Alias for Neovim's event loop (libuv) +local packages = {} -- Table of 'name':{options} pairs local function print_res(action, args, ok) local res = ok and 'Paq: ' or 'Paq: Failed to ' print(res .. action .. ' ' .. args) end -local function call_git(action, name, ...) +local function call_git(name, dir, action, ...) local args = {...} local handle - handle = loop.spawn('git', - {args=args}, + handle = uv.spawn('git', + {args=args, cwd=dir}, vim.schedule_wrap( function(code, signal) print_res(action, name, code == 0) @@ -34,57 +25,57 @@ local function call_git(action, name, ...) ) end -local function install_pkg(name, dir, args) - if not is_pkg_dir(dir) then +local function install_pkg(name, dir, isdir, args) + if not isdir then + uv.fs_mkdir(dir, uv.fs_stat(PATH).mode) if args.branch then - call_git('install', name, 'clone', args.url, '-b', args.branch, '--single-branch', dir) + call_git(name, dir, 'install', 'clone', args.url, '-b', args.branch, '--single-branch', '.') else - call_git('install', name, 'clone', args.url, dir) + call_git(name, dir, 'install', 'clone', args.url, '.') end end end -local function update_pkg(name, dir) - if is_pkg_dir(dir) then - call_git('update', name, '-C', dir, 'pull') +local function update_pkg(name, dir, isdir) + if isdir then + call_git(name, dir, 'update', 'pull') end end local function map_pkgs(fn) - local dir + local dir, isdir for name, args in pairs(packages) do - dir = get_dir(name, args.opt) - fn(name, dir, args) + dir = PATH .. (opt and 'opt/' or 'start/') .. name + isdir = vim.fn.isdirectory(dir) ~= 0 + fn(name, dir, isdir, args) end end -function rmdir(dir, ispkgdir) - local name, child - local ok = true -- Some calls to this function might be NOP - local handle = loop.fs_scandir(dir) +local function rmdir(dir, ispkgdir) + local name, t, child, ok + local handle = uv.fs_scandir(dir) while handle do - name, t = loop.fs_scandir_next(handle) + name, t = uv.fs_scandir_next(handle) if not name then break end child = dir .. '/' .. name if ispkgdir then --check which packages are listed - if not packages[name] then --package isn't listed + if packages[name] then --do nothing + ok = true + else --package isn't listed, remove it ok = rmdir(child) print_res('uninstall', name, ok) end else --it's an arbitrary directory or file - ok = (t == 'directory') and rmdir(child) or loop.fs_unlink(child) + ok = (t == 'directory') and rmdir(child) or uv.fs_unlink(child) end if not ok then return end end - return ispkgdir or loop.fs_rmdir(dir) -- Don't delete start or opt + return ispkgdir or uv.fs_rmdir(dir) -- Don't delete start or opt end local function paq(args) - local t = type(args) - if t == 'string' then + if type(args) == 'string' then args = {args} - elseif t ~= 'table' then - return end local reponame = args[1]:match(REPO_RE)