Skip to content
This repository has been archived by the owner on Jul 28, 2024. It is now read-only.

chore(docs): removed the toc and corrected the formatter chapter #34

Merged
merged 2 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 27 additions & 47 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,6 @@
Create up-to-date [harpoon2] information for any place where
that information can be useful. For example, in statuslines and the tabline.

## TOC

<!--toc:start-->
- [Harpoonline](#harpoonline)
- [Demo](#demo)
- [Features](#features)
- [Requirements](#requirements)
- [Setup](#setup)
- [Using lazy.nvim and lualine](#using-lazynvim-and-lualine)
- [Using mini.deps and mini.statusline](#using-minideps-and-ministatusline)
- [Configuration](#configuration)
- [Formatters](#formatters)
- [The "default" built-in](#the-default-built-in)
- [The "short" built-in](#the-short-built-in)
- [Customize a built-in](#customize-a-built-in)
- [Use a custom formatter](#use-a-custom-formatter)
- [Harpoon lists](#harpoon-lists)
- [Recipes](#recipes)
- [Heirline](#heirline)
- [NvChad statusline](#nvchad-statusline)
- [Related plugins](#related-plugins)
- [Acknowledgements](#acknowledgements)
<!--toc:end-->

## Demo

<https://github.com/abeldekat/harpoonline/assets/58370433/ec56eeb2-3cbf-46fe-bc9d-633f6aa8bb9b>
Expand Down Expand Up @@ -142,9 +118,10 @@ The following configuration is implied when calling `setup` without arguments:
```lua
---@class HarpoonLineConfig
Harpoonline.config = {
-- other nice icons: "󰀱", "", "󱡅", "󰛢"
-- other candidates: "󰀱", "", "󱡅", "󰶳"
-- default: icon nf-md-hook in nerdfont, unicode f06e2:
---@type string
icon = '󰀱', -- An empty string disables showing the icon
icon = '󰛢', -- An empty string disables showing the icon

-- Harpoon:list(), when name is nil, retrieves the default list:
-- default_list_name: Configures the display name for the default list.
Expand Down Expand Up @@ -178,34 +155,36 @@ Harpoonline.config = {

*Note*: The icon does not display properly in the browser...

### Formatters
## Formatters

Scenario's:

- A: 3 marks, the current buffer is not harpooned
- B: 3 marks, the current buffer is harpooned on mark 2

#### The "default" built-in
*Note*: More examples can be found in [ak.config.ui.harpoonline]

### The "default" built-in

Default options: `config.formatter_opts.default`

Output A: :anchor: ` 1 2 3 `
Output A: 󰛢 ` 1 2 3 `

Output B: :anchor: ` 1 [2] 3 `
Output B: 󰛢 ` 1 [2] 3 `

**Note**: Five marks, the fifth mark is the active buffer:

Output B: :anchor: ` 1 2 3 4 […] `
Output B: 󰛢 ` 1 2 3 4 […] `

#### The "short" built-in
### The "short" built-in

Add to the config: `formatter = 'short'`. Default options: `config.formatter_opts.short`

Output A: :anchor: `[3]`
Output A: 󰛢 `[3]`

Output B: :anchor: `[2|3]`
Output B: 󰛢 `[2|3]`

#### Customize a built-in
### Customize a built-in

```lua
Harpoonline.setup({
Expand All @@ -220,11 +199,11 @@ Harpoonline.setup({
})
```

Output A: :anchor: `123`
Output A: 󰛢 `123`

Output B: :anchor: `1[2]3`
Output B: 󰛢 `1[2]3`

#### Use a custom formatter
### Use a custom formatter

The following data is kept up-to-date internally, to be processed by formatters:

Expand All @@ -235,7 +214,7 @@ The following data is kept up-to-date internally, to be processed by formatters:
---@field active_idx number|nil -- the harpoon index of the current buffer
```

Example "very short":
#### Example "very short"

```lua
Harpoonline.setup({
Expand All @@ -255,11 +234,11 @@ Harpoonline.setup({
})
```

Output A: :anchor: `-`
Output A: 󰛢 `-`

Output B: :anchor: `2`
Output B: 󰛢 `2`

Example "letters":
#### Example "letters"

```lua
Harpoonline.setup({
Expand All @@ -284,15 +263,15 @@ Harpoonline.setup({
})
```

Output A: :anchor: `jkl`
Output A: 󰛢 `jkl`

Output B: :anchor: `jKl`
Output B: 󰛢 `jKl`

*Note*:

- You can also use inner highlights in the formatter function.
- It is possible to also use inner highlights in the formatter function.
See the example recipe for NvChad.
- You can use the `harpoon` information inside each `data.items`
- It is possible to use the `harpoon` information inside each `data.items`

## Harpoon lists

Expand Down Expand Up @@ -436,10 +415,11 @@ return M
- @echasnovski: The structure of this plugin is heavily based on [mini.nvim]

[harpoon2]: https://github.com/ThePrimeagen/harpoon/tree/harpoon2
[mini.statusline]: https://github.com/echasnovski/mini.statusline
[lualine]: https://github.com/nvim-lualine/lualine.nvim
[mini.statusline]: https://github.com/echasnovski/mini.statusline
[heirline]: https://github.com/rebelot/heirline.nvim
[mini.nvim]: https://github.com/echasnovski/mini.nvim
[harpoon-lualine]: https://github.com/letieu/harpoon-lualine
[ak.config.editor.harpoon]: https://github.com/abeldekat/nvim_pde/blob/main/lua/ak/config/editor/harpoon.lua
[ak.config.ui.harpoonline]: https://github.com/abeldekat/nvim_pde/blob/main/lua/ak/config/ui/harpoonline.lua
[ak.config.ui.mini_statusline]: https://github.com/abeldekat/nvim_pde/blob/main/lua/ak/config/ui/mini_statusline.lua
5 changes: 3 additions & 2 deletions lua/harpoonline/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ end

---@class HarpoonLineConfig
Harpoonline.config = {
-- other nice icons: "󰀱", "", "󱡅"
-- other candidates: "󰀱", "", "󱡅", "󰶳"
-- default: icon nf-md-hook in nerdfont, unicode f06e2:
---@type string
icon = '󰀱', -- An empty string disables showing the icon
icon = '󰛢', -- An empty string disables showing the icon

-- Harpoon:list(), when name is nil, retrieves the default list:
-- default_list_name: Configures the display name for the default list.
Expand Down
2 changes: 1 addition & 1 deletion tests/test_harpoonline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ local add_files_to_list = function(names, list_name)
end
end

local icon = '󰀱'
local icon = '󰛢'
local more = '…'

-- ╭─────────────────────────────────────────────────────────╮
Expand Down