Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
savq committed Nov 20, 2020
2 parents 8fe5b25 + f4d0c3b commit afcfcf8
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 99 deletions.
21 changes: 21 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -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?`
11 changes: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

49 changes: 0 additions & 49 deletions doc/paq-nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ CONTENTS *paq-contents*
Commands |paq-commands|
Paq directory |paq-directory|
Moving from other package managers |paq-moving|
Contributing |paq-contributing|


==============================================================================
Expand Down Expand Up @@ -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:
69 changes: 30 additions & 39 deletions lua/paq-nvim.lua
Original file line number Diff line number Diff line change
@@ -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)
Expand All @@ -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)
Expand Down

0 comments on commit afcfcf8

Please sign in to comment.