|
| 1 | +# Contributing to `obsidian.nvim` |
| 2 | + |
| 3 | +Thanks for considering contributing! |
| 4 | +Please read this document to learn the various steps you should take before submitting a pull request. |
| 5 | + |
| 6 | +## TL;DR |
| 7 | + |
| 8 | +- Start an issue to discuss the planned changes |
| 9 | +- To submit a pull request |
| 10 | + - Start developing your feature in a branch |
| 11 | + - Make sure that your codes complies the `obsidian.nvim` code style, run |
| 12 | + `make chores` |
| 13 | + - The PR should contain |
| 14 | + - The code changes |
| 15 | + - Tests for the code changes |
| 16 | + - Documentation for the code changes (in the code itself and in the `README.md`) |
| 17 | + - `CHANGELOG.md` entry for the code changes |
| 18 | + |
| 19 | +## Details |
| 20 | + |
| 21 | +Note: we automate tedious tasks using a `Makefile` in the root of the repository. |
| 22 | +Just call `make` to see what you can do, or `make chores` to run the most important tasks on your code. |
| 23 | +You can override some parts of the `Makefile` by setting env variables. |
| 24 | + |
| 25 | +### Local development with LuaLS and `plenary.nvim` |
| 26 | + |
| 27 | +If you're using the [Lua Language Server](https://luals.github.io) (LuaLS) you'll probably want to add `plenary.nvim` as a workspace library since we rely heavily on plenary throughout the codebase. |
| 28 | +You can do this by adding a `.luarc.json` configuration file that looks like this: |
| 29 | + |
| 30 | +```json |
| 31 | +{ |
| 32 | + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", |
| 33 | + "workspace.library": ["~/.local/share/nvim/lazy/plenary.nvim/"], |
| 34 | + "runtime.version": "Lua 5.1" |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +Make sure that the path there to plenary is correct for you. |
| 39 | + |
| 40 | +### Keeping the `CHANGELOG.md` up-to-date |
| 41 | + |
| 42 | +This project tries hard to adhere to [Semantic Versioning](https://semver.org/spec/v2.0.0.html), |
| 43 | +and we maintain a [`CHANGELOG`](https://github.com/obsidian-nvim/obsidian.nvim/blob/main/CHANGELOG.md) |
| 44 | +with a format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). |
| 45 | +If your PR addresses a bug or makes any other substantial change, |
| 46 | +please be sure to add an entry under the "Unreleased" section at the top of `CHANGELOG.md`. |
| 47 | +Entries should always be in the form of a list item under a level-3 header of either "Added", "Fixed", "Changed", or "Removed" for the most part. |
| 48 | +If the corresponding level-3 header for your item does not already exist in the "Unreleased" section, you should add it. |
| 49 | + |
| 50 | +### Formatting code |
| 51 | + |
| 52 | +TL;DR: `make style` |
| 53 | + |
| 54 | +Lua code should be formatted using [StyLua](https://github.com/JohnnyMorganz/StyLua). |
| 55 | +Once you have StyLua installed, you can run `make style` to automatically apply styling to all of the Lua files in this repo. |
| 56 | + |
| 57 | +### Linting code |
| 58 | + |
| 59 | +TL;DR: `make lint` |
| 60 | + |
| 61 | +We use [luacheck](https://github.com/mpeterv/luacheck) to lint the Lua code. |
| 62 | +Once you have `luacheck` installed, you can run `make lint` to get a report. |
| 63 | + |
| 64 | +### Running tests |
| 65 | + |
| 66 | +TL;DR: `make test` |
| 67 | + |
| 68 | +Tests are written in the `test/` folder and are run using the [Plenary](https://github.com/nvim-lua/plenary.nvim) test harness. |
| 69 | +Since Plenary is a dependency of `obsidian.nvim`, you probably already have it installed somewhere. |
| 70 | +To run the tests locally you'll need to know where it's installed, which depends on your plugin manager. |
| 71 | +In my case I use `Lazy.nvim` which puts Plenary at `~/.local/share/nvim/lazy/plenary.nvim/`. |
| 72 | + |
| 73 | +### Building the vim user documentation |
| 74 | + |
| 75 | +TL;DR: `make user-docs` |
| 76 | + |
| 77 | +The Vim documentation lives at `doc/obsidian.txt`, which is automatically generated from the `README.md` using [panvimdoc](https://github.com/kdheepak/panvimdoc). |
| 78 | +**Please only commit documentation changes to the `README.md`, not `doc/obsidian.txt`.** |
| 79 | + |
| 80 | +However you can test how changes to the README will affect the Vim doc by running `panvimdoc` locally. |
| 81 | +To do this you'll need install `pandoc` (e.g. `brew install pandoc` on Mac) |
| 82 | +and clone [panvimdoc ](https://github.com/kdheepak/panvimdoc) (e.g. `git clone [email protected]:kdheepak/panvimdoc.git ../panvimdoc`). |
| 83 | + |
| 84 | +This will build the Vim documentation to `/tmp/obsidian.txt`. |
| 85 | + |
| 86 | +### Building the vim API documentation |
| 87 | + |
| 88 | +TL;DR: `make api-docs` |
| 89 | + |
| 90 | +The API docs lives in `doc/obsidian_api.txt` and is generated from the source code using [`mini.docs`](https://github.com/echasnovski/mini.doc). |
| 91 | +It is automatically generated via CI. |
0 commit comments