From 879d3509a717f8e24478642e58f13baf0ebd5683 Mon Sep 17 00:00:00 2001 From: pysan3 Date: Tue, 14 Nov 2023 04:10:07 +0900 Subject: [PATCH] feat(base): implement plugin template --- .busted | 12 +++++ .editorconfig | 8 ++++ .github/ISSUE_TEMPLATE/bug_report.yml | 56 ++++++++++++++++++++++ .github/ISSUE_TEMPLATE/config.yml | 3 ++ .github/ISSUE_TEMPLATE/feature_request.yml | 37 ++++++++++++++ .github/workflows/generate-docs.yml | 31 ++++++++++++ .github/workflows/lua_ls-typecheck.yml | 22 +++++++++ .github/workflows/luarocks-tag-release.yml | 42 ++++++++++++++++ .github/workflows/release-please.yml | 26 ++++++++++ .github/workflows/stylua.yml | 49 +++++++++++++++++++ .gitignore | 7 +++ .luacheckrc | 10 ++++ .luarc.json | 7 +++ README.md | 45 ++++++++++++++++- README.norg | 38 +++++++++++++++ lua/pathlib/base.lua | 51 ++++++++++++++++++++ lua/pathlib/init.lua | 29 +++++++++++ lua/pathlib/posix.lua | 0 lua/pathlib/utils/init.lua | 4 ++ lua/pathlib/utils/lists.lua | 29 +++++++++++ lua/pathlib/utils/tables.lua | 10 ++++ lua/pathlib/windows.lua | 0 pathlib.nvim-scm-1.rockspec | 15 ++++++ run-local-tests.sh | 12 +++++ spec/basic_path_spec.lua | 43 +++++++++++++++++ spec/busted_spec.lua | 31 ++++++++++++ spec/hello_world_spec.lua | 11 +++++ stylua.toml | 6 +++ 28 files changed, 632 insertions(+), 2 deletions(-) create mode 100644 .busted create mode 100644 .editorconfig create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml create mode 100644 .github/ISSUE_TEMPLATE/config.yml create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml create mode 100644 .github/workflows/generate-docs.yml create mode 100644 .github/workflows/lua_ls-typecheck.yml create mode 100644 .github/workflows/luarocks-tag-release.yml create mode 100644 .github/workflows/release-please.yml create mode 100644 .github/workflows/stylua.yml create mode 100644 .luacheckrc create mode 100644 .luarc.json create mode 100644 README.norg create mode 100644 lua/pathlib/base.lua create mode 100644 lua/pathlib/init.lua create mode 100644 lua/pathlib/posix.lua create mode 100644 lua/pathlib/utils/init.lua create mode 100644 lua/pathlib/utils/lists.lua create mode 100644 lua/pathlib/utils/tables.lua create mode 100644 lua/pathlib/windows.lua create mode 100644 pathlib.nvim-scm-1.rockspec create mode 100755 run-local-tests.sh create mode 100644 spec/basic_path_spec.lua create mode 100644 spec/busted_spec.lua create mode 100644 spec/hello_world_spec.lua create mode 100644 stylua.toml diff --git a/.busted b/.busted new file mode 100644 index 0000000..a8d9d0c --- /dev/null +++ b/.busted @@ -0,0 +1,12 @@ +return { + _all = { + coverage = false, + lpath = "lua/?.lua;lua/?/init.lua", + }, + default = { + verbose = true, + }, + tests = { + verbose = true, + }, +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6ac203f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +root = true + +[*.{lua,md,hs,nix}] +end_of_line = lf +charset = utf-8 +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml new file mode 100644 index 0000000..e5c9e60 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.yml @@ -0,0 +1,56 @@ +name: Bug Report +description: Report a problem in Neorg +labels: [bug] +body: + + - type: checkboxes + id: faq-prerequisite + attributes: + label: Prerequisites + options: + - label: I am using the latest stable release of Neovim + required: true + - label: I am using the latest version of the plugin + required: true + + - type: input + attributes: + label: "Neovim Version" + description: "`nvim --version`:" + validations: + required: true + + - type: textarea + attributes: + label: "Actual behavior" + description: "A description of actual behavior. Extra points if it includes images or videos." + validations: + required: true + + - type: textarea + attributes: + label: "Expected behavior" + description: "A description of the behavior you expected." + validations: + required: true + + - type: textarea + attributes: + label: "Other information" + description: "Other information that could be helpful with debugging." + + - type: dropdown + id: help + attributes: + label: "Help" + description: "Would you be able to resolve this issue by submitting a pull request?" + options: + - "Yes" + - "Yes, but I don't know how to start. I would need guidance (check question below)" + - "No" + + - type: textarea + attributes: + label: "Implementation help" + description: "If you selected yes in the last question please specify what you would need help with in order to resolve the issue." + diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000..57b7e55 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1,3 @@ +contact_links: + - name: Ask a question + about: If you need help with configuration or something else diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml new file mode 100644 index 0000000..25a1192 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -0,0 +1,37 @@ +name: Feature request +description: Request a feature for Neorg +labels: [feature] +body: + + - type: checkboxes + id: issue-prerequisite + attributes: + label: Issues + options: + - label: I have checked [existing issues](https://github.com/pysan3/pathlib.nvim/issues?q=is%3Aissue) and there are no existing ones with the same request. + required: true + + - type: textarea + attributes: + label: "Feature description" + validations: + required: true + + - type: dropdown + id: help + attributes: + label: "Help" + description: "Would you be able to implement this by submitting a pull request?" + options: + - "Yes" + - "Yes, but I don't know how to start. I would need guidance" + - "No" + validations: + required: true + + - type: textarea + attributes: + label: "Implementation help" + description: "If you selected yes in the last question please specify in detail what you would need help with in order to implement this." + validations: + required: false diff --git a/.github/workflows/generate-docs.yml b/.github/workflows/generate-docs.yml new file mode 100644 index 0000000..e24d551 --- /dev/null +++ b/.github/workflows/generate-docs.yml @@ -0,0 +1,31 @@ +name: generate-docs + +on: + push: + branches-ignore: + - main + +jobs: + docs: + name: Generate docs + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: cachix/install-nix-action@v23 + + - name: Generating docs + run: nix run ".#docgen" + + - name: Update documentation + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + COMMIT_MSG: | + docs(generated): update doc/pathlib.nvim.txt + skip-checks: true + run: | + git config user.email "actions@github" + git config user.name "Github Actions" + git remote set-url origin https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git + git add doc/ + # Only commit and push if we have changes + git diff --quiet && git diff --staged --quiet || (git commit -m "${COMMIT_MSG}"; git push origin HEAD:${GITHUB_REF}) diff --git a/.github/workflows/lua_ls-typecheck.yml b/.github/workflows/lua_ls-typecheck.yml new file mode 100644 index 0000000..e80fcd9 --- /dev/null +++ b/.github/workflows/lua_ls-typecheck.yml @@ -0,0 +1,22 @@ +name: lua_ls-typecheck +on: + pull_request: ~ + push: + branches: + - '*' + +jobs: + build: + name: Type Check Code Base + runs-on: ubuntu-latest + + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Type Check Code Base + uses: mrcjkb/lua-typecheck-action@v0.1.2 + with: + directories: | + lua + tests diff --git a/.github/workflows/luarocks-tag-release.yml b/.github/workflows/luarocks-tag-release.yml new file mode 100644 index 0000000..677e440 --- /dev/null +++ b/.github/workflows/luarocks-tag-release.yml @@ -0,0 +1,42 @@ +name: luarocks-tag-release + +on: + push: + release: + types: + - created + tags: + - '*' + workflow_dispatch: + +jobs: + luarocks-upload: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 # Required to count the commits + - name: Get Version + run: echo "LUAROCKS_VERSION=$(git describe --abbrev=0 --tags)" >> $GITHUB_ENV + - name: LuaRocks Upload + uses: nvim-neorocks/luarocks-tag-release@v5 + env: + LUAROCKS_API_KEY: ${{ secrets.LUAROCKS_API_KEY }} + with: + summary: "OS Independent, ultimate solution to path handling in neovim." + detailed_description: | + This plugin aims to decrease the difficulties of path management across mutliple OSs. + The plugin API is heavily inspired by Python's `pathlib.Path` with tweaks to fit neovim usage. + It is mainly used in neo-tree.nvim but it is as simple as you can use it in your own configs! + version: ${{ env.LUAROCKS_VERSION }} + labels: | + neovim + nvim + pathlib + os + test_interpreters: + neovim-stable + neovim-nightly + copy_directories: | + {{ neovim.plugin.dirs }} + doc diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..7fd7433 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -0,0 +1,26 @@ +name: release-please + +on: + push: + branches: + - main + workflow_run: + workflows: + - lua_ls-typecheck + - stylua + types: + - complete + +permissions: + contents: write + pull-requests: write + +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - uses: google-github-actions/release-please-action@v3 + with: + release-type: simple + package-name: pathlib.nvim diff --git a/.github/workflows/stylua.yml b/.github/workflows/stylua.yml new file mode 100644 index 0000000..d8236fa --- /dev/null +++ b/.github/workflows/stylua.yml @@ -0,0 +1,49 @@ +name: stylua + +on: + push: + branches: + - '*' + paths-ignore: + - ".github/**" + - "**.md" + - "**.norg" + +jobs: + format-with-stylua: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Cache cargo modules + id: cache-cargo + uses: actions/cache@v2 + env: + cache-name: cache-node-modules + with: + path: ~/.cargo + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/Cargo.toml') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: Install cargo + run: curl https://sh.rustup.rs -sSf | sh -s -- -y + + - name: Install stylua + run: cargo install stylua --features lua51 + + - name: Run formatting + run: stylua -v --verify . + + - uses: stefanzweifel/git-auto-commit-action@v4 + with: + commit_message: "chore: autoformat with stylua" + branch: ${{ github.ref }} + + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: ${{ github.ref }} diff --git a/.gitignore b/.gitignore index 8305aa8..1e64e29 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,10 @@ luac.out *.x86_64 *.hex +# Luarocks testing files +/luarocks +/lua_modules +/.luarocks +/lua + +!/lua diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..70eb8ac --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,10 @@ +ignore = { + "631", -- max_line_length + "122", -- read-only field of global variable +} +read_globals = { + "vim", + "describe", + "it", + "assert" +} diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 0000000..e575cd0 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,7 @@ +{ + "$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", + "Lua.diagnostics.globals": [ + "vim" + ], + "workspace.checkThirdParty": false +} diff --git a/README.md b/README.md index 2cc7414..aebf0ce 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,43 @@ -# pathlib.nvim -Ultimate solution to path handling in neovim. OS Independent. +``` document.meta +title: README +description: +authors: takuto +categories: +created: 2023-11-14 +updated: 2023-11-14T01:17:18+0900 +version: 1.1.1 +``` + +``` embed +
+

pathlib.nvim

+

+ + OS Independent, ultimate solution to path handling in neovim. + +

+
+``` + +# `pathlib.nvim` + +This plugin aims to decrease the difficulties of path management across +mutliple OSs. The plugin API is heavily inspired by Python's +`pathlib.Path` with tweaks to fit neovim usage. It is mainly used in +[neo-tree.nvim](https://github.com/nvim-neo-tree/neo-tree.nvim) but it +is as simple as you can use it in your own configs! + +[![Neovim](https://img.shields.io/badge/NeoVim-%2357A143.svg?&style=for-the-badge&logo=neovim&logoColor=white)](https://neovim.io/) +[![Lua](https://img.shields.io/badge/lua-%232C2D72.svg?style=for-the-badge&logo=lua&logoColor=white)](https://www.lua.org/) + +[![MLP-2.0](https://img.shields.io/github/license/pysan3/pathlib.nvim.svg?style=for-the-badge)](https://github.com/pysan3/pathlib.nvim/blob/master/LICENSE) +[![Issues](https://img.shields.io/github/issues/pysan3/pathlib.nvim.svg?style=for-the-badge)](https://github.com/pysan3/pathlib.nvim/issues) +[![Build +Status](https://img.shields.io/github/actions/workflow/status/pysan3/pathlib.nvim/release-please.yml?style=for-the-badge)](https://github.com/pysan3/pathlib.nvim/actions/workflows/release-please.yml) +[![LuaRocks](https://img.shields.io/luarocks/v/pysan3/pathlib.nvim?logo=lua&color=purple&style=for-the-badge)](https://luarocks.org/modules/pysan3/pathlib.nvim) + +# Other Projects + +- Python `pathlib` + + - diff --git a/README.norg b/README.norg new file mode 100644 index 0000000..a7e5d90 --- /dev/null +++ b/README.norg @@ -0,0 +1,38 @@ +@document.meta +title: README +description: +authors: takuto +categories: +created: 2023-11-14 +updated: 2023-11-14T01:17:18+0900 +version: 1.1.1 +@end + +@embed html +
+

pathlib.nvim

+

+ + OS Independent, ultimate solution to path handling in neovim. + +

+
+@end + +* `pathlib.nvim` + This plugin aims to decrease the difficulties of path management across mutliple OSs. + The plugin API is heavily inspired by Python's `pathlib.Path` with tweaks to fit neovim usage. + It is mainly used in {https://github.com/nvim-neo-tree/neo-tree.nvim}[neo-tree.nvim] + but it is as simple as you can use it in your own configs! + + {https://neovim.io/}[!{https://img.shields.io/badge/NeoVim-%2357A143.svg?&style=for-the-badge&logo=neovim&logoColor=white}[Neovim]] + {https://www.lua.org/}[!{https://img.shields.io/badge/lua-%232C2D72.svg?style=for-the-badge&logo=lua&logoColor=white}[Lua]] + + {https://github.com/pysan3/pathlib.nvim/blob/master/LICENSE}[!{https://img.shields.io/github/license/pysan3/pathlib.nvim.svg?style=for-the-badge}[MLP-2.0]] + {https://github.com/pysan3/pathlib.nvim/issues}[!{https://img.shields.io/github/issues/pysan3/pathlib.nvim.svg?style=for-the-badge}[Issues]] + {https://github.com/pysan3/pathlib.nvim/actions/workflows/release-please.yml}[!{https://img.shields.io/github/actions/workflow/status/pysan3/pathlib.nvim/release-please.yml?style=for-the-badge}[Build Status]] + {https://luarocks.org/modules/pysan3/pathlib.nvim}[!{https://img.shields.io/luarocks/v/pysan3/pathlib.nvim?logo=lua&color=purple&style=for-the-badge}[LuaRocks]] + +* Other Projects + - Python `pathlib` + -- {https://docs.python.org/3/library/pathlib.html} diff --git a/lua/pathlib/base.lua b/lua/pathlib/base.lua new file mode 100644 index 0000000..f770e51 --- /dev/null +++ b/lua/pathlib/base.lua @@ -0,0 +1,51 @@ +local luv = vim.loop +local fs = vim.fs +local utils = require("pathlib.utils") + +local PathlibPath = "PathlibPath" +---@class PathlibPath +---@field _raw_paths PathlibStrList +local Path = { + mytype = PathlibPath, + ---Drive name for Windows path. ("C:", "D:") + _drive_name = "", +} +Path.__index = Path +setmetatable(Path, { + __call = function(cls, ...) + return cls.new(...) + end, +}) + +function Path.new(...) + local self = setmetatable({}, Path) + self._raw_paths = utils.lists.str_list.new() + for i, s in ipairs({ ... }) do + if utils.tables.is_type_of(s, PathlibPath) then + if i == 1 then + self:copy_all_from(s) + else + assert(not s:is_absolute(), ("new: invalid root path object in %sth argument: %s"):format(i, s)) + self._raw_paths:extend(s._raw_paths) + end + elseif type(s) == "string" then + local path = fs.normalize(s, { expand_env = true }) + self._raw_paths:extend(vim.split(path, "/", { plain = true, trimempty = false })) + end + end + return self +end + +---Copy all attributes from `path` to self +---@param path PathlibPath +function Path:copy_all_from(path) + self.mytype = path.mytype + self._drive_name = path._drive_name +end + +function Path:is_absolute() + -- TODO: Not implemented <2023-11-14> + return false +end + +return Path diff --git a/lua/pathlib/init.lua b/lua/pathlib/init.lua new file mode 100644 index 0000000..043c773 --- /dev/null +++ b/lua/pathlib/init.lua @@ -0,0 +1,29 @@ +---@toc pathlib.contents + +---@mod intro Introduction +---@brief [[ +---This plugin aims to decrease the difficulties of path management across mutliple OSs. +---The plugin API is heavily inspired by Python's `pathlib.Path` with tweaks to fit neovim usage. +---It is mainly used in {https://github.com/nvim-neo-tree/neo-tree.nvim}[neo-tree.nvim] +---but it is as simple as you can use it in your own configs! +--- +---@brief ]] + +---@mod pathlib The pathlib module +---@brief [[ +---Entry-point into this plugin's public API. +--- +---Example: +--->lua +------@type PathlibPath +---local Path = require("pathlib") +---< +---@brief ]] + +IS_WINDOWS = vim.fn.has("win32") == 1 or vim.fn.has("win32unix") == 1 + +if IS_WINDOWS then + return require("pathlib.windows") +else + return require("pathlib.posix") +end diff --git a/lua/pathlib/posix.lua b/lua/pathlib/posix.lua new file mode 100644 index 0000000..e69de29 diff --git a/lua/pathlib/utils/init.lua b/lua/pathlib/utils/init.lua new file mode 100644 index 0000000..108a9c6 --- /dev/null +++ b/lua/pathlib/utils/init.lua @@ -0,0 +1,4 @@ +return { + tables = require("pathlib.utils.tables"), + lists = require("pathlib.utils.lists"), +} diff --git a/lua/pathlib/utils/lists.lua b/lua/pathlib/utils/lists.lua new file mode 100644 index 0000000..4b74b09 --- /dev/null +++ b/lua/pathlib/utils/lists.lua @@ -0,0 +1,29 @@ +---@class PathlibStrList +local str_list = {} +str_list.__index = str_list +setmetatable(str_list, { + __call = function(cls, ...) + return cls.new(...) + end, +}) + +function str_list.new() + return setmetatable({}, str_list) +end + +---@param value string +function str_list:append(value) + self[#self + 1] = value +end + +---@param list PathlibStrList +function str_list:extend(list) + local start_from = #self + for index, value in ipairs(list) do + self[start_from + index] = value + end +end + +return { + str_list = str_list, +} diff --git a/lua/pathlib/utils/tables.lua b/lua/pathlib/utils/tables.lua new file mode 100644 index 0000000..135f72e --- /dev/null +++ b/lua/pathlib/utils/tables.lua @@ -0,0 +1,10 @@ +local M = {} + +function M.is_type_of(tbl, type_name) + if type(tbl) ~= "table" then + return false + end + return tbl.mytype == type_name +end + +return M diff --git a/lua/pathlib/windows.lua b/lua/pathlib/windows.lua new file mode 100644 index 0000000..e69de29 diff --git a/pathlib.nvim-scm-1.rockspec b/pathlib.nvim-scm-1.rockspec new file mode 100644 index 0000000..6451132 --- /dev/null +++ b/pathlib.nvim-scm-1.rockspec @@ -0,0 +1,15 @@ +rockspec_format = "3.0" +package = "pathlib.nvim" +version = "scm-1" + +test_dependencies = { + "lua >= 5.1", +} + +source = { + url = "git://github.com/pysan3/" .. package, +} + +build = { + type = "builtin", +} diff --git a/run-local-tests.sh b/run-local-tests.sh new file mode 100755 index 0000000..cc20f5c --- /dev/null +++ b/run-local-tests.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +# +# Run local tests for lua using luarocks and busted extension +# with neovim as the runtime environment. + +BUSTED_VERSION="2.2.0-1" +luarocks init +luarocks install busted "$BUSTED_VERSION" +luarocks config --scope project lua_version 5.1 +nvim -u NONE \ + -c "lua package.path='lua_modules/share/lua/5.1/?.lua;lua_modules/share/lua/5.1/?/init.lua;'..package.path;package.cpath='lua_modules/lib/lua/5.1/?.so;'..package.cpath;local k,l,_=pcall(require,'luarocks.loader') _=k and l.add_context('busted','$BUSTED_VERSION')" \ + -l "lua_modules/lib/luarocks/rocks-5.1/busted/$BUSTED_VERSION/bin/busted" "$@" diff --git a/spec/basic_path_spec.lua b/spec/basic_path_spec.lua new file mode 100644 index 0000000..ec91bb3 --- /dev/null +++ b/spec/basic_path_spec.lua @@ -0,0 +1,43 @@ +---@module 'busted' + +local _ = require("pathlib") + +describe("Simple PathlibPath test;", function() + describe("Import test.", function() + it("import test:", function() + local path_ok, Path = pcall(require, "pathlib.base") + assert.is_true(path_ok) + assert.is_not_nil(Path) + + local utils_ok, utils = pcall(require, "pathlib.utils") + assert.is_true(utils_ok) + assert.is_not_nil(utils) + end) + end) + + describe("Relative init.", function() + local Path = require("pathlib.base") + local utils = require("pathlib.utils") + + it("signle args", function() + local path = Path.new(".") + assert.is_true(utils.tables.is_type_of(path, "PathlibPath")) + assert.are_same(path._raw_paths, { "." }) + end) + end) + + describe("Object is not shared.", function() + local Path = require("pathlib.base") + + local path1 = Path.new("a") + local path2 = Path.new("b") + + for key, value in pairs(path1) do + if type(value) == "table" then + it("check " .. key, function() + assert.are_not_same(path1[key], path2[value]) + end) + end + end + end) +end) diff --git a/spec/busted_spec.lua b/spec/busted_spec.lua new file mode 100644 index 0000000..2cf4cfb --- /dev/null +++ b/spec/busted_spec.lua @@ -0,0 +1,31 @@ +---@module 'busted' + +describe("Busted unit testing framework", function() + describe("should be awesome", function() + it("should be easy to use", function() + assert.truthy("Yup.") + end) + + it("should have lots of features", function() + -- deep check comparisons! + assert.are.same({ table = "great" }, { table = "great" }) + + -- or check by reference! + assert.are_not.equal({ table = "great" }, { table = "great" }) + + assert.truthy("this is a string") -- truthy: not false or nil + + assert.True(1 == 1) + assert.is_true(1 == 1) + + assert.falsy(nil) + assert.has_error(function() + error("Wat") + end, "Wat") + end) + + it("should provide some shortcuts to common functions", function() + assert.are.unique({ { thing = 1 }, { thing = 2 }, { thing = 3 } }) + end) + end) +end) diff --git a/spec/hello_world_spec.lua b/spec/hello_world_spec.lua new file mode 100644 index 0000000..f61fccf --- /dev/null +++ b/spec/hello_world_spec.lua @@ -0,0 +1,11 @@ +---@module 'busted' + +describe("Hello World Test;", function() + describe("Simple test to check if luarocks is working correctly.", function() + it("Check: hello world", function() + local foo = "Hello World" + local bar = "Hello World" + assert.are.equal(foo, bar) + end) + end) +end) diff --git a/stylua.toml b/stylua.toml new file mode 100644 index 0000000..0fd4cb5 --- /dev/null +++ b/stylua.toml @@ -0,0 +1,6 @@ +column_width = 120 +line_endings = "Unix" +indent_type = "Spaces" +indent_width = 2 +quote_style = "AutoPreferDouble" +no_call_parentheses = false