-
Notifications
You must be signed in to change notification settings - Fork 1
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 d550b93
Showing
22 changed files
with
1,125 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,13 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
[Makefile] | ||
indent_style = tab | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[{*.lua,*.md}] | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 4 | ||
insert_final_newline = 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,41 @@ | ||
name: Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
unit_tests: | ||
name: unit tests | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
include: | ||
- os: ubuntu-22.04 | ||
rev: nightly/nvim-linux64.tar.gz | ||
- os: ubuntu-22.04 | ||
rev: v0.9.0/nvim-linux64.tar.gz | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: date +%F > todays-date | ||
- name: Restore from todays cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: _neovim | ||
key: ${{ runner.os }}-${{ matrix.rev }}-${{ hashFiles('todays-date') }} | ||
|
||
- name: Prepare | ||
run: | | ||
test -d _neovim || { | ||
mkdir -p _neovim | ||
curl -sL "https://github.com/neovim/neovim/releases/download/${{ matrix.rev }}" | tar xzf - --strip-components=1 -C "${PWD}/_neovim" | ||
} | ||
- name: Dependencies | ||
run: | | ||
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim | ||
ln -s "$(pwd)" ~/.local/share/nvim/site/pack/vendor/start | ||
- name: Run tests | ||
run: | | ||
export PATH="${PWD}/_neovim/bin:${PATH}" | ||
nvim --version | ||
make test | ||
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,26 @@ | ||
name: Format | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
format: | ||
name: Stylua | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- run: date +%W > weekly | ||
|
||
- name: Restore cache | ||
id: cache | ||
uses: actions/cache@v4 | ||
with: | ||
path: | | ||
~/.cargo/bin | ||
key: ${{ runner.os }}-cargo-${{ hashFiles('weekly') }} | ||
|
||
- name: Install | ||
if: steps.cache.outputs.cache-hit != 'true' | ||
run: cargo install stylua | ||
|
||
- name: Format | ||
run: stylua --check lua/ --config-path=.stylua.toml |
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,18 @@ | ||
name: Lint | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
name: Luacheck | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup | ||
run: | | ||
sudo apt-get update | ||
sudo apt-get install luarocks | ||
sudo luarocks install luacheck | ||
- name: Lint | ||
run: luacheck lua/ --globals vim |
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 @@ | ||
deps/ |
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,4 @@ | ||
{ | ||
"$schema": "https://raw.githubusercontent.com/sumneko/vscode-lua/master/setting/schema.json", | ||
"Lua.workspace.checkThirdParty": false | ||
} |
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,5 @@ | ||
column_width = 80 | ||
line_endings = "Unix" | ||
indent_type = "Spaces" | ||
indent_width = 4 | ||
quote_style = "AutoPreferDouble" |
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) 2023-2024 marlin.nvim | ||
|
||
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. |
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,24 @@ | ||
.PHONY: test fmt link deps documentation | ||
|
||
default: all | ||
|
||
all: fmt lint test documentation | ||
|
||
fmt: | ||
stylua lua/ --config-path=.stylua.toml | ||
|
||
lint: | ||
luacheck lua/ --globals vim | ||
|
||
test: | ||
nvim --headless --noplugin -u scripts/test/minimal.vim \ | ||
-c "PlenaryBustedDirectory lua/marlin/test/ {minimal_init = 'scripts/test/minimal.vim'}" | ||
|
||
deps: | ||
@mkdir -p deps | ||
git clone --depth 1 https://github.com/echasnovski/mini.nvim deps/mini.nvim | ||
|
||
documentation: | ||
nvim --headless --noplugin -u ./scripts/minimal_init_doc.lua -c "lua require('mini.doc').generate()" -c "qa!" | ||
|
||
documentation-ci: deps documentation |
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,131 @@ | ||
# marlin.nvim | ||
##### Smooth sailing between buffers of interest | ||
|
||
Persistent and extensible jumps across project buffers of interest with ease. | ||
|
||
### Setup | ||
|
||
Example using the lazy plugin manager | ||
|
||
```lua | ||
{ | ||
"desdic/marlin.nvim", | ||
opts = {}, | ||
config = function(_, opts) | ||
local marlin = require("marlin") | ||
marlin.setup(opts) | ||
|
||
local keymap = vim.keymap.set | ||
keymap("n", "<Leader>fa", function() marlin.add() end, { desc = "add file" }) | ||
keymap("n", "<Leader>fd", function() marlin.remove() end, { desc = "remove file" }) | ||
keymap("n", "<Leader>fx", function() marlin.remove_all() end, { desc = "remove all for current project" }) | ||
keymap("n", "<Leader>f]", function() marlin.move_up() end, { desc = "move up" }) | ||
keymap("n", "<Leader>f[", function() marlin.move_down() end, { desc = "move down" }) | ||
keymap("n", "<Leader>fs", function() marlin.sort() end, { desc = "sort" }) | ||
|
||
for index = 1,4 do | ||
keymap("n", "<Leader>"..index, function() marlin.open(index) end, { desc = "goto "..index }) | ||
end | ||
end | ||
} | ||
``` | ||
|
||
### Default configuration | ||
|
||
```lua | ||
local default = { | ||
patterns = { ".git", ".svn" }, -- look for root of project | ||
datafile = vim.fn.stdpath("data") .. "/marlin.json", -- location of data file | ||
open_callback = callbacks.change_buffer -- default way to open buffer | ||
sorter = sorter.by_buffer -- sort by bufferid | ||
} | ||
``` | ||
|
||
### Easy integration with most status lines | ||
|
||
Example with [lualine](https://github.com/nvim-lualine/lualine.nvim) | ||
|
||
```lua | ||
return { | ||
"nvim-lualine/lualine.nvim", | ||
config = function() | ||
local marlin = require("marlin") | ||
|
||
local marlin_component = function() | ||
local indexes = marlin.num_indexes() | ||
if indexes == 0 then | ||
return "" | ||
end | ||
local cur_index = marlin.cur_index() | ||
|
||
return " " .. cur_index .. "/" .. indexes | ||
end | ||
|
||
require("lualine").setup({ | ||
... | ||
sections = { | ||
... | ||
lualine_c = { marlin_component }, | ||
... | ||
}, | ||
}) | ||
end | ||
``` | ||
|
||
### Extending behaviour | ||
|
||
`marlin.callbacks` has a few options like | ||
|
||
- change_buffer (which does what it says, default) | ||
- use_split (if file is already open in a split switch to it) | ||
|
||
But its possible to change the open_call function to get the behaviour you want. If you want to open new buffers in a vsplit you can | ||
|
||
```lua | ||
open_callback = function(bufnr, _) | ||
vim.cmd("vsplit") | ||
vim.api.nvim_set_current_buf(bufnr) | ||
end, | ||
``` | ||
|
||
Or if want to add an options to open_index that switches to the buffer if already open in a split | ||
|
||
```lua | ||
open_callback = function(bufnr, opts) | ||
if opts.use_split then | ||
local wins = vim.api.nvim_tabpage_list_wins(0) | ||
for _, win in ipairs(wins) do | ||
local winbufnr = vim.api.nvim_win_get_buf(win) | ||
|
||
if winbufnr == bufnr then | ||
vim.api.nvim_set_current_win(win) | ||
return | ||
end | ||
end | ||
end | ||
|
||
vim.api.nvim_set_current_buf(bufnr) | ||
end, | ||
``` | ||
|
||
Sorting also has a few options like | ||
|
||
- by_buffer sorts by buffer id (The order they where opened in) | ||
- by_name (Sorts by path+filename) | ||
|
||
But they can also be change if you want to write your own sorter. | ||
|
||
Choice is yours | ||
|
||
### Why yet another .. | ||
|
||
When I first saw harpoon I was immediately hooked but I missed a few key features. | ||
|
||
- I use splits and wanted to have it jump to the buffer and not replace the current one. | ||
- I wanted persistent jumps per project and not per directory. | ||
|
||
Like anyone else missing a feature I created a patch but it seems that many other did the same. | ||
|
||
### Credits | ||
|
||
Credit goes to [ThePrimeagen](https://github.com/ThePrimeagen/harpoon/) for the idea. |
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 @@ | ||
# TODO | ||
|
||
- Currently no GUI and there might not be one |
Oops, something went wrong.