Skip to content

Commit 9d2db00

Browse files
committed
feat(refactor): nvim plugin for formatting sql code
1 parent 53b2086 commit 9d2db00

File tree

19 files changed

+772
-426
lines changed

19 files changed

+772
-426
lines changed

.github/FUNDING.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
# These are supported funding model platforms
2-
3-
github: andevgo # Replace with your GitHub Sponsors username
4-
open_collective: # Replace with your Open Collective username
5-
ko_fi: # Replace with your Ko-fi username
6-
tidelift: # Replace with your Tidelift platform name/username
7-
community_bridge: # Replace with your Community Bridge project name
8-
liberapay: # Replace with your Liberapay username
9-
issuehunt: # Replace with your IssueHunt username
10-
otechie: # Replace with your Otechie username
11-
custom: # Replace with your custom funding URL
2+
funding:
3+
github: andev0x
4+
gitee: andev0x
5+
patreon: andev0x
6+
ko-fi: andev0x
7+
custom:
8+
url: https://github.com/sponsors/andev0x/
9+
description: "Support my work on this project"
10+
image: https://raw.githubusercontent.com/aha999/DonateButtons/master/Paypal.png

.github/workflows/ci.yml

Lines changed: 51 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -2,81 +2,75 @@ name: CI
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [main, develop]
66
pull_request:
7-
branches: [ main ]
7+
branches: [main]
88

99
jobs:
1010
test:
1111
runs-on: ubuntu-latest
1212
strategy:
1313
matrix:
14-
python-version: [3.8, 3.9, '3.10', '3.11']
15-
neovim-version: ['stable', 'nightly']
14+
nvim-version: ["stable", "nightly"]
1615

1716
steps:
18-
- uses: actions/checkout@v3
17+
- uses: actions/checkout@v3
1918

20-
- name: Set up Python ${{ matrix.python-version }}
21-
uses: actions/setup-python@v4
22-
with:
23-
python-version: ${{ matrix.python-version }}
19+
- name: Setup Neovim
20+
uses: rhymond/setup-neovim@v1
21+
with:
22+
version: ${{ matrix.nvim-version }}
2423

25-
- name: Install Python dependencies
26-
run: |
27-
python -m pip install --upgrade pip
28-
pip install sqlparse
29-
pip install vim-vint
30-
pip install pynvim
24+
- name: Setup Python
25+
uses: actions/setup-python@v4
26+
with:
27+
python-version: "3.x"
3128

32-
- name: Install Neovim
33-
run: |
34-
if [ "${{ matrix.neovim-version }}" = "stable" ]; then
35-
sudo add-apt-repository -y ppa:neovim-ppa/stable
36-
else
37-
sudo add-apt-repository -y ppa:neovim-ppa/unstable
38-
fi
39-
sudo apt-get update
40-
sudo apt-get install -y neovim
29+
- name: Install sqlparse
30+
run: pip install sqlparse
4131

42-
- name: Check VimScript syntax
43-
run: |
44-
vint plugin/
45-
vint autoload/
32+
- name: Install Lua dependencies
33+
run: |
34+
sudo apt-get update
35+
sudo apt-get install -y luarocks
36+
sudo luarocks install luacheck
4637
47-
- name: Run Python tests
48-
run: |
49-
python -m unittest discover -s tests
38+
- name: Run luacheck
39+
run: luacheck lua/ --globals vim
5040

51-
- name: Check for Python syntax errors
52-
run: |
53-
python -m py_compile python/*.py
41+
- name: Check plugin loads
42+
run: |
43+
nvim --headless -c "lua require('sql-formatter')" -c "qa!"
5444
55-
- name: Check for Python type hints
56-
run: |
57-
pip install mypy
58-
mypy python/*.py
45+
- name: Test external formatter
46+
run: |
47+
echo "SELECT * FROM users WHERE active=1;" | sqlformat --reindent --keywords upper --identifiers lower -
5948
60-
lint:
49+
release:
50+
needs: test
6151
runs-on: ubuntu-latest
62-
steps:
63-
- uses: actions/checkout@v3
64-
65-
- name: Set up Python
66-
uses: actions/setup-python@v4
67-
with:
68-
python-version: '3.11'
52+
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
6953

70-
- name: Install dependencies
71-
run: |
72-
python -m pip install --upgrade pip
73-
pip install flake8
74-
pip install black
54+
steps:
55+
- uses: actions/checkout@v3
56+
with:
57+
fetch-depth: 0
7558

76-
- name: Run flake8
77-
run: |
78-
flake8 python/ --count --select=E9,F63,F7,F82 --show-source --statistics
59+
- name: Generate changelog
60+
id: changelog
61+
run: |
62+
# Simple changelog generation
63+
echo "## Changes" > CHANGELOG.tmp
64+
git log --oneline --since="$(git describe --tags --abbrev=0 2>/dev/null || echo '1970-01-01')" >> CHANGELOG.tmp
7965
80-
- name: Run black
81-
run: |
82-
black --check python/
66+
- name: Create Release
67+
uses: actions/create-release@v1
68+
if: contains(github.event.head_commit.message, '[release]')
69+
env:
70+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
71+
with:
72+
tag_name: v${{ github.run_number }}
73+
release_name: Release v${{ github.run_number }}
74+
body_path: CHANGELOG.tmp
75+
draft: false
76+
prerelease: false

Makefile

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Makefile for nvim-sql-formatter
2+
3+
.PHONY: install test lint clean format check-deps
4+
5+
# Installation
6+
install:
7+
@echo "Installing development dependencies..."
8+
@command -v luacheck >/dev/null 2>&1 || { echo "Installing luacheck..."; luarocks install luacheck; }
9+
@command -v stylua >/dev/null 2>&1 || { echo "Installing stylua..."; cargo install stylua; }
10+
11+
# Testing
12+
test:
13+
@echo "Running tests..."
14+
@nvim --headless -c "lua require('plenary.test_harness').test_directory('tests')" -c "qa!"
15+
16+
# Linting
17+
lint:
18+
@echo "Running luacheck..."
19+
@luacheck lua/ --globals vim
20+
21+
# Formatting
22+
format:
23+
@echo "Formatting Lua files..."
24+
@stylua lua/
25+
26+
# Check dependencies
27+
check-deps:
28+
@echo "Checking dependencies..."
29+
@command -v nvim >/dev/null 2>&1 || { echo "Neovim not found"; exit 1; }
30+
@nvim --version | head -1
31+
@command -v sqlformat >/dev/null 2>&1 && echo "sqlparse: Available" || echo "sqlparse: Not available (install with: pip install sqlparse)"
32+
33+
# Clean
34+
clean:
35+
@echo "Cleaning temporary files..."
36+
@find . -name "*.tmp" -delete
37+
@find . -name ".DS_Store" -delete
38+
39+
# Development setup
40+
dev-setup: install check-deps
41+
@echo "Development environment ready!"

0 commit comments

Comments
 (0)