Compare commits
3 commits
bd2481d41e
...
da4688e583
Author | SHA1 | Date | |
---|---|---|---|
da4688e583 | |||
6b65c5085f | |||
c9e490e042 |
5 changed files with 29 additions and 9 deletions
3
.luacheckrc
Normal file
3
.luacheckrc
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
globals = {
|
||||||
|
"vim",
|
||||||
|
}
|
12
.woodpecker.yml
Normal file
12
.woodpecker.yml
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
# branches: main
|
||||||
|
|
||||||
|
pipeline:
|
||||||
|
code_lint:
|
||||||
|
image: pipelinecomponents/luacheck
|
||||||
|
commands:
|
||||||
|
- luacheck lua/zettelkasten
|
||||||
|
|
||||||
|
unit_tests:
|
||||||
|
image: imega/busted
|
||||||
|
commands:
|
||||||
|
- busted test -C lua
|
|
@ -1,7 +1,12 @@
|
||||||
local action = require 'zettelkasten.action'
|
local action = require 'zettelkasten.action'
|
||||||
|
|
||||||
before_each(function()
|
before_each(function()
|
||||||
_G.vim = {g = {}, b = {}, loop = {fs_scandir = function() end}}
|
_G.vim = {
|
||||||
|
g = {},
|
||||||
|
b = {},
|
||||||
|
fn = {fnameescape = function(input) return input end},
|
||||||
|
loop = {fs_scandir = function() end}
|
||||||
|
}
|
||||||
end)
|
end)
|
||||||
after_each(function() _G.vim = nil end)
|
after_each(function() _G.vim = nil end)
|
||||||
|
|
||||||
|
@ -102,7 +107,7 @@ end)
|
||||||
|
|
||||||
describe("create_link", function()
|
describe("create_link", function()
|
||||||
it("substitutes the argument text with a link", function()
|
it("substitutes the argument text with a link", function()
|
||||||
pending()
|
pending("not implemented")
|
||||||
vim.fn = {getpos = function() return {1, 2, 3} end}
|
vim.fn = {getpos = function() return {1, 2, 3} end}
|
||||||
vim.api = {
|
vim.api = {
|
||||||
nvim_buf_get_lines = function() return {"hi", 1, 2} end,
|
nvim_buf_get_lines = function() return {"hi", 1, 2} end,
|
||||||
|
|
|
@ -19,7 +19,7 @@ local function simple_api_mock(files)
|
||||||
end
|
end
|
||||||
|
|
||||||
describe("get_anchors_and_paths", function()
|
describe("get_anchors_and_paths", function()
|
||||||
before_each(function() get_api_mock = simple_api_mock end)
|
before_each(function() Get_api_mock = simple_api_mock end)
|
||||||
after_each(function() _G.vim = nil end)
|
after_each(function() _G.vim = nil end)
|
||||||
|
|
||||||
it("should return anchor-keyed table pointing to filename of zettel",
|
it("should return anchor-keyed table pointing to filename of zettel",
|
||||||
|
@ -27,7 +27,7 @@ describe("get_anchors_and_paths", function()
|
||||||
local file_list = {}
|
local file_list = {}
|
||||||
file_list["someDir/1910291645 this-is-a-testfile.md"] =
|
file_list["someDir/1910291645 this-is-a-testfile.md"] =
|
||||||
"1910291645 this-is-a-testfile.md"
|
"1910291645 this-is-a-testfile.md"
|
||||||
_G.vim = get_api_mock(file_list)
|
_G.vim = Get_api_mock(file_list)
|
||||||
|
|
||||||
local expected = {
|
local expected = {
|
||||||
["1910291645"] = "someDir/1910291645 this-is-a-testfile.md"
|
["1910291645"] = "someDir/1910291645 this-is-a-testfile.md"
|
||||||
|
@ -43,7 +43,7 @@ describe("get_anchors_and_paths", function()
|
||||||
["1910271456 this-is-wrong-extension.txt"] = "1910271456 this-is-wrong-extension.txt",
|
["1910271456 this-is-wrong-extension.txt"] = "1910271456 this-is-wrong-extension.txt",
|
||||||
["1812 this-is-ignored.md"] = "1812 this-is-ignored.md"
|
["1812 this-is-ignored.md"] = "1812 this-is-ignored.md"
|
||||||
}
|
}
|
||||||
_G.vim = get_api_mock(file_list)
|
_G.vim = Get_api_mock(file_list)
|
||||||
|
|
||||||
local expected = {
|
local expected = {
|
||||||
["1910291645"] = "someDir/1910291645 this-is-a-testfile.md",
|
["1910291645"] = "someDir/1910291645 this-is-a-testfile.md",
|
||||||
|
@ -57,7 +57,7 @@ describe("get_anchors_and_paths", function()
|
||||||
["mydirectory/1910291645 myfile.wiki"] = "1910291645 myfile.wiki",
|
["mydirectory/1910291645 myfile.wiki"] = "1910291645 myfile.wiki",
|
||||||
["mydirectory/2345678901 another.wiki"] = "2345678901 another.wiki"
|
["mydirectory/2345678901 another.wiki"] = "2345678901 another.wiki"
|
||||||
}
|
}
|
||||||
_G.vim = get_api_mock(file_list)
|
_G.vim = Get_api_mock(file_list)
|
||||||
vim.g['zettel_extension'] = '.wiki'
|
vim.g['zettel_extension'] = '.wiki'
|
||||||
|
|
||||||
local expected = {
|
local expected = {
|
||||||
|
@ -71,7 +71,7 @@ describe("get_anchors_and_paths", function()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe("get_all_files", function()
|
describe("get_all_files", function()
|
||||||
it("should recurse into directories if recursive argument passed in ",
|
it("should recurse into directories if recursive argument passed in",
|
||||||
function()
|
function()
|
||||||
local files = {
|
local files = {
|
||||||
{"1910271456 testfile.md", "file"},
|
{"1910271456 testfile.md", "file"},
|
||||||
|
@ -91,7 +91,7 @@ describe("get_all_files", function()
|
||||||
end,
|
end,
|
||||||
fs_scandir_next = function()
|
fs_scandir_next = function()
|
||||||
if #files == 0 then return nil end
|
if #files == 0 then return nil end
|
||||||
local fname, ftype = unpack(table.remove(files))
|
local fname, ftype = table.unpack(table.remove(files))
|
||||||
return fname, ftype
|
return fname, ftype
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
|
@ -11,7 +11,7 @@ function A.open(link)
|
||||||
if not link or not link.ref then return end
|
if not link or not link.ref then return end
|
||||||
local fname = f.get_zettel_by_anchor(link.anchor) or
|
local fname = f.get_zettel_by_anchor(link.anchor) or
|
||||||
f.get_zettel_by_ref(link.ref) or link.ref
|
f.get_zettel_by_ref(link.ref) or link.ref
|
||||||
vim.api.nvim_command(string.format("edit %s", fname))
|
vim.api.nvim_command(string.format("edit %s", vim.fn.fnameescape(fname)))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Gets the input at the current buffer cursor and opens it
|
-- Gets the input at the current buffer cursor and opens it
|
||||||
|
|
Loading…
Reference in a new issue