Commit graph

1292 commits

Author SHA1 Message Date
Folke Lemaitre
6db50cfe2d
fix(scratch): always set filetype on the buffer. Fixes #179 2024-12-01 20:06:04 +01:00
Folke Lemaitre
4bdf7daece
fix(dashboard): truncate file names when too long. Fixes #183 2024-12-01 19:56:44 +01:00
Folke Lemaitre
b99bc64ef9
feat(dashbard): explude files from stdpath data/cache/state in recent files and projects 2024-12-01 19:49:26 +01:00
Folke Lemaitre
891648a483
feat(bigfile): disable matchparen, set foldmethod=manual, set conceallevel=0 2024-12-01 19:48:06 +01:00
Folke Lemaitre
85f51320b2
fix(profiler): startup opts 2024-12-01 19:47:27 +01:00
Folke Lemaitre
93b254d658
fix(dashboard): prevent possible duplicate recent files. Fixes #171 2024-12-01 18:16:43 +01:00
Iordanis Petkakis
e5bc11e328
feat(gitbrowse): allow custom branch (#172)
## Description
Allow the user to be able to define custom branch with
`Snacks.gitbrowse`. I also added `start_line` and `end_line` (default to
`nil`), because from my testing when using a keymap such as the one in
[my comment in the related
issue](https://github.com/folke/snacks.nvim/issues/170#issuecomment-2508476110)
or this one which I came up later while implementing this
```lua
vim.keymap.set({ "n", "x" }, "<leader>gY", function()
  local function system(cmd, err)
    local proc = vim.fn.system(cmd)
    if vim.v.shell_error ~= 0 then
      Snacks.notify.error({ err, proc }, { title = "Git Browse" })
      error(err)
    end
    return vim.split(vim.trim(proc), "\n")
  end
  local branches = {}
  local start_line, end_line
  if vim.fn.mode() == "v" or vim.fn.mode() == "V" then
    start_line = vim.fn.line("v")
    end_line = vim.fn.line(".")
    if start_line > end_line then
      start_line, end_line = end_line, start_line
    end
  end
  for _, branch in ipairs(system({ "git", "branch" }, "Failed to get git branches")) do
    branch = branch:match("%s*[%*]?%s*(%S+)")
    table.insert(branches, branch)
  end
  vim.ui.select(branches, {
    prompt = "Select branch",
  }, function(choice)
    if choice then
      Snacks.gitbrowse({ start_line = start_line or nil, end_line = end_line or nil, branch = choice })
    end
  end)
end, { desc = "Git Browse ()" })
```
Then the visual lines would not work. My guess is that in the first case
the command line prompt and in the second case the `vim.ui.select`
before calling `Snacks.gitbrowse` break the Visual mode state and any
visual selection is not propagated to `Snacks.gitbrowse` to be properly
evaluated by the internal code for visual lines selection, which works
just fine when you just call directly `Snacks.gitbrowse()` via a
function in a keymap (which I assume doesn't break Visual mode state).
That's why I had to implement the visual selection again in the keymap
as well and needed the extra parameters to pass the newly evaluated
values.

Please do correct me if I'm somehow wrong in my logical deduction (which
is based mostly on observation and guessing) and maybe `start_line` and
`end_line` are not needed. Except if the user passes the option directly
in the keymap, but then he would have to create multiple keymaps for
different branches, which in my personal opinion defeats the purpose of
this feature.

In both cases of the keymaps I mentioned the user can dynamically either
type or choose the branch available to him. But maybe I'm missing
something in both the keymaps implementations that I came up with.
<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Related Issue(s)
Closes #170.
<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->

---------

Co-authored-by: Folke Lemaitre <folke.lemaitre@gmail.com>
2024-12-01 18:11:59 +01:00
Folke Lemaitre
ddaa2aaba5
fix(util): better support for nvim-web-devicons 2024-12-01 17:57:28 +01:00
Folke Lemaitre
ca7188c531
fix(util): make sure to always return an icon 2024-12-01 17:46:23 +01:00
Folke Lemaitre
7a47eb76df
feat(dashboard): allow items to be hidden, but still create the keymaps etc 2024-12-01 17:41:10 +01:00
Folke Lemaitre
0043fa9ee1
fix(win): allow resolving nil window option values. Fixes #179 2024-12-01 17:19:14 +01:00
Folke Lemaitre
999ae07808
feat(toggle): toggles for the profiler 2024-12-01 13:36:09 +01:00
Folke Lemaitre
808879951f
feat(snacks): added Snacks.profiler 2024-12-01 13:35:37 +01:00
Folke Lemaitre
32c46b4e2f
feat(scratch): use Snacks.debug.run() to execute buffer/selection 2024-12-01 12:46:52 +01:00
Folke Lemaitre
7db0ed4239
feat(scratch): change keymap to execute buffer/selection to <cr> 2024-12-01 12:46:24 +01:00
Folke Lemaitre
e1fe4f5afe
feat(debug): added Snacks.debug.run() to execute the buffer or selection with inlined print and errors 2024-12-01 12:45:39 +01:00
Folke Lemaitre
5a50738b8e
feat(notifier): reverse notif history by default for show_history 2024-12-01 09:30:19 +01:00
Folke Lemaitre
1cec695fef
feat(snacks): added new scratch snack 2024-12-01 09:08:03 +01:00
Folke Lemaitre
e6f63970de
feat(util): encode/decode a string to be used as a filename 2024-12-01 09:07:26 +01:00
Folke Lemaitre
7c29848e89
feat(util): simple function to get an icon 2024-12-01 09:06:52 +01:00
Folke Lemaitre
d517b11cab
fix(win): don't force close modified buffers 2024-11-30 21:47:33 +01:00
Folke Lemaitre
b813c3383c
refactor(win): normalize keys during init 2024-11-30 21:46:55 +01:00
Folke Lemaitre
8e6d977ec9
perf(dashboard): properly cleanup autocmds 2024-11-30 21:45:41 +01:00
Folke Lemaitre
d0794dcf8e
fix(init): use rawget when loading modules to prevent possible recursive loading with invalid module fields 2024-11-29 07:37:49 +01:00
Folke Lemaitre
dbb1764ae0
ci(docs): added support for module subdirectories 2024-11-29 07:37:49 +01:00
Folke Lemaitre
51996dfeac
feat(win): go back to the previous window, when closing a snacks window 2024-11-29 07:37:49 +01:00
Folke Lemaitre
45fd0efe41
fix(config): check correct var for single config result. Fixes #167 2024-11-27 23:56:56 +01:00
Folke Lemaitre
d730a13b55
feat(config): allow overriding resolved options for a plugin. See #164 2024-11-27 21:43:15 +01:00
Folke Lemaitre
6e3cb7e53c
feat(config): make it easier to use examples in your config 2024-11-27 21:27:56 +01:00
Iordanis Petkakis
59c8eb36ae
feat(gitbrowse): open commit when word is valid hash (#161)
## Description
`gitbrowse` opens commit when word under cursor is valid commit hash.
Please check the Lua pattern for the commit hash in the validation
function I used as I'm not confident as to if it covers all the cases. I
only tested with `diffview` file history and `gitsigns` blame buffer as
I don't use other tools.
<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

## Related Issue(s)
Closes #138.
<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

## Screenshots

<!-- Add screenshots of the changes if applicable. -->
2024-11-27 18:22:14 +01:00
Folke Lemaitre
59f8f0db99
feat(dashboard): always render cache even when expired. Then refresh when needed. 2024-11-27 17:40:32 +01:00
Folke Lemaitre
985be4a759
perf(statuscolumn): some small optims 2024-11-26 14:00:07 +01:00
Folke Lemaitre
f83a7b0ffb
fix(dashboard): terminal commands get 5 seconds to complete to trigger caching 2024-11-26 13:59:49 +01:00
Folke Lemaitre
b3a60c087a
docs(statuscolumn): duplicate help tags 2024-11-26 12:06:13 +01:00
Krishna Balasubramanian
53441c9703
feat(gitbrowse): add Bitbucket URL patterns (#163)
## Description

<!-- Describe the big picture of your changes to communicate to the
maintainers
  why we should accept this pull request. -->

This enables users to open commits hosted on bitbucket repositories.

## Related Issue(s)

<!--
  If this PR fixes any issues, please link to the issue here.
  - Fixes #<issue_number>
-->

https://github.com/folke/snacks.nvim/issues/162

https://github.com/folke/snacks.nvim/issues/138

## Screenshots

<!-- Add screenshots of the changes if applicable. -->

Co-authored-by: Krishna Balasubramanian <krishna@foxbots.com>
2024-11-26 09:17:30 +01:00
Folke Lemaitre
7564a30cad
fix(statuscolumn): bad copy/paste!! Fixes #152 2024-11-23 14:29:07 +01:00
Folke Lemaitre
cf840087c5
fix(statuscolumn): never error (in case of E565 for example). Fixes #150 2024-11-23 13:10:33 +01:00
Folke Lemaitre
0bbc9e7ae6
fix(notifier): gracefully handle E565 errors 2024-11-23 13:10:33 +01:00
Folke Lemaitre
0b020449ad
fix(win): handle E565 errors on close 2024-11-23 13:10:33 +01:00
Folke Lemaitre
2c7b4b7971
feat(health): check that snacks.nvim plugin spec is correctly setup 2024-11-23 08:12:46 +01:00
Folke Lemaitre
417e07c0d2
feat(dashboard): allow passing win=0, buf=0 to use for the dashboard instead of creating a new window 2024-11-23 00:10:16 +01:00
Folke Lemaitre
02d90ff843
docs(notifier): docgen 2024-11-23 00:04:35 +01:00
Folke Lemaitre
bebd7e70cd
feat(notifier): added history opts.reverse 2024-11-23 00:03:02 +01:00
Folke Lemaitre
0c7f7c5970
fix(notifier): always show notifs directly when blocking 2024-11-22 23:52:50 +01:00
Ughur Alakbarov
c014c6dcfb
docs(dashboard): typo (#148)
supersedes #141
2024-11-22 22:32:36 +01:00
Folke Lemaitre
4e04b70ea3
fix(dashboard): fixed mini.sessions.read. Fixes #144 2024-11-22 18:58:07 +01:00
Folke Lemaitre
9462273bf7
fix(git): make git.get_root work for work-trees and cache git root checks. Closes #136. Fixes #115 2024-11-22 13:26:34 +01:00
Folke Lemaitre
54d521cd0f
fix(dashboard): align should always set width even if no alignment is needed. Fixes #137 2024-11-22 07:20:02 +01:00
Folke Lemaitre
96426953a0
feat(util): set_hl managed 2024-11-21 22:10:25 +01:00
Folke Lemaitre
b0da066536
feat(util): get hl color 2024-11-21 22:10:10 +01:00