Skip to content

Commit eb5987e

Browse files
committed
feat: first working version
1 parent 100fd00 commit eb5987e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1977
-0
lines changed

.envrc

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
layout python
2+
python -c 'import pyparsing' 2> /dev/null || pip install pyparsing==3.0.9 black isort mypy

.github/ISSUE_TEMPLATE/bug_report.yml

+112
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
name: Bug Report
2+
description: File a bug/issue
3+
title: "bug: "
4+
labels: [bug]
5+
body:
6+
- type: markdown
7+
attributes:
8+
value: |
9+
Before reporting a bug, make sure to search [existing issues](https://github.com/stevearc/conform.nvim/issues)
10+
- type: input
11+
attributes:
12+
label: "Neovim version (nvim -v)"
13+
placeholder: "0.8.0 commit db1b0ee3b30f"
14+
validations:
15+
required: true
16+
- type: input
17+
attributes:
18+
label: "Operating system/version"
19+
placeholder: "MacOS 11.5"
20+
validations:
21+
required: true
22+
- type: textarea
23+
attributes:
24+
label: "Output of :checkhealth conform"
25+
validations:
26+
required: true
27+
- type: textarea
28+
attributes:
29+
label: Describe the bug
30+
description: A clear and concise description of what the bug is.
31+
validations:
32+
required: true
33+
- type: textarea
34+
attributes:
35+
label: Steps To Reproduce
36+
description: Steps to reproduce the behavior.
37+
placeholder: |
38+
1. nvim -u repro.lua
39+
2.
40+
3.
41+
validations:
42+
required: true
43+
- type: textarea
44+
attributes:
45+
label: Expected Behavior
46+
description: A concise description of what you expected to happen.
47+
validations:
48+
required: true
49+
- type: textarea
50+
attributes:
51+
label: Minimal example file
52+
description: A small example file you are editing that produces the issue
53+
validations:
54+
required: false
55+
- type: textarea
56+
attributes:
57+
label: Minimal init.lua
58+
description:
59+
Minimal `init.lua` to reproduce this issue. Save as `repro.lua` and run with `nvim -u repro.lua`
60+
This uses lazy.nvim (a plugin manager).
61+
value: |
62+
-- DO NOT change the paths and don't remove the colorscheme
63+
local root = vim.fn.fnamemodify("./.repro", ":p")
64+
65+
-- set stdpaths to use .repro
66+
for _, name in ipairs({ "config", "data", "state", "cache" }) do
67+
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
68+
end
69+
70+
-- bootstrap lazy
71+
local lazypath = root .. "/plugins/lazy.nvim"
72+
if not vim.loop.fs_stat(lazypath) then
73+
vim.fn.system({
74+
"git",
75+
"clone",
76+
"--filter=blob:none",
77+
"--single-branch",
78+
"https://github.com/folke/lazy.nvim.git",
79+
lazypath,
80+
})
81+
end
82+
vim.opt.runtimepath:prepend(lazypath)
83+
84+
-- install plugins
85+
local plugins = {
86+
"folke/tokyonight.nvim",
87+
{
88+
"stevearc/conform.nvim",
89+
config = function()
90+
require("conform").setup({
91+
log_level = vim.log.levels.DEBUG,
92+
-- add your config here
93+
})
94+
end,
95+
},
96+
-- add any other plugins here
97+
}
98+
require("lazy").setup(plugins, {
99+
root = root .. "/plugins",
100+
})
101+
102+
vim.cmd.colorscheme("tokyonight")
103+
-- add anything else here
104+
render: Lua
105+
validations:
106+
required: false
107+
- type: textarea
108+
attributes:
109+
label: Additional context
110+
description: Any additional information or screenshots you would like to provide
111+
validations:
112+
required: false

.github/generate.py

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
import os
2+
import os.path
3+
import re
4+
from typing import List
5+
6+
from nvim_doc_tools import (
7+
Vimdoc,
8+
VimdocSection,
9+
generate_md_toc,
10+
parse_functions,
11+
read_nvim_json,
12+
render_md_api,
13+
render_vimdoc_api,
14+
replace_section,
15+
)
16+
17+
HERE = os.path.dirname(__file__)
18+
ROOT = os.path.abspath(os.path.join(HERE, os.path.pardir))
19+
README = os.path.join(ROOT, "README.md")
20+
DOC = os.path.join(ROOT, "doc")
21+
VIMDOC = os.path.join(DOC, "conform.txt")
22+
23+
24+
def update_formatter_list():
25+
formatters = sorted(
26+
[
27+
os.path.splitext(file)[0]
28+
for file in os.listdir(os.path.join(ROOT, "lua", "conform", "formatters"))
29+
]
30+
)
31+
formatter_lines = ["\n"]
32+
for formatter in formatters:
33+
meta = read_nvim_json(f'require("conform.formatters.{formatter}").meta')
34+
formatter_lines.append(
35+
f"- [{formatter}]({meta['url']}) - {meta['description']}\n"
36+
)
37+
replace_section(
38+
README,
39+
r"^<!-- FORMATTERS -->$",
40+
r"^<!-- /FORMATTERS -->$",
41+
formatter_lines,
42+
)
43+
44+
45+
def add_md_link_path(path: str, lines: List[str]) -> List[str]:
46+
ret = []
47+
for line in lines:
48+
ret.append(re.sub(r"(\(#)", "(" + path + "#", line))
49+
return ret
50+
51+
52+
def update_md_api():
53+
funcs = parse_functions(os.path.join(ROOT, "lua", "conform", "init.lua"))
54+
lines = ["\n"] + render_md_api(funcs, 3)[:-1] # trim last newline
55+
replace_section(
56+
README,
57+
r"^<!-- API -->$",
58+
r"^<!-- /API -->$",
59+
lines,
60+
)
61+
62+
63+
def update_readme_toc():
64+
toc = ["\n"] + generate_md_toc(README) + ["\n"]
65+
replace_section(
66+
README,
67+
r"^<!-- TOC -->$",
68+
r"^<!-- /TOC -->$",
69+
toc,
70+
)
71+
72+
73+
def generate_vimdoc():
74+
doc = Vimdoc("conform.txt", "conform")
75+
funcs = parse_functions(os.path.join(ROOT, "lua", "conform", "init.lua"))
76+
doc.sections.extend(
77+
[
78+
VimdocSection("API", "conform-api", render_vimdoc_api("conform", funcs)),
79+
]
80+
)
81+
82+
with open(VIMDOC, "w", encoding="utf-8") as ofile:
83+
ofile.writelines(doc.render())
84+
85+
86+
def main() -> None:
87+
"""Update the README"""
88+
update_formatter_list()
89+
update_md_api()
90+
update_readme_toc()
91+
generate_vimdoc()

.github/main.py

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env python
2+
import argparse
3+
import os
4+
import sys
5+
6+
HERE = os.path.dirname(__file__)
7+
ROOT = os.path.abspath(os.path.join(HERE, os.path.pardir))
8+
DOC = os.path.join(ROOT, "doc")
9+
10+
11+
def main() -> None:
12+
"""Generate docs"""
13+
sys.path.append(HERE)
14+
parser = argparse.ArgumentParser(description=main.__doc__)
15+
parser.add_argument("command", choices=["generate", "lint"])
16+
args = parser.parse_args()
17+
if args.command == "generate":
18+
import generate
19+
20+
generate.main()
21+
elif args.command == "lint":
22+
from nvim_doc_tools import lint_md_links
23+
24+
files = [os.path.join(ROOT, "README.md")] + [
25+
os.path.join(DOC, file) for file in os.listdir(DOC) if file.endswith(".md")
26+
]
27+
lint_md_links.main(ROOT, files)
28+
29+
30+
if __name__ == "__main__":
31+
main()

.github/nvim_doc_tools

Submodule nvim_doc_tools added at 4260b37

.github/pre-commit

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/bin/bash
2+
set -e
3+
luacheck lua tests
4+
5+
stylua --check .

.github/pre-push

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/bash
2+
set -e
3+
luacheck lua tests
4+
5+
stylua --check .
6+
7+
lua-typecheck lua

.github/workflows/install_nvim.sh

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
set -e
3+
PLUGINS="$HOME/.local/share/nvim/site/pack/plugins/start"
4+
mkdir -p "$PLUGINS"
5+
6+
wget "https://github.com/neovim/neovim/releases/download/${NVIM_TAG}/nvim.appimage"
7+
chmod +x nvim.appimage
8+
./nvim.appimage --appimage-extract >/dev/null
9+
rm -f nvim.appimage
10+
mkdir -p ~/.local/share/nvim
11+
mv squashfs-root ~/.local/share/nvim/appimage
12+
sudo ln -s "$HOME/.local/share/nvim/appimage/AppRun" /usr/bin/nvim

.github/workflows/tests.yml

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Run tests
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
luacheck:
7+
name: Luacheck
8+
runs-on: ubuntu-22.04
9+
steps:
10+
- uses: actions/checkout@v3
11+
12+
- name: Prepare
13+
run: |
14+
sudo apt-get update
15+
sudo add-apt-repository universe
16+
sudo apt install luarocks -y
17+
sudo luarocks install luacheck
18+
19+
- name: Run Luacheck
20+
run: luacheck .
21+
22+
typecheck:
23+
name: typecheck
24+
runs-on: ubuntu-22.04
25+
steps:
26+
- uses: actions/checkout@v3
27+
- uses: stevearc/nvim-typecheck-action@v1
28+
with:
29+
path: lua
30+
31+
stylua:
32+
name: StyLua
33+
runs-on: ubuntu-22.04
34+
steps:
35+
- uses: actions/checkout@v3
36+
- name: Stylua
37+
uses: JohnnyMorganz/stylua-action@v3
38+
with:
39+
token: ${{ secrets.GITHUB_TOKEN }}
40+
version: v0.15.2
41+
args: --check .
42+
43+
release:
44+
name: release
45+
46+
if: ${{ github.ref == 'refs/heads/master' }}
47+
needs:
48+
- luacheck
49+
- stylua
50+
- typecheck
51+
runs-on: ubuntu-22.04
52+
steps:
53+
- uses: google-github-actions/release-please-action@v3
54+
id: release
55+
with:
56+
release-type: simple
57+
package-name: conform.nvim
58+
- uses: actions/checkout@v3
59+
- uses: rickstaa/action-create-tag@v1
60+
if: ${{ steps.release.outputs.release_created }}
61+
with:
62+
tag: stable
63+
message: "Current stable release: ${{ steps.release.outputs.tag_name }}"
64+
tag_exists_error: false
65+
force_push_tag: true

.github/workflows/update-docs.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Update docs
2+
3+
on: push
4+
5+
jobs:
6+
update-readme:
7+
name: Update docs
8+
runs-on: ubuntu-22.04
9+
steps:
10+
- uses: actions/checkout@v3
11+
with:
12+
submodules: true
13+
14+
- name: Install Neovim and dependencies
15+
env:
16+
NVIM_TAG: v0.8.3
17+
run: |
18+
bash ./.github/workflows/install_nvim.sh
19+
20+
- name: Update docs
21+
env:
22+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
COMMIT_MSG: |
24+
[docgen] Update docs
25+
skip-checks: true
26+
run: |
27+
git config user.email "actions@github"
28+
git config user.name "Github Actions"
29+
git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git
30+
python -m pip install pyparsing==3.0.9
31+
python .github/main.py generate
32+
python .github/main.py lint
33+
git add README.md doc
34+
# Only commit and push if we have changes
35+
git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin HEAD:${GITHUB_REF})

0 commit comments

Comments
 (0)