diff options
| author | nsfisis <nsfisis@gmail.com> | 2022-12-21 21:26:48 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2022-12-21 21:27:01 +0900 |
| commit | 041d8e92d17b28ac7e887cd8e334d88ef4e0f569 (patch) | |
| tree | 94df80549a08e94671af9d65d5ddf51efc66b2b3 | |
| parent | 665cf512e3084356ba4362e80342828a2c6b2409 (diff) | |
| download | dotfiles-041d8e92d17b28ac7e887cd8e334d88ef4e0f569.tar.gz dotfiles-041d8e92d17b28ac7e887cd8e334d88ef4e0f569.tar.zst dotfiles-041d8e92d17b28ac7e887cd8e334d88ef4e0f569.zip | |
neovim:uniquify: shorten path if there are other paths that are exactly the same
| -rw-r--r-- | .config/nvim/lua/tests/uniquify.lua | 1 | ||||
| -rw-r--r-- | .config/nvim/lua/uniquify.lua | 6 |
2 files changed, 7 insertions, 0 deletions
diff --git a/.config/nvim/lua/tests/uniquify.lua b/.config/nvim/lua/tests/uniquify.lua index 9f58298..a8a190f 100644 --- a/.config/nvim/lua/tests/uniquify.lua +++ b/.config/nvim/lua/tests/uniquify.lua @@ -17,6 +17,7 @@ function M.test(t) {'foo/b/baz.txt', 'foo/bar/baz.txt', {'spam/bar/baz.txt'}}, {'foo/b/baz.txt', 'foo/bar/baz.txt', {'fiz/foo/bar/baz.txt', 'spam/bar/baz.txt'}}, {'fiz/f/b/baz.txt', 'fiz/foo/bar/baz.txt', {'foo/bar/baz.txt'}}, + {'foo.txt', 'bar/foo.txt', {'bar/foo.txt'}}, } for _, row in ipairs(test_cases) do diff --git a/.config/nvim/lua/uniquify.lua b/.config/nvim/lua/uniquify.lua index b9b9d32..c7f8482 100644 --- a/.config/nvim/lua/uniquify.lua +++ b/.config/nvim/lua/uniquify.lua @@ -8,6 +8,12 @@ local stricmp = vim.stricmp function M.uniquify(this_path, other_paths) + for i = 1, #other_paths do + if other_paths[i] == this_path then + table.remove(other_paths, i) + end + end + -- Split each path into slash-separated parts. for i = 1, #other_paths do other_paths[i] = split(other_paths[i], '[\\/]') |
