-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit cecb702
Showing
20 changed files
with
1,051 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Release | ||
on: [push] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
env: | ||
VERSION: ${{ github.ref_name }} | ||
steps: | ||
- name: Checkout git repo | ||
uses: actions/checkout@v3 | ||
|
||
- uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'temurin' | ||
java-version: '21' | ||
|
||
- uses: extractions/setup-just@v1 | ||
|
||
- uses: DeLaGuardo/[email protected] | ||
with: | ||
cli: latest | ||
|
||
- name: Build | ||
run: | | ||
just build | ||
- name: Release | ||
if: ${{ github.ref_type == 'tag' && startsWith(github.ref_name, 'v') }} | ||
env: | ||
CLOJARS_USERNAME: ${{ secrets.CLOJARS_USERNAME }} | ||
CLOJARS_PASSWORD: ${{ secrets.CLOJARS_PASSWORD }} | ||
run: | | ||
just release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.DS_Store | ||
|
||
.build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"diagnostics.globals": ["vim", "describe", "it", "before_each", "after_each"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
column_width = 120 | ||
line_endings = "Unix" | ||
indent_type = "Spaces" | ||
indent_width = 2 | ||
quote_style = "AutoPreferDouble" | ||
call_parentheses = "Always" | ||
collapse_simple_statement = "Never" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
build: | ||
clojure -T:build build | ||
|
||
release: | ||
clojure -T:build release | ||
|
||
[macos] | ||
prepare-nvim channel: | ||
#!/usr/bin/env sh | ||
set -eo pipefail | ||
NVIM_DIR=".build/nvim/{{ channel }}" | ||
test -d $NVIM_DIR || { | ||
mkdir -p $NVIM_DIR | ||
|
||
curl -L https://github.com/neovim/neovim/releases/download/{{ channel }}/nvim-macos-$(arch).tar.gz > ./.build/nvim-macos.tar.gz | ||
xattr -c ./.build/nvim-macos.tar.gz | ||
tar xzf ./.build/nvim-macos.tar.gz -C $NVIM_DIR --strip-components=1 | ||
rm ./.build/nvim-macos.tar.gz | ||
} | ||
|
||
[linux] | ||
prepare-nvim channel: | ||
#!/usr/bin/env sh | ||
set -eo pipefail | ||
NVIM_DIR=".build/nvim/{{ channel }}" | ||
test -d $NVIM_DIR || { | ||
mkdir -p $NVIM_DIR | ||
|
||
curl -L https://github.com/neovim/neovim/releases/download/{{ channel }}/nvim-linux64.tar.gz > ./.build/nvim-linux64.tar.gz | ||
tar xzf ./.build/nvim-linux64.tar.gz -C $NVIM_DIR --strip-components=1 | ||
rm ./.build/nvim-linux64.tar.gz | ||
} | ||
|
||
prepare-dependencies: | ||
#!/usr/bin/env sh | ||
set -eo pipefail | ||
test -d .build/dependencies || { | ||
mkdir -p ./.build/dependencies | ||
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ./.build/dependencies/plenary.nvim | ||
git clone --depth 1 https://github.com/MunifTanjim/nui.nvim ./.build/dependencies/nui.nvim | ||
} | ||
prepare channel: (prepare-nvim channel) prepare-dependencies | ||
|
||
test channel="stable" file="": (prepare channel) | ||
#!/usr/bin/env sh | ||
NVIM_DIR=".build/nvim/{{ channel }}" | ||
./$NVIM_DIR/bin/nvim --version | ||
./$NVIM_DIR/bin/nvim \ | ||
--headless \ | ||
--noplugin \ | ||
-u tests/config.lua \ | ||
-c "PlenaryBustedDirectory tests/diff-tool/{{ file }} { minimal_init='tests/config.lua', sequential=true }" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Julien Vincent | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
local fs = require("diff-tool.api.fs") | ||
|
||
local M = {} | ||
|
||
function M.diff_file(left, right) | ||
local left_content = fs.read_file(left) or "" | ||
local right_content = fs.read_file(right) or "" | ||
local hunks = vim.diff(left_content, right_content, { | ||
result_type = "indices", | ||
}) | ||
|
||
if type(hunks) ~= "table" then | ||
return {} | ||
end | ||
|
||
return vim.tbl_map(function(hunk) | ||
return { | ||
left = { hunk[1], hunk[2] }, | ||
right = { hunk[3], hunk[4] }, | ||
} | ||
end, hunks) | ||
end | ||
|
||
function M.apply_diff(left, right, change) | ||
local hunks = change.hunks | ||
local selected_lines = change.selected_lines | ||
|
||
local result = {} | ||
|
||
local left_index = 1 | ||
local hunk_index = 1 | ||
local hunk = hunks[hunk_index] | ||
|
||
if change.type == "added" then | ||
for i = hunk.right[1], hunk.right[1] + hunk.right[2] - 1 do | ||
if selected_lines.right[i] then | ||
table.insert(result, right[i]) | ||
end | ||
end | ||
return result | ||
end | ||
|
||
while left_index <= #left do | ||
if hunk and left_index == hunk.left[1] then | ||
for i = left_index, left_index + hunk.left[2] - 1 do | ||
left_index = i | ||
if not selected_lines.left[i] then | ||
table.insert(result, left[i]) | ||
end | ||
end | ||
|
||
if hunk.left[2] == 0 then | ||
table.insert(result, left[left_index]) | ||
end | ||
|
||
for i = hunk.right[1], hunk.right[1] + hunk.right[2] - 1 do | ||
if selected_lines.right[i] then | ||
table.insert(result, right[i]) | ||
end | ||
end | ||
|
||
hunk_index = hunk_index + 1 | ||
hunk = hunks[hunk_index] | ||
else | ||
table.insert(result, left[left_index]) | ||
end | ||
|
||
left_index = left_index + 1 | ||
end | ||
|
||
return result | ||
end | ||
|
||
-- local hunks = { | ||
-- { | ||
-- left = { 1, 4 }, | ||
-- right = { 1, 1 }, | ||
-- }, | ||
-- { | ||
-- left = { 6, 0 }, | ||
-- right = { 4, 3 }, | ||
-- }, | ||
-- } | ||
-- | ||
-- M.apply_diff({ "a", "b", "c", "f", "e", "f" }, { "a1", "e", "f", "g", "h", "i" }, hunks, { | ||
-- left = { [1] = true, [2] = true, [3] = true, [4] = true }, | ||
-- right = { [1] = true, [4] = true, [5] = true, [6] = true }, | ||
-- }) | ||
-- | ||
-- vim.diff("a\nb\nc\nf\ne\nf\n", "a1\ne\nf\ng\nh\ni\n", { | ||
-- result_type = "indices", | ||
-- }) | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
local M = {} | ||
|
||
function M.list_files_recursively(dir) | ||
local files = {} | ||
local p = io.popen('find "' .. dir .. '" -type f') | ||
if not p then | ||
return {} | ||
end | ||
for file in p:lines() do | ||
table.insert(files, file) | ||
end | ||
p:close() | ||
return vim.tbl_map(function(file) | ||
return string.sub(file, #dir + 2) | ||
end, files) | ||
end | ||
|
||
function M.read_file(file_path) | ||
local file = io.open(file_path, "r") | ||
if not file then | ||
return nil | ||
end | ||
local content = file:read("*a") | ||
file:close() | ||
return content | ||
end | ||
|
||
function M.read_file_as_lines(file_path) | ||
local content = vim.split(M.read_file(file_path) or "", "\n") | ||
if content[#content] == "" then | ||
table.remove(content, #content) | ||
end | ||
return content | ||
end | ||
|
||
function M.make_parents(file_path) | ||
local parent_dir = file_path:match("(.*/)") | ||
vim.fn.mkdir(parent_dir, "p") | ||
end | ||
|
||
function M.write_file(file_path, content) | ||
M.make_parents(file_path) | ||
|
||
local file = io.open(file_path, "w") | ||
if not file then | ||
return | ||
end | ||
|
||
for _, line in ipairs(content) do | ||
file:write(line .. "\n") | ||
end | ||
|
||
file:close() | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
local M = {} | ||
|
||
function M.set_win_hl(winid, highlights) | ||
vim.api.nvim_set_option_value("winhl", table.concat(highlights, ","), { | ||
win = winid, | ||
}) | ||
end | ||
|
||
function M.define_highlights() | ||
local diff_delete_highlight = vim.api.nvim_get_hl(0, { | ||
name = "DiffDelete", | ||
link = true, | ||
}) | ||
|
||
vim.api.nvim_set_hl(0, "DiffToolDiffAddAsDelete", { | ||
bg = string.format("#%06x", diff_delete_highlight.bg), | ||
}) | ||
|
||
vim.api.nvim_set_hl(0, "DiffToolDiffDeleteDim", { | ||
default = true, | ||
link = "Comment", | ||
}) | ||
|
||
vim.api.nvim_set_hl(0, "DiffToolDiffDelete", { | ||
link = "DiffToolDiffDeleteDim", | ||
}) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
return { | ||
diff = require("diff-tool.api.diff"), | ||
fs = require("diff-tool.api.fs"), | ||
signs = require("diff-tool.api.signs"), | ||
highlights = require("diff-tool.api.highlights"), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
local M = { | ||
signs = { | ||
selected = { | ||
name = "DiffToolLineSelected", | ||
hl = "DiffToolSignSelected", | ||
}, | ||
deselected = { | ||
name = "DiffToolLineDeselected", | ||
hl = "DiffToolSignDeselected", | ||
}, | ||
}, | ||
} | ||
|
||
function M.place_sign(buf, sign, linenr) | ||
vim.fn.sign_place(0, "DiffTool", sign.name, buf, { | ||
lnum = linenr, | ||
priority = 100, | ||
}) | ||
end | ||
|
||
function M.define_signs() | ||
vim.fn.sign_define({ | ||
{ | ||
name = M.signs.selected.name, | ||
text = "", | ||
texthl = M.signs.selected.hl, | ||
}, | ||
{ | ||
name = M.signs.deselected.name, | ||
text = "", | ||
texthl = M.signs.deselected.hl, | ||
}, | ||
}) | ||
end | ||
|
||
return M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
local M = { | ||
keys = { | ||
ui = { | ||
expand_node = { "l", "<Right>" }, | ||
collapse_node = { "h", "<Left>" }, | ||
open_file = { "<Cr>", "gd" }, | ||
preview_file = { "<Cr>", "gd" }, | ||
|
||
quit = { "q", "<Esc>" }, | ||
}, | ||
}, | ||
} | ||
|
||
function M.update_config(new_config) | ||
local config = vim.tbl_deep_extend("force", M, new_config) | ||
for key, value in pairs(config) do | ||
M[key] = value | ||
end | ||
end | ||
|
||
return M |
Oops, something went wrong.