docs: lazygit

This commit is contained in:
Folke Lemaitre 2024-11-06 13:30:17 +01:00
parent bbda275681
commit aa17f60c19
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
4 changed files with 47 additions and 10 deletions

View file

@ -1,5 +1,28 @@
# 🍿 debug
Utility functions you can use in your code.
Personally, I have the code below at the top of my `init.lua`:
```lua
_G.dd = function(...)
Snacks.debug.inspect(...)
end
_G.bt = function()
Snacks.debug.backtrace()
end
vim.print = _G.dd
```
What this does:
- Add a global `dd(...)` you can use anywhere to quickly show a
notification with a pretty printed dump of the object(s)
with lua treesitter highlighting
- Add a global `bt()` to show a notification with a pretty
backtrace.
- Override Neovim's `vim.print`, which is also used by `:= {something = 123}`
<!-- docgen -->
## 📦 Module
@ -13,18 +36,27 @@ Snacks.debug()
### `Snacks.debug.backtrace()`
Show a notification with a pretty backtrace
```lua
Snacks.debug.backtrace()
```
### `Snacks.debug.inspect()`
Show a notification with a pretty printed dump of the object(s)
with lua treesitter highlighting and the location of the caller
```lua
Snacks.debug.inspect(...)
```
### `Snacks.debug.profile()`
Very simple function to profile a lua function.
* **flush**: set to `true` to use `jit.flush` in every iteration.
* **count**: defaults to 100
```lua
---@param fn fun()
---@param opts? {count?: number, flush?: boolean}

View file

@ -1,5 +1,7 @@
# 🍿 gitbrowse
Open the repo of the active file in the browser (e.g., GitHub)
<!-- docgen -->
## ⚙️ Config
@ -7,6 +9,8 @@
```lua
---@class snacks.gitbrowse.Config
{
-- Handler to open the url in a browser
---@param url string
open = function(url)
if vim.fn.has("nvim-0.10") == 0 then
require("lazy.util").open(url, { system = true })
@ -14,6 +18,7 @@
end
vim.ui.open(url)
end,
-- patterns to transform remotes to an actual URL
patterns = {
{ "^(https?://.*)%.git$" , "%1" },
{ "^git@(.+):(.+)%.git$" , "https://%1/%2" },
@ -40,14 +45,6 @@
Snacks.gitbrowse()
```
### `Snacks.gitbrowse.get_url()`
```lua
---@param remote string
---@param opts? snacks.gitbrowse.Config
Snacks.gitbrowse.get_url(remote, opts)
```
### `Snacks.gitbrowse.open()`
```lua

View file

@ -70,6 +70,8 @@ Snacks.lazygit()
### `Snacks.lazygit.log()`
Opens lazygit with the log view
```lua
---@param opts? snacks.lazygit.Config
Snacks.lazygit.log(opts)
@ -77,6 +79,8 @@ Snacks.lazygit.log(opts)
### `Snacks.lazygit.log_file()`
Opens lazygit with the log of the current file
```lua
---@param opts? snacks.lazygit.Config
Snacks.lazygit.log_file(opts)
@ -84,7 +88,8 @@ Snacks.lazygit.log_file(opts)
### `Snacks.lazygit.open()`
Opens lazygit
Opens lazygit, properly configured to use the current colorscheme
and integrate with the current neovim instance
```lua
---@param opts? snacks.lazygit.Config

View file

@ -151,7 +151,8 @@ gui:
dirty = false
end
-- Opens lazygit
-- Opens lazygit, properly configured to use the current colorscheme
-- and integrate with the current neovim instance
---@param opts? snacks.lazygit.Config
function M.open(opts)
---@type snacks.lazygit.Config
@ -170,6 +171,7 @@ function M.open(opts)
return Snacks.terminal(cmd, opts)
end
-- Opens lazygit with the log view
---@param opts? snacks.lazygit.Config
function M.log(opts)
opts = opts or {}
@ -177,6 +179,7 @@ function M.log(opts)
return M.open(opts)
end
-- Opens lazygit with the log of the current file
---@param opts? snacks.lazygit.Config
function M.log_file(opts)
local file = vim.trim(vim.api.nvim_buf_get_name(0))