Skip to content

Commit b20a146

Browse files
authored
Merge pull request #2 from magnusriga/test-suite
Test suite
2 parents 8dc578b + dcee949 commit b20a146

26 files changed

+2040
-1410
lines changed

.github/workflows/changelog.yml

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# .github/workflows/changelog.yml
2+
name: Check Changelog
3+
4+
on:
5+
pull_request:
6+
types:
7+
- opened
8+
- synchronize
9+
- reopened
10+
branches:
11+
- main
12+
13+
jobs:
14+
check-changelog:
15+
name: Verify CHANGELOG.md update
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0 # Fetch all history to compare changes
21+
22+
- name: Get changed files
23+
id: changed-files
24+
uses: tj-actions/changed-files@v44 # Use a dedicated action to get changed files
25+
with:
26+
files: CHANGELOG.md
27+
28+
- name: Check if CHANGELOG.md was modified
29+
if: steps.changed-files.outputs.any_changed != 'true'
30+
run: |
31+
echo "Error: No changes detected in CHANGELOG.md."
32+
echo "Please update the CHANGELOG.md file with details about your changes."
33+
exit 1

.github/workflows/lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# .github/workflows/lint.yml
2+
name: Lint
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
stylua:
12+
name: Check Lua code style with stylua
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
- name: Run stylua check
17+
uses: JohnnyMorganz/stylua-action@v4
18+
with:
19+
token: ${{ secrets.GITHUB_TOKEN }}
20+
version: latest
21+
args: --check . # Explicitly tell stylua to check the current directory

.github/workflows/test.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# .github/workflows/test.yml
2+
name: Test
3+
4+
on:
5+
push:
6+
branches: [main]
7+
pull_request:
8+
branches: [main]
9+
10+
jobs:
11+
test:
12+
name: Run tests
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- name: Set up Neovim
18+
uses: rhysd/action-setup-vim@v1
19+
with:
20+
neovim: true
21+
version: stable # Or specify a version like 'v0.9.5'
22+
23+
- name: Run tests
24+
run: make test # Use Makefile target

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
.Trashes
1010
ehthumbs.db
1111
Thumbs.db
12+
13+
# Test dependencies
14+
plenary.nvim/

CHANGELOG.md

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
99

1010
## [Unreleased]
1111

12+
### Added
13+
14+
- Added comprehensive test suite using `plenary.nvim`.
15+
- Added `stylua` for code formatting and linting.
16+
17+
### Changed
18+
19+
- Updated `MarkdownCodeBlock` command to correctly handle visual selections, including multi-line selections and selections starting mid-line.
20+
1221
## [1.0.1] - 2025-05-05
1322

1423
### Added
1524

1625
### Changed
26+
1727
- Allow `MarkdownNewTemplate` command to be used in any filetype.
1828

1929
### Deprecated
2030

2131
### Removed
2232

2333
### Fixed
34+
2435
- Visual mode keymap for inserting headers now correctly exits visual mode before executing the command.
2536

2637
### Security
@@ -49,4 +60,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4960
[Unreleased]: https://github.com/magnusriga/markdown-tools.nvim/compare/v1.0.1...HEAD
5061
[1.0.1]: https://github.com/magnusriga/markdown-tools.nvim/compare/v1.0.0...v1.0.1
5162
[1.0.0]: https://github.com/magnusriga/markdown-tools.nvim/compare/v0.1.0...v1.0.0
52-
[0.1.0]: https://github.com/magnusriga/markdown-tools.nvim/releases/tag/v0.1.0

Makefile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Makefile
2+
3+
# Prevent targets from conflicting with files of the same name
4+
.PHONY: test lint clean
5+
6+
# Default target (optional, runs if you just type 'make')
7+
default: test
8+
9+
# Run the test suite
10+
test:
11+
@echo "Running tests..."
12+
@./scripts/test
13+
14+
# Check Lua code style
15+
lint:
16+
@echo "Checking code style with stylua..."
17+
@stylua --check .
18+
19+
# Remove temporary test dependencies
20+
clean:
21+
@echo "Cleaning up test dependencies..."
22+
@rm -rf plenary.nvim

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
# markdown-tools.nvim 🪄
1+
# markdown-tools.nvim 🪄
22

33
[![Lua](https://img.shields.io/badge/Lua-blue.svg?style=flat-square&logo=lua)](https://www.lua.org)
44
[![License](https://img.shields.io/github/license/magnusriga/markdown-tools.nvim?style=flat-square)](LICENSE)
5+
[![Neovim >= 0.8.0](https://img.shields.io/badge/Neovim-%3E%3D%200.8.0-blueviolet.svg?style=flat-square)](https://neovim.io/)
6+
[![CI Status](https://img.shields.io/github/actions/workflow/status/magnusriga/markdown-tools.nvim/lint.yml?branch=main&style=flat-square)](https://github.com/magnusriga/markdown-tools.nvim/actions)
57

68
> Enhancing your Markdown editing experience in Neovim with intuitive shortcuts and commands.
79
@@ -13,7 +15,7 @@ The markdown created, including the frontmatter, is compatible with [obsidian](h
1315

1416
## ✨ Features
1517

16-
- **📝 Template Creation:** Create new Markdown files from predefined templates using your choice of picker (`snacks`, `fzf-lua`, `telescope`). Automatically adds frontmatter with placeholders (e.g., `alias`, `tags`).
18+
- **📝 Template Creation:** Create new Markdown files from predefined templates, using picker `snacks`, `fzf-lua`, or `telescope`. Automatically adds configurable frontmatter with placeholders (e.g., `alias`, `tags`).
1719
- **🧱 Insert Markdown Elements:** Quickly add links, checkboxes, tables, headers, bold/italic/highlight text, code blocks, ++.
1820
- **🎨 Visual Mode Integration:** Wrap selected text with bold, italic, links, or highlights.
1921
- **✅ Checkbox Management:** Insert new checkboxes and toggle their state.

lua/markdown-tools/autocmds.lua

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ local M = {}
44
--- Setup autocommands for markdown files
55
---@param options table Plugin configuration options
66
function M.setup_autocmds(options)
7-
-- Create autocommand group
8-
local augroup = vim.api.nvim_create_augroup("MarkdownShortcuts", { clear = true })
7+
-- Create autocommand group
8+
local augroup = vim.api.nvim_create_augroup("MarkdownShortcuts", { clear = true })
99

10-
-- Set up autocommands for markdown files
11-
vim.api.nvim_create_autocmd("FileType", {
12-
group = augroup,
13-
pattern = "markdown",
14-
callback = function()
15-
-- Set up local options for markdown files
16-
if options.enable_local_options then
17-
vim.opt_local.wrap = options.wrap
18-
vim.opt_local.conceallevel = options.conceallevel
19-
vim.opt_local.concealcursor = options.concealcursor
20-
vim.opt_local.spell = options.spell
21-
vim.opt_local.spelllang = options.spelllang
22-
end
23-
end,
24-
})
10+
-- Set up autocommands for markdown files
11+
vim.api.nvim_create_autocmd("FileType", {
12+
group = augroup,
13+
pattern = "markdown",
14+
callback = function()
15+
-- Set up local options for markdown files
16+
if options.enable_local_options then
17+
vim.opt_local.wrap = options.wrap
18+
vim.opt_local.conceallevel = options.conceallevel
19+
vim.opt_local.concealcursor = options.concealcursor
20+
vim.opt_local.spell = options.spell
21+
vim.opt_local.spelllang = options.spelllang
22+
end
23+
end,
24+
})
2525
end
2626

2727
return M

0 commit comments

Comments
 (0)