Merge branch 'main' into lang/typst

This commit is contained in:
Võ Quang Chiến 2024-11-09 07:34:42 +07:00 committed by GitHub
commit c352553069
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
74 changed files with 886 additions and 1242 deletions

View file

@ -1,3 +1,3 @@
{ {
".": "12.38.2" ".": "13.0.0"
} }

View file

@ -1,5 +1,158 @@
# Changelog # Changelog
## [13.0.0](https://github.com/LazyVim/LazyVim/compare/v12.44.1...v13.0.0) (2024-11-08)
### ⚠ BREAKING CHANGES
* **core:** move a bunch of LazyVim features to snacks.nvim ([#4706](https://github.com/LazyVim/LazyVim/issues/4706))
### Features
* **core:** move a bunch of LazyVim features to snacks.nvim ([#4706](https://github.com/LazyVim/LazyVim/issues/4706)) ([2f46974](https://github.com/LazyVim/LazyVim/commit/2f4697443c0186663ba4421bd4b856e36c3bd7cc))
* **elixir:** add support for livebook files (`*.livemd`) ([#4184](https://github.com/LazyVim/LazyVim/issues/4184)) ([2fcd4cd](https://github.com/LazyVim/LazyVim/commit/2fcd4cdc5fdbed0d2ac097db31578acb0b86b8a2))
* **eslint:** add option to disable eslint auto format ([#4225](https://github.com/LazyVim/LazyVim/issues/4225)) ([2d2e425](https://github.com/LazyVim/LazyVim/commit/2d2e425d25b02b93ef3e4ce4cb0a3edc30903fa5))
* **extras.nushell:** update to upstream treesitter ([#4715](https://github.com/LazyVim/LazyVim/issues/4715)) ([37cc039](https://github.com/LazyVim/LazyVim/commit/37cc03948d8a2475c4889d788df17b293bb7d1e9))
* **extras:** lang/zig ([#4437](https://github.com/LazyVim/LazyVim/issues/4437)) ([4379faf](https://github.com/LazyVim/LazyVim/commit/4379fafc7bbfe69f4e4d0da8131089cb7601f7c4))
* **extras:** rego language support ([#4297](https://github.com/LazyVim/LazyVim/issues/4297)) ([cf86484](https://github.com/LazyVim/LazyVim/commit/cf86484797f70d1783166e8f572a4cfedd510ab5))
* **keymaps:** only add lazygit keymaps when available. Closes [#4643](https://github.com/LazyVim/LazyVim/issues/4643). Closes [#4247](https://github.com/LazyVim/LazyVim/issues/4247) ([aa53cd4](https://github.com/LazyVim/LazyVim/commit/aa53cd47c45ad4a087a35ab9150807d1dfef65ed))
* **lang.angular:** configure `prettier` as formatter for `angular` templates ([#4345](https://github.com/LazyVim/LazyVim/issues/4345)) ([2d6687c](https://github.com/LazyVim/LazyVim/commit/2d6687c6460e8e4ab639bc0a655d7c3f2b90d002))
* **scala:** add key for worksheet hover ([#3853](https://github.com/LazyVim/LazyVim/issues/3853)) ([859646f](https://github.com/LazyVim/LazyVim/commit/859646f628ff0d99e6afe835ba0a48faed2972af))
* **toggle:** add illuminate toggle for which-key ([#4708](https://github.com/LazyVim/LazyVim/issues/4708)) ([67ba582](https://github.com/LazyVim/LazyVim/commit/67ba58215b9122f4c422801c4af74412a8aa21d4))
### Bug Fixes
* **blink:** remove `draw="reversed"` for now till new release ([b841a1d](https://github.com/LazyVim/LazyVim/commit/b841a1dfc36f68033ed02866b57a0a03112b06c3))
* **copilot-chat:** setup cmp conditionally ([#4716](https://github.com/LazyVim/LazyVim/issues/4716)) ([a86c252](https://github.com/LazyVim/LazyVim/commit/a86c25286b83d766af8935db31417c0ce417b865))
* **dap:** use dap's splitstr when running with args. Closes [#4387](https://github.com/LazyVim/LazyVim/issues/4387) ([776994a](https://github.com/LazyVim/LazyVim/commit/776994a20703d9f9cca380dbb0398ec2a6d79bd8))
* **dial:** follow comment explanation for integers ([#4658](https://github.com/LazyVim/LazyVim/issues/4658)) ([c879b39](https://github.com/LazyVim/LazyVim/commit/c879b397c7c4998c060247c0aa7ab68400967022))
* **extras:** make kulala keys only for http files ([#4574](https://github.com/LazyVim/LazyVim/issues/4574)) ([b0ced33](https://github.com/LazyVim/LazyVim/commit/b0ced339a8e19253b93c147e796e921c44735418))
* **extras:** use the correct naming when setting up eruby formatter ([#4625](https://github.com/LazyVim/LazyVim/issues/4625)) ([8534af4](https://github.com/LazyVim/LazyVim/commit/8534af4a7938d6fb8e7cfe5314ad13943414a42e))
* **lang/r:** make keymaps in which-key menu available in visual mode ([#4565](https://github.com/LazyVim/LazyVim/issues/4565)) ([ee2ec7e](https://github.com/LazyVim/LazyVim/commit/ee2ec7e4747f1be73f56f8a5f75047e5bc64cc93))
* **lang/ruby:** do not enable Rubocop as LSP if Solargraph is used ([#4566](https://github.com/LazyVim/LazyVim/issues/4566)) ([fd361d0](https://github.com/LazyVim/LazyVim/commit/fd361d07a295313273c64548784fdcdea59b8a69))
* **lsp:** wrap hover and signature_help ([7616816](https://github.com/LazyVim/LazyVim/commit/76168166e565a5aa135f2b5c5dabb2ffbb8a6075))
* **lualine:** apply highlight groups correctly to truncated pretty_paths ([#4379](https://github.com/LazyVim/LazyVim/issues/4379)) ([1d4157e](https://github.com/LazyVim/LazyVim/commit/1d4157e68128373609385452d594b3bdf77b0fc0))
* **lualine:** make sure path is in root before substituting ([67b216c](https://github.com/LazyVim/LazyVim/commit/67b216c973dd03fee84e362465266bab96402831))
* **navic:** use the same background color as lualine section_c ([#4231](https://github.com/LazyVim/LazyVim/issues/4231)) ([64b0f0b](https://github.com/LazyVim/LazyVim/commit/64b0f0b71d2678ca1342429c594eee61d8b9e0af))
* **neotest:** disambiguous key map descriptions ([#4374](https://github.com/LazyVim/LazyVim/issues/4374)) ([dfde914](https://github.com/LazyVim/LazyVim/commit/dfde9148ef128d8c81a836ff85eb9cd25a01ac1f))
* **options:** disable default ruler ([#4731](https://github.com/LazyVim/LazyVim/issues/4731)) ([da3058a](https://github.com/LazyVim/LazyVim/commit/da3058a72dbf086128b10ce19a0011000669b9ff))
* **options:** removed deprecated options ([1e975be](https://github.com/LazyVim/LazyVim/commit/1e975be7a547f9a2dea63edb21cbaefab40d0cfa))
* **prettier:** keep existing formatters_by_ft ([#4719](https://github.com/LazyVim/LazyVim/issues/4719)) ([4ff3606](https://github.com/LazyVim/LazyVim/commit/4ff36062dd33b852f9734d3731c55a5a8c50cf75))
* **project.nvim:** correctly delete projects ([#4314](https://github.com/LazyVim/LazyVim/issues/4314)) ([c097355](https://github.com/LazyVim/LazyVim/commit/c09735594a26a1749b775847c958e98f566fbac5))
* **snacks:** dont add `snacks_notif` to close_with_q ([e6f612f](https://github.com/LazyVim/LazyVim/commit/e6f612f1cc5dfe942a4b48878d8c356c32232fad))
* **snippet:** don't set navigation mappings in nightly ([#4375](https://github.com/LazyVim/LazyVim/issues/4375)) ([1552791](https://github.com/LazyVim/LazyVim/commit/15527910c321f3a6a01e1216442f8d21e5f19247))
* **telescope:** buffers to start at final item ([#4189](https://github.com/LazyVim/LazyVim/issues/4189)) ([f78bc3b](https://github.com/LazyVim/LazyVim/commit/f78bc3b85881b43fd082add4c80d9a75c573a882))
* **telescope:** check for gmake if needed ([0bc09d8](https://github.com/LazyVim/LazyVim/commit/0bc09d8206cfec1a4b3481acbc3e864a548c499a))
## [12.44.1](https://github.com/LazyVim/LazyVim/compare/v12.44.0...v12.44.1) (2024-11-03)
### Bug Fixes
* **blink:** use release version ([7ebed53](https://github.com/LazyVim/LazyVim/commit/7ebed5349d49dd9996d61155bc12605871058ec1))
* **copilot:** properly process tab with copilot and blink. Fixes [#4692](https://github.com/LazyVim/LazyVim/issues/4692) ([fa37396](https://github.com/LazyVim/LazyVim/commit/fa3739678af494b8657d68ddc44bcc598f9bd00a))
* **java:** jdtls run with args ([#4689](https://github.com/LazyVim/LazyVim/issues/4689)) ([0403e80](https://github.com/LazyVim/LazyVim/commit/0403e80a8e6250130fe94af1034a6f0760a24ca8))
## [12.44.0](https://github.com/LazyVim/LazyVim/compare/v12.43.0...v12.44.0) (2024-11-02)
### Features
* **blink:** use vim.o.pumblend as winblend option for autocomplete menu in blink ([28da1eb](https://github.com/LazyVim/LazyVim/commit/28da1eb073f99abda9ea9b2349e5d8b8087ffcce))
* **extras:** blink ([#4680](https://github.com/LazyVim/LazyVim/issues/4680)) ([ad52bf9](https://github.com/LazyVim/LazyVim/commit/ad52bf91bc8f1821bbb0b7218d03768eec9a9e42))
* **extras:** enable crates.nvim in-process lsp server ([#4684](https://github.com/LazyVim/LazyVim/issues/4684)) ([db8895b](https://github.com/LazyVim/LazyVim/commit/db8895b518278331fb73bbd81975cbe5012c8f71))
### Bug Fixes
* **autocmds:** `vim.highlight` is deprecated ([a7b4c43](https://github.com/LazyVim/LazyVim/commit/a7b4c4391bccc894f56847ead7abe4ae7a8e4fc0))
* **autocmds:** change mapping for `lazyvim_close_with_q` ([#4638](https://github.com/LazyVim/LazyVim/issues/4638)) ([5f432d9](https://github.com/LazyVim/LazyVim/commit/5f432d997e397790cea39d9bb8826c1d4ca14afb))
* **autocmds:** close window and force delete buf on q. See [#4638](https://github.com/LazyVim/LazyVim/issues/4638) ([cb40a09](https://github.com/LazyVim/LazyVim/commit/cb40a09538dc0c417a7ffbbacdbdec90be4a792c))
* **autocmds:** force close buffers with q. See [#4638](https://github.com/LazyVim/LazyVim/issues/4638) ([0eb4009](https://github.com/LazyVim/LazyVim/commit/0eb400908d17f4116f02c6464d7ef81456ca303c))
* **blink:** explicetely set version=false for now ([ec616a3](https://github.com/LazyVim/LazyVim/commit/ec616a3cecaf1e5de1687223575ff019ad688e55))
* **catppuccin:** fix bufferline integration when no colorscheme is set. Closes [#4641](https://github.com/LazyVim/LazyVim/issues/4641) ([6570a14](https://github.com/LazyVim/LazyVim/commit/6570a141c0de30fccee38e2b10dcd14830624e16))
* **copilot:** create undo point before accepting copilot suggestion when using blink ([6e1d099](https://github.com/LazyVim/LazyVim/commit/6e1d0994d99e63a46c3eff737c44ca47e3ecbe28))
* **dap:** remove explicit `load_launchjs` call ([#4634](https://github.com/LazyVim/LazyVim/issues/4634)) ([2f6c1f6](https://github.com/LazyVim/LazyVim/commit/2f6c1f60834108359b3404748453a65843909a03))
* **lazygit:** file history when cwd is outside the repo ([#4666](https://github.com/LazyVim/LazyVim/issues/4666)) ([4ee6be4](https://github.com/LazyVim/LazyVim/commit/4ee6be4499008db458089fb2573b13f6b5ec5d3b))
* **rust:** disable rust_analyzer in the rust extra. Fixes [#4685](https://github.com/LazyVim/LazyVim/issues/4685) ([1d3d64f](https://github.com/LazyVim/LazyVim/commit/1d3d64fd1ae26581b71f39091c816e568b7a3b39))
## [12.43.0](https://github.com/LazyVim/LazyVim/compare/v12.42.0...v12.43.0) (2024-10-23)
### Features
* **catppuccin:** bufferline integration. Closes [#4583](https://github.com/LazyVim/LazyVim/issues/4583). Closes [#4581](https://github.com/LazyVim/LazyVim/issues/4581) ([917c685](https://github.com/LazyVim/LazyVim/commit/917c685c1fb3774375ea2236e5e7aaa3d951fdda))
* **extras:** expose `prios` to users for customization ([#4587](https://github.com/LazyVim/LazyVim/issues/4587)) ([e46cb62](https://github.com/LazyVim/LazyVim/commit/e46cb62a17e1f4b7f163f4e0fdd13593c4af3abd))
* **keymaps:** allow `v:count1` when moving lines ([#4618](https://github.com/LazyVim/LazyVim/issues/4618)) ([b4eb4e1](https://github.com/LazyVim/LazyVim/commit/b4eb4e1f4a4024229fe40782fdb12683c1c69634))
### Bug Fixes
* **folds:** enable folds when treesitter available. Fixes [#4563](https://github.com/LazyVim/LazyVim/issues/4563) ([fe7003d](https://github.com/LazyVim/LazyVim/commit/fe7003de506ef7022a6c5f623476630d7bc30944))
## [12.42.0](https://github.com/LazyVim/LazyVim/compare/v12.41.0...v12.42.0) (2024-10-04)
### Features
* **root:** provide `vim.g.root_lsp_ignore` to ignore LSP servers ([#4332](https://github.com/LazyVim/LazyVim/issues/4332)) ([90a9231](https://github.com/LazyVim/LazyVim/commit/90a92312aed79d4ee9d231f9eb3f8cd4debc46d1))
### Bug Fixes
* **gitsigns:** change name of filetype blame ([#4243](https://github.com/LazyVim/LazyVim/issues/4243)) ([3e257fd](https://github.com/LazyVim/LazyVim/commit/3e257fdb8874d7112446dc3ca1caf9c3263d8194))
* **neotest:** properly initialize adapter with call table. Fixes [#4538](https://github.com/LazyVim/LazyVim/issues/4538) ([327e829](https://github.com/LazyVim/LazyVim/commit/327e829c156864975785914038fe4515dadcba87))
## [12.41.0](https://github.com/LazyVim/LazyVim/compare/v12.40.0...v12.41.0) (2024-10-02)
### Features
* **rust:** update rustaceanvim ([#4477](https://github.com/LazyVim/LazyVim/issues/4477)) ([04515b1](https://github.com/LazyVim/LazyVim/commit/04515b139973173e90604f700d70f4e6d714da1f))
* **toggle:** add more `M.wk` fields for better user customization ([#4521](https://github.com/LazyVim/LazyVim/issues/4521)) ([57c0c0b](https://github.com/LazyVim/LazyVim/commit/57c0c0bc9f86467d90c0c10aac680bdba8e56469))
### Bug Fixes
* **extras:** migrate away from deprecated `get_target_window()` in mini-files ([#4479](https://github.com/LazyVim/LazyVim/issues/4479)) ([b110550](https://github.com/LazyVim/LazyVim/commit/b110550393957a3434db1f4f0dc5804a9d31820f))
## [12.40.0](https://github.com/LazyVim/LazyVim/compare/v12.39.0...v12.40.0) (2024-10-02)
### Features
* **lang:** add ts_ls to lsp config ([#4406](https://github.com/LazyVim/LazyVim/issues/4406)) ([34f0e56](https://github.com/LazyVim/LazyVim/commit/34f0e568d4e853cc2b4f0d628749cb66cd1b9aaf))
### Bug Fixes
* **extras:** rename `lspconfig.server_configurations` to `lspconfig.configs` ([#4518](https://github.com/LazyVim/LazyVim/issues/4518)) ([7432574](https://github.com/LazyVim/LazyVim/commit/74325743e7ff9d9efe9172ba96ec063c65ee219c))
* **lsp:** backward compat with lspconfig refactor. Fixes [#4525](https://github.com/LazyVim/LazyVim/issues/4525). See [#4518](https://github.com/LazyVim/LazyVim/issues/4518) ([6e40252](https://github.com/LazyVim/LazyVim/commit/6e4025229d4628a7278cf7c09f942af6dfea05dd))
* **render-markdown:** remove redundant `opts.file_types` ([#4506](https://github.com/LazyVim/LazyVim/issues/4506)) ([9b17672](https://github.com/LazyVim/LazyVim/commit/9b1767205cffd958ee9c74ceca299bd6c128b5f8))
## [12.39.0](https://github.com/LazyVim/LazyVim/compare/v12.38.2...v12.39.0) (2024-09-18)
### Features
* **cmp:** better c-n and c-p mapping fallback. Fixes [#4414](https://github.com/LazyVim/LazyVim/issues/4414) ([86d4f14](https://github.com/LazyVim/LazyVim/commit/86d4f14bc89b2174cadde93a4f49fc83a01df642))
* **lazygit:** allow user to override LazyVim config with custom file ([#4367](https://github.com/LazyVim/LazyVim/issues/4367)) ([41a8f3a](https://github.com/LazyVim/LazyVim/commit/41a8f3a5fb2bb84036f33764d77049cafb0adedf))
* **persistence:** added leader-qS to select a session ([5a0122b](https://github.com/LazyVim/LazyVim/commit/5a0122b61977b5b2c392b64eb615025f49f2aef7))
* **vscode:** make use of vscode builtin terminal ([#4392](https://github.com/LazyVim/LazyVim/issues/4392)) ([ead5955](https://github.com/LazyVim/LazyVim/commit/ead5955befe8d6e1e06877ea923c78375dcfad1e))
### Bug Fixes
* **extra:** make copilot-chat.lua fallback to the latest model ([#4411](https://github.com/LazyVim/LazyVim/issues/4411)) ([ae17b32](https://github.com/LazyVim/LazyVim/commit/ae17b321c7fc95e8c678865368ebfcac7c2e7483))
* **grug:** grug_far -> grug.open ([#4404](https://github.com/LazyVim/LazyVim/issues/4404)) ([746ea8f](https://github.com/LazyVim/LazyVim/commit/746ea8f1e6afdad89d0fab4ad04f370cf3998f67))
* **markdown-preview:** unknown function `mkdp#util#install` ([#4196](https://github.com/LazyVim/LazyVim/issues/4196)) ([b892861](https://github.com/LazyVim/LazyVim/commit/b892861bdee888f83401e745bda1798dc01e2c54))
* **ocaml:** get_language_id ([#4327](https://github.com/LazyVim/LazyVim/issues/4327)) ([6dcd979](https://github.com/LazyVim/LazyVim/commit/6dcd9794b1819965eb4f3dca70a1eb3c463de3cf))
* **omnisharp:** use Go To Definition with fzf.lua ([#4260](https://github.com/LazyVim/LazyVim/issues/4260)) ([39ca76c](https://github.com/LazyVim/LazyVim/commit/39ca76c9607a7d92aff5b97c50b7ccbf1b2d46b6))
* **toggle:** diagnostics enable/disable. See [#4205](https://github.com/LazyVim/LazyVim/issues/4205) ([3dbace9](https://github.com/LazyVim/LazyVim/commit/3dbace941ee935c89c73fd774267043d12f57fe2))
* **toggle:** make `diagnostics` compatible with nvim-0.9.5 ([#4205](https://github.com/LazyVim/LazyVim/issues/4205)) ([c012f85](https://github.com/LazyVim/LazyVim/commit/c012f859597c4ba3e54dd26372351098a25379cd))
* **vue:** ensure css treesitter installed ([#4308](https://github.com/LazyVim/LazyVim/issues/4308)) ([627215a](https://github.com/LazyVim/LazyVim/commit/627215a72b7744973a778722724d07eccefa0c79))
## [12.38.2](https://github.com/LazyVim/LazyVim/compare/v12.38.1...v12.38.2) (2024-07-25) ## [12.38.2](https://github.com/LazyVim/LazyVim/compare/v12.38.1...v12.38.2) (2024-07-25)

14
NEWS.md
View file

@ -1,5 +1,19 @@
# What's new? # What's new?
## 13.x
- Big new release with a lot of changes and improvements!
- The biggest change is the move of a bunch of core features to
[snacks.nvim](https://github.com/folke/snacks.nvim) and fully
integrating it into **LazyVim**.
- I highly suggest having a look at the **snacks.nvim** documentation
to see all the new features and improvements. Most important changes:
- `Snacks.notifier` for notifications instead of `nvim-notify`
- `Snacks.terminal` is similar to `lazyterm`, but has more features
and creates bottom splits by default (similar to the `edgy` integrating)
## 12.x ## 12.x
- **Markdown Extra**: [headlines.nvim](https://github.com/lukas-reineke/headlines.nvim) has been removed in favor of [markdown.nvim](https://github.com/MeanderingProgrammer/markdown.nvim) - **Markdown Extra**: [headlines.nvim](https://github.com/lukas-reineke/headlines.nvim) has been removed in favor of [markdown.nvim](https://github.com/MeanderingProgrammer/markdown.nvim)

View file

@ -115,7 +115,7 @@ There's a great video created by [@elijahmanor](https://github.com/elijahmanor)
[![Watch the video](https://img.youtube.com/vi/N93cTbtLCIM/hqdefault.jpg)](https://www.youtube.com/watch?v=N93cTbtLCIM) [![Watch the video](https://img.youtube.com/vi/N93cTbtLCIM/hqdefault.jpg)](https://www.youtube.com/watch?v=N93cTbtLCIM)
[@dusty-phillips](https://github.com/dusty-phillips) is working on a book called [@dusty-phillips](https://github.com/dusty-phillips) wrote a comprehensive book called
[LazyVim for Ambitious Developers](https://lazyvim-ambitious-devs.phillips.codes) [LazyVim for Ambitious Developers](https://lazyvim-ambitious-devs.phillips.codes)
available for free online. available for free online.

View file

@ -1,4 +1,4 @@
*LazyVim.txt* For Neovim Last change: 2024 September 16 *LazyVim.txt* For Neovim Last change: 2024 November 08
============================================================================== ==============================================================================
Table of Contents *LazyVim-table-of-contents* Table of Contents *LazyVim-table-of-contents*
@ -102,8 +102,8 @@ Theres a great video created by @elijahmanor
<https://www.youtube.com/watch?v=N93cTbtLCIM> <https://www.youtube.com/watch?v=N93cTbtLCIM>
@dusty-phillips <https://github.com/dusty-phillips> is working on a book called @dusty-phillips <https://github.com/dusty-phillips> wrote a comprehensive book
LazyVim for Ambitious Developers called LazyVim for Ambitious Developers
<https://lazyvim-ambitious-devs.phillips.codes> available for free online. <https://lazyvim-ambitious-devs.phillips.codes> available for free online.

View file

@ -18,7 +18,7 @@ vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, {
vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd("TextYankPost", {
group = augroup("highlight_yank"), group = augroup("highlight_yank"),
callback = function() callback = function()
vim.highlight.on_yank() (vim.hl or vim.highlight).on_yank()
end, end,
}) })
@ -55,28 +55,34 @@ vim.api.nvim_create_autocmd("FileType", {
group = augroup("close_with_q"), group = augroup("close_with_q"),
pattern = { pattern = {
"PlenaryTestPopup", "PlenaryTestPopup",
"checkhealth",
"dbout",
"gitsigns-blame",
"grug-far", "grug-far",
"help", "help",
"lspinfo", "lspinfo",
"neotest-output",
"neotest-output-panel",
"neotest-summary",
"notify", "notify",
"qf", "qf",
"snacks_win",
"spectre_panel", "spectre_panel",
"startuptime", "startuptime",
"tsplayground", "tsplayground",
"neotest-output",
"checkhealth",
"neotest-summary",
"neotest-output-panel",
"dbout",
"gitsigns.blame",
}, },
callback = function(event) callback = function(event)
vim.bo[event.buf].buflisted = false vim.bo[event.buf].buflisted = false
vim.keymap.set("n", "q", "<cmd>close<cr>", { vim.schedule(function()
vim.keymap.set("n", "q", function()
vim.cmd("close")
pcall(vim.api.nvim_buf_delete, event.buf, { force = true })
end, {
buffer = event.buf, buffer = event.buf,
silent = true, silent = true,
desc = "Quit buffer", desc = "Quit buffer",
}) })
end)
end, end,
}) })
@ -119,29 +125,3 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
end, end,
}) })
vim.filetype.add({
pattern = {
[".*"] = {
function(path, buf)
return vim.bo[buf]
and vim.bo[buf].filetype ~= "bigfile"
and path
and vim.fn.getfsize(path) > vim.g.bigfile_size
and "bigfile"
or nil
end,
},
},
})
vim.api.nvim_create_autocmd({ "FileType" }, {
group = augroup("bigfile"),
pattern = "bigfile",
callback = function(ev)
vim.b.minianimate_disable = true
vim.schedule(function()
vim.bo[ev.buf].syntax = vim.filetype.match({ buf = ev.buf }) or ""
end)
end,
})

View file

@ -3,7 +3,7 @@ _G.LazyVim = require("lazyvim.util")
---@class LazyVimConfig: LazyVimOptions ---@class LazyVimConfig: LazyVimOptions
local M = {} local M = {}
M.version = "12.38.2" -- x-release-please-version M.version = "13.0.0" -- x-release-please-version
LazyVim.config = M LazyVim.config = M
---@class LazyVimOptions ---@class LazyVimOptions

View file

@ -23,12 +23,12 @@ map("n", "<C-Left>", "<cmd>vertical resize -2<cr>", { desc = "Decrease Window Wi
map("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "Increase Window Width" }) map("n", "<C-Right>", "<cmd>vertical resize +2<cr>", { desc = "Increase Window Width" })
-- Move Lines -- Move Lines
map("n", "<A-j>", "<cmd>m .+1<cr>==", { desc = "Move Down" }) map("n", "<A-j>", "<cmd>execute 'move .+' . v:count1<cr>==", { desc = "Move Down" })
map("n", "<A-k>", "<cmd>m .-2<cr>==", { desc = "Move Up" }) map("n", "<A-k>", "<cmd>execute 'move .-' . (v:count1 + 1)<cr>==", { desc = "Move Up" })
map("i", "<A-j>", "<esc><cmd>m .+1<cr>==gi", { desc = "Move Down" }) map("i", "<A-j>", "<esc><cmd>m .+1<cr>==gi", { desc = "Move Down" })
map("i", "<A-k>", "<esc><cmd>m .-2<cr>==gi", { desc = "Move Up" }) map("i", "<A-k>", "<esc><cmd>m .-2<cr>==gi", { desc = "Move Up" })
map("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move Down" }) map("v", "<A-j>", ":<C-u>execute \"'<,'>move '>+\" . v:count1<cr>gv=gv", { desc = "Move Down" })
map("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move Up" }) map("v", "<A-k>", ":<C-u>execute \"'<,'>move '<-\" . (v:count1 + 1)<cr>gv=gv", { desc = "Move Up" })
-- buffers -- buffers
map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev Buffer" }) map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev Buffer" })
@ -37,7 +37,9 @@ map("n", "[b", "<cmd>bprevious<cr>", { desc = "Prev Buffer" })
map("n", "]b", "<cmd>bnext<cr>", { desc = "Next Buffer" }) map("n", "]b", "<cmd>bnext<cr>", { desc = "Next Buffer" })
map("n", "<leader>bb", "<cmd>e #<cr>", { desc = "Switch to Other Buffer" }) map("n", "<leader>bb", "<cmd>e #<cr>", { desc = "Switch to Other Buffer" })
map("n", "<leader>`", "<cmd>e #<cr>", { desc = "Switch to Other Buffer" }) map("n", "<leader>`", "<cmd>e #<cr>", { desc = "Switch to Other Buffer" })
map("n", "<leader>bd", LazyVim.ui.bufremove, { desc = "Delete Buffer" }) map("n", "<leader>bd", function()
Snacks.bufdelete()
end, { desc = "Delete Buffer" })
map("n", "<leader>bD", "<cmd>:bd<cr>", { desc = "Delete Buffer and Window" }) map("n", "<leader>bD", "<cmd>:bd<cr>", { desc = "Delete Buffer and Window" })
-- Clear search with <esc> -- Clear search with <esc>
@ -115,37 +117,30 @@ map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" })
-- stylua: ignore start -- stylua: ignore start
-- toggle options -- toggle options
LazyVim.toggle.map("<leader>uf", LazyVim.toggle.format()) LazyVim.format.snacks_toggle():map("<leader>uf")
LazyVim.toggle.map("<leader>uF", LazyVim.toggle.format(true)) LazyVim.format.snacks_toggle(true):map("<leader>uF")
LazyVim.toggle.map("<leader>us", LazyVim.toggle("spell", { name = "Spelling" })) Snacks.toggle.option("spell", { name = "Spelling"}):map("<leader>us")
LazyVim.toggle.map("<leader>uw", LazyVim.toggle("wrap", { name = "Wrap" })) Snacks.toggle.option("wrap", {name = "Wrap"}):map("<leader>uw")
LazyVim.toggle.map("<leader>uL", LazyVim.toggle("relativenumber", { name = "Relative Number" })) Snacks.toggle.option("relativenumber", { name = "Relative Number"}):map("<leader>uL")
LazyVim.toggle.map("<leader>ud", LazyVim.toggle.diagnostics) Snacks.toggle.diagnostics():map("<leader>ud")
LazyVim.toggle.map("<leader>ul", LazyVim.toggle.number) Snacks.toggle.line_number():map("<leader>ul")
LazyVim.toggle.map( "<leader>uc", LazyVim.toggle("conceallevel", { values = { 0, vim.o.conceallevel > 0 and vim.o.conceallevel or 2 } })) Snacks.toggle.option("conceallevel", {off = 0, on = vim.o.conceallevel > 0 and vim.o.conceallevel or 2}):map("<leader>uc")
LazyVim.toggle.map("<leader>uT", LazyVim.toggle.treesitter) Snacks.toggle.treesitter():map("<leader>uT")
LazyVim.toggle.map("<leader>ub", LazyVim.toggle("background", { values = { "light", "dark" }, name = "Background" })) Snacks.toggle.option("background", { off = "light", on = "dark" , name = "Dark Background"}):map("<leader>ub")
if vim.lsp.inlay_hint then if vim.lsp.inlay_hint then
LazyVim.toggle.map("<leader>uh", LazyVim.toggle.inlay_hints) Snacks.toggle.inlay_hints():map("<leader>uh")
end end
-- lazygit -- lazygit
map("n", "<leader>gg", function() LazyVim.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" }) if vim.fn.executable("lazygit") == 1 then
map("n", "<leader>gG", function() LazyVim.lazygit() end, { desc = "Lazygit (cwd)" }) map("n", "<leader>gg", function() Snacks.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" })
map("n", "<leader>gb", LazyVim.lazygit.blame_line, { desc = "Git Blame Line" }) map("n", "<leader>gG", function() Snacks.lazygit() end, { desc = "Lazygit (cwd)" })
map("n", "<leader>gB", LazyVim.lazygit.browse, { desc = "Git Browse" }) map("n", "<leader>gb", function() Snacks.git.blame_line() end, { desc = "Git Blame Line" })
map("n", "<leader>gB", function() Snacks.gitbrowse() end, { desc = "Git Browse" })
map("n", "<leader>gf", function() map("n", "<leader>gf", function() Snacks.lazygit.log_file() end, { desc = "Lazygit Current File History" })
local git_path = vim.api.nvim_buf_get_name(0) map("n", "<leader>gl", function() Snacks.lazygit.log({ cwd = LazyVim.root.git() }) end, { desc = "Lazygit Log" })
LazyVim.lazygit({args = { "-f", vim.trim(git_path) }}) map("n", "<leader>gL", function() Snacks.lazygit.log() end, { desc = "Lazygit Log (cwd)" })
end, { desc = "Lazygit Current File History" }) end
map("n", "<leader>gl", function()
LazyVim.lazygit({ args = { "log" }, cwd = LazyVim.root.git() })
end, { desc = "Lazygit Log" })
map("n", "<leader>gL", function()
LazyVim.lazygit({ args = { "log" } })
end, { desc = "Lazygit Log (cwd)" })
-- quit -- quit
map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit All" }) map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit All" })
@ -158,18 +153,12 @@ map("n", "<leader>uI", "<cmd>InspectTree<cr>", { desc = "Inspect Tree" })
map("n", "<leader>L", function() LazyVim.news.changelog() end, { desc = "LazyVim Changelog" }) map("n", "<leader>L", function() LazyVim.news.changelog() end, { desc = "LazyVim Changelog" })
-- floating terminal -- floating terminal
local lazyterm = function() LazyVim.terminal(nil, { cwd = LazyVim.root() }) end map("n", "<leader>fT", function() Snacks.terminal() end, { desc = "Terminal (cwd)" })
map("n", "<leader>ft", lazyterm, { desc = "Terminal (Root Dir)" }) map("n", "<leader>ft", function() Snacks.terminal(nil, { cwd = LazyVim.root() }) end, { desc = "Terminal (Root Dir)" })
map("n", "<leader>fT", function() LazyVim.terminal() end, { desc = "Terminal (cwd)" }) map("n", "<c-/>", function() Snacks.terminal(nil, { cwd = LazyVim.root() }) end, { desc = "Terminal (Root Dir)" })
map("n", "<c-/>", lazyterm, { desc = "Terminal (Root Dir)" }) map("n", "<c-_>", function() Snacks.terminal(nil, { cwd = LazyVim.root() }) end, { desc = "which_key_ignore" })
map("n", "<c-_>", lazyterm, { desc = "which_key_ignore" })
-- Terminal Mappings -- Terminal Mappings
map("t", "<esc><esc>", "<c-\\><c-n>", { desc = "Enter Normal Mode" })
map("t", "<C-h>", "<cmd>wincmd h<cr>", { desc = "Go to Left Window" })
map("t", "<C-j>", "<cmd>wincmd j<cr>", { desc = "Go to Lower Window" })
map("t", "<C-k>", "<cmd>wincmd k<cr>", { desc = "Go to Upper Window" })
map("t", "<C-l>", "<cmd>wincmd l<cr>", { desc = "Go to Right Window" })
map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" }) map("t", "<C-/>", "<cmd>close<cr>", { desc = "Hide Terminal" })
map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" }) map("t", "<c-_>", "<cmd>close<cr>", { desc = "which_key_ignore" })
@ -178,7 +167,7 @@ map("n", "<leader>w", "<c-w>", { desc = "Windows", remap = true })
map("n", "<leader>-", "<C-W>s", { desc = "Split Window Below", remap = true }) map("n", "<leader>-", "<C-W>s", { desc = "Split Window Below", remap = true })
map("n", "<leader>|", "<C-W>v", { desc = "Split Window Right", remap = true }) map("n", "<leader>|", "<C-W>v", { desc = "Split Window Right", remap = true })
map("n", "<leader>wd", "<C-W>c", { desc = "Delete Window", remap = true }) map("n", "<leader>wd", "<C-W>c", { desc = "Delete Window", remap = true })
LazyVim.toggle.map("<leader>wm", LazyVim.toggle.maximize) LazyVim.ui.maximize():map("<leader>wm")
-- tabs -- tabs
map("n", "<leader><tab>l", "<cmd>tablast<cr>", { desc = "Last Tab" }) map("n", "<leader><tab>l", "<cmd>tablast<cr>", { desc = "Last Tab" })

View file

@ -18,37 +18,19 @@ vim.g.lazyvim_picker = "auto"
-- * a function with signature `function(buf) -> string|string[]` -- * a function with signature `function(buf) -> string|string[]`
vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" } vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" }
-- LazyVim automatically configures lazygit:
-- * theme, based on the active colorscheme.
-- * editPreset to nvim-remote
-- * enables nerd font icons
-- Set to false to disable.
-- Set the options you want to override in `~/.config/lazygit/custom.yml`
-- WARN: on Windows you might want to set `editPreset: "nvim"` due to
-- this issue https://github.com/jesseduffield/lazygit/issues/3467
vim.g.lazygit_config = true
-- Options for the LazyVim statuscolumn
vim.g.lazyvim_statuscolumn = {
folds_open = false, -- show fold sign when fold is open
folds_githl = false, -- highlight fold sign with git sign color
}
-- Optionally setup the terminal to use -- Optionally setup the terminal to use
-- This sets `vim.o.shell` and does some additional configuration for: -- This sets `vim.o.shell` and does some additional configuration for:
-- * pwsh -- * pwsh
-- * powershell -- * powershell
-- LazyVim.terminal.setup("pwsh") -- LazyVim.terminal.setup("pwsh")
-- Set LSP servers to be ignored when used with `util.root.detectors.lsp`
-- for detecting the LSP root
vim.g.root_lsp_ignore = { "copilot" }
-- Hide deprecation warnings -- Hide deprecation warnings
vim.g.deprecation_warnings = false vim.g.deprecation_warnings = false
-- Set filetype to `bigfile` for files larger than 1.5 MB
-- Only vim syntax will be enabled (with the correct filetype)
-- LSP, treesitter and other ft plugins will be disabled.
-- mini.animate will also be disabled.
vim.g.bigfile_size = 1024 * 1024 * 1.5 -- 1.5 MB
-- Show the current document symbols location from Trouble in lualine -- Show the current document symbols location from Trouble in lualine
-- You can disable this for a buffer by setting `vim.b.trouble_lualine = false` -- You can disable this for a buffer by setting `vim.b.trouble_lualine = false`
vim.g.trouble_lualine = true vim.g.trouble_lualine = true
@ -88,6 +70,7 @@ opt.number = true -- Print line number
opt.pumblend = 10 -- Popup blend opt.pumblend = 10 -- Popup blend
opt.pumheight = 10 -- Maximum number of entries in a popup opt.pumheight = 10 -- Maximum number of entries in a popup
opt.relativenumber = true -- Relative line numbers opt.relativenumber = true -- Relative line numbers
opt.ruler = false -- Disable the default ruler
opt.scrolloff = 4 -- Lines of context opt.scrolloff = 4 -- Lines of context
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" } opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" }
opt.shiftround = true -- Round indent opt.shiftround = true -- Round indent
@ -99,11 +82,9 @@ opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift t
opt.smartcase = true -- Don't ignore case with capitals opt.smartcase = true -- Don't ignore case with capitals
opt.smartindent = true -- Insert indents automatically opt.smartindent = true -- Insert indents automatically
opt.spelllang = { "en" } opt.spelllang = { "en" }
opt.spelloptions:append("noplainbuffer")
opt.splitbelow = true -- Put new windows below current opt.splitbelow = true -- Put new windows below current
opt.splitkeep = "screen" opt.splitkeep = "screen"
opt.splitright = true -- Put new windows right of current opt.splitright = true -- Put new windows right of current
opt.statuscolumn = [[%!v:lua.require'lazyvim.util'.ui.statuscolumn()]]
opt.tabstop = 2 -- Number of spaces tabs count for opt.tabstop = 2 -- Number of spaces tabs count for
opt.termguicolors = true -- True color support opt.termguicolors = true -- True color support
opt.timeoutlen = vim.g.vscode and 1000 or 300 -- Lower than default (1000) to quickly trigger which-key opt.timeoutlen = vim.g.vscode and 1000 or 300 -- Lower than default (1000) to quickly trigger which-key

View file

@ -33,6 +33,8 @@ return {
mapping = cmp.mapping.preset.insert({ mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4), ["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-n>"] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-p>"] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }),
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<CR>"] = LazyVim.cmp.confirm({ select = auto_select }), ["<CR>"] = LazyVim.cmp.confirm({ select = auto_select }),
["<C-y>"] = LazyVim.cmp.confirm({ select = true }), ["<C-y>"] = LazyVim.cmp.confirm({ select = true }),
@ -83,6 +85,7 @@ return {
-- snippets -- snippets
{ {
"nvim-cmp", "nvim-cmp",
optional = true,
dependencies = { dependencies = {
{ {
"garymjr/nvim-snippets", "garymjr/nvim-snippets",
@ -102,26 +105,17 @@ return {
table.insert(opts.sources, { name = "snippets" }) table.insert(opts.sources, { name = "snippets" })
end end
end, end,
keys = { init = function()
{ -- Neovim enabled snippet navigation mappings by default in v0.11
"<Tab>", if vim.fn.has("nvim-0.11") == 0 then
function() vim.keymap.set({ "i", "s" }, "<Tab>", function()
return vim.snippet.active({ direction = 1 }) and "<cmd>lua vim.snippet.jump(1)<cr>" or "<Tab>" return vim.snippet.active({ direction = 1 }) and "<cmd>lua vim.snippet.jump(1)<cr>" or "<Tab>"
end, end, { expr = true, silent = true })
expr = true, vim.keymap.set({ "i", "s" }, "<S-Tab>", function()
silent = true,
mode = { "i", "s" },
},
{
"<S-Tab>",
function()
return vim.snippet.active({ direction = -1 }) and "<cmd>lua vim.snippet.jump(-1)<cr>" or "<S-Tab>" return vim.snippet.active({ direction = -1 }) and "<cmd>lua vim.snippet.jump(-1)<cr>" or "<S-Tab>"
end, { expr = true, silent = true })
end
end, end,
expr = true,
silent = true,
mode = { "i", "s" },
},
},
}, },
-- auto pairs -- auto pairs
@ -198,6 +192,7 @@ return {
library = { library = {
{ path = "luvit-meta/library", words = { "vim%.uv" } }, { path = "luvit-meta/library", words = { "vim%.uv" } },
{ path = "LazyVim", words = { "LazyVim" } }, { path = "LazyVim", words = { "LazyVim" } },
{ path = "snacks.nvim", words = { "Snacks" } },
{ path = "lazy.nvim", words = { "LazyVim" } }, { path = "lazy.nvim", words = { "LazyVim" } },
}, },
}, },
@ -207,6 +202,7 @@ return {
-- Add lazydev source to cmp -- Add lazydev source to cmp
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
optional = true,
opts = function(_, opts) opts = function(_, opts)
table.insert(opts.sources, { name = "lazydev", group_index = 0 }) table.insert(opts.sources, { name = "lazydev", group_index = 0 })
end, end,

View file

@ -50,5 +50,16 @@ return {
which_key = true, which_key = true,
}, },
}, },
specs = {
{
"akinsho/bufferline.nvim",
optional = true,
opts = function(_, opts)
if (vim.g.colors_name or ""):find("catppuccin") then
opts.highlights = require("catppuccin.groups.integrations.bufferline").get()
end
end,
},
},
}, },
} }

View file

@ -105,7 +105,7 @@ return {
}, },
config = function(_, opts) config = function(_, opts)
local function on_move(data) local function on_move(data)
LazyVim.lsp.on_rename(data.source, data.destination) Snacks.rename.on_rename_file(data.source, data.destination)
end end
local events = require("neo-tree.events") local events = require("neo-tree.events")

View file

@ -0,0 +1,90 @@
return {
{
"hrsh7th/nvim-cmp",
enabled = false,
},
{
"saghen/blink.cmp",
version = "*",
opts_extend = { "sources.completion.enabled_providers" },
dependencies = {
"rafamadriz/friendly-snippets",
-- add blink.compat to dependencies
-- { "saghen/blink.compat", opts = {} },
},
event = "InsertEnter",
---@module 'blink.cmp'
---@type blink.cmp.Config
opts = {
highlight = {
-- sets the fallback highlight groups to nvim-cmp's highlight groups
-- useful for when your theme doesn't support blink.cmp
-- will be removed in a future release, assuming themes add support
use_nvim_cmp_as_default = false,
},
-- set to 'mono' for 'Nerd Font Mono' or 'normal' for 'Nerd Font'
-- adjusts spacing to ensure icons are aligned
nerd_font_variant = "mono",
windows = {
autocomplete = {
-- draw = "reversed",
winblend = vim.o.pumblend,
},
documentation = {
auto_show = true,
},
ghost_text = {
enabled = true,
},
},
-- experimental auto-brackets support
accept = { auto_brackets = { enabled = true } },
-- experimental signature help support
-- trigger = { signature_help = { enabled = true } }
sources = {
completion = {
-- remember to enable your providers here
enabled_providers = { "lsp", "path", "snippets", "buffer" },
},
},
keymap = {
preset = "enter",
},
},
},
-- add icons
{
"saghen/blink.cmp",
opts = function(_, opts)
opts.kind_icons = LazyVim.config.icons.kinds
end,
},
-- lazydev
{
"saghen/blink.cmp",
opts = {
sources = {
completion = {
-- add lazydev to your completion providers
enabled_providers = { "lazydev" },
},
providers = {
lsp = {
-- dont show LuaLS require statements when lazydev has items
fallback_for = { "lazydev" },
},
lazydev = {
name = "LazyDev",
module = "lazydev.integrations.blink",
},
},
},
},
},
}

View file

@ -73,7 +73,9 @@ return {
}, },
config = function(_, opts) config = function(_, opts)
local chat = require("CopilotChat") local chat = require("CopilotChat")
if pcall(require, "cmp") then
require("CopilotChat.integrations.cmp").setup() require("CopilotChat.integrations.cmp").setup()
end
vim.api.nvim_create_autocmd("BufEnter", { vim.api.nvim_create_autocmd("BufEnter", {
pattern = "copilot-chat", pattern = "copilot-chat",

View file

@ -80,4 +80,46 @@ return {
}) })
end, end,
}, },
{
"saghen/blink.cmp",
optional = true,
specs = {
{
"zbirenbaum/copilot.lua",
event = "InsertEnter",
opts = {
suggestion = {
enabled = true,
auto_trigger = true,
keymap = { accept = false },
},
},
},
},
opts = {
windows = {
ghost_text = {
enabled = false,
},
},
keymap = {
["<Tab>"] = {
function(cmp)
if cmp.is_in_snippet() then
return cmp.accept()
elseif require("copilot.suggestion").is_visible() then
LazyVim.create_undo()
require("copilot.suggestion").accept()
return true
else
return cmp.select_and_accept()
end
end,
"snippet_forward",
"fallback",
},
},
},
},
} }

View file

@ -2,6 +2,7 @@ return {
-- Tabnine cmp source -- Tabnine cmp source
{ {
"nvim-cmp", "nvim-cmp",
optional = true,
dependencies = { dependencies = {
{ {
"tzachar/cmp-tabnine", "tzachar/cmp-tabnine",

View file

@ -1,11 +1,17 @@
---@param config {args?:string[]|fun():string[]?} ---@param config {type?:string, args?:string[]|fun():string[]?}
local function get_args(config) local function get_args(config)
local args = type(config.args) == "function" and (config.args() or {}) or config.args or {} local args = type(config.args) == "function" and (config.args() or {}) or config.args or {} --[[@as string[] | string ]]
local args_str = type(args) == "table" and table.concat(args, " ") or args --[[@as string]]
config = vim.deepcopy(config) config = vim.deepcopy(config)
---@cast args string[] ---@cast args string[]
config.args = function() config.args = function()
local new_args = vim.fn.input("Run with args: ", table.concat(args, " ")) --[[@as string]] local new_args = vim.fn.expand(vim.fn.input("Run with args: ", args_str)) --[[@as string]]
return vim.split(vim.fn.expand(new_args) --[[@as string]], " ") if config.type and config.type == "java" then
---@diagnostic disable-next-line: return-type-mismatch
return new_args
end
return require("dap.utils").splitstr(new_args)
end end
return config return config
end end
@ -30,7 +36,7 @@ return {
{ "<leader>d", "", desc = "+debug", mode = {"n", "v"} }, { "<leader>d", "", desc = "+debug", mode = {"n", "v"} },
{ "<leader>dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" }, { "<leader>dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" },
{ "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" }, { "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" },
{ "<leader>dc", function() require("dap").continue() end, desc = "Continue" }, { "<leader>dc", function() require("dap").continue() end, desc = "Run/Continue" },
{ "<leader>da", function() require("dap").continue({ before = get_args }) end, desc = "Run with Args" }, { "<leader>da", function() require("dap").continue({ before = get_args }) end, desc = "Run with Args" },
{ "<leader>dC", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" }, { "<leader>dC", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" },
{ "<leader>dg", function() require("dap").goto_() end, desc = "Go to Line (No Execute)" }, { "<leader>dg", function() require("dap").goto_() end, desc = "Go to Line (No Execute)" },
@ -69,11 +75,6 @@ return {
vscode.json_decode = function(str) vscode.json_decode = function(str)
return vim.json.decode(json.json_strip_comments(str)) return vim.json.decode(json.json_strip_comments(str))
end end
-- Extends dap.configurations with entries read from .vscode/launch.json
if vim.fn.filereadable(".vscode/launch.json") then
vscode.load_launchjs()
end
end, end,
}, },

View file

@ -120,17 +120,17 @@ return {
months, months,
}, },
typescript = { typescript = {
augend.integer.alias.decimal, -- nonnegative and negative decimal number augend.integer.alias.decimal_int, -- nonnegative and negative decimal number
augend.constant.alias.bool, -- boolean value (true <-> false) augend.constant.alias.bool, -- boolean value (true <-> false)
logical_alias, logical_alias,
augend.constant.new({ elements = { "let", "const" } }), augend.constant.new({ elements = { "let", "const" } }),
}, },
yaml = { yaml = {
augend.integer.alias.decimal, -- nonnegative and negative decimal number augend.integer.alias.decimal_int, -- nonnegative and negative decimal number
augend.constant.alias.bool, -- boolean value (true <-> false) augend.constant.alias.bool, -- boolean value (true <-> false)
}, },
css = { css = {
augend.integer.alias.decimal, -- nonnegative and negative decimal number augend.integer.alias.decimal_int, -- nonnegative and negative decimal number
augend.hexcolor.new({ augend.hexcolor.new({
case = "lower", case = "lower",
}), }),
@ -142,11 +142,11 @@ return {
augend.misc.alias.markdown_header, augend.misc.alias.markdown_header,
}, },
json = { json = {
augend.integer.alias.decimal, -- nonnegative and negative decimal number augend.integer.alias.decimal_int, -- nonnegative and negative decimal number
augend.semver.alias.semver, -- versioning (v1.1.2) augend.semver.alias.semver, -- versioning (v1.1.2)
}, },
lua = { lua = {
augend.integer.alias.decimal, -- nonnegative and negative decimal number augend.integer.alias.decimal_int, -- nonnegative and negative decimal number
augend.constant.alias.bool, -- boolean value (true <-> false) augend.constant.alias.bool, -- boolean value (true <-> false)
augend.constant.new({ augend.constant.new({
elements = { "and", "or" }, elements = { "and", "or" },
@ -155,7 +155,7 @@ return {
}), }),
}, },
python = { python = {
augend.integer.alias.decimal, -- nonnegative and negative decimal number augend.integer.alias.decimal_int, -- nonnegative and negative decimal number
capitalized_boolean, capitalized_boolean,
logical_alias, logical_alias,
}, },

View file

@ -15,6 +15,21 @@ return {
config = function(_, opts) config = function(_, opts)
require("illuminate").configure(opts) require("illuminate").configure(opts)
Snacks.toggle({
name = "Illuminate",
get = function()
return not require("illuminate.engine").is_paused()
end,
set = function(enabled)
local m = require("illuminate")
if enabled then
m.resume()
else
m.pause()
end
end,
}):map("<leader>ux")
local function map(key, dir, buffer) local function map(key, dir, buffer)
vim.keymap.set("n", key, function() vim.keymap.set("n", key, function()
require("illuminate")["goto_" .. dir .. "_reference"](false) require("illuminate")["goto_" .. dir .. "_reference"](false)

View file

@ -48,7 +48,7 @@ return {
local map_split = function(buf_id, lhs, direction, close_on_file) local map_split = function(buf_id, lhs, direction, close_on_file)
local rhs = function() local rhs = function()
local new_target_window local new_target_window
local cur_target_window = require("mini.files").get_target_window() local cur_target_window = require("mini.files").get_explorer_state().target_window
if cur_target_window ~= nil then if cur_target_window ~= nil then
vim.api.nvim_win_call(cur_target_window, function() vim.api.nvim_win_call(cur_target_window, function()
vim.cmd("belowright " .. direction .. " split") vim.cmd("belowright " .. direction .. " split")
@ -104,7 +104,7 @@ return {
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesActionRename", pattern = "MiniFilesActionRename",
callback = function(event) callback = function(event)
LazyVim.lsp.on_rename(event.data.from, event.data.to) Snacks.rename.on_rename_file(event.data.from, event.data.to)
end, end,
}) })
end, end,

View file

@ -30,14 +30,7 @@ return {
optional = true, optional = true,
opts = function(_, opts) opts = function(_, opts)
if not vim.g.trouble_lualine then if not vim.g.trouble_lualine then
table.insert(opts.sections.lualine_c, { table.insert(opts.sections.lualine_c, { "navic", color_correction = "dynamic" })
function()
return require("nvim-navic").get_location()
end,
cond = function()
return package.loaded["nvim-navic"] and require("nvim-navic").is_available()
end,
})
end end
end, end,
}, },

View file

@ -4,8 +4,13 @@ if lazyvim_docs then
vim.g.lazyvim_picker = "telescope" vim.g.lazyvim_picker = "telescope"
end end
local have_make = vim.fn.executable("make") == 1 local build_cmd ---@type string?
local have_cmake = vim.fn.executable("cmake") == 1 for _, cmd in ipairs({ "make", "cmake", "gmake" }) do
if vim.fn.executable(cmd) == 1 then
build_cmd = cmd
break
end
end
---@type LazyPicker ---@type LazyPicker
local picker = { local picker = {
@ -63,9 +68,9 @@ return {
dependencies = { dependencies = {
{ {
"nvim-telescope/telescope-fzf-native.nvim", "nvim-telescope/telescope-fzf-native.nvim",
build = have_make and "make" build = (build_cmd ~= "cmake") and "make"
or "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build", or "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build",
enabled = have_make or have_cmake, enabled = build_cmd ~= nil,
config = function(plugin) config = function(plugin)
LazyVim.on_load("telescope.nvim", function() LazyVim.on_load("telescope.nvim", function()
local ok, err = pcall(require("telescope").load_extension, "fzf") local ok, err = pcall(require("telescope").load_extension, "fzf")
@ -94,7 +99,11 @@ return {
{ "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" }, { "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" },
{ "<leader><space>", LazyVim.pick("files"), desc = "Find Files (Root Dir)" }, { "<leader><space>", LazyVim.pick("files"), desc = "Find Files (Root Dir)" },
-- find -- find
{ "<leader>fb", "<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>", desc = "Buffers" }, {
"<leader>fb",
"<cmd>Telescope buffers sort_mru=true sort_lastused=true ignore_current_buffer=true<cr>",
desc = "Buffers",
},
{ "<leader>fc", LazyVim.pick.config_files(), desc = "Find Config File" }, { "<leader>fc", LazyVim.pick.config_files(), desc = "Find Config File" },
{ "<leader>ff", LazyVim.pick("files"), desc = "Find Files (Root Dir)" }, { "<leader>ff", LazyVim.pick("files"), desc = "Find Files (Root Dir)" },
{ "<leader>fF", LazyVim.pick("files", { root = false }), desc = "Find Files (cwd)" }, { "<leader>fF", LazyVim.pick("files", { root = false }), desc = "Find Files (cwd)" },

View file

@ -70,7 +70,8 @@ return {
opts = function(_, opts) opts = function(_, opts)
opts.formatters_by_ft = opts.formatters_by_ft or {} opts.formatters_by_ft = opts.formatters_by_ft or {}
for _, ft in ipairs(supported) do for _, ft in ipairs(supported) do
opts.formatters_by_ft[ft] = { "prettier" } opts.formatters_by_ft[ft] = opts.formatters_by_ft[ft] or {}
table.insert(opts.formatters_by_ft[ft], "prettier")
end end
opts.formatters = opts.formatters or {} opts.formatters = opts.formatters or {}

View file

@ -57,4 +57,15 @@ return {
}) })
end, end,
}, },
-- formatting
{
"conform.nvim",
opts = function(_, opts)
if LazyVim.has_extra("formatting.prettier") then
opts.formatters_by_ft = opts.formatters_by_ft or {}
opts.formatters_by_ft.htmlangular = { "prettier" }
end
end,
},
} }

View file

@ -17,7 +17,7 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "astro" } }, opts = { ensure_installed = { "astro", "css" } },
}, },
-- LSP Servers -- LSP Servers

View file

@ -1,7 +1,7 @@
return { return {
recommended = function() recommended = function()
return LazyVim.extras.wants({ return LazyVim.extras.wants({
ft = { "elixir", "eelixir", "heex", "surface" }, ft = { "elixir", "eelixir", "heex", "surface", "livebook" },
root = "mix.exs", root = "mix.exs",
}) })
end, end,
@ -40,7 +40,11 @@ return {
}, },
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "elixir", "heex", "eex" } }, opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "elixir", "heex", "eex" })
vim.treesitter.language.register("markdown", "livebook")
end,
}, },
{ {
"nvim-neotest/neotest", "nvim-neotest/neotest",
@ -85,4 +89,11 @@ return {
} }
end, end,
}, },
{
"MeanderingProgrammer/render-markdown.nvim",
optional = true,
ft = function(_, ft)
vim.list_extend(ft, { "livebook" })
end,
},
} }

View file

@ -1,4 +1,4 @@
-- This is the same as in lspconfig.server_configurations.jdtls, but avoids -- This is the same as in lspconfig.configs.jdtls, but avoids
-- needing to require that when this module loads. -- needing to require that when this module loads.
local java_filetypes = { "java" } local java_filetypes = { "java" }
@ -76,7 +76,7 @@ return {
return { return {
-- How to find the root dir for a given filename. The default comes from -- How to find the root dir for a given filename. The default comes from
-- lspconfig which provides a function specifically for java projects. -- lspconfig which provides a function specifically for java projects.
root_dir = require("lspconfig.server_configurations.jdtls").default_config.root_dir, root_dir = LazyVim.lsp.get_raw_config("jdtls").default_config.root_dir,
-- How to find the project name for a given root dir. -- How to find the project name for a given root dir.
project_name = function(root_dir) project_name = function(root_dir)

View file

@ -17,7 +17,7 @@ return {
-- --
-- false to disable, otherwise should be a table of options to pass to `leanls` -- false to disable, otherwise should be a table of options to pass to `leanls`
-- --
-- See https://github.com/neovim/nvim-lspconfig/blob/master/doc/server_configurations.md#leanls for details. -- See https://github.com/neovim/nvim-lspconfig/blob/master/doc/configs.md#leanls for details.
-- In particular ensure you have followed instructions setting up a callback -- In particular ensure you have followed instructions setting up a callback
-- for `LspAttach` which sets your key bindings! -- for `LspAttach` which sets your key bindings!
lsp = { lsp = {

View file

@ -95,7 +95,6 @@ return {
{ {
"MeanderingProgrammer/render-markdown.nvim", "MeanderingProgrammer/render-markdown.nvim",
opts = { opts = {
file_types = { "markdown", "norg", "rmd", "org" },
code = { code = {
sign = false, sign = false,
width = "block", width = "block",
@ -109,7 +108,7 @@ return {
ft = { "markdown", "norg", "rmd", "org" }, ft = { "markdown", "norg", "rmd", "org" },
config = function(_, opts) config = function(_, opts)
require("render-markdown").setup(opts) require("render-markdown").setup(opts)
LazyVim.toggle.map("<leader>um", { Snacks.toggle({
name = "Render Markdown", name = "Render Markdown",
get = function() get = function()
return require("render-markdown.state").enabled return require("render-markdown.state").enabled
@ -122,7 +121,7 @@ return {
m.disable() m.disable()
end end
end, end,
}) }):map("<leader>um")
end, end,
}, },
} }

View file

@ -12,23 +12,6 @@ return {
}, },
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
dependencies = { opts = { ensure_installed = { "nu" } },
{ "nushell/tree-sitter-nu" },
},
opts = function(_, opts)
---@diagnostic disable-next-line: inject-field
require("nvim-treesitter.parsers").get_parser_configs().nu = {
install_info = {
url = "https://github.com/nushell/tree-sitter-nu",
files = { "src/parser.c" },
branch = "main",
},
filetype = "nu",
}
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "nu" })
end
end,
}, },
} }

View file

@ -18,9 +18,14 @@ return {
opts = { opts = {
servers = { servers = {
ocamllsp = { ocamllsp = {
get_language_id = function(_, ftype) filetypes = {
return language_id_of[ftype] "ocaml",
end, "ocaml.menhir",
"ocaml.interface",
"ocaml.ocamllex",
"reason",
"dune",
},
root_dir = function(fname) root_dir = function(fname)
return require("lspconfig.util").root_pattern( return require("lspconfig.util").root_pattern(
"*.opam", "*.opam",

View file

@ -52,8 +52,10 @@ return {
keys = { keys = {
{ {
"gd", "gd",
function() LazyVim.has("telescope.nvim") and function()
require("omnisharp_extended").telescope_lsp_definitions() require("omnisharp_extended").telescope_lsp_definitions()
end or function()
require("omnisharp_extended").lsp_definitions()
end, end,
desc = "Goto Definition", desc = "Goto Definition",
}, },

View file

@ -133,6 +133,7 @@ return {
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
optional = true,
opts = function(_, opts) opts = function(_, opts)
opts.auto_brackets = opts.auto_brackets or {} opts.auto_brackets = opts.auto_brackets or {}
table.insert(opts.auto_brackets, "python") table.insert(opts.auto_brackets, "python")

View file

@ -22,6 +22,7 @@ return {
local wk = require("which-key") local wk = require("which-key")
wk.add({ wk.add({
buffer = true, buffer = true,
mode = { "n", "v" },
{ "<localleader>a", group = "all" }, { "<localleader>a", group = "all" },
{ "<localleader>b", group = "between marks" }, { "<localleader>b", group = "between marks" },
{ "<localleader>c", group = "chunks" }, { "<localleader>c", group = "chunks" },

View file

@ -0,0 +1,20 @@
return {
recommended = {
ft = "rego",
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
regols = {},
regal = {},
},
},
},
{
"nvim-treesitter/nvim-treesitter",
opts = {
ensure_installed = { "rego" },
},
},
}

View file

@ -36,7 +36,10 @@ return {
enabled = lsp == "solargraph", enabled = lsp == "solargraph",
}, },
rubocop = { rubocop = {
enabled = formatter == "rubocop", -- If Solargraph and Rubocop are both enabled as an LSP,
-- diagnostics will be duplicated because Solargraph
-- already calls Rubocop if it is installed
enabled = formatter == "rubocop" and lsp ~= "solargraph",
}, },
standardrb = { standardrb = {
enabled = formatter == "standardrb", enabled = formatter == "standardrb",
@ -64,7 +67,7 @@ return {
opts = { opts = {
formatters_by_ft = { formatters_by_ft = {
ruby = { formatter }, ruby = { formatter },
eruby = { "erb-format" }, eruby = { "erb_format" },
}, },
}, },
}, },

View file

@ -6,25 +6,23 @@ return {
}) })
end, end,
-- Extend auto completion -- LSP for Cargo.toml
{
"hrsh7th/nvim-cmp",
dependencies = {
{ {
"Saecki/crates.nvim", "Saecki/crates.nvim",
event = { "BufRead Cargo.toml" }, event = { "BufRead Cargo.toml" },
opts = { opts = {
completion = { completion = {
cmp = { enabled = true }, crates = {
enabled = true,
}, },
}, },
lsp = {
enabled = true,
actions = true,
completion = true,
hover = true,
}, },
}, },
---@param opts cmp.ConfigSchema
opts = function(_, opts)
opts.sources = opts.sources or {}
table.insert(opts.sources, { name = "crates" })
end,
}, },
-- Add Rust & related to treesitter -- Add Rust & related to treesitter
@ -42,7 +40,7 @@ return {
{ {
"mrcjkb/rustaceanvim", "mrcjkb/rustaceanvim",
version = "^4", -- Recommended version = vim.fn.has("nvim-0.10.0") == 0 and "^4" or false,
ft = { "rust" }, ft = { "rust" },
opts = { opts = {
server = { server = {
@ -94,21 +92,7 @@ return {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
opts = { opts = {
servers = { servers = {
taplo = { rust_analyzer = { enabled = false },
keys = {
{
"K",
function()
if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then
require("crates").show_popup()
else
vim.lsp.buf.hover()
end
end,
desc = "Show Crate Documentation",
},
},
},
}, },
}, },
}, },

View file

@ -34,6 +34,13 @@ return {
end, end,
desc = "Metals compile cascade", desc = "Metals compile cascade",
}, },
{
"<leader>mh",
function()
require("metals").hover_worksheet()
end,
desc = "Metals hover worksheet",
},
}, },
init_options = { init_options = {
statusBarProvider = "off", statusBarProvider = "off",

View file

@ -28,7 +28,7 @@ return {
}, },
setup = { setup = {
tailwindcss = function(_, opts) tailwindcss = function(_, opts)
local tw = require("lspconfig.server_configurations.tailwindcss") local tw = LazyVim.lsp.get_raw_config("tailwindcss")
opts.filetypes = opts.filetypes or {} opts.filetypes = opts.filetypes or {}
-- Add default filetypes -- Add default filetypes
@ -59,6 +59,7 @@ return {
}, },
{ {
"hrsh7th/nvim-cmp", "hrsh7th/nvim-cmp",
optional = true,
dependencies = { dependencies = {
{ "roobert/tailwindcss-colorizer-cmp.nvim", opts = {} }, { "roobert/tailwindcss-colorizer-cmp.nvim", opts = {} },
}, },

View file

@ -29,6 +29,7 @@ return {
opts = function(_, opts) opts = function(_, opts)
local null_ls = require("null-ls") local null_ls = require("null-ls")
opts.sources = vim.list_extend(opts.sources or {}, { opts.sources = vim.list_extend(opts.sources or {}, {
null_ls.builtins.formatting.packer,
null_ls.builtins.formatting.terraform_fmt, null_ls.builtins.formatting.terraform_fmt,
null_ls.builtins.diagnostics.terraform_validate, null_ls.builtins.diagnostics.terraform_validate,
}) })
@ -49,6 +50,7 @@ return {
optional = true, optional = true,
opts = { opts = {
formatters_by_ft = { formatters_by_ft = {
hcl = { "packer_fmt" },
terraform = { "terraform_fmt" }, terraform = { "terraform_fmt" },
tf = { "terraform_fmt" }, tf = { "terraform_fmt" },
["terraform-vars"] = { "terraform_fmt" }, ["terraform-vars"] = { "terraform_fmt" },
@ -58,9 +60,10 @@ return {
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
optional = true, optional = true,
dependencies = { specs = {
{ {
"ANGkeith/telescope-terraform-doc.nvim", "ANGkeith/telescope-terraform-doc.nvim",
ft = { "terraform", "hcl" },
config = function() config = function()
LazyVim.on_load("telescope.nvim", function() LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("terraform_doc") require("telescope").load_extension("terraform_doc")
@ -69,6 +72,7 @@ return {
}, },
{ {
"cappyzawa/telescope-terraform.nvim", "cappyzawa/telescope-terraform.nvim",
ft = { "terraform", "hcl" },
config = function() config = function()
LazyVim.on_load("telescope.nvim", function() LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("terraform") require("telescope").load_extension("terraform")

View file

@ -30,7 +30,7 @@ return {
vim.g.vimtex_quickfix_method = vim.fn.executable("pplatex") == 1 and "pplatex" or "latexlog" vim.g.vimtex_quickfix_method = vim.fn.executable("pplatex") == 1 and "pplatex" or "latexlog"
end, end,
keys = { keys = {
{ "<localLeader>l", "", desc = "+vimtext" }, { "<localLeader>l", "", desc = "+vimtex" },
}, },
}, },

View file

@ -19,9 +19,14 @@ return {
opts = { opts = {
-- make sure mason installs the server -- make sure mason installs the server
servers = { servers = {
--- @deprecated -- tsserver renamed to ts_ls but not yet released, so keep this for now
--- the proper approach is to check the nvim-lspconfig release version when it's released to determine the server name dynamically
tsserver = { tsserver = {
enabled = false, enabled = false,
}, },
ts_ls = {
enabled = false,
},
vtsls = { vtsls = {
-- explicitly add default filetypes, so that we can extend -- explicitly add default filetypes, so that we can extend
-- them in related extras -- them in related extras
@ -114,10 +119,16 @@ return {
}, },
}, },
setup = { setup = {
--- @deprecated -- tsserver renamed to ts_ls but not yet released, so keep this for now
--- the proper approach is to check the nvim-lspconfig release version when it's released to determine the server name dynamically
tsserver = function() tsserver = function()
-- disable tsserver -- disable tsserver
return true return true
end, end,
ts_ls = function()
-- disable tsserver
return true
end,
vtsls = function(_, opts) vtsls = function(_, opts)
LazyVim.lsp.on_attach(function(client, buffer) LazyVim.lsp.on_attach(function(client, buffer)
client.commands["_typescript.moveToFileRefactoring"] = function(command, ctx) client.commands["_typescript.moveToFileRefactoring"] = function(command, ctx)

View file

@ -11,7 +11,7 @@ return {
{ {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "vue" } }, opts = { ensure_installed = { "vue", "css" } },
}, },
-- Add LSP servers -- Add LSP servers

View file

@ -0,0 +1,32 @@
return {
recommended = function()
return LazyVim.extras.wants({
ft = { "zig", "zir" },
root = { "zls.json", "build.zig" },
})
end,
{
"nvim-treesitter/nvim-treesitter",
opts = { ensure_installed = { "zig" } },
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
zls = {},
},
},
},
{
"nvim-neotest/neotest",
optional = true,
dependencies = {
"lawrence-laz/neotest-zig",
},
opts = {
adapters = {
["neotest-zig"] = {},
},
},
},
}

View file

@ -1,3 +1,10 @@
if lazyvim_docs then
-- Set to false to disable auto format
vim.g.lazyvim_eslint_auto_format = true
end
local auto_format = vim.g.lazyvim_eslint_auto_format == nil or vim.g.lazyvim_eslint_auto_format
return { return {
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
@ -9,11 +16,16 @@ return {
settings = { settings = {
-- helps eslint find the eslintrc when it's placed in a subfolder instead of the cwd root -- helps eslint find the eslintrc when it's placed in a subfolder instead of the cwd root
workingDirectories = { mode = "auto" }, workingDirectories = { mode = "auto" },
format = auto_format,
}, },
}, },
}, },
setup = { setup = {
eslint = function() eslint = function()
if not auto_format then
return
end
local function get_client(buf) local function get_client(buf)
return LazyVim.lsp.get_clients({ name = "eslint", bufnr = buf })[1] return LazyVim.lsp.get_clients({ name = "eslint", bufnr = buf })[1]
end end

View file

@ -90,7 +90,7 @@ return {
adapter.adapter(config) adapter.adapter(config)
adapter = adapter.adapter adapter = adapter.adapter
elseif meta and meta.__call then elseif meta and meta.__call then
adapter(config) adapter = adapter(config)
else else
error("Adapter " .. name .. " does not support setup") error("Adapter " .. name .. " does not support setup")
end end
@ -106,15 +106,15 @@ return {
-- stylua: ignore -- stylua: ignore
keys = { keys = {
{"<leader>t", "", desc = "+test"}, {"<leader>t", "", desc = "+test"},
{ "<leader>tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" }, { "<leader>tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File (Neotest)" },
{ "<leader>tT", function() require("neotest").run.run(vim.uv.cwd()) end, desc = "Run All Test Files" }, { "<leader>tT", function() require("neotest").run.run(vim.uv.cwd()) end, desc = "Run All Test Files (Neotest)" },
{ "<leader>tr", function() require("neotest").run.run() end, desc = "Run Nearest" }, { "<leader>tr", function() require("neotest").run.run() end, desc = "Run Nearest (Neotest)" },
{ "<leader>tl", function() require("neotest").run.run_last() end, desc = "Run Last" }, { "<leader>tl", function() require("neotest").run.run_last() end, desc = "Run Last (Neotest)" },
{ "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" }, { "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary (Neotest)" },
{ "<leader>to", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" }, { "<leader>to", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output (Neotest)" },
{ "<leader>tO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" }, { "<leader>tO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel (Neotest)" },
{ "<leader>tS", function() require("neotest").run.stop() end, desc = "Stop" }, { "<leader>tS", function() require("neotest").run.stop() end, desc = "Stop (Neotest)" },
{ "<leader>tw", function() require("neotest").watch.toggle(vim.fn.expand("%")) end, desc = "Toggle Watch" }, { "<leader>tw", function() require("neotest").watch.toggle(vim.fn.expand("%")) end, desc = "Toggle Watch (Neotest)" },
}, },
}, },
{ {

View file

@ -31,14 +31,6 @@ return {
return vim.api.nvim_win_get_config(win).relative == "" return vim.api.nvim_win_get_config(win).relative == ""
end, end,
}, },
{
ft = "lazyterm",
title = "LazyTerm",
size = { height = 0.4 },
filter = function(buf)
return not vim.b[buf].lazyterm_cmd
end,
},
"Trouble", "Trouble",
{ ft = "qf", title = "QuickFix" }, { ft = "qf", title = "QuickFix" },
{ {
@ -103,6 +95,7 @@ return {
end end
end end
-- trouble
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
opts[pos] = opts[pos] or {} opts[pos] = opts[pos] or {}
table.insert(opts[pos], { table.insert(opts[pos], {
@ -116,6 +109,22 @@ return {
end, end,
}) })
end end
-- snacks terminal
for _, pos in ipairs({ "top", "bottom", "left", "right" }) do
opts[pos] = opts[pos] or {}
table.insert(opts[pos], {
ft = "snacks_terminal",
size = { height = 0.4 },
title = "%{b:snacks_terminal.id}: %{b:term_title}",
filter = function(_buf, win)
return vim.w[win].snacks_win
and vim.w[win].snacks_win.position == pos
and vim.w[win].snacks_win.relative == "editor"
and not vim.w[win].trouble_preview
end,
})
end
return opts return opts
end, end,
}, },

View file

@ -21,7 +21,7 @@ return {
end, end,
}) })
LazyVim.toggle.map("<leader>ua", { Snacks.toggle({
name = "Mini Animate", name = "Mini Animate",
get = function() get = function()
return not vim.g.minianimate_disable return not vim.g.minianimate_disable
@ -29,7 +29,7 @@ return {
set = function(state) set = function(state)
vim.g.minianimate_disable = not state vim.g.minianimate_disable = not state
end, end,
}) }):map("<leader>ua")
local animate = require("mini.animate") local animate = require("mini.animate")
return { return {

View file

@ -14,17 +14,19 @@ return {
init = function() init = function()
vim.api.nvim_create_autocmd("FileType", { vim.api.nvim_create_autocmd("FileType", {
pattern = { pattern = {
"Trouble",
"alpha", "alpha",
"dashboard", "dashboard",
"fzf", "fzf",
"help", "help",
"lazy", "lazy",
"lazyterm",
"mason", "mason",
"neo-tree", "neo-tree",
"notify", "notify",
"snacks_notif",
"snacks_terminal",
"snacks_win",
"toggleterm", "toggleterm",
"Trouble",
"trouble", "trouble",
}, },
callback = function() callback = function()

View file

@ -4,8 +4,7 @@ return {
event = "VeryLazy", event = "VeryLazy",
opts = function() opts = function()
local tsc = require("treesitter-context") local tsc = require("treesitter-context")
Snacks.toggle({
LazyVim.toggle.map("<leader>ut", {
name = "Treesitter Context", name = "Treesitter Context",
get = tsc.enabled, get = tsc.enabled,
set = function(state) set = function(state)
@ -15,8 +14,7 @@ return {
tsc.disable() tsc.disable()
end end
end, end,
}) }):map("<leader>ut")
return { mode = "cursor", max_lines = 3 } return { mode = "cursor", max_lines = 3 }
end, end,
} }

View file

@ -8,14 +8,14 @@ return {
{ {
"<leader>gG", "<leader>gG",
function() function()
LazyVim.terminal.open({ "gitui" }, { esc_esc = false, ctrl_hjkl = false }) Snacks.terminal({ "gitui" })
end, end,
desc = "GitUi (cwd)", desc = "GitUi (cwd)",
}, },
{ {
"<leader>gg", "<leader>gg",
function() function()
LazyVim.terminal.open({ "gitui" }, { cwd = LazyVim.root.get(), esc_esc = false, ctrl_hjkl = false }) Snacks.terminal({ "gitui" }, { cwd = LazyVim.root.get() })
end, end,
desc = "GitUi (Root Dir)", desc = "GitUi (Root Dir)",
}, },

View file

@ -91,6 +91,15 @@ return {
event = "VeryLazy", event = "VeryLazy",
config = function(_, opts) config = function(_, opts)
require("project_nvim").setup(opts) require("project_nvim").setup(opts)
local history = require("project_nvim.utils.history")
history.delete_project = function(project)
for k, v in pairs(history.recent_projects) do
if v == project.value then
history.recent_projects[k] = nil
return
end
end
end
LazyVim.on_load("telescope.nvim", function() LazyVim.on_load("telescope.nvim", function()
require("telescope").load_extension("projects") require("telescope").load_extension("projects")
end) end)

View file

@ -8,11 +8,11 @@ return {
"mistweaverco/kulala.nvim", "mistweaverco/kulala.nvim",
ft = "http", ft = "http",
keys = { keys = {
{ "<leader>R", "", desc = "+Rest" }, { "<leader>R", "", desc = "+Rest", ft = "http" },
{ "<leader>Rs", "<cmd>lua require('kulala').run()<cr>", desc = "Send the request" }, { "<leader>Rs", "<cmd>lua require('kulala').run()<cr>", desc = "Send the request", ft = "http" },
{ "<leader>Rt", "<cmd>lua require('kulala').toggle_view()<cr>", desc = "Toggle headers/body" }, { "<leader>Rt", "<cmd>lua require('kulala').toggle_view()<cr>", desc = "Toggle headers/body", ft = "http" },
{ "<leader>Rp", "<cmd>lua require('kulala').jump_prev()<cr>", desc = "Jump to previous request" }, { "<leader>Rp", "<cmd>lua require('kulala').jump_prev()<cr>", desc = "Jump to previous request", ft = "http" },
{ "<leader>Rn", "<cmd>lua require('kulala').jump_next()<cr>", desc = "Jump to next request" }, { "<leader>Rn", "<cmd>lua require('kulala').jump_next()<cr>", desc = "Jump to next request", ft = "http" },
}, },
opts = {}, opts = {},
}, },

View file

@ -33,11 +33,15 @@ vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimKeymapsDefaults", pattern = "LazyVimKeymapsDefaults",
callback = function() callback = function()
vim.keymap.set("n", "<leader><space>", "<cmd>Find<cr>") vim.keymap.set("n", "<leader><space>", "<cmd>Find<cr>")
vim.keymap.set("n", "<leader>/", [[<cmd>call VSCodeNotify('workbench.action.findInFiles')<cr>]]) vim.keymap.set("n", "<leader>/", [[<cmd>lua require('vscode').action('workbench.action.findInFiles')<cr>]])
vim.keymap.set("n", "<leader>ss", [[<cmd>call VSCodeNotify('workbench.action.gotoSymbol')<cr>]]) vim.keymap.set("n", "<leader>ss", [[<cmd>lua require('vscode').action('workbench.action.gotoSymbol')<cr>]])
end, end,
}) })
function LazyVim.terminal()
require("vscode").action("workbench.action.terminal.toggleTerminal")
end
return { return {
{ {
"LazyVim/LazyVim", "LazyVim/LazyVim",

View file

@ -10,7 +10,48 @@ end
require("lazyvim.config").init() require("lazyvim.config").init()
-- Terminal Mappings
local function term_nav(dir)
---@param self snacks.terminal
return function(self)
return self:is_floating() and "<c-" .. dir .. ">" or vim.schedule(function()
vim.cmd.wincmd(dir)
end)
end
end
return { return {
{ "folke/lazy.nvim", version = "*" }, { "folke/lazy.nvim", version = "*" },
{ "LazyVim/LazyVim", priority = 10000, lazy = false, opts = {}, cond = true, version = "*" }, { "LazyVim/LazyVim", priority = 10000, lazy = false, opts = {}, cond = true, version = "*" },
{
"folke/snacks.nvim",
priority = 1000,
lazy = false,
opts = function()
---@type snacks.Config
return {
toggle = { map = LazyVim.safe_keymap_set },
notifier = { enabled = not LazyVim.has("noice.nvim") },
terminal = {
win = {
keys = {
nav_h = { "<C-h>", term_nav("h"), desc = "Go to Left Window", expr = true, mode = "t" },
nav_j = { "<C-j>", term_nav("j"), desc = "Go to Lower Window", expr = true, mode = "t" },
nav_k = { "<C-k>", term_nav("k"), desc = "Go to Upper Window", expr = true, mode = "t" },
nav_l = { "<C-l>", term_nav("l"), desc = "Go to Right Window", expr = true, mode = "t" },
},
},
},
}
end,
keys = {
{
"<leader>un",
function()
Snacks.notifier.hide()
end,
desc = "Dismiss All Notifications",
},
},
},
} }

View file

@ -129,8 +129,6 @@ return {
LazyVim.lsp.setup() LazyVim.lsp.setup()
LazyVim.lsp.on_dynamic_capability(require("lazyvim.plugins.lsp.keymaps").on_attach) LazyVim.lsp.on_dynamic_capability(require("lazyvim.plugins.lsp.keymaps").on_attach)
LazyVim.lsp.words.setup(opts.document_highlight)
-- diagnostics signs -- diagnostics signs
if vim.fn.has("nvim-0.10.0") == 0 then if vim.fn.has("nvim-0.10.0") == 0 then
if type(opts.diagnostics.signs) ~= "boolean" then if type(opts.diagnostics.signs) ~= "boolean" then
@ -184,11 +182,13 @@ return {
local servers = opts.servers local servers = opts.servers
local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp")
local has_blink, blink = pcall(require, "blink.cmp")
local capabilities = vim.tbl_deep_extend( local capabilities = vim.tbl_deep_extend(
"force", "force",
{}, {},
vim.lsp.protocol.make_client_capabilities(), vim.lsp.protocol.make_client_capabilities(),
has_cmp and cmp_nvim_lsp.default_capabilities() or {}, has_cmp and cmp_nvim_lsp.default_capabilities() or {},
has_blink and blink.get_lsp_capabilities() or {},
opts.capabilities or {} opts.capabilities or {}
) )

View file

@ -19,23 +19,23 @@ function M.get()
{ "gI", vim.lsp.buf.implementation, desc = "Goto Implementation" }, { "gI", vim.lsp.buf.implementation, desc = "Goto Implementation" },
{ "gy", vim.lsp.buf.type_definition, desc = "Goto T[y]pe Definition" }, { "gy", vim.lsp.buf.type_definition, desc = "Goto T[y]pe Definition" },
{ "gD", vim.lsp.buf.declaration, desc = "Goto Declaration" }, { "gD", vim.lsp.buf.declaration, desc = "Goto Declaration" },
{ "K", vim.lsp.buf.hover, desc = "Hover" }, { "K", function() return vim.lsp.buf.hover() end, desc = "Hover" },
{ "gK", vim.lsp.buf.signature_help, desc = "Signature Help", has = "signatureHelp" }, { "gK", function() return vim.lsp.buf.signature_help() end, desc = "Signature Help", has = "signatureHelp" },
{ "<c-k>", vim.lsp.buf.signature_help, mode = "i", desc = "Signature Help", has = "signatureHelp" }, { "<c-k>", vim.lsp.buf.signature_help, mode = "i", desc = "Signature Help", has = "signatureHelp" },
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" }, { "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
{ "<leader>cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" }, { "<leader>cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" },
{ "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" }, { "<leader>cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" },
{ "<leader>cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } }, { "<leader>cR", function() Snacks.rename.rename_file() end, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } },
{ "<leader>cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" }, { "<leader>cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" },
{ "<leader>cA", LazyVim.lsp.action.source, desc = "Source Action", has = "codeAction" }, { "<leader>cA", LazyVim.lsp.action.source, desc = "Source Action", has = "codeAction" },
{ "]]", function() LazyVim.lsp.words.jump(vim.v.count1) end, has = "documentHighlight", { "]]", function() Snacks.words.jump(vim.v.count1) end, has = "documentHighlight",
desc = "Next Reference", cond = function() return LazyVim.lsp.words.enabled end }, desc = "Next Reference", cond = function() return Snacks.words.is_enabled() end },
{ "[[", function() LazyVim.lsp.words.jump(-vim.v.count1) end, has = "documentHighlight", { "[[", function() Snacks.words.jump(-vim.v.count1) end, has = "documentHighlight",
desc = "Prev Reference", cond = function() return LazyVim.lsp.words.enabled end }, desc = "Prev Reference", cond = function() return Snacks.words.is_enabled() end },
{ "<a-n>", function() LazyVim.lsp.words.jump(vim.v.count1, true) end, has = "documentHighlight", { "<a-n>", function() Snacks.words.jump(vim.v.count1, true) end, has = "documentHighlight",
desc = "Next Reference", cond = function() return LazyVim.lsp.words.enabled end }, desc = "Next Reference", cond = function() return Snacks.words.is_enabled() end },
{ "<a-p>", function() LazyVim.lsp.words.jump(-vim.v.count1, true) end, has = "documentHighlight", { "<a-p>", function() Snacks.words.jump(-vim.v.count1, true) end, has = "documentHighlight",
desc = "Prev Reference", cond = function() return LazyVim.lsp.words.enabled end }, desc = "Prev Reference", cond = function() return Snacks.words.is_enabled() end },
} }
return M._keys return M._keys

View file

@ -1,39 +1,4 @@
return { return {
-- Better `vim.notify()`
{
"rcarriga/nvim-notify",
keys = {
{
"<leader>un",
function()
require("notify").dismiss({ silent = true, pending = true })
end,
desc = "Dismiss All Notifications",
},
},
opts = {
stages = "static",
timeout = 3000,
max_height = function()
return math.floor(vim.o.lines * 0.75)
end,
max_width = function()
return math.floor(vim.o.columns * 0.75)
end,
on_open = function(win)
vim.api.nvim_win_set_config(win, { zindex = 100 })
end,
},
init = function()
-- when noice is not enabled, install notify on VeryLazy
if not LazyVim.has("noice.nvim") then
LazyVim.on_very_lazy(function()
vim.notify = require("notify")
end)
end
end,
},
-- This is what powers LazyVim's fancy-looking -- This is what powers LazyVim's fancy-looking
-- tabs, which include filetype icons and close buttons. -- tabs, which include filetype icons and close buttons.
{ {
@ -55,9 +20,9 @@ return {
opts = { opts = {
options = { options = {
-- stylua: ignore -- stylua: ignore
close_command = function(n) LazyVim.ui.bufremove(n) end, close_command = function(n) Snacks.bufdelete(n) end,
-- stylua: ignore -- stylua: ignore
right_mouse_command = function(n) LazyVim.ui.bufremove(n) end, right_mouse_command = function(n) Snacks.bufdelete(n) end,
diagnostics = "nvim_lsp", diagnostics = "nvim_lsp",
always_show_bufferline = false, always_show_bufferline = false,
diagnostics_indicator = function(_, _, diag) diagnostics_indicator = function(_, _, diag)
@ -226,7 +191,7 @@ return {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
event = "LazyFile", event = "LazyFile",
opts = function() opts = function()
LazyVim.toggle.map("<leader>ug", { Snacks.toggle({
name = "Indention Guides", name = "Indention Guides",
get = function() get = function()
return require("ibl.config").get_config(0).enabled return require("ibl.config").get_config(0).enabled
@ -234,7 +199,7 @@ return {
set = function(state) set = function(state)
require("ibl").setup_buffer(0, { enabled = state }) require("ibl").setup_buffer(0, { enabled = state })
end, end,
}) }):map("<leader>ug")
return { return {
indent = { indent = {
@ -244,17 +209,19 @@ return {
scope = { show_start = false, show_end = false }, scope = { show_start = false, show_end = false },
exclude = { exclude = {
filetypes = { filetypes = {
"help", "Trouble",
"alpha", "alpha",
"dashboard", "dashboard",
"neo-tree", "help",
"Trouble",
"trouble",
"lazy", "lazy",
"mason", "mason",
"neo-tree",
"notify", "notify",
"snacks_notif",
"snacks_terminal",
"snacks_win",
"toggleterm", "toggleterm",
"lazyterm", "trouble",
}, },
}, },
} }

View file

@ -4,12 +4,17 @@ local prios = {
["lazyvim.plugins.extras.dap.core"] = 1, ["lazyvim.plugins.extras.dap.core"] = 1,
["lazyvim.plugins.extras.ui.edgy"] = 2, ["lazyvim.plugins.extras.ui.edgy"] = 2,
["lazyvim.plugins.extras.lang.typescript"] = 5, ["lazyvim.plugins.extras.lang.typescript"] = 5,
["lazyvim.plugins.extras.coding.blink"] = 5,
["lazyvim.plugins.extras.formatting.prettier"] = 10, ["lazyvim.plugins.extras.formatting.prettier"] = 10,
-- default priority is 50 -- default priority is 50
["lazyvim.plugins.extras.editor.aerial"] = 100, ["lazyvim.plugins.extras.editor.aerial"] = 100,
["lazyvim.plugins.extras.editor.outline"] = 100, ["lazyvim.plugins.extras.editor.outline"] = 100,
} }
if vim.g.xtras_prios then
prios = vim.tbl_deep_extend("force", prios, vim.g.xtras_prios or {})
end
---@type string[] ---@type string[]
local extras = LazyVim.dedup(LazyVim.config.json.data.extras) local extras = LazyVim.dedup(LazyVim.config.json.data.extras)

View file

@ -71,9 +71,17 @@ function M.add_missing_snippet_docs(window)
end end
function M.visible() function M.visible()
---@module 'blink.cmp'
local blink = package.loaded["blink.cmp"]
if blink then
return blink.windows and blink.windows.autocomplete.win:is_open()
end
---@module 'cmp' ---@module 'cmp'
local cmp = package.loaded["cmp"] local cmp = package.loaded["cmp"]
return cmp and cmp.core.view:visible() if cmp then
return cmp.core.view:visible()
end
return false
end end
-- This is a better implementation of `cmp.confirm`: -- This is a better implementation of `cmp.confirm`:

View file

@ -0,0 +1,59 @@
local M = {}
M.moved = {
lsp = {
rename_file = { "Snacks.rename.rename_file" },
on_rename = { "Snacks.rename.on_rename_file" },
words = { "Snacks.words" },
},
terminal = {
open = { "Snacks.terminal" },
__call = { "Snacks.terminal" },
},
ui = {
statuscolumn = { "Snacks.statuscolumn" },
bufremove = { "Snacks.bufdelete" },
},
}
---@param name string
---@param mod table
function M.decorate(name, mod)
if not M.moved[name] then
return mod
end
setmetatable(mod, {
__call = function(_, ...)
local to = M.moved[name].__call[1]
LazyVim.deprecate("LazyVim." .. name, to)
local ret = vim.tbl_get(_G, unpack(vim.split(to, ".", { plain = true })))
return ret(...)
end,
__index = function(_, k)
if M.moved[name][k] then
local to = M.moved[name][k][1]
LazyVim.deprecate("LazyVim." .. name .. "." .. k, to)
local ret = vim.tbl_get(_G, unpack(vim.split(to, ".", { plain = true })))
return ret
end
return nil
end,
})
end
function M.lazygit()
LazyVim.deprecate("LazyVim.lazygit", "Snacks.lazygit")
return Snacks.lazygit
end
function M.toggle()
LazyVim.deprecate("LazyVim.toggle", "Snacks.toggle")
return {
map = function() end,
wrap = function()
return {}
end,
}
end
return M

View file

@ -177,4 +177,20 @@ function M.setup()
end, { desc = "Show info about the formatters for the current buffer" }) end, { desc = "Show info about the formatters for the current buffer" })
end end
---@param buf? boolean
function M.snacks_toggle(buf)
return Snacks.toggle({
name = "Auto Format (" .. (buf and "Buffer" or "Global") .. ")",
get = function()
if not buf then
return vim.g.autoformat == nil or vim.g.autoformat
end
return LazyVim.format.enabled()
end,
set = function(state)
LazyVim.format.enable(state, buf)
end,
})
end
return M return M

View file

@ -6,8 +6,6 @@ local LazyUtil = require("lazy.core.util")
---@field lsp lazyvim.util.lsp ---@field lsp lazyvim.util.lsp
---@field root lazyvim.util.root ---@field root lazyvim.util.root
---@field terminal lazyvim.util.terminal ---@field terminal lazyvim.util.terminal
---@field lazygit lazyvim.util.lazygit
---@field toggle lazyvim.util.toggle
---@field format lazyvim.util.format ---@field format lazyvim.util.format
---@field plugin lazyvim.util.plugin ---@field plugin lazyvim.util.plugin
---@field extras lazyvim.util.extras ---@field extras lazyvim.util.extras
@ -20,36 +18,17 @@ local LazyUtil = require("lazy.core.util")
---@field cmp lazyvim.util.cmp ---@field cmp lazyvim.util.cmp
local M = {} local M = {}
---@type table<string, string|string[]>
local deprecated = {
get_clients = "lsp",
on_attach = "lsp",
on_rename = "lsp",
root_patterns = { "root", "patterns" },
get_root = { "root", "get" },
float_term = { "terminal", "open" },
toggle_diagnostics = { "toggle", "diagnostics" },
toggle_number = { "toggle", "number" },
fg = "ui",
telescope = "pick",
}
setmetatable(M, { setmetatable(M, {
__index = function(t, k) __index = function(t, k)
if LazyUtil[k] then if LazyUtil[k] then
return LazyUtil[k] return LazyUtil[k]
end end
local dep = deprecated[k] if k == "lazygit" or k == "toggle" then -- HACK: special case for lazygit
if dep then return M.deprecated[k]()
local mod = type(dep) == "table" and dep[1] or dep
local key = type(dep) == "table" and dep[2] or k
M.deprecate([[LazyVim.]] .. k, [[LazyVim.]] .. mod .. "." .. key)
---@diagnostic disable-next-line: no-unknown
t[mod] = require("lazyvim.util." .. mod) -- load here to prevent loops
return t[mod][key]
end end
---@diagnostic disable-next-line: no-unknown ---@diagnostic disable-next-line: no-unknown
t[k] = require("lazyvim.util." .. k) t[k] = require("lazyvim.util." .. k)
M.deprecated.decorate(k, t[k])
return t[k] return t[k]
end, end,
}) })

View file

@ -1,231 +0,0 @@
---@class lazyvim.util.lazygit
---@field config_dir? string
---@overload fun(cmd: string|string[], opts: LazyTermOpts): LazyFloat
local M = setmetatable({}, {
__call = function(m, ...)
return m.open(...)
end,
})
---@alias LazyGitColor {fg?:string, bg?:string, bold?:boolean}
---@class LazyGitTheme: table<number, LazyGitColor>
---@field activeBorderColor LazyGitColor
---@field cherryPickedCommitBgColor LazyGitColor
---@field cherryPickedCommitFgColor LazyGitColor
---@field defaultFgColor LazyGitColor
---@field inactiveBorderColor LazyGitColor
---@field optionsTextColor LazyGitColor
---@field searchingActiveBorderColor LazyGitColor
---@field selectedLineBgColor LazyGitColor
---@field unstagedChangesColor LazyGitColor
M.theme = {
[241] = { fg = "Special" },
activeBorderColor = { fg = "MatchParen", bold = true },
cherryPickedCommitBgColor = { fg = "Identifier" },
cherryPickedCommitFgColor = { fg = "Function" },
defaultFgColor = { fg = "Normal" },
inactiveBorderColor = { fg = "FloatBorder" },
optionsTextColor = { fg = "Function" },
searchingActiveBorderColor = { fg = "MatchParen", bold = true },
selectedLineBgColor = { bg = "Visual" }, -- set to `default` to have no background colour
unstagedChangesColor = { fg = "DiagnosticError" },
}
M.theme_path = LazyVim.norm(vim.fn.stdpath("cache") .. "/lazygit-theme.yml")
-- re-create config file on startup
M.dirty = true
-- re-create theme file on ColorScheme change
vim.api.nvim_create_autocmd("ColorScheme", {
callback = function()
M.dirty = true
end,
})
-- Opens lazygit
---@param opts? LazyTermOpts | {args?: string[]}
function M.open(opts)
if vim.g.lazygit_theme ~= nil then
LazyVim.deprecate("vim.g.lazygit_theme", "vim.g.lazygit_config")
end
opts = vim.tbl_deep_extend("force", {}, {
esc_esc = false,
ctrl_hjkl = false,
}, opts or {})
local cmd = { "lazygit" }
vim.list_extend(cmd, opts.args or {})
if vim.g.lazygit_config then
if M.dirty then
M.update_config()
end
if not M.config_dir then
local Process = require("lazy.manage.process")
local ok, lines = pcall(Process.exec, { "lazygit", "-cd" })
if ok then
M.config_dir = lines[1]
vim.env.LG_CONFIG_FILE = LazyVim.norm(M.config_dir .. "/config.yml" .. "," .. M.theme_path)
local custom_config = LazyVim.norm(M.config_dir .. "/custom.yml")
if vim.uv.fs_stat(custom_config) and vim.uv.fs_stat(custom_config).type == "file" then
vim.env.LG_CONFIG_FILE = vim.env.LG_CONFIG_FILE .. "," .. custom_config
end
else
---@diagnostic disable-next-line: cast-type-mismatch
---@cast lines string
LazyVim.error(
{ "Failed to get **lazygit** config directory.", "Will not apply **lazygit** config.", "", "# Error:", lines },
{ title = "lazygit" }
)
end
end
end
return LazyVim.terminal(cmd, opts)
end
function M.set_ansi_color(idx, color)
io.write(("\27]4;%d;%s\7"):format(idx, color))
end
---@param v LazyGitColor
---@return string[]
function M.get_color(v)
---@type string[]
local color = {}
if v.fg then
color[1] = LazyVim.ui.color(v.fg)
elseif v.bg then
color[1] = LazyVim.ui.color(v.bg, true)
end
if v.bold then
table.insert(color, "bold")
end
return color
end
function M.update_config()
---@type table<string, string[]>
local theme = {}
for k, v in pairs(M.theme) do
if type(k) == "number" then
local color = M.get_color(v)
-- LazyGit uses color 241 a lot, so also set it to a nice color
-- pcall, since some terminals don't like this
pcall(M.set_ansi_color, k, color[1])
else
theme[k] = M.get_color(v)
end
end
local config = [[
os:
editPreset: "nvim-remote"
gui:
nerdFontsVersion: 3
theme:
]]
---@type string[]
local lines = {}
for k, v in pairs(theme) do
lines[#lines + 1] = (" %s:"):format(k)
for _, c in ipairs(v) do
lines[#lines + 1] = (" - %q"):format(c)
end
end
config = config .. table.concat(lines, "\n")
require("lazy.util").write_file(M.theme_path, config)
M.dirty = false
end
---@param opts? {count?: number}|LazyCmdOptions
function M.blame_line(opts)
opts = vim.tbl_deep_extend("force", {
count = 3,
filetype = "git",
size = {
width = 0.6,
height = 0.6,
},
border = "rounded",
}, opts or {})
local cursor = vim.api.nvim_win_get_cursor(0)
local line = cursor[1]
local file = vim.api.nvim_buf_get_name(0)
local root = LazyVim.root.detectors.pattern(0, { ".git" })[1] or "."
local cmd = { "git", "-C", root, "log", "-n", opts.count, "-u", "-L", line .. ",+1:" .. file }
return require("lazy.util").float_cmd(cmd, opts)
end
-- stylua: ignore
M.remote_patterns = {
{ "^(https?://.*)%.git$" , "%1" },
{ "^git@(.+):(.+)%.git$" , "https://%1/%2" },
{ "^git@(.+):(.+)$" , "https://%1/%2" },
{ "^git@(.+)/(.+)$" , "https://%1/%2" },
{ "^ssh://git@(.*)$" , "https://%1" },
{ "ssh%.dev%.azure%.com/v3/(.*)/(.*)$", "dev.azure.com/%1/_git/%2" },
{ "^https://%w*@(.*)" , "https://%1" },
{ "^git@(.*)" , "https://%1" },
{ ":%d+" , "" },
{ "%.git$" , "" },
}
---@param remote string
function M.get_url(remote)
local ret = remote
for _, pattern in ipairs(M.remote_patterns) do
ret = ret:gsub(pattern[1], pattern[2])
end
return ret:find("https://") == 1 and ret or ("https://%s"):format(ret)
end
function M.browse()
local lines = require("lazy.manage.process").exec({ "git", "remote", "-v" })
local remotes = {} ---@type {name:string, url:string}[]
for _, line in ipairs(lines) do
local name, remote = line:match("(%S+)%s+(%S+)%s+%(fetch%)")
if name and remote then
local url = M.get_url(remote)
if url then
table.insert(remotes, {
name = name,
url = url,
})
end
end
end
local function open(remote)
if remote then
LazyVim.info(("Opening [%s](%s)"):format(remote.name, remote.url))
if vim.fn.has("nvim-0.10") == 0 then
require("lazy.util").open(remote.url, { system = true })
return
end
vim.ui.open(remote.url)
end
end
if #remotes == 0 then
return LazyVim.error("No git remotes found")
elseif #remotes == 1 then
return open(remotes[1])
end
vim.ui.select(remotes, {
prompt = "Select remote to browse",
format_item = function(item)
return item.name .. (" "):rep(8 - #item.name) .. " 🔗 " .. item.url
end,
}, open)
end
return M

View file

@ -118,69 +118,21 @@ function M.on_supports_method(method, fn)
}) })
end end
function M.rename_file()
local buf = vim.api.nvim_get_current_buf()
local old = assert(LazyVim.root.realpath(vim.api.nvim_buf_get_name(buf)))
local root = assert(LazyVim.root.realpath(LazyVim.root.get({ normalize = true })))
assert(old:find(root, 1, true) == 1, "File not in project root")
local extra = old:sub(#root + 2)
vim.ui.input({
prompt = "New File Name: ",
default = extra,
completion = "file",
}, function(new)
if not new or new == "" or new == extra then
return
end
new = LazyVim.norm(root .. "/" .. new)
vim.fn.mkdir(vim.fs.dirname(new), "p")
M.on_rename(old, new, function()
vim.fn.rename(old, new)
vim.cmd.edit(new)
vim.api.nvim_buf_delete(buf, { force = true })
vim.fn.delete(old)
end)
end)
end
---@param from string
---@param to string
---@param rename? fun()
function M.on_rename(from, to, rename)
local changes = { files = { {
oldUri = vim.uri_from_fname(from),
newUri = vim.uri_from_fname(to),
} } }
local clients = M.get_clients()
for _, client in ipairs(clients) do
if client.supports_method("workspace/willRenameFiles") then
local resp = client.request_sync("workspace/willRenameFiles", changes, 1000, 0)
if resp and resp.result ~= nil then
vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding)
end
end
end
if rename then
rename()
end
for _, client in ipairs(clients) do
if client.supports_method("workspace/didRenameFiles") then
client.notify("workspace/didRenameFiles", changes)
end
end
end
---@return _.lspconfig.options ---@return _.lspconfig.options
function M.get_config(server) function M.get_config(server)
local configs = require("lspconfig.configs") local configs = require("lspconfig.configs")
return rawget(configs, server) return rawget(configs, server)
end end
---@return {default_config:lspconfig.Config}
function M.get_raw_config(server)
local ok, ret = pcall(require, "lspconfig.configs." .. server)
if ok then
return ret
end
return require("lspconfig.server_configurations." .. server)
end
function M.is_enabled(server) function M.is_enabled(server)
local c = M.get_config(server) local c = M.get_config(server)
return c and c.enabled ~= false return c and c.enabled ~= false
@ -251,82 +203,6 @@ function M.format(opts)
end end
end end
---@alias LspWord {from:{[1]:number, [2]:number}, to:{[1]:number, [2]:number}} 1-0 indexed
M.words = {}
M.words.enabled = false
M.words.ns = vim.api.nvim_create_namespace("vim_lsp_references")
---@param opts? {enabled?: boolean}
function M.words.setup(opts)
opts = opts or {}
if not opts.enabled then
return
end
M.words.enabled = true
local handler = vim.lsp.handlers["textDocument/documentHighlight"]
vim.lsp.handlers["textDocument/documentHighlight"] = function(err, result, ctx, config)
if not vim.api.nvim_buf_is_loaded(ctx.bufnr) then
return
end
vim.lsp.buf.clear_references()
return handler(err, result, ctx, config)
end
M.on_supports_method("textDocument/documentHighlight", function(_, buf)
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI", "CursorMoved", "CursorMovedI" }, {
group = vim.api.nvim_create_augroup("lsp_word_" .. buf, { clear = true }),
buffer = buf,
callback = function(ev)
if not require("lazyvim.plugins.lsp.keymaps").has(buf, "documentHighlight") then
return false
end
if not ({ M.words.get() })[2] then
if ev.event:find("CursorMoved") then
vim.lsp.buf.clear_references()
elseif not LazyVim.cmp.visible() then
vim.lsp.buf.document_highlight()
end
end
end,
})
end)
end
---@return LspWord[] words, number? current
function M.words.get()
local cursor = vim.api.nvim_win_get_cursor(0)
local current, ret = nil, {} ---@type number?, LspWord[]
for _, extmark in ipairs(vim.api.nvim_buf_get_extmarks(0, M.words.ns, 0, -1, { details = true })) do
local w = {
from = { extmark[2] + 1, extmark[3] },
to = { extmark[4].end_row + 1, extmark[4].end_col },
}
ret[#ret + 1] = w
if cursor[1] >= w.from[1] and cursor[1] <= w.to[1] and cursor[2] >= w.from[2] and cursor[2] <= w.to[2] then
current = #ret
end
end
return ret, current
end
---@param count number
---@param cycle? boolean
function M.words.jump(count, cycle)
local words, idx = M.words.get()
if not idx then
return
end
idx = idx + count
if cycle then
idx = (idx - 1) % #words + 1
end
local target = words[idx]
if target then
vim.api.nvim_win_set_cursor(0, target.from)
end
end
M.action = setmetatable({}, { M.action = setmetatable({}, {
__index = function(_, action) __index = function(_, action)
return function() return function()

View file

@ -96,7 +96,7 @@ function M.pretty_path(opts)
if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then
path = path:sub(#cwd + 2) path = path:sub(#cwd + 2)
else elseif path:find(root, 1, true) == 1 then
path = path:sub(#root + 2) path = path:sub(#root + 2)
end end
@ -106,7 +106,7 @@ function M.pretty_path(opts)
if opts.length == 0 then if opts.length == 0 then
parts = parts parts = parts
elseif #parts > opts.length then elseif #parts > opts.length then
parts = { parts[1], "", table.concat({ unpack(parts, #parts - opts.length + 2, #parts) }, sep) } parts = { parts[1], "", unpack(parts, #parts - opts.length + 2, #parts) }
end end
if opts.modified_hl and vim.bo.modified then if opts.modified_hl and vim.bo.modified then

View file

@ -121,7 +121,7 @@ end
---@param opts {skip_next: string, skip_ts: string[], skip_unbalanced: boolean, markdown: boolean} ---@param opts {skip_next: string, skip_ts: string[], skip_unbalanced: boolean, markdown: boolean}
function M.pairs(opts) function M.pairs(opts)
LazyVim.toggle.map("<leader>up", { Snacks.toggle({
name = "Mini Pairs", name = "Mini Pairs",
get = function() get = function()
return not vim.g.minipairs_disable return not vim.g.minipairs_disable
@ -129,7 +129,8 @@ function M.pairs(opts)
set = function(state) set = function(state)
vim.g.minipairs_disable = not state vim.g.minipairs_disable = not state
end, end,
}) }):map("<leader>up")
local pairs = require("mini.pairs") local pairs = require("mini.pairs")
pairs.setup(opts) pairs.setup(opts)
local open = pairs.open local open = pairs.open

View file

@ -72,15 +72,23 @@ function M.open(file, opts)
end end
end end
local float = require("lazy.util").float({ Snacks.config.style("news", {
file = file, width = 0.6,
size = { width = 0.6, height = 0.6 }, height = 0.6,
wo = {
spell = false,
wrap = false,
signcolumn = "yes",
statuscolumn = " ",
conceallevel = 3,
},
}) })
vim.opt_local.spell = false
vim.opt_local.wrap = false local float = Snacks.win({
vim.opt_local.signcolumn = "yes" file = file,
vim.opt_local.statuscolumn = " " style = "news",
vim.opt_local.conceallevel = 3 })
if vim.diagnostic.enable then if vim.diagnostic.enable then
pcall(vim.diagnostic.enable, false, { bufnr = float.buf }) pcall(vim.diagnostic.enable, false, { bufnr = float.buf })
else else

View file

@ -71,31 +71,6 @@ function M.extra_idx(name)
end end
function M.lazy_file() function M.lazy_file()
-- This autocmd will only trigger when a file was loaded from the cmdline.
-- It will render the file as quickly as possible.
vim.api.nvim_create_autocmd("BufReadPost", {
once = true,
callback = function(event)
-- Skip if we already entered vim
if vim.v.vim_did_enter == 1 then
return
end
-- Try to guess the filetype (may change later on during Neovim startup)
local ft = vim.filetype.match({ buf = event.buf })
if ft then
-- Add treesitter highlights and fallback to syntax
local lang = vim.treesitter.language.get_lang(ft)
if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then
vim.bo[event.buf].syntax = ft
end
-- Trigger early redraw
vim.cmd([[redraw]])
end
end,
})
-- Add support for the LazyFile event -- Add support for the LazyFile event
local Event = require("lazy.core.handler.event") local Event = require("lazy.core.handler.event")

View file

@ -29,7 +29,11 @@ function M.detectors.lsp(buf)
return {} return {}
end end
local roots = {} ---@type string[] local roots = {} ---@type string[]
for _, client in pairs(LazyVim.lsp.get_clients({ bufnr = buf })) do local clients = LazyVim.lsp.get_clients({ bufnr = buf })
clients = vim.tbl_filter(function(client)
return not vim.tbl_contains(vim.g.root_lsp_ignore or {}, client.name)
end, clients)
for _, client in pairs(clients) do
local workspace = client.config.workspace_folders local workspace = client.config.workspace_folders
for _, ws in pairs(workspace or {}) do for _, ws in pairs(workspace or {}) do
roots[#roots + 1] = vim.uri_to_fname(ws.uri) roots[#roots + 1] = vim.uri_to_fname(ws.uri)

View file

@ -1,13 +1,5 @@
---@class lazyvim.util.terminal ---@class lazyvim.util.terminal
---@overload fun(cmd: string|string[], opts: LazyTermOpts): LazyFloat local M = {}
local M = setmetatable({}, {
__call = function(m, ...)
return m.open(...)
end,
})
---@type table<string,LazyFloat>
local terminals = {}
---@param shell? string ---@param shell? string
function M.setup(shell) function M.setup(shell)
@ -40,58 +32,4 @@ function M.setup(shell)
end end
end end
---@class LazyTermOpts: LazyCmdOptions
---@field interactive? boolean
---@field esc_esc? boolean
---@field ctrl_hjkl? boolean
-- Opens a floating terminal (interactive by default)
---@param cmd? string[]|string
---@param opts? LazyTermOpts
function M.open(cmd, opts)
opts = vim.tbl_deep_extend("force", {
ft = "lazyterm",
size = { width = 0.9, height = 0.9 },
backdrop = LazyVim.has("edgy.nvim") and not cmd and 100 or nil,
}, opts or {}, { persistent = true }) --[[@as LazyTermOpts]]
local termkey = vim.inspect({ cmd = cmd or "shell", cwd = opts.cwd, env = opts.env, count = vim.v.count1 })
if terminals[termkey] and terminals[termkey]:buf_valid() then
terminals[termkey]:toggle()
else
terminals[termkey] = require("lazy.util").float_term(cmd, opts)
local buf = terminals[termkey].buf
vim.b[buf].lazyterm_cmd = cmd
if opts.esc_esc == false then
vim.keymap.set("t", "<esc>", "<esc>", { buffer = buf, nowait = true })
end
if opts.ctrl_hjkl == false then
vim.keymap.set("t", "<c-h>", "<c-h>", { buffer = buf, nowait = true })
vim.keymap.set("t", "<c-j>", "<c-j>", { buffer = buf, nowait = true })
vim.keymap.set("t", "<c-k>", "<c-k>", { buffer = buf, nowait = true })
vim.keymap.set("t", "<c-l>", "<c-l>", { buffer = buf, nowait = true })
end
vim.keymap.set("n", "gf", function()
local f = vim.fn.findfile(vim.fn.expand("<cfile>"))
if f ~= "" then
vim.cmd("close")
vim.cmd("e " .. f)
end
end, { buffer = buf })
vim.api.nvim_create_autocmd("BufEnter", {
buffer = buf,
callback = function()
vim.cmd.startinsert()
end,
})
vim.cmd("noh")
end
return terminals[termkey]
end
return M return M

View file

@ -1,206 +0,0 @@
---@class lazyvim.util.toggle
local M = {}
---@class lazyvim.Toggle
---@field name string
---@field get fun():boolean
---@field set fun(state:boolean)
---@class lazyvim.Toggle.wrap: lazyvim.Toggle
---@operator call:boolean
---@param toggle lazyvim.Toggle
function M.wrap(toggle)
return setmetatable(toggle, {
__call = function()
toggle.set(not toggle.get())
local state = toggle.get()
if state then
LazyVim.info("Enabled " .. toggle.name, { title = toggle.name })
else
LazyVim.warn("Disabled " .. toggle.name, { title = toggle.name })
end
return state
end,
}) --[[@as lazyvim.Toggle.wrap]]
end
---@param lhs string
---@param toggle lazyvim.Toggle
function M.map(lhs, toggle)
local t = M.wrap(toggle)
LazyVim.safe_keymap_set("n", lhs, function()
t()
end, { desc = "Toggle " .. toggle.name })
M.wk(lhs, toggle)
end
function M.wk(lhs, toggle)
if not LazyVim.has("which-key.nvim") then
return
end
local function safe_get()
local ok, enabled = pcall(toggle.get)
if not ok then
LazyVim.error({ "Failed to get toggle state for **" .. toggle.name .. "**:\n", enabled }, { once = true })
end
return enabled
end
require("which-key").add({
{
lhs,
icon = function()
return safe_get() and { icon = "", color = "green" } or { icon = "", color = "yellow" }
end,
desc = function()
return (safe_get() and "Disable " or "Enable ") .. toggle.name
end,
},
})
end
M.treesitter = M.wrap({
name = "Treesitter Highlight",
get = function()
return vim.b.ts_highlight
end,
set = function(state)
if state then
vim.treesitter.start()
else
vim.treesitter.stop()
end
end,
})
---@param buf? boolean
function M.format(buf)
return M.wrap({
name = "Auto Format (" .. (buf and "Buffer" or "Global") .. ")",
get = function()
if not buf then
return vim.g.autoformat == nil or vim.g.autoformat
end
return LazyVim.format.enabled()
end,
set = function(state)
LazyVim.format.enable(state, buf)
end,
})
end
---@param opts? {values?: {[1]:any, [2]:any}, name?: string}
function M.option(option, opts)
opts = opts or {}
local name = opts.name or option
local on = opts.values and opts.values[2] or true
local off = opts.values and opts.values[1] or false
return M.wrap({
name = name,
get = function()
return vim.opt_local[option]:get() == on
end,
set = function(state)
vim.opt_local[option] = state and on or off
end,
})
end
local nu = { number = true, relativenumber = true }
M.number = M.wrap({
name = "Line Numbers",
get = function()
return vim.opt_local.number:get() or vim.opt_local.relativenumber:get()
end,
set = function(state)
if state then
vim.opt_local.number = nu.number
vim.opt_local.relativenumber = nu.relativenumber
else
nu = { number = vim.opt_local.number:get(), relativenumber = vim.opt_local.relativenumber:get() }
vim.opt_local.number = false
vim.opt_local.relativenumber = false
end
end,
})
M.diagnostics = M.wrap({
name = "Diagnostics",
get = function()
local enabled = false
if vim.diagnostic.is_enabled then
enabled = vim.diagnostic.is_enabled()
elseif vim.diagnostic.is_disabled then
enabled = not vim.diagnostic.is_disabled()
end
return enabled
end,
set = function(state)
if vim.fn.has("nvim-0.10") == 0 then
if state then
pcall(vim.diagnostic.enable)
else
pcall(vim.diagnostic.disable)
end
else
vim.diagnostic.enable(state)
end
end,
})
M.inlay_hints = M.wrap({
name = "Inlay Hints",
get = function()
return vim.lsp.inlay_hint.is_enabled({ bufnr = 0 })
end,
set = function(state)
vim.lsp.inlay_hint.enable(state, { bufnr = 0 })
end,
})
---@type {k:string, v:any}[]
M._maximized = nil
M.maximize = M.wrap({
name = "Maximize",
get = function()
return M._maximized ~= nil
end,
set = function(state)
if state then
M._maximized = {}
local function set(k, v)
table.insert(M._maximized, 1, { k = k, v = vim.o[k] })
vim.o[k] = v
end
set("winwidth", 999)
set("winheight", 999)
set("winminwidth", 10)
set("winminheight", 4)
vim.cmd("wincmd =")
-- `QuitPre` seems to be executed even if we quit a normal window, so we don't want that
-- `VimLeavePre` might be another consideration? Not sure about differences between the 2
vim.api.nvim_create_autocmd("ExitPre", {
once = true,
group = vim.api.nvim_create_augroup("lazyvim_restore_max_exit_pre", { clear = true }),
desc = "Restore width/height when close Neovim while maximized",
callback = function()
M.maximize.set(false)
end,
})
else
for _, opt in ipairs(M._maximized) do
vim.o[opt.k] = opt.v
end
M._maximized = nil
vim.cmd("wincmd =")
end
end,
})
setmetatable(M, {
__call = function(m, ...)
return m.option(...)
end,
})
return M

View file

@ -1,77 +1,6 @@
---@class lazyvim.util.ui ---@class lazyvim.util.ui
local M = {} local M = {}
---@alias Sign {name:string, text:string, texthl:string, priority:number}
-- Returns a list of regular and extmark signs sorted by priority (low to high)
---@return Sign[]
---@param buf number
---@param lnum number
function M.get_signs(buf, lnum)
-- Get regular signs
---@type Sign[]
local signs = {}
if vim.fn.has("nvim-0.10") == 0 then
-- Only needed for Neovim <0.10
-- Newer versions include legacy signs in nvim_buf_get_extmarks
for _, sign in ipairs(vim.fn.sign_getplaced(buf, { group = "*", lnum = lnum })[1].signs) do
local ret = vim.fn.sign_getdefined(sign.name)[1] --[[@as Sign]]
if ret then
ret.priority = sign.priority
signs[#signs + 1] = ret
end
end
end
-- Get extmark signs
local extmarks = vim.api.nvim_buf_get_extmarks(
buf,
-1,
{ lnum - 1, 0 },
{ lnum - 1, -1 },
{ details = true, type = "sign" }
)
for _, extmark in pairs(extmarks) do
signs[#signs + 1] = {
name = extmark[4].sign_hl_group or extmark[4].sign_name or "",
text = extmark[4].sign_text,
texthl = extmark[4].sign_hl_group,
priority = extmark[4].priority,
}
end
-- Sort by priority
table.sort(signs, function(a, b)
return (a.priority or 0) < (b.priority or 0)
end)
return signs
end
---@return Sign?
---@param buf number
---@param lnum number
function M.get_mark(buf, lnum)
local marks = vim.fn.getmarklist(buf)
vim.list_extend(marks, vim.fn.getmarklist())
for _, mark in ipairs(marks) do
if mark.pos[1] == buf and mark.pos[2] == lnum and mark.mark:match("[a-zA-Z]") then
return { text = mark.mark:sub(2), texthl = "DiagnosticHint" }
end
end
end
---@param sign? Sign
---@param len? number
function M.icon(sign, len)
sign = sign or {}
len = len or 2
local text = vim.fn.strcharpart(sign.text or "", 0, len) ---@type string
text = text .. string.rep(" ", len - vim.fn.strchars(text))
return sign.texthl and ("%#" .. sign.texthl .. "#" .. text .. "%*") or text
end
function M.foldtext() function M.foldtext()
local ok = pcall(vim.treesitter.get_parser, vim.api.nvim_get_current_buf()) local ok = pcall(vim.treesitter.get_parser, vim.api.nvim_get_current_buf())
local ret = ok and vim.treesitter.foldtext and vim.treesitter.foldtext() local ret = ok and vim.treesitter.foldtext and vim.treesitter.foldtext()
@ -91,74 +20,6 @@ function M.foldtext()
return ret return ret
end end
function M.statuscolumn()
local win = vim.g.statusline_winid
local buf = vim.api.nvim_win_get_buf(win)
local is_file = vim.bo[buf].buftype == ""
local show_signs = vim.wo[win].signcolumn ~= "no"
local components = { "", "", "" } -- left, middle, right
local show_open_folds = vim.g.lazyvim_statuscolumn and vim.g.lazyvim_statuscolumn.folds_open
local use_githl = vim.g.lazyvim_statuscolumn and vim.g.lazyvim_statuscolumn.folds_githl
if show_signs then
local signs = M.get_signs(buf, vim.v.lnum)
---@type Sign?,Sign?,Sign?
local left, right, fold, githl
for _, s in ipairs(signs) do
if s.name and (s.name:find("GitSign") or s.name:find("MiniDiffSign")) then
right = s
if use_githl then
githl = s["texthl"]
end
else
left = s
end
end
vim.api.nvim_win_call(win, function()
if vim.fn.foldclosed(vim.v.lnum) >= 0 then
fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = githl or "Folded" }
elseif
show_open_folds
and not LazyVim.ui.skip_foldexpr[buf]
and tostring(vim.treesitter.foldexpr(vim.v.lnum)):sub(1, 1) == ">"
then -- fold start
fold = { text = vim.opt.fillchars:get().foldopen or "", texthl = githl }
end
end)
-- Left: mark or non-git sign
components[1] = M.icon(M.get_mark(buf, vim.v.lnum) or left)
-- Right: fold icon or git sign (only if file)
components[3] = is_file and M.icon(fold or right) or ""
end
-- Numbers in Neovim are weird
-- They show when either number or relativenumber is true
local is_num = vim.wo[win].number
local is_relnum = vim.wo[win].relativenumber
if (is_num or is_relnum) and vim.v.virtnum == 0 then
if vim.fn.has("nvim-0.11") == 1 then
components[2] = "%l" -- 0.11 handles both the current and other lines with %l
else
if vim.v.relnum == 0 then
components[2] = is_num and "%l" or "%r" -- the current line
else
components[2] = is_relnum and "%r" or "%l" -- other lines
end
end
components[2] = "%=" .. components[2] .. " " -- right align
end
if vim.v.virtnum ~= 0 then
components[2] = "%= "
end
return table.concat(components, "")
end
---@return {fg?:string}? ---@return {fg?:string}?
function M.fg(name) function M.fg(name)
local color = M.color(name) local color = M.color(name)
@ -197,8 +58,8 @@ function M.foldexpr()
return "0" return "0"
end end
-- don't use treesitter folds for non-file buffers -- don't use treesitter folds for terminal
if vim.bo[buf].buftype ~= "" then if vim.bo[buf].buftype == "terminal" then
return "0" return "0"
end end
@ -224,47 +85,45 @@ function M.foldexpr()
return "0" return "0"
end end
---@param buf number? function M.maximize()
function M.bufremove(buf) ---@type {k:string, v:any}[]?
buf = buf or 0 local maximized = nil
buf = buf == 0 and vim.api.nvim_get_current_buf() or buf return Snacks.toggle({
name = "Maximize",
if vim.bo.modified then get = function()
local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel") return maximized ~= nil
if choice == 0 or choice == 3 then -- 0 for <Esc>/<C-c> and 3 for Cancel end,
return set = function(state)
if state then
maximized = {}
local function set(k, v)
table.insert(maximized, 1, { k = k, v = vim.o[k] })
vim.o[k] = v
end end
if choice == 1 then -- Yes set("winwidth", 999)
vim.cmd.write() set("winheight", 999)
set("winminwidth", 10)
set("winminheight", 4)
vim.cmd("wincmd =")
-- `QuitPre` seems to be executed even if we quit a normal window, so we don't want that
-- `VimLeavePre` might be another consideration? Not sure about differences between the 2
vim.api.nvim_create_autocmd("ExitPre", {
once = true,
group = vim.api.nvim_create_augroup("lazyvim_restore_max_exit_pre", { clear = true }),
desc = "Restore width/height when close Neovim while maximized",
callback = function()
M.maximize.set(false)
end,
})
else
for _, opt in ipairs(maximized) do
vim.o[opt.k] = opt.v
end end
maximized = nil
vim.cmd("wincmd =")
end end
end,
for _, win in ipairs(vim.fn.win_findbuf(buf)) do })
vim.api.nvim_win_call(win, function()
if not vim.api.nvim_win_is_valid(win) or vim.api.nvim_win_get_buf(win) ~= buf then
return
end
-- Try using alternate buffer
local alt = vim.fn.bufnr("#")
if alt ~= buf and vim.fn.buflisted(alt) == 1 then
vim.api.nvim_win_set_buf(win, alt)
return
end
-- Try using previous buffer
local has_previous = pcall(vim.cmd, "bprevious")
if has_previous and buf ~= vim.api.nvim_win_get_buf(win) then
return
end
-- Create new listed buffer
local new_buf = vim.api.nvim_create_buf(true, false)
vim.api.nvim_win_set_buf(win, new_buf)
end)
end
if vim.api.nvim_buf_is_valid(buf) then
pcall(vim.cmd, "bdelete! " .. buf)
end
end end
return M return M

View file

@ -1,42 +0,0 @@
---@module "luassert"
_G.LazyVim = require("lazyvim.util")
-- stylua: ignore
local git_remotes_cases = {
["https://github.com/LazyVim/LazyVim.git"] = "https://github.com/LazyVim/LazyVim",
["https://github.com/LazyVim/LazyVim"] = "https://github.com/LazyVim/LazyVim",
["git@github.com:LazyVim/LazyVim"] = "https://github.com/LazyVim/LazyVim",
["git@ssh.dev.azure.com:v3/neovim-org/owner/repo"] = "https://dev.azure.com/neovim-org/owner/_git/repo",
["https://folkelemaitre@bitbucket.org/samiulazim/neovim.git"] = "https://bitbucket.org/samiulazim/neovim",
["git@bitbucket.org:samiulazim/neovim.git"] = "https://bitbucket.org/samiulazim/neovim",
["git@gitlab.com:inkscape/inkscape.git"] = "https://gitlab.com/inkscape/inkscape",
["https://gitlab.com/inkscape/inkscape.git"] = "https://gitlab.com/inkscape/inkscape",
["git@github.com:torvalds/linux.git"] = "https://github.com/torvalds/linux",
["https://github.com/torvalds/linux.git"] = "https://github.com/torvalds/linux",
["git@bitbucket.org:team/repo.git"] = "https://bitbucket.org/team/repo",
["https://bitbucket.org/team/repo.git"] = "https://bitbucket.org/team/repo",
["git@gitlab.com:example-group/example-project.git"] = "https://gitlab.com/example-group/example-project",
["https://gitlab.com/example-group/example-project.git"] = "https://gitlab.com/example-group/example-project",
["git@ssh.dev.azure.com:v3/org/project/repo"] = "https://dev.azure.com/org/project/_git/repo",
["https://username@dev.azure.com/org/project/_git/repo"] = "https://dev.azure.com/org/project/_git/repo",
["ssh://git@ghe.example.com:2222/org/repo.git"] = "https://ghe.example.com/org/repo",
["https://ghe.example.com/org/repo.git"] = "https://ghe.example.com/org/repo",
["git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo"] = "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo",
["https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo"] = "https://git-codecommit.us-east-1.amazonaws.com/v1/repos/MyDemoRepo",
["ssh://git@source.developers.google.com:2022/p/project/r/repo"] = "https://source.developers.google.com/p/project/r/repo",
["https://source.developers.google.com/p/project/r/repo"] = "https://source.developers.google.com/p/project/r/repo",
["git@git.sr.ht:~user/repo"] = "https://git.sr.ht/~user/repo",
["https://git.sr.ht/~user/repo"] = "https://git.sr.ht/~user/repo",
["git@git.sr.ht:~user/another-repo"] = "https://git.sr.ht/~user/another-repo",
["https://git.sr.ht/~user/another-repo"] = "https://git.sr.ht/~user/another-repo",
}
describe("util.lazygit", function()
for remote, expected in pairs(git_remotes_cases) do
it("should parse git remote " .. remote, function()
local url = LazyVim.lazygit.get_url(remote)
assert.are.equal(expected, url)
end)
end
end)