Skip to content

Commit

Permalink
Setup autodocs
Browse files Browse the repository at this point in the history
does it need to be empty

i see

idk

force update through readme

chore(docs): generate vimdoc

continue working towards release

auto generate vimdoc

retry luacheck

okay ci done mayhapsd

auto generate vimdoc

fixup
  • Loading branch information
claydugo committed Nov 24, 2024
1 parent c8c3de6 commit 084e0e8
Show file tree
Hide file tree
Showing 9 changed files with 276 additions and 50 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/docs_update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Generate documentation

on:
push:
branches:
- main
paths:
- 'README.md'
- 'lua/**'
- 'plugin/**'

permissions:
contents: write

jobs:
generate-docs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate Vim documentation
uses: kdheepak/panvimdoc@main
with:
vimdoc: browsher
pandoc: "README.md"
toc: true
demojify: true

- name: Commit and push changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: 'auto generate vimdoc'
branch: ${{ github.ref }}
file_pattern: doc/browsher.txt
commit_user_name: 'github-actions[bot]'
commit_user_email: 'github-actions[bot]@users.noreply.github.com'
26 changes: 26 additions & 0 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Lint

on:
push:
pull_request:

jobs:
lint:
name: Lint and Format Check
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Luacheck
uses: lunarmodules/[email protected]
with:
args: lua/ plugin/

- name: Run Stylua
uses: JohnnyMorganz/stylua-action@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
version: latest
args: --check .
1 change: 1 addition & 0 deletions .luacheckrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
globals = { 'vim' }
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: local
hooks:
- id: stylua-system
name: StyLua (system)
description: An opinionated Lua code formatter
entry: stylua
language: system
types:
- lua
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

- **Open files in the browser**: Quickly open the current file in your remote Git repository's web interface.
- **Line and Range Support**: Supports opening specific lines or ranges, including multiline selections from visual mode.
- **Customizable providers**: Support for GitHub, GitLab, and custom providers.
- **Customizable providers**: Support for GitHub, GitLab, and the ability to specify custom git web interfaces.
- **Custom open commands**: Specify custom commands to open URLs (e.g., use a specific browser).

# 📦 Installation
Expand Down Expand Up @@ -88,11 +88,11 @@ require("browsher").setup({
Add the following key mappings to your Neovim configuration to quickly open files in the browser:

```lua
-- Open from the latest commit
-- Open from the latest commit, the recommended default operation
vim.api.nvim_set_keymap('n', '<leader>b', '<cmd>Browsher commit<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('v', '<leader>b', ":'<,'>Browsher commit<CR>gv", { noremap = true, silent = true })

-- Open from the latest tag
-- Open from the latest tag, for more human readable urls (with risk of outdated line numbers)
vim.api.nvim_set_keymap('n', '<leader>B', '<cmd>Browsher tag<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('v', '<leader>B', ":'<,'>Browsher tag<CR>gv", { noremap = true, silent = true })
```
Expand Down
Empty file added doc/.gitkeep
Empty file.
198 changes: 198 additions & 0 deletions doc/browsher.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
*browsher.txt* For NVIM v0.8.0 Last change: 2024 November 24

==============================================================================
Table of Contents *browsher-table-of-contents*

1. browsher.nvim |browsher-browsher.nvim|
2. Features |browsher-features|
3. Installation |browsher-installation|
4. Configuration |browsher-configuration|
- Key Mappings |browsher-configuration-key-mappings|
5. Usage |browsher-usage|
6. Examples |browsher-examples|
7. Notes |browsher-notes|

==============================================================================
1. browsher.nvim *browsher-browsher.nvim*

`browsher.nvim` is a highly customizable Neovim plugin that opens the current
file at the specified lines or range in your default browser, pinned to a
specific branch, tag, commit, or the repository root in your remote Git
repository.


==============================================================================
2. Features *browsher-features*

- **Open files in the browser**Quickly open the current file in your remote Git repository’s web interface.
- **Line and Range Support**Supports opening specific lines or ranges, including multiline selections from visual mode.
- **Customizable providers**Support for GitHub, GitLab, and the ability to specify custom git web interfaces.
- **Custom open commands**Specify custom commands to open URLs (e.g., use a specific browser).


==============================================================================
3. Installation *browsher-installation*

Using lazy.nvim <https://github.com/folke/lazy.nvim>

>lua
{
'claydugo/browsher.nvim',
event = "VeryLazy",
config = function()
-- Specify empty to use below default options
require('browsher').setup()
end
}
<

Using packer.nvim <https://github.com/wbthomason/packer.nvim>

>lua
use { 'claydugo/browsher.nvim' }
<


==============================================================================
4. Configuration *browsher-configuration*

You can customize `browsher.nvim` by passing options to the setup function,
below are the default options.


DEFAULT OPTIONS

>lua
require("browsher").setup({
--- Default remote name (e.g., 'origin').
default_remote = nil,
--- Default branch name.
default_branch = nil,
--- Default pin type ('commit', 'branch', or 'tag').
default_pin = "commit",
--- Length of the commit hash to use in URLs. If nil, use full length. (40)
commit_length = nil,
--- Allow line numbers with uncommitted changes.
allow_line_numbers_with_uncommitted_changes = false,
--- Command to open URLs (e.g., 'firefox').
open_cmd = nil,
--- Custom providers for building URLs.
---
--- Each provider is a table with the following keys:
--- - `url_template`: The URL template, where `%s` are placeholders.
--- The placeholders are, in order:
--- 1. Remote URL
--- 2. Branch or tag
--- 3. Relative file path
--- - `single_line_format`: Format string for a single line (e.g., `#L%d`).
--- - `multi_line_format`: Format string for multiple lines (e.g., `#L%d-L%d`).
---
--- Example:
--- ```lua
--- providers = {
--- ["mygit.com"] = {
--- url_template = "%s/src/%s/%s",
--- single_line_format = "?line=%d",
--- multi_line_format = "?start=%d&end=%d",
--- },
--- }
providers = {
["github.com"] = {
url_template = "%s/blob/%s/%s",
single_line_format = "#L%d",
multi_line_format = "#L%d-L%d",
},
["gitlab.com"] = {
url_template = "%s/-/blob/%s/%s",
single_line_format = "#L%d",
multi_line_format = "#L%d-%d",
},
},
})
<


KEY MAPPINGS *browsher-configuration-key-mappings*

Add the following key mappings to your Neovim configuration to quickly open
files in the browser:

>lua
-- Open from the latest commit, the recommended default operation
vim.api.nvim_set_keymap('n', '<leader>b', '<cmd>Browsher commit<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('v', '<leader>b', ":'<,'>Browsher commit<CR>gv", { noremap = true, silent = true })

-- Open from the latest tag, for more human readable urls (with risk of outdated line numbers)
vim.api.nvim_set_keymap('n', '<leader>B', '<cmd>Browsher tag<CR>', { noremap = true, silent = true })
vim.api.nvim_set_keymap('v', '<leader>B', ":'<,'>Browsher tag<CR>gv", { noremap = true, silent = true })
<


==============================================================================
5. Usage *browsher-usage*

Use the `:Browsher` command to open the current file in your browser:

>
:Browsher [pin_type] [commit_hash]
<

- `pin_type` (optional): Specifies how to pin the file in the URL. Can be `branch`, `tag`, or `commit`.
If omitted, uses the default pin type from the configuration (`commit` by default).
- `commit_hash` (optional): Specific commit hash to use when `pin_type` is `commit`.


==============================================================================
6. Examples *browsher-examples*

Open current file at the latest commit:

>
:Browsher
<

Open the repository root URL:

>
:Browsher root
<

Open current file at the current branch:

>
:Browsher branch
<

Open current file at the latest tag:

>
:Browsher tag
<

Open current file at a specific commit:

>
:Browsher commit 123abc
<

Open a visual selection of lines:

>
:'<,'>Browsher commit
<

Select lines in visual mode and run:

>
:Browsher
<


==============================================================================
7. Notes *browsher-notes*

- **Uncommitted Changes**If the current file has uncommitted changes, line numbers may not correspond to what’s on the remote repository. By default, line numbers are omitted when there are uncommitted changes unless `allow_line_numbers_with_uncommitted_changes` is set to true.

Generated by panvimdoc <https://github.com/kdheepak/panvimdoc>

vim:tw=78:ts=8:noet:ft=help:norl:
2 changes: 1 addition & 1 deletion lua/browsher/git.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function M.get_current_commit_hash()
return nil
end

local abbrev_arg = ""
local abbrev_arg
local commit_length = config.options.commit_length
if commit_length then
abbrev_arg = string.format("--short=%d", commit_length)
Expand Down
46 changes: 0 additions & 46 deletions test.lua

This file was deleted.

0 comments on commit 084e0e8

Please sign in to comment.