Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
first usable version
Browse files Browse the repository at this point in the history
  • Loading branch information
NStefan002 committed Sep 25, 2023
1 parent eca01e6 commit 7f08de9
Show file tree
Hide file tree
Showing 10 changed files with 288 additions and 41 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @nstefan002
22 changes: 22 additions & 0 deletions .github/ISSUE_TEMPLATE/Bug_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
name: Bug report
about: It helps making the plugin more stable.
---

## Description

<!-- A clear and concise description of what the bug is. -->

## Steps to reproduce

1. I did `...`
2. Then I saw `...`
3. Error

## Expected behavior

<!-- A clear and concise description of what you expected to happen. -->

## Environment

- Neovim version: [e.g. 0.5.x / 0.6.x / 0.7.x / 0.8.x / Nightly]
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/Feature_request.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
name: Feature request
about: Suggest anything that would make your life easier, or the plugin better.
---

## Describe the problem

<!-- Explain what the new feature is, or if it's for the documentation, what do you expect. -->

## Describe the solution

<!-- Explain what your solution would look like. -->

7 changes: 7 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 📃 Summary

<!-- Provide some context about the pull request, it makes the review easier. -->

## 📸 Preview

<!-- If there's a visual impact to your change, please provide a screenshot. You can directly upload it to GitHub by dragging in this text area. -->
101 changes: 101 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
name: main
on:
push:
pull_request:

jobs:
tests_nightly:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Neovim
shell: bash
run: |
mkdir -p /tmp/nvim
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
cd /tmp/nvim
chmod a+x ./nvim.appimage
./nvim.appimage --appimage-extract
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
- name: Run Tests
run: |
nvim --version
[ ! -d tests ] && exit 0
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
tests_stable:
strategy:
matrix:
os: [ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Install Neovim
shell: bash
run: |
mkdir -p /tmp/nvim
wget -q https://github.com/neovim/neovim/releases/download/stable/nvim.appimage -O /tmp/nvim/nvim.appimage
cd /tmp/nvim
chmod a+x ./nvim.appimage
./nvim.appimage --appimage-extract
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
- name: Run Tests
run: |
nvim --version
[ ! -d tests ] && exit 0
nvim --headless -u tests/init.lua -c "PlenaryBustedDirectory tests/ {minimal_init = 'tests/init.lua', sequential = true}"
docs:
runs-on: ubuntu-latest
needs:
- tests_nightly
- tests_stable
if: ${{ github.ref == 'refs/heads/main' }}
steps:
- uses: actions/checkout@v3
- name: panvimdoc
uses: kdheepak/panvimdoc@main
with:
vimdoc: mdmaker.nvim
version: "Neovim >= 0.9.1"
demojify: true
treesitter: true
- name: apply stylua
uses: JohnnyMorganz/stylua-action@v2
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --config-path=stylua.toml lua/
- name: Push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: "chore(build): auto-generate vimdoc / stylua"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
commit_author: "github-actions[bot] <github-actions[bot]@users.noreply.github.com>"
release:
name: release
if: ${{ github.ref == 'refs/heads/main' }}
needs:
- docs
- tests_nightly
- tests_stable
runs-on: ubuntu-latest
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: simple
package-name: mdmaker.nvim
- uses: actions/checkout@v3
- name: tag stable versions
if: ${{ steps.release.outputs.release_created }}
run: |
git config user.name github-actions[bot]
git config user.email github-actions[bot]@users.noreply.github.com
git remote add gh-token "https://${{ secrets.GITHUB_TOKEN }}@github.com/google-github-actions/release-please-action.git"
git tag -d stable || true
git push origin :stable || true
git tag -a stable -m "Last Stable Release"
git push origin stable
42 changes: 1 addition & 41 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,41 +1 @@
# Compiled Lua sources
luac.out

# luarocks build files
*.src.rock
*.zip
*.tar.gz

# Object files
*.o
*.os
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo
*.def
*.exp

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

.luarc.json
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# ⚒️ MdMaker
>README.md generator for your Neovim config repo. Created for lazy people like me.
## 📺 Showcase

## ✨ Features
104 changes: 104 additions & 0 deletions lua/mdmaker/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
local M = {}
local api = vim.api
local util = require("mdmaker.util")

---@type table<string, any>
M.default_opts = {
nvim_dir = "~/.config/nvim/",
output = "~/.config/nvim/README.md",
package_maganer = "folke/lazy.nvim",
-- if you don't want any of the following fields, set them to ""
title = "Neovim configuration",
version_manager = { name = "", url = "" },
gui = { name = "", url = "" },
enable_url_check = false, -- greatly slows down neovim for few seconds, use it when you REALLY need it
}

---@type table<string, any>
M.opts = {}

function M.setup(opts)
M.opts = vim.tbl_deep_extend("force", M.default_opts, opts or {})
if string.sub(M.opts.nvim_dir, 1, 1) == "~" then
local home_dir = os.getenv("HOME")
M.opts.nvim_dir = home_dir .. string.sub(M.opts.nvim_dir, 2)
end
api.nvim_create_user_command("MdMake", M.generate, {
nargs = 0,
desc = "Generate README.md file for personal nvim config directory.",
})
end

function M.generate()
local ok, files =
pcall(io.popen, "/usr/bin/find " .. M.opts.nvim_dir .. " -type f | /usr/bin/grep lua$", "r")
if not ok then
util.error("Could open/find directory.")
return
end
local repo_pattern = '"[^%s/]+/[^%s/]-"'
local links = {}
for file in files:lines("*l") do
local reader = io.open(file, "r")
local repo_name = nil
local plugin_name = nil
for line in reader:lines("*l") do
repo_name = string.match(line, repo_pattern)
if repo_name and #repo_name <= 39 then
repo_name = string.sub(repo_name, 2, -2)
plugin_name = string.sub(repo_name, string.find(repo_name, "/") + 1)
local url = "https://github.com/" .. repo_name
if M.opts.enable_url_check then
if util.url_is_valid(url) then
table.insert(links, "* [" .. plugin_name .. "](" .. url .. ")\n")
end
else
table.insert(links, "* [" .. plugin_name .. "](" .. url .. ")\n")
end
end
end
reader:close()
end
local output_string = ""
if #M.opts.title > 0 then
output_string = output_string .. "# " .. M.opts.title .. "\n"
end
output_string = output_string
.. "## 📦 Package manager\n* ["
.. string.sub(M.opts.package_maganer, string.find(M.opts.package_maganer, "/") + 1)
.. "](https://github.com/"
.. M.opts.package_maganer
.. ")\n## 🔌 Plugins"
.. "\n"
table.sort(links)
for _, l in pairs(links) do
output_string = output_string .. l
end
if #M.opts.version_manager.name > 0 then
output_string = output_string
.. "## 🗃️ Version manager\n* ["
.. M.opts.version_manager.name
.. "]("
.. M.opts.version_manager.url
.. ")\n"
end
if #M.opts.gui.name > 0 then
output_string = output_string
.. "## ✨ GUI\n* ["
.. M.opts.gui.name
.. "]("
.. M.opts.gui.url
.. ")\n"
end
local output_file
ok, output_file = pcall(io.open, M.opts.output, "w")
if not ok then
util.error("Could not write file.")
return
end
util.info(M.opts.output .. " successfully generated.")
output_file:write(output_string)
output_file:close()
end

return M
28 changes: 28 additions & 0 deletions lua/mdmaker/util.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
local M = {}

---notify user of an error
---@param msg string
function M.error(msg)
-- "\n" for nvim configs that don't use nvim-notify
vim.notify("\n" .. msg, vim.log.levels.WARN, { title = "Mdmaker" })
end

---@param msg string
function M.info(msg)
-- "\n" for nvim configs that don't use nvim-notify
vim.notify("\n" .. msg, vim.log.levels.INFO, { title = "Mdmaker" })
end

---@param url string
function M.url_is_valid(url)
local reader = io.popen(
"/usr/bin/curl --head --silent " .. url .. " | /usr/bin/head -n 1 | /usr/bin/grep -o 200",
"r"
)
local status_code = reader:read("*n")
-- print(status_code)
reader:close()
return status_code == 200
end

return M
5 changes: 5 additions & 0 deletions stylua.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
indent_type = "Spaces"
indent_width = 4
column_width = 100
quote_style = "AutoPreferDouble"
no_call_parentheses = false

0 comments on commit 7f08de9

Please sign in to comment.