Skip to content

Commit 3d48d48

Browse files
committed
refactor(nvim): Add CONTRIBUTING.md and refactor tests
1 parent b4448e2 commit 3d48d48

File tree

3 files changed

+62
-50
lines changed

3 files changed

+62
-50
lines changed

CONTRIBUTING.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Contributing
2+
3+
Thanks for contributing to `remote-nvim.nvim`. Your help means a lot!
4+
5+
You can make contributions in the following ways:
6+
7+
- **Mention it** to others if it has helped enhance/improve your workflow.
8+
- **Create GitHub issues** so that we know what we should work on building/fixing next.
9+
- **Raise PR** to fix bugs, improve documentation, add features, etc. The list goes on.
10+
- **Participate** in issues and discussions.
11+
12+
## Getting started
13+
14+
If you are setting the repo up, run `make install-hooks` to install the pre-commit hooks. These hooks should take care
15+
of most meta-things needed. Please make sure that the pre-commit checks and tests pass before raising the PR. In case,
16+
something is unclear, please raise the PR and we can take care of it then!
17+
18+
### Pre-requisites
19+
20+
- LuaLS (LSP server)
21+
- [lazydev.nvim](https://github.com/folke/lazydev.nvim/)
22+
- pre-commit
23+
24+
Steps:
25+
26+
1. Run `make install-hooks`: Installs all necessary pre-commit hooks. Post setup, it should take care of all meta-things
27+
like formatting, linting, etc.
28+
2. Setup [lazydev.nvim](https://github.com/folke/lazydev.nvim/). If this is not your thing, setup
29+
[.luarc.json](https://github.com/amitds1997/remote-nvim.nvim/blob/2d5158a/.luarc.json) file at the root
30+
of the project.
31+
32+
Once setup, make your changes!
33+
34+
### Testing
35+
36+
If you make any code changes, please add relevant test(s) post that. Once done,
37+
run `make clean-test` to run the tests. Make sure that the tests pass before creating the PR.
38+
39+
### Commit message guidelines
40+
41+
- For any features, bugs, etc. please use conventional commit message format. This helps in
42+
automatic changelog generations.
43+
- For any minor changes that is not code related, it is OK if you do not use conventional commits.
44+
45+
### Other information
46+
47+
- Help file is generated from the README (which is not an ideal solution, but it helps reduce the workload). So,
48+
update the README, if documentation needs to be updated.
49+
50+
## Credits
51+
52+
This documentation is heavily plaguarized from the `mini.nvim` CONTRIBUTING.md. So, thanks!

tests/init.lua

Lines changed: 8 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,8 @@
1-
local M = {}
2-
3-
function M.root(root)
4-
local f = debug.getinfo(1, "S").source:sub(2)
5-
return vim.fn.fnamemodify(f, ":p:h:h") .. "/" .. (root or "")
6-
end
7-
8-
---@param plugin string
9-
function M.load(plugin)
10-
local name = plugin:match(".*/(.*)")
11-
local package_root = M.root(".tests/site/pack/deps/start/")
12-
local uv = vim.fn.has("nvim-0.10") and vim.uv or vim.loop
13-
---@diagnostic disable-next-line: undefined-field
14-
if not uv.fs_stat(package_root .. name) then
15-
print("Installing " .. plugin)
16-
vim.fn.mkdir(package_root, "p")
17-
vim.fn.system({
18-
"git",
19-
"clone",
20-
"--depth=1",
21-
"https://github.com/" .. plugin .. ".git",
22-
package_root .. "/" .. name,
23-
})
24-
end
25-
end
26-
27-
function M.setup()
28-
vim.cmd([[set runtimepath=$VIMRUNTIME]])
29-
vim.opt.runtimepath:append(M.root())
30-
vim.opt.packpath = { M.root(".tests/site") }
31-
vim.opt.termguicolors = true
32-
vim.env.XDG_CONFIG_HOME = M.root(".tests/config")
33-
vim.env.XDG_DATA_HOME = M.root(".tests/data")
34-
vim.env.XDG_STATE_HOME = M.root(".tests/state")
35-
vim.env.XDG_CACHE_HOME = M.root(".tests/cache")
36-
37-
M.load("MunifTanjim/nui.nvim")
38-
M.load("nvim-lua/plenary.nvim")
39-
M.load("nvim-telescope/telescope.nvim")
40-
41-
require("remote-nvim").setup({
42-
log = {
43-
level = "debug",
44-
max_size = 0,
45-
},
46-
})
47-
end
48-
49-
M.setup()
1+
vim.env.LAZY_STDPATH = ".tests"
2+
load(vim.fn.system("curl -s https://raw.githubusercontent.com/folke/lazy.nvim/main/bootstrap.lua"))()
3+
4+
require("lazy.minit").repro({
5+
spec = {
6+
{ dir = vim.uv.cwd(), config = true },
7+
},
8+
})

tests/remote-nvim/providers/provider_spec.lua

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,10 @@ describe("Provider", function()
7373

7474
describe("should handle setting workspace variables", function()
7575
local detect_remote_os_and_arch_stub, get_remote_neovim_version_preference_stub
76-
local workspace_id = require("remote-nvim.utils").generate_random_string(10)
76+
local workspace_id
7777

7878
before_each(function()
79+
workspace_id = require("remote-nvim.utils").generate_random_string(10)
7980
provider = Provider({
8081
host = provider_host,
8182
conn_opts = { "-p", "3011" },

0 commit comments

Comments
 (0)