Merge branch 'main' into add-nvim-metals

This commit is contained in:
Christian Kleinbölting 2023-11-03 10:44:35 +01:00
commit 753228f686
No known key found for this signature in database
GPG key ID: 5F178E68D510477C
80 changed files with 4589 additions and 1037 deletions

1
.github/ISSUE_TEMPLATE/config.yml vendored Normal file
View file

@ -0,0 +1 @@
blank_issues_enabled: false

View file

@ -36,7 +36,7 @@ jobs:
uses: kdheepak/panvimdoc@main uses: kdheepak/panvimdoc@main
with: with:
vimdoc: LazyVim vimdoc: LazyVim
version: "Neovim >= 0.8.0" version: "Neovim >= 0.9.0"
demojify: true demojify: true
treesitter: true treesitter: true
- name: Push changes - name: Push changes
@ -59,6 +59,8 @@ jobs:
with: with:
release-type: simple release-type: simple
package-name: LazyVim package-name: LazyVim
extra-files: |
lua/lazyvim/config/init.lua
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- name: tag stable versions - name: tag stable versions
if: ${{ steps.release.outputs.release_created }} if: ${{ steps.release.outputs.release_created }}

View file

@ -1,5 +1,700 @@
# Changelog # Changelog
## [10.7.1](https://github.com/LazyVim/LazyVim/compare/v10.7.0...v10.7.1) (2023-10-25)
### Bug Fixes
* **catppuccin:** trouble integration. Fixes [#1872](https://github.com/LazyVim/LazyVim/issues/1872) ([f589154](https://github.com/LazyVim/LazyVim/commit/f589154268dfcb3e8f91075791a0a618c97fe59d))
* **util:** pcall deletion of lazy_file augroup. See [#1863](https://github.com/LazyVim/LazyVim/issues/1863) ([60e5707](https://github.com/LazyVim/LazyVim/commit/60e57070131f4c544e17541610415d4d51769d62))
## [10.7.0](https://github.com/LazyVim/LazyVim/compare/v10.6.0...v10.7.0) (2023-10-25)
### Features
* **nvim:** extend j/k enhancements to up/down arrows ([#1833](https://github.com/LazyVim/LazyVim/issues/1833)) ([9e1f835](https://github.com/LazyVim/LazyVim/commit/9e1f83522396d141455de8f2d5e0b3e8beca8d0a))
### Bug Fixes
* **extras.python-semshi:** improve highlights ([#1845](https://github.com/LazyVim/LazyVim/issues/1845)) ([3795358](https://github.com/LazyVim/LazyVim/commit/37953585bb06b3ffbdb37b40bb586590fde2b2a9))
* fix jdtls not spwaning in windows ([#1864](https://github.com/LazyVim/LazyVim/issues/1864)) ([61fae7d](https://github.com/LazyVim/LazyVim/commit/61fae7d23f5689a9112b265f4bfb8468a131ae66))
* **lang:** add cmakelint to ensure installed list ([#1826](https://github.com/LazyVim/LazyVim/issues/1826)) ([58ddf40](https://github.com/LazyVim/LazyVim/commit/58ddf405e09da967eca29169571114b01172fff3))
## [10.6.0](https://github.com/LazyVim/LazyVim/compare/v10.5.0...v10.6.0) (2023-10-25)
### Features
* **telescope:** sort buffers with lastused and mru ([99598ef](https://github.com/LazyVim/LazyVim/commit/99598ef7c7c15c980b6d5c36f8e9cefd745fcf34))
### Bug Fixes
* **markdown:** create default numbered Headline groups for colorschemes that dont support them. Fixes [#1822](https://github.com/LazyVim/LazyVim/issues/1822) ([eab464d](https://github.com/LazyVim/LazyVim/commit/eab464d52d28d4e24e5d189ee627c96e720e057c))
* **mini.hipatterns:** use `extmark_opts` instead of soft deprecated `priority` ([#1841](https://github.com/LazyVim/LazyVim/issues/1841)) ([e55ab41](https://github.com/LazyVim/LazyVim/commit/e55ab411b42c75919b33b87e19714b5c595316d4))
* **treesitter:** make treesitter queries available at startup. See [#1816](https://github.com/LazyVim/LazyVim/issues/1816) Fixes [#1858](https://github.com/LazyVim/LazyVim/issues/1858) ([1e1b68d](https://github.com/LazyVim/LazyVim/commit/1e1b68d633d4bd4faa912ba5f49ab6b8601dc0c9))
### Performance Improvements
* **markdown:** prevent headlines.nvim slowing down initial rendering with `nvim README.md` ([b651560](https://github.com/LazyVim/LazyVim/commit/b651560ad0ee750c96bca6866cfdc008e75d397c))
* **ui:** wrap treesitter.foldexpr and cache get_parser during a event loop tick. Fixes [#1846](https://github.com/LazyVim/LazyVim/issues/1846) ([a5c9708](https://github.com/LazyVim/LazyVim/commit/a5c9708736f6ecd3e3413ad0ca34b7b1fa3d4862))
## [10.5.0](https://github.com/LazyVim/LazyVim/compare/v10.4.4...v10.5.0) (2023-10-19)
### Features
* **dashboard:** remove unnecessary brackets from keys ([#1791](https://github.com/LazyVim/LazyVim/issues/1791)) ([d73aee4](https://github.com/LazyVim/LazyVim/commit/d73aee4a934b0aa12e07039da9e2df0215ba2cba))
* **typescript:** added remove unused imports ([#1794](https://github.com/LazyVim/LazyVim/issues/1794)) ([8df44b3](https://github.com/LazyVim/LazyVim/commit/8df44b3bb54483e42a27dc30a8b343acc5d5d242))
### Bug Fixes
* **conform:** allow overriding all conform format options. Fixes [#1790](https://github.com/LazyVim/LazyVim/issues/1790) ([ea3155a](https://github.com/LazyVim/LazyVim/commit/ea3155aef6d47e744cb2b4a7a3b567288d780f8d))
* **nvim-ts-autotag:** make it actually work :) ([82da244](https://github.com/LazyVim/LazyVim/commit/82da2440e4c9d7e604cf998aee0655f78ddfdd5c))
* **tabnine:** run `:CmpTabnineHub` automatically on build ([#1788](https://github.com/LazyVim/LazyVim/issues/1788)) ([fad3777](https://github.com/LazyVim/LazyVim/commit/fad37772967f06c65d6f0b52c2ea6f190b3218ee))
* **treesitter-context:** set default max_lines=3 ([0ac8f6f](https://github.com/LazyVim/LazyVim/commit/0ac8f6fb3b1705c2b675a0e3cbee4968370f047a))
## [10.5.0](https://github.com/LazyVim/LazyVim/compare/v10.4.4...v10.5.0) (2023-10-19)
### Features
* **dashboard:** remove unnecessary brackets from keys ([#1791](https://github.com/LazyVim/LazyVim/issues/1791)) ([d73aee4](https://github.com/LazyVim/LazyVim/commit/d73aee4a934b0aa12e07039da9e2df0215ba2cba))
### Bug Fixes
* **conform:** allow overriding all conform format options. Fixes [#1790](https://github.com/LazyVim/LazyVim/issues/1790) ([ea3155a](https://github.com/LazyVim/LazyVim/commit/ea3155aef6d47e744cb2b4a7a3b567288d780f8d))
* **nvim-ts-autotag:** make it actually work :) ([82da244](https://github.com/LazyVim/LazyVim/commit/82da2440e4c9d7e604cf998aee0655f78ddfdd5c))
* **tabnine:** run `:CmpTabnineHub` automatically on build ([#1788](https://github.com/LazyVim/LazyVim/issues/1788)) ([fad3777](https://github.com/LazyVim/LazyVim/commit/fad37772967f06c65d6f0b52c2ea6f190b3218ee))
* **treesitter-context:** set default max_lines=3 ([0ac8f6f](https://github.com/LazyVim/LazyVim/commit/0ac8f6fb3b1705c2b675a0e3cbee4968370f047a))
## [10.4.4](https://github.com/LazyVim/LazyVim/compare/v10.4.3...v10.4.4) (2023-10-18)
### Bug Fixes
* **project:** don't let `project.nvim` change the cwd. Leads to too much confusion ([7d8b3e8](https://github.com/LazyVim/LazyVim/commit/7d8b3e8ef96f91f96c8e3a0ba62dfab270debf9f))
## [10.4.3](https://github.com/LazyVim/LazyVim/compare/v10.4.2...v10.4.3) (2023-10-17)
### Bug Fixes
* **dashboard:** config shortcut when opening dashboard again. Fixes [#1768](https://github.com/LazyVim/LazyVim/issues/1768) ([5c16567](https://github.com/LazyVim/LazyVim/commit/5c1656729aeb39fbb8dc29d4f3d6d86d0836f8b4))
* **dot:** treesitter langs in dot extra were not added ([b0ded5c](https://github.com/LazyVim/LazyVim/commit/b0ded5c015a68f07a32fab64a2cd0f27f4d69870))
* **keymaps:** let keymap n and N opens folds ([#1298](https://github.com/LazyVim/LazyVim/issues/1298)) ([1d4fbd3](https://github.com/LazyVim/LazyVim/commit/1d4fbd3b2e48eaae448073af020ca2617ab7bd5c))
* **neotest:** better integration with trouble: no longer steals focus and hides when all ok ([2e308d5](https://github.com/LazyVim/LazyVim/commit/2e308d5440c830bb37531d03a0313af3a5c94bb5))
## [10.4.2](https://github.com/LazyVim/LazyVim/compare/v10.4.1...v10.4.2) (2023-10-17)
### Bug Fixes
* **statuscolumn:** correct line numbers & respect more options ([315df37](https://github.com/LazyVim/LazyVim/commit/315df373f2d0c354b08acd607f6227b07436ce03))
## [10.4.1](https://github.com/LazyVim/LazyVim/compare/v10.4.0...v10.4.1) (2023-10-16)
### Bug Fixes
* **format:** set formatexpr in options so users can override it. Fixes [#1759](https://github.com/LazyVim/LazyVim/issues/1759) ([ff64cc5](https://github.com/LazyVim/LazyVim/commit/ff64cc53992b966a2558e95afc449e1da29dd44d))
* **ui:** fix BufferLineClose commands ([#1756](https://github.com/LazyVim/LazyVim/issues/1756)) ([fef0b3f](https://github.com/LazyVim/LazyVim/commit/fef0b3f7564e64f92df129cd86bc904afc19b976))
## [10.4.0](https://github.com/LazyVim/LazyVim/compare/v10.3.0...v10.4.0) (2023-10-16)
### Features
* **keymaps:** added toggle for treesitter highlights ([be5eea4](https://github.com/LazyVim/LazyVim/commit/be5eea476c98d46aefbbaee04b7f2bc82bb51c27))
* **lualine:** use gitsigns for diff source ([#1744](https://github.com/LazyVim/LazyVim/issues/1744)) ([8c726cd](https://github.com/LazyVim/LazyVim/commit/8c726cd16638f51308f479f26143d94a6c3013ea))
* **markdown:** added headlines.nvim to markdown extra ([152e1c6](https://github.com/LazyVim/LazyVim/commit/152e1c6692566a2e2a3968fbfc6eca69d33ba02c))
* **ui:** add keymap to close other buffers ([#1743](https://github.com/LazyVim/LazyVim/issues/1743)) ([c3daced](https://github.com/LazyVim/LazyVim/commit/c3daced11ce33875059ad5dd74832bf4a232f195))
### Bug Fixes
* **conform:** remove LazyVim's conform config changes since that's now merged in conform ([982c8e3](https://github.com/LazyVim/LazyVim/commit/982c8e301bb432f44a85d915a8268442c7db05fa))
* **markdown:** add marksman to mason install ([3dbeda9](https://github.com/LazyVim/LazyVim/commit/3dbeda9d96a2225875c4991116cb834f20588ddb))
* **root:** root dir for windows. Fixes [#1749](https://github.com/LazyVim/LazyVim/issues/1749) ([9517e64](https://github.com/LazyVim/LazyVim/commit/9517e64009a1a547f5e5b96a8fc78bf5ea0bbb6e))
### Performance Improvements
* **root:** cache root detection. Fixes [#1753](https://github.com/LazyVim/LazyVim/issues/1753) ([98db7ec](https://github.com/LazyVim/LazyVim/commit/98db7ec0d287adcd8eaf6a93c4a392f588b5615a))
## [10.3.0](https://github.com/LazyVim/LazyVim/compare/v10.2.0...v10.3.0) (2023-10-15)
### Features
* **dashboard:** `c` on dahboard now opens telescope for config dir instead of useless `init.lua` ([53e1637](https://github.com/LazyVim/LazyVim/commit/53e1637a864cb7e8f21af107b8073bc8b24acd11))
* disable kind_filter for markdown and help ([782fe0b](https://github.com/LazyVim/LazyVim/commit/782fe0bef0789c8f090284df80c00799471bc16f))
* **linting:** ability to configure global and fallback linters ([#1727](https://github.com/LazyVim/LazyVim/issues/1727)) ([6e0e352](https://github.com/LazyVim/LazyVim/commit/6e0e352fea4cd930ea7fc42a0252c2c70b279bee))
* **lualine:** new root dir component that only shows when cwd != root_dir ([dfdfcad](https://github.com/LazyVim/LazyVim/commit/dfdfcad1aab0ee39ac3876e47cbeb727eb4f1e95))
* **lualine:** pretty_path now highlights file basename when modified ([8af7309](https://github.com/LazyVim/LazyVim/commit/8af7309c7e31f55125eaade5fe86d04d63133999))
* **tabnine:** add build cmd for Windows ([#1737](https://github.com/LazyVim/LazyVim/issues/1737)) ([c8e5501](https://github.com/LazyVim/LazyVim/commit/c8e5501ee5ecd1a7b27ff3aa5f41e54c2e98ff0b))
### Bug Fixes
* **prettier:** use prettier instead of prettierd. Too many people get truncated files. Fixes [#712](https://github.com/LazyVim/LazyVim/issues/712). See [#1735](https://github.com/LazyVim/LazyVim/issues/1735) ([57b504b](https://github.com/LazyVim/LazyVim/commit/57b504b9e8ae95c294c17e97e7f017f6f802ebbc))
* **python:** add `ft` to Python keymaps, and fix "Markdown Preview" toggle description ([#1729](https://github.com/LazyVim/LazyVim/issues/1729)) ([7c60431](https://github.com/LazyVim/LazyVim/commit/7c60431c58a050cf4badced0609f3179bd284137))
* **root:** dont use single-file lsps for root detection. use workspaces only ([6f88b8b](https://github.com/LazyVim/LazyVim/commit/6f88b8b36f8d4fd0e958e59b4e37e1a9ed2acb78))
## [10.2.0](https://github.com/LazyVim/LazyVim/compare/v10.1.1...v10.2.0) (2023-10-14)
### Features
* **conform:** make it easier to add `extra_args` ([3eb91c6](https://github.com/LazyVim/LazyVim/commit/3eb91c64b5960ccd84bd8e6a3318a1ee79cb85c5))
* **conform:** show error when user overwrites conform config function ([b6e68fa](https://github.com/LazyVim/LazyVim/commit/b6e68fa2bf829753be86ba8cc56baafd47b7da67))
* **conform:** use conform.nvim `opts.format` options for formatting with conform ([6fd66f4](https://github.com/LazyVim/LazyVim/commit/6fd66f486e210e35b4c375691fbfd61a611b6027))
* **extras:** added TabNine ([#1651](https://github.com/LazyVim/LazyVim/issues/1651)) ([95ff5aa](https://github.com/LazyVim/LazyVim/commit/95ff5aaa6245244d45609916b0a623c5e8c79d16))
* **format:** use conform as lsp formatter since it has better format diffs ([4584410](https://github.com/LazyVim/LazyVim/commit/4584410e76bf8a6ba426270bef8eca5a100d4cce))
* **go:** add gofumpt formatter with conform/none-ls ([#1683](https://github.com/LazyVim/LazyVim/issues/1683)) ([385c99d](https://github.com/LazyVim/LazyVim/commit/385c99dbb7ccdcf53276086892cceee65b85fa21))
* **lang:** add markdown support ([#1718](https://github.com/LazyVim/LazyVim/issues/1718)) ([b3d46bc](https://github.com/LazyVim/LazyVim/commit/b3d46bc0141c23bfd4302718ff42dfa172c6952b))
* **python:** add key binding for organize imports ([#1670](https://github.com/LazyVim/LazyVim/issues/1670)) ([8f42733](https://github.com/LazyVim/LazyVim/commit/8f42733ce526b6c866b26824d78a1822730c2852))
* **toggle:** add keymap to toggle treesitter context ([#1711](https://github.com/LazyVim/LazyVim/issues/1711)) ([5e1a86d](https://github.com/LazyVim/LazyVim/commit/5e1a86d3b257db37c8b443deea6ca1fefcb0b1aa))
### Bug Fixes
* **dashboard-nvim:** repository has moved to nvimdev/dashboard-nvim ([#1715](https://github.com/LazyVim/LazyVim/issues/1715)) ([ff9bf00](https://github.com/LazyVim/LazyVim/commit/ff9bf005b6957bb46a5541188925f32a1d86365d))
* dont lazy-load on ft. Load on cmd or keys only ([3a93757](https://github.com/LazyVim/LazyVim/commit/3a93757bb1ee28c3e1b59c6c47ea5c4e74d8f1b2))
* **keymaps:** no diagnostic keymaps w/o lsp attached ([#1698](https://github.com/LazyVim/LazyVim/issues/1698)) ([873ff89](https://github.com/LazyVim/LazyVim/commit/873ff892843898033be0b59cee8130c6b1b29d85))
* **lsp:** trigger FileType commands after installing LSP servers ([5b89bc8](https://github.com/LazyVim/LazyVim/commit/5b89bc8cbf990edec201d07c146a3fe28db3302f))
* **news:** dont show news when it has never been viewed (new install) ([6b9ee96](https://github.com/LazyVim/LazyVim/commit/6b9ee963e2684e7b37120b86bab5049918e14899))
* **spectre:** add title to Spectre panel in edgy ([#1703](https://github.com/LazyVim/LazyVim/issues/1703)) ([7fe68d9](https://github.com/LazyVim/LazyVim/commit/7fe68d9f055fd34d95f19a8711e281ab40629482))
## [10.1.1](https://github.com/LazyVim/LazyVim/compare/v10.1.0...v10.1.1) (2023-10-13)
### Bug Fixes
* **aerial:** use new sep_icon option for aerial lualine component ([bd1928b](https://github.com/LazyVim/LazyVim/commit/bd1928ba597d777ca79f9f2f4b14217de4c291bc))
* **json:** always write version to prevent spurious migrations. Fixes [#1692](https://github.com/LazyVim/LazyVim/issues/1692) ([01dbd07](https://github.com/LazyVim/LazyVim/commit/01dbd070738a9448ffbdc63602ed9eb5421158da))
## [10.1.0](https://github.com/LazyVim/LazyVim/compare/v10.0.1...v10.1.0) (2023-10-12)
### Features
* **config:** `lazyvim.json` is now versioned and migrates to a newer version when needed ([c989265](https://github.com/LazyVim/LazyVim/commit/c9892652d271663f52edd7b0d88d2565d8f65a52))
* **extras:** LazyExtras can now manage user extras `lua/plugins/extras`. Fixes [#1681](https://github.com/LazyVim/LazyVim/issues/1681) ([1bcf6b9](https://github.com/LazyVim/LazyVim/commit/1bcf6b9a282bc839d4fde92a94b800185ad58118))
* **neot-ree:** add keymaps to toggle git & buffer ([#1339](https://github.com/LazyVim/LazyVim/issues/1339)) ([b31d71d](https://github.com/LazyVim/LazyVim/commit/b31d71da9d6ca6c290a8ee7e7cc7ad5ccb3cc0bd))
### Bug Fixes
* **nvim-lint:** check on linter name instead of linter. Fixes [#1685](https://github.com/LazyVim/LazyVim/issues/1685) ([cdae38d](https://github.com/LazyVim/LazyVim/commit/cdae38ddd44edbf5e124129fc94e9d1038592760))
* **nvim-lint:** make sure to set custom linters. Fixes [#1687](https://github.com/LazyVim/LazyVim/issues/1687) ([8e71968](https://github.com/LazyVim/LazyVim/commit/8e71968c2bd9e59e535cdac0a99e667f8f120322))
## [10.0.1](https://github.com/LazyVim/LazyVim/compare/v10.0.0...v10.0.1) (2023-10-12)
### Bug Fixes
* **config:** make lazyvim.json idempotent, pretty-printed and remove full paths ([2a0b7a8](https://github.com/LazyVim/LazyVim/commit/2a0b7a88ba4b4562361dd5abb4a071547d004e59))
* **toggle:** dont show incorrect deprecation warning for toggle. Fixes [#1679](https://github.com/LazyVim/LazyVim/issues/1679) ([7c7b4be](https://github.com/LazyVim/LazyVim/commit/7c7b4be8dbec5c5e888d02ebdaae944fecf99407))
## [10.0.0](https://github.com/LazyVim/LazyVim/compare/v9.9.1...v10.0.0) (2023-10-12)
### ⚠ BREAKING CHANGES
* **starter:** `dashboard.nvim` is now the default starter. To keep using `alpha.nvim`, enable the extra.
* make `conform.nvim` and `nvim-lint` the default formatters/linters
### Features
* added aerial extra with integrations for edgy, telescope and lualine ([b43c57d](https://github.com/LazyVim/LazyVim/commit/b43c57d943b2a13460d45f01a288e98cb54f2c1f))
* added NEWS.md and option to automatically show when changed (enabled by default) ([73acab1](https://github.com/LazyVim/LazyVim/commit/73acab16758d37982bd6b2d9b2be37c4ee83cde3))
* **config:** better kind filter default for lua to deal with luals weirdness ([f64039f](https://github.com/LazyVim/LazyVim/commit/f64039f54620fe3fc9e8f464e35b184c6834ed6e))
* **config:** load/save some data in lazyvim.json ([11d66e7](https://github.com/LazyVim/LazyVim/commit/11d66e713467410add9ad5a7a68a3bca0aa24082))
* **config:** make kind filter configurable for telescope/aerial/... ([eb7a7d7](https://github.com/LazyVim/LazyVim/commit/eb7a7d7a8e586d30ed6839f4a621e0f019d32410))
* **config:** use lazy's new custom events (`Event.mappings`) for a better `LazyFile` ([4ea1c68](https://github.com/LazyVim/LazyVim/commit/4ea1c6865e6d877207de8626e11a5a863950ae55))
* **dashboard:** added LazyExtras shortcut to dashboard/alpha ([5bb7420](https://github.com/LazyVim/LazyVim/commit/5bb74205a06a89f048902ba142473dd679b228b8))
* **extras:** added extra for `symbols-outline.nvim` ([b4ba5d8](https://github.com/LazyVim/LazyVim/commit/b4ba5d881dcb801d3c502665f9767d2f75ca1110))
* **format:** new LazyVim formatter with integrations for lsp/none-ls/conform/eslint/... ([f1a8f24](https://github.com/LazyVim/LazyVim/commit/f1a8f24a361d0de198f6b1458168652a6835c932))
* **inject:** util method to get upvalue ([14f3f03](https://github.com/LazyVim/LazyVim/commit/14f3f036e9223315f310ba9d35182690638e7bd7))
* make `conform.nvim` and `nvim-lint` the default formatters/linters ([14c091b](https://github.com/LazyVim/LazyVim/commit/14c091b1fc6b0dc0b22ac49ccac69f8a02e3844c))
* **mini.starter:** adding mini.starter to lualine disabled files ([#1667](https://github.com/LazyVim/LazyVim/issues/1667)) ([1c34af7](https://github.com/LazyVim/LazyVim/commit/1c34af7f0138323d9f465437d0bcef621a8dbe94))
* **navic:** moved navic to extras ([305e82f](https://github.com/LazyVim/LazyVim/commit/305e82f2cacd5d0074027ea545a87a41379afc88))
* **root:** allow custom functions as part of `vim.g.root_spec` ([c33e748](https://github.com/LazyVim/LazyVim/commit/c33e7489ecdaef7295a63079410f2f24a1cbc9b6))
* **root:** cached pretty path function for statuslines ([8d7361c](https://github.com/LazyVim/LazyVim/commit/8d7361c4602993a7ea119cb7ce78d421b6787dfb))
* **root:** customizable root detection and `:LazyRoot` command ([a2d6049](https://github.com/LazyVim/LazyVim/commit/a2d604928b5629d14797437a26022065f7385216))
* **starter:** `dashboard.nvim` is now the default starter. To keep using `alpha.nvim`, enable the extra. ([4cbe42c](https://github.com/LazyVim/LazyVim/commit/4cbe42cd247c72dfc70c3fcddfa3fb6b5e6485e0))
* **starter:** added Lazy Extras to `mini.starter` ([ce74e28](https://github.com/LazyVim/LazyVim/commit/ce74e28464daa7d694f9ab4e41fae3174e30c8b3))
* **treesitter:** add nvim-treesitter-context by default ([7b2c317](https://github.com/LazyVim/LazyVim/commit/7b2c31740782fb0754ce715be6ea128083e48c4f))
* **treesitter:** install nvim-ts-autotag by default ([cb7f5ac](https://github.com/LazyVim/LazyVim/commit/cb7f5aca7a04cf2d1d06397e9a80fe078d17976b))
* **ui:** added `:LazyExtras` to manage enabled extras in LazyVim ([c4e55e4](https://github.com/LazyVim/LazyVim/commit/c4e55e4d67a7195b7aa9160cd8ece3ddc2f6cb51))
* **ui:** show optional plugins in a different color ([eedb4a3](https://github.com/LazyVim/LazyVim/commit/eedb4a34050443448d0b752e22803d5b1278b419))
* **util:** inject module ([e239235](https://github.com/LazyVim/LazyVim/commit/e239235cd34ac9c286eac1e620670784566ef673))
### Bug Fixes
* **aerial:** keymap ([c772027](https://github.com/LazyVim/LazyVim/commit/c7720275c3fa8b19c9ad7e05bfb6ed5c510bf2bb))
* **dap:** copy config before overriding args ([72f3cc6](https://github.com/LazyVim/LazyVim/commit/72f3cc684bd1e8f19b2d3c56da3f359032b8c5dc))
* **extras:** make sure we use priorities to import extras in correct order ([a4e3931](https://github.com/LazyVim/LazyVim/commit/a4e393154f61b95da5835b6461e211eb94740268))
* **format:** always show formatter status even when no sources available ([a4abbdc](https://github.com/LazyVim/LazyVim/commit/a4abbdc89bd1d49378ac5873db1279e7e5398927))
* **lualine:** when opening nvim with a file, show an empty statusline till lualine loads ([8373467](https://github.com/LazyVim/LazyVim/commit/83734675b0f93fbd11a350ee0662c09995836b59))
* **neo-tree:** during init check global argslist instead of window-local ([8fbde2c](https://github.com/LazyVim/LazyVim/commit/8fbde2c3668960ed085f9225bb4650aca77cc495))
* **nlua:** make nlua dap work with regular continue. Fixes [#1666](https://github.com/LazyVim/LazyVim/issues/1666) ([85215f3](https://github.com/LazyVim/LazyVim/commit/85215f396b6fd4de24636a202ec1149dafa5f7b5))
* **notify:** set default zindex=100 ([7fb7948](https://github.com/LazyVim/LazyVim/commit/7fb79486ed1b251b98b95a44ef50b3742edd708d))
* **plugin:** add nvim-treesitter-context rename warning ([db5d28b](https://github.com/LazyVim/LazyVim/commit/db5d28b039f656ccb47d3b9f787e8bb482cc6ec1))
* **plugin:** enable lazy_file ([f59cdff](https://github.com/LazyVim/LazyVim/commit/f59cdff4d9f04ff349cefdee0b363d573954ce0d))
* **plugin:** show warning of removed core plugin when trying to load them without having the extra ([3256abd](https://github.com/LazyVim/LazyVim/commit/3256abda65ae03358ecdbef1c7789782440fe39e))
* **root:** only use workspace folders that contain the buffer ([592f3b0](https://github.com/LazyVim/LazyVim/commit/592f3b03bb3cd01df42ee5db4cd6ba43937f067e))
* **ui:** dont show left signs on virtual line numbers (wrap). Fixes [#1654](https://github.com/LazyVim/LazyVim/issues/1654) ([e6d294d](https://github.com/LazyVim/LazyVim/commit/e6d294df6fbd973644d4b7f9691d5f48cc5efdde))
### Performance Improvements
* **lualine:** get rid of lualine's weird lualine_require ([13dbe4a](https://github.com/LazyVim/LazyVim/commit/13dbe4ad55a4e4b9a3dd345521b359411cdc5879))
* **plugin:** move all lazy.nvim related code to `lazyvim.util.plugin` ([70f9195](https://github.com/LazyVim/LazyVim/commit/70f91956e7f03e740b51cbc14c87df6a6f74538f))
* **util:** split lazyvim.util in smaller separate modules ([c8c929c](https://github.com/LazyVim/LazyVim/commit/c8c929c9fdc44cc69cb034c47bd89d2bc4e4a429))
## [9.9.1](https://github.com/LazyVim/LazyVim/compare/v9.9.0...v9.9.1) (2023-10-11)
### Bug Fixes
* **config:** disable LazyFile till v10.0 ([ee7a401](https://github.com/LazyVim/LazyVim/commit/ee7a401388f2933729afcd7090fb8e69631b912f))
## [9.9.0](https://github.com/LazyVim/LazyVim/compare/v9.8.0...v9.9.0) (2023-10-10)
### Features
* **dap:** added run with args `leader-ca`. Fixes [#1629](https://github.com/LazyVim/LazyVim/issues/1629) ([b1c9fd1](https://github.com/LazyVim/LazyVim/commit/b1c9fd15bdbc0bae5bf1ba1efd88ce7355e7f2c1))
### Bug Fixes
* **hypr:** automatically update/install hypr treesitter parser when needed ([88d465c](https://github.com/LazyVim/LazyVim/commit/88d465c3efac065f912e1de162c9a48bbae15316))
* **treesitter:** typo with commands ([599798a](https://github.com/LazyVim/LazyVim/commit/599798a366d5fead7e8486e1b02dd2362d2e6bd1))
## [9.8.0](https://github.com/LazyVim/LazyVim/compare/v9.7.0...v9.8.0) (2023-10-09)
### Features
* **cmp:** ctrl+CR will abort cmp and enter a new line ([d894556](https://github.com/LazyVim/LazyVim/commit/d894556c375c1c2398f170c21f9323c9c1eba9d4))
* **dashboard:** show loaded/count plugins on dashboard instead of just count ([9670c8a](https://github.com/LazyVim/LazyVim/commit/9670c8a400100d38e15c9662f488232508bfb1bb))
* **edgy:** when edgy is enabled, use edgy's main window for Telescope to open results in ([fb70170](https://github.com/LazyVim/LazyVim/commit/fb7017005809d6be06a1ece748ef2406c37a34d9))
* **options:** set `virtualedit=block` by default ([6b857f1](https://github.com/LazyVim/LazyVim/commit/6b857f1de648292f2410f9beaa95318bd30454d5))
* **telescope:** add telescope-fzf-native by default. Will only be enabled if `make` is on your system. ([44984dc](https://github.com/LazyVim/LazyVim/commit/44984dcbe25c13e0e1bc582d5a51ccc2a4be8f70))
* **telescope:** smarter way to determine the window to open a file in ([c0ce89f](https://github.com/LazyVim/LazyVim/commit/c0ce89fe62bffc0fe35bf76d3e5f501c8b5276c2))
### Bug Fixes
* **autocmds:** extra check that we didn't do last_loc more than once for the buffer ([5d44c97](https://github.com/LazyVim/LazyVim/commit/5d44c976a746e29cfe52ceab93dd3de5db2eafa8))
* **cmp:** set default group_index to 1 to prevent issues with custom sources ([0a05888](https://github.com/LazyVim/LazyVim/commit/0a05888d992b37749f9aae25c7f63f2534ec1024))
* **edgy:** typo ([9357ea2](https://github.com/LazyVim/LazyVim/commit/9357ea2881fdd57b028256597c01e15601c29aaf))
* **project:** make sure to load telescope extension after telescope ran setup ([0955129](https://github.com/LazyVim/LazyVim/commit/0955129796749651e1413006e36e9a1c6d3027f3))
* **telescope:** remove telescope folding hack since PR with fix has been merged upstream ([02bc414](https://github.com/LazyVim/LazyVim/commit/02bc41412a14c1c0bb823421ef82ff5596f42571))
* **util:** dont schedule on_load ([4e8a88f](https://github.com/LazyVim/LazyVim/commit/4e8a88fc1f28d0420aa3badb703296f344d89968))
## [9.7.0](https://github.com/LazyVim/LazyVim/compare/v9.6.0...v9.7.0) (2023-10-09)
### Features
* **black:** added an extra for black with none-ls & conform.nvim ([#1245](https://github.com/LazyVim/LazyVim/issues/1245)) ([5219cad](https://github.com/LazyVim/LazyVim/commit/5219cad564152337d5d48572466ac976f300a557))
* **cmp:** added custom comparator to prioritize AI sources like copilot and codeium ([eddd3af](https://github.com/LazyVim/LazyVim/commit/eddd3af3512133f22eb26dda81c3c6f871453276))
* **cmp:** removed priority comparator in favor of source priorities for copilot/codeium ([bff3a99](https://github.com/LazyVim/LazyVim/commit/bff3a996971c1f526eb893d8e778daa19a4245b5))
* **codeium:** added lualine component with codeium status similar to copilot ([b05783d](https://github.com/LazyVim/LazyVim/commit/b05783de8c518c8a6e5c3f648448c3a6f00d0050))
* **codeium:** use actual codeium icon ([302c1ff](https://github.com/LazyVim/LazyVim/commit/302c1ff66e5b1d7bbe95f29e81c2d642e2cd4468))
### Bug Fixes
* **black:** remove unknown blackd from conform ([#1640](https://github.com/LazyVim/LazyVim/issues/1640)) ([1779858](https://github.com/LazyVim/LazyVim/commit/177985842665921e11f9e9813348fd6bef852e27))
* **bufferline:** fix bufferline when restoring a session ([838ce85](https://github.com/LazyVim/LazyVim/commit/838ce85ad6ae2dc2fa1d7518b0c5eb1eb8fe29b2))
* **cmp:** properly set cmp `group_index` to fix issues with copilot and other sources ([#1639](https://github.com/LazyVim/LazyVim/issues/1639)) ([de93848](https://github.com/LazyVim/LazyVim/commit/de93848f584b3443204247f49b405b81b0a3d4c1))
* **lualine:** only show statusline as soon as lualine loads ([dd55cbd](https://github.com/LazyVim/LazyVim/commit/dd55cbdc99021267bee8260c224582a053552dfe))
* **options:** set sessionoptions the same as persistence ([502d324](https://github.com/LazyVim/LazyVim/commit/502d32490b29e7f52b2941cfa6a306b45633d63e))
* **plugins:** make sure init specs are loaded first ([51e25a9](https://github.com/LazyVim/LazyVim/commit/51e25a94b4ff2339028bdded993756360145d1b3))
### Performance Improvements
* **util:** closure for get_clients to prevent loading vim.lsp cascade early ([1eac633](https://github.com/LazyVim/LazyVim/commit/1eac633c4f0621d5bd07db1ab7d563db5b342e82))
## [9.6.0](https://github.com/LazyVim/LazyVim/compare/v9.5.0...v9.6.0) (2023-10-08)
### Features
* **extra:** add extra `util.dot` that configures multiple ft and treesitter langs when needed ([639a6e7](https://github.com/LazyVim/LazyVim/commit/639a6e7545830602c09711b3757a28537baf8e75))
### Bug Fixes
* **config:** trigger LazyFile additionally on BufWritePre for saving unnamed files ([e11a3cb](https://github.com/LazyVim/LazyVim/commit/e11a3cbe800a1216062f7cefd25827f6fdad9daa))
* **yaml:** yaml schemas are a dict, not a list, so merge properly. Fixes [#1636](https://github.com/LazyVim/LazyVim/issues/1636) ([33c677a](https://github.com/LazyVim/LazyVim/commit/33c677a55e97ee115ad7050856856df7cd96b3e1))
## [9.5.0](https://github.com/LazyVim/LazyVim/compare/v9.4.1...v9.5.0) (2023-10-08)
### Features
* **treesitter:** add diff, jsonc and yaml by default ([c9bbb92](https://github.com/LazyVim/LazyVim/commit/c9bbb922e58b223d49785cddbed2feeea536237e))
### Bug Fixes
* **util:** fixup typo vim.lsp.get_active_clients ([eebdcec](https://github.com/LazyVim/LazyVim/commit/eebdceca1723801e1889d2a65bd676d17139fc6c))
## [9.4.1](https://github.com/LazyVim/LazyVim/compare/v9.4.0...v9.4.1) (2023-10-08)
### Bug Fixes
* **config:** dont append LazyVim early to the rtp when bootstrapping ([4e0a058](https://github.com/LazyVim/LazyVim/commit/4e0a05808cb0997e0ac7d939421f68e9dfa5d74d))
* **util:** fixed lsp willRenameFiles support check ([21ee35f](https://github.com/LazyVim/LazyVim/commit/21ee35f7108f4eefbce84d88a002572b168fc357))
## [9.4.0](https://github.com/LazyVim/LazyVim/compare/v9.3.1...v9.4.0) (2023-10-08)
### Features
* **codeium:** add codeium extra ([#1619](https://github.com/LazyVim/LazyVim/issues/1619)) ([af9e452](https://github.com/LazyVim/LazyVim/commit/af9e4528543d98bccce333d39eccc34e433ef6dc))
* **keymaps:** added support for lazy's per-mode keymap disabling ([1bc7827](https://github.com/LazyVim/LazyVim/commit/1bc78272da28821479e98df528d399214a8cdbee))
* **nlua:** make lua dap keybindings buffer-local ([9372d78](https://github.com/LazyVim/LazyVim/commit/9372d78e7e4ed46612de9818868373da81b6f4f1))
### Bug Fixes
* **alpha:** reset laststatus when alpha unloads. Fixes [#1623](https://github.com/LazyVim/LazyVim/issues/1623) ([30d5735](https://github.com/LazyVim/LazyVim/commit/30d573502a2f9264273a14143e6bddb0b876a391))
### Performance Improvements
* **navic:** enable lazy_update_context option to update context on "CursorHold" instead of of using default "CursorMove" ([#1620](https://github.com/LazyVim/LazyVim/issues/1620)) ([3c92fa4](https://github.com/LazyVim/LazyVim/commit/3c92fa4eb04f827c79c095905ca9391d540fea79))
## [9.3.1](https://github.com/LazyVim/LazyVim/compare/v9.3.0...v9.3.1) (2023-10-07)
### Bug Fixes
* **config:** trigger all buf filetype events on LazyFile ([862e140](https://github.com/LazyVim/LazyVim/commit/862e140a7ad8452cd5a103982687fca63a2f44da))
* **rust:** explicitly enable nvim-cmp source registration for crates ([#1609](https://github.com/LazyVim/LazyVim/issues/1609)) ([237be9e](https://github.com/LazyVim/LazyVim/commit/237be9e3a7f5ca8165d4242d47df34d8d407f4cc))
* **treesitter-textobjects:** use normal ]c,]C,[c,[C when in diff-mode instead of goto class. Fixes [#1610](https://github.com/LazyVim/LazyVim/issues/1610) ([1935486](https://github.com/LazyVim/LazyVim/commit/1935486ff143dd5cf100b8c89204dc01d8e06021))
* **ui:** properly handly signs without name. Fixes [#1612](https://github.com/LazyVim/LazyVim/issues/1612) ([0fcdbe2](https://github.com/LazyVim/LazyVim/commit/0fcdbe20daf44f00252668b3866b19ac18b339df))
## [9.3.0](https://github.com/LazyVim/LazyVim/compare/v9.2.0...v9.3.0) (2023-10-06)
### Features
* **bufremove:** ask to save changes before trying to remove a buffer ([54df3e2](https://github.com/LazyVim/LazyVim/commit/54df3e26aca5c5c4da746f210e6f7e7de30673bb))
### Bug Fixes
* **tailwind:** nil check for filetypes_include. Fixes [#1607](https://github.com/LazyVim/LazyVim/issues/1607) ([d8f4382](https://github.com/LazyVim/LazyVim/commit/d8f4382dd3850550076b33d64a5f455daf7e6450))
### Performance Improvements
* **config:** only enable LazyFile when opening a file from the cmdline ([11c9084](https://github.com/LazyVim/LazyVim/commit/11c9084ec576c8735a87550f7975640eb75e6ff7))
## [9.2.0](https://github.com/LazyVim/LazyVim/compare/v9.1.1...v9.2.0) (2023-10-06)
### Features
* **conform:** ignore formatting errors for injected languages and fix condition example ([a1c5886](https://github.com/LazyVim/LazyVim/commit/a1c5886947e20059ad7802e71e0a82b413af6657))
### Bug Fixes
* **config:** fixed issues related to LazyFile. Fixes [#1601](https://github.com/LazyVim/LazyVim/issues/1601) ([6e0e01f](https://github.com/LazyVim/LazyVim/commit/6e0e01f5b4dd7e97abbb50241a207d36d0ce9cd5))
* **elixir:** only enable credo when installed. Fixes [#1546](https://github.com/LazyVim/LazyVim/issues/1546) ([8a1de2b](https://github.com/LazyVim/LazyVim/commit/8a1de2b90a699bdfee704f3d4422e2ced18ae0f3))
* **which-key:** change surround group key ([#1598](https://github.com/LazyVim/LazyVim/issues/1598)) ([f1ea518](https://github.com/LazyVim/LazyVim/commit/f1ea518e29a601b773d9c9c94489fc9d273c2dea))
## [9.1.1](https://github.com/LazyVim/LazyVim/compare/v9.1.0...v9.1.1) (2023-10-05)
### Bug Fixes
* **ui:** include extmark signs in signcolumn. Fixes [#1596](https://github.com/LazyVim/LazyVim/issues/1596) ([337cfdb](https://github.com/LazyVim/LazyVim/commit/337cfdbec43003cb2c269e59b27167aa752bf41f))
## [9.1.0](https://github.com/LazyVim/LazyVim/compare/v9.0.2...v9.1.0) (2023-10-05)
### Features
* **dashboard:** add projects if enabled ([#1595](https://github.com/LazyVim/LazyVim/issues/1595)) ([6f1cdfe](https://github.com/LazyVim/LazyVim/commit/6f1cdfe4bd2ec9a85c92a312fa52ba86e02d1a9f))
### Bug Fixes
* **dashboard:** disable alpha only once ([d6b56c0](https://github.com/LazyVim/LazyVim/commit/d6b56c075e88ce12e9e16fb2eeeea38fb7853600))
* **options:** set default laststatus=3 and set it to 0 before loading dashboard to prevent flickering ([1eb0192](https://github.com/LazyVim/LazyVim/commit/1eb019274b5564e66ac6c7e119c140bae262e10c))
* **tailwind:** allow overriding filetypes. Fixes [#1590](https://github.com/LazyVim/LazyVim/issues/1590) ([d3e7f77](https://github.com/LazyVim/LazyVim/commit/d3e7f7717e960bb883b35e9a75badfd5b938cace))
## [9.0.2](https://github.com/LazyVim/LazyVim/compare/v9.0.1...v9.0.2) (2023-10-04)
### Bug Fixes
* **autocmds:** last_loc autocmd didn't work correctly for first opened file ([0cc80b1](https://github.com/LazyVim/LazyVim/commit/0cc80b1b0594516ccc2c1e6c9a60c84012a29abb))
* **bufferline:** load bufferline on VeryLazy. Fixes [#1587](https://github.com/LazyVim/LazyVim/issues/1587) ([7272b3e](https://github.com/LazyVim/LazyVim/commit/7272b3e4b5b626597658dabf774998057892d066))
* **treesitter:** dont enable ]c, [c, ... in diff-mode ([86de423](https://github.com/LazyVim/LazyVim/commit/86de423ef029abd085531e18b197a5f90e201d98))
## [9.0.1](https://github.com/LazyVim/LazyVim/compare/v9.0.0...v9.0.1) (2023-10-04)
### Bug Fixes
* **alpha:** use `<cmd>` instead of `:` for shortcuts ([1abcffb](https://github.com/LazyVim/LazyVim/commit/1abcffbfd940588fa67cc7438ce2115df1c58e92))
* **options:** only enable treesitter `foldexpr` on nightly. Fixes [#1581](https://github.com/LazyVim/LazyVim/issues/1581) ([d989ecc](https://github.com/LazyVim/LazyVim/commit/d989ecc943b3240db0be3aa0369b96089cee4b40))
* **ui:** show global marks in the correct buffer only ([3849e01](https://github.com/LazyVim/LazyVim/commit/3849e0150b0a616dbd6e7e12ec5025aff6c81d39))
## [9.0.0](https://github.com/LazyVim/LazyVim/compare/v8.4.4...v9.0.0) (2023-10-04)
### ⚠ BREAKING CHANGES
* **mini.surround:** default surround mappings are now gs instead of gz (unless you enabled the leap extra)
### Features
* **extras:** added extra for dashboard.nvim ([417de01](https://github.com/LazyVim/LazyVim/commit/417de0193dd0663100a8b1eaedc2bc4976712c61))
* **mini.surround:** default surround mappings are now gs instead of gz (unless you enabled the leap extra) ([d28c69e](https://github.com/LazyVim/LazyVim/commit/d28c69e49eab62b45f7d1562b3bc00afee5fbb65))
* **treesitter:** added ]f, [f, ]F, [F, ]c, ]C, [c, [C for treesitter-textobjects ([0e66ef8](https://github.com/LazyVim/LazyVim/commit/0e66ef83934eb62ee2237e331dcbc0a22b809aae))
* **treesitter:** map `vim` to `[@namespace](https://github.com/namespace).builtin` ([5f0713d](https://github.com/LazyVim/LazyVim/commit/5f0713d2b612a814586bffec39700ab6a30dc0ea))
* **typescript:** add typescriptreact/javascriptreact to types ([#1574](https://github.com/LazyVim/LazyVim/issues/1574)) ([626ae13](https://github.com/LazyVim/LazyVim/commit/626ae1338a88f6cd8962d6c20bd79953a67f0b72))
* **ui:** show alpha marks in statuscolumn ([bd2ac54](https://github.com/LazyVim/LazyVim/commit/bd2ac542a0bb4c58237cd6ca8848063bd20a5282))
### Bug Fixes
* **autocmds:** restore last location for correct buffer ([afc8e7f](https://github.com/LazyVim/LazyVim/commit/afc8e7f8cac06335efd12ec5f71cabb1f38a09b0))
* **conform:** dont try merging function formatters. Fixes [#1582](https://github.com/LazyVim/LazyVim/issues/1582) ([f475085](https://github.com/LazyVim/LazyVim/commit/f4750859f2c2c9a41b3974ac05962ce9648d6c16))
* **conform:** dont try to merge formatter functions ([9f034ab](https://github.com/LazyVim/LazyVim/commit/9f034ab10650e306e178d5189ee9214a52f2e8e5))
* **nvim-lint:** dont try merging function linters ([79010ae](https://github.com/LazyVim/LazyVim/commit/79010ae671035d8ed0040ce51df4fb59ec3962f8))
* **ui:** use custom fold when treesitter foldtext returns a string ([3505329](https://github.com/LazyVim/LazyVim/commit/35053290bf957a230c8758d31ba3997c0699f5f9))
### Performance Improvements
* added support for `LazyFile` event that properly loads file based plugins without blocking the ui ([936d74b](https://github.com/LazyVim/LazyVim/commit/936d74bb6127721eeefa62e5f697d9693ab04fdd))
* **config:** add LazyVim to the rtp early for faster spec loading ([2f16a7b](https://github.com/LazyVim/LazyVim/commit/2f16a7b2d96e912c9ab50ce99d9994413ff3678d))
## [8.4.4](https://github.com/LazyVim/LazyVim/compare/v8.4.3...v8.4.4) (2023-10-03)
### Bug Fixes
* **ui:** work-around for telescope issue with treesitter folds ([ccff868](https://github.com/LazyVim/LazyVim/commit/ccff8683ba957250d71ef66429fc877f0ee5cedb))
## [8.4.3](https://github.com/LazyVim/LazyVim/compare/v8.4.2...v8.4.3) (2023-10-03)
### Bug Fixes
* **ui:** always pad to 2 cells for status column icons. Fixes [#1571](https://github.com/LazyVim/LazyVim/issues/1571) ([6cf6b0a](https://github.com/LazyVim/LazyVim/commit/6cf6b0a6241c659113f5646ff64fba7dbf5161b9))
## [8.4.2](https://github.com/LazyVim/LazyVim/compare/v8.4.1...v8.4.2) (2023-10-03)
### Bug Fixes
* **nvim-lint:** dont evaluate conditions for linter functions. Fixes [#1569](https://github.com/LazyVim/LazyVim/issues/1569) ([b1ad480](https://github.com/LazyVim/LazyVim/commit/b1ad48067e2c18747bedd7b7054c3ce97ef32890))
* **ui:** fixed foldtext on Neovim < 0.10 ([1b74d67](https://github.com/LazyVim/LazyVim/commit/1b74d67a0d5783e587dedc73a715cb0c9db6cd16))
### Performance Improvements
* **options:** better detection for foldtext,statuscolumn,folexpr support ([e105c9d](https://github.com/LazyVim/LazyVim/commit/e105c9daf6e973b4a294a17b4d2d1882f2188ac6))
## [8.4.1](https://github.com/LazyVim/LazyVim/compare/v8.4.0...v8.4.1) (2023-10-03)
### Bug Fixes
* **ui:** check folds of the statuscolumn win instead of current win ([13e9f6e](https://github.com/LazyVim/LazyVim/commit/13e9f6e6b5b085191b0ecf194ddf4c9e2d3ae6d7))
## [8.4.0](https://github.com/LazyVim/LazyVim/compare/v8.3.0...v8.4.0) (2023-10-03)
### Features
* **keymaps:** added toggle for relative line numbers ([3f868aa](https://github.com/LazyVim/LazyVim/commit/3f868aa8254efbd494f6bf100c86a59c5a002c1c))
* **options:** enable smoothscroll on nightly ([450e0c6](https://github.com/LazyVim/LazyVim/commit/450e0c6bebc5bb9a0c513cdffaf9c46d5f62d5fa))
* **options:** enabled treesitter folding and foldtext when available ([19926d2](https://github.com/LazyVim/LazyVim/commit/19926d284862b5e58f29e73b71ec532ac29c54ba))
* **ui:** fancy fold text ([f1ce075](https://github.com/LazyVim/LazyVim/commit/f1ce07510d2048e33fec2b609814d68a7175d591))
* **ui:** fancy status column ([364bcf3](https://github.com/LazyVim/LazyVim/commit/364bcf325d91a06e6bd6516bdfed84399566cdb6))
### Bug Fixes
* **ui:** better fallback for foldtext when buffer does not have TreeSitter ([762017d](https://github.com/LazyVim/LazyVim/commit/762017dc35fc961bdcc7879a5527dbccced27792))
* **ui:** Neovim < 0.10 ([afbe204](https://github.com/LazyVim/LazyVim/commit/afbe2043a73b6c90476812f9cc0ca4759814e5ac))
## [8.3.0](https://github.com/LazyVim/LazyVim/compare/v8.2.0...v8.3.0) (2023-10-02)
### Features
* **conform:** added new keymap (leader-cF) to format injected languages ([86d3694](https://github.com/LazyVim/LazyVim/commit/86d36946727bade57918c6a358c6b6bae52d441b))
### Bug Fixes
* **indent-blankline:** set `config.indent.tab_char` ([#1552](https://github.com/LazyVim/LazyVim/issues/1552)) ([7c5a458](https://github.com/LazyVim/LazyVim/commit/7c5a458761fe7002c6603d602e8d130b9a62dd68))
## [8.2.0](https://github.com/LazyVim/LazyVim/compare/v8.1.0...v8.2.0) (2023-10-02)
### Features
* **mini.files:** added lsp rename support to mini.files ([4ff51cd](https://github.com/LazyVim/LazyVim/commit/4ff51cd678343ea32668eaf0c1103caacb4334a2))
## [8.1.0](https://github.com/LazyVim/LazyVim/compare/v8.0.0...v8.1.0) (2023-10-01)
### Features
* **conform:** set vim.opt.formatexpr ([766d5e5](https://github.com/LazyVim/LazyVim/commit/766d5e5bf7a8e40910a00aef4dc30f36376e5652))
* **elixir:** Add credo if none-ls is used ([#1546](https://github.com/LazyVim/LazyVim/issues/1546)) ([2ffd629](https://github.com/LazyVim/LazyVim/commit/2ffd629cc7a68e6e4a721ac8babe6b7cf612868e))
* **format:** show warning when no formatter ran when using the format keymap ([e36f7d8](https://github.com/LazyVim/LazyVim/commit/e36f7d811c396b60bcbf65f962b3f52d2f75b0b3))
* **go:** add goimports ([#1549](https://github.com/LazyVim/LazyVim/issues/1549)) ([e8ab2ff](https://github.com/LazyVim/LazyVim/commit/e8ab2ff5b6a75952943d3ba44586c7de5588be33))
### Bug Fixes
* **format:** moved formatting keymap to lua/lazyvim/config/keymaps.lua ([9b16770](https://github.com/LazyVim/LazyVim/commit/9b1677057377400ab292c51bbc085c82637a39d4))
## [8.0.0](https://github.com/LazyVim/LazyVim/compare/v7.0.3...v8.0.0) (2023-10-01)
### ⚠ BREAKING CHANGES
* LazyVim now requires Neovim >= 0.9.0
### Features
* replace Copilot icon with logo ([#1539](https://github.com/LazyVim/LazyVim/issues/1539)) ([9bb4e87](https://github.com/LazyVim/LazyVim/commit/9bb4e8755f5a822659ca1d8cb3689732435d90d0))
* show error and exit Neovim when version is too old ([2aea5c7](https://github.com/LazyVim/LazyVim/commit/2aea5c7210882a2f98526ee29115fe2e1a41d7b4))
### Bug Fixes
* cleanup all Neovim < 0.9.0 code ([9935dc3](https://github.com/LazyVim/LazyVim/commit/9935dc3944c4724d7ee7f70b6bc450f8c3b34a08))
### Performance Improvements
* dont't load schemastore as an lspconfig dep ([9d17c43](https://github.com/LazyVim/LazyVim/commit/9d17c4308713e8db7ec03871ba62ff80a3bfb79c))
### Documentation
* LazyVim now requires Neovim >= 0.9.0 ([bfe0422](https://github.com/LazyVim/LazyVim/commit/bfe04222fe5585179f03197b01a6f6ed711d4421))
## [7.0.3](https://github.com/LazyVim/LazyVim/compare/v7.0.2...v7.0.3) (2023-09-30)
### Bug Fixes
* **extras.go:** remove unneeded formatters since gopls handles them ([#1535](https://github.com/LazyVim/LazyVim/issues/1535)) ([964dd6c](https://github.com/LazyVim/LazyVim/commit/964dd6c4b2135399758c87afed7e1f3c8e30b487))
## [7.0.2](https://github.com/LazyVim/LazyVim/compare/v7.0.1...v7.0.2) (2023-09-30)
### Bug Fixes
* **format:** allow `custom_format` to return early ([#1531](https://github.com/LazyVim/LazyVim/issues/1531)) ([1c878b9](https://github.com/LazyVim/LazyVim/commit/1c878b9d06fb116135419d098fe5dfde5304b709))
* **python:** make venv-selector `dap_enabled` conditional on `nvim-dap-python` ([#1529](https://github.com/LazyVim/LazyVim/issues/1529)) ([7821c0e](https://github.com/LazyVim/LazyVim/commit/7821c0e85199205af98ceedfb2c4990c96900e46))
## [7.0.1](https://github.com/LazyVim/LazyVim/compare/v7.0.0...v7.0.1) (2023-09-29)
### Bug Fixes
* **nvim-lint:** dont use default configured linters from nvim-lint ([ff5f588](https://github.com/LazyVim/LazyVim/commit/ff5f5886db321679e3fdc5dbb82b12daf6075510))
## [7.0.0](https://github.com/LazyVim/LazyVim/compare/v6.4.3...v7.0.0) (2023-09-29)
### ⚠ BREAKING CHANGES
* **typescript:** removed `typescript.nvim` since it's deprecated
* **null-ls:** use none-ls instead of null-ls ([#1517](https://github.com/LazyVim/LazyVim/issues/1517))
### Features
* **extras:** added `conform.nvim` extra you can use instead of null-ls/none-ls ([f61a243](https://github.com/LazyVim/LazyVim/commit/f61a243d1aca582963aca3f2c2c7c2ae0be16b06))
* **extras:** added extra for nvim-lint ([05f45bb](https://github.com/LazyVim/LazyVim/commit/05f45bb7200a6fd33ab7366553b957fa222e2cdf))
* **neo-tree:** added support for LSP renaming to NeoTree ([9762e7e](https://github.com/LazyVim/LazyVim/commit/9762e7e43110013a0931b8470be2929b54b4b641))
* **null-ls:** use none-ls instead of null-ls ([#1517](https://github.com/LazyVim/LazyVim/issues/1517)) ([7cac6f0](https://github.com/LazyVim/LazyVim/commit/7cac6f064c5b30f6b0ae4dffab62100aa6fe2568))
### Bug Fixes
* **conform:** use `formatters` for both custom and overriding formatters ([6bb0d1b](https://github.com/LazyVim/LazyVim/commit/6bb0d1b66ffe6d0a77ad96d0f945113ddcb9fdb3))
* **docker:** put hadolint in its own spec ([718c5c6](https://github.com/LazyVim/LazyVim/commit/718c5c6036f2aff6534501e151dd3e5ff13a42fa))
* **format:** wrap custom formatter with error handler ([0e5ff5c](https://github.com/LazyVim/LazyVim/commit/0e5ff5c0ab6930190122df086db5e3f91d8b38b8))
* **nvim-lint:** use `linters` for both custom and overriding linters ([31d9136](https://github.com/LazyVim/LazyVim/commit/31d913697bc9b731bc941362021ce06617f627d3))
* remove deprecated leap/flit code checks ([6b05ed7](https://github.com/LazyVim/LazyVim/commit/6b05ed7dcd729322e2e5b6752655a9491cd17f86))
* **typescript:** removed `typescript.nvim` since it's deprecated ([aab365a](https://github.com/LazyVim/LazyVim/commit/aab365a9f8b6405c6c5a938cb4745e9b770f2261))
## [6.4.3](https://github.com/LazyVim/LazyVim/compare/v6.4.2...v6.4.3) (2023-09-28)
### Bug Fixes
* **ibl:** use default hl groups ([74786c2](https://github.com/LazyVim/LazyVim/commit/74786c21d743db0fabed61b90bf7ecaab16bbf14))
* **lsp:** don't install jsonls by default. It's part of the json extra ([fa6cbfc](https://github.com/LazyVim/LazyVim/commit/fa6cbfc6020efcd2168ffe09a209037599b91442))
* **telescope:** add enums and consts to search symbols ([#1512](https://github.com/LazyVim/LazyVim/issues/1512)) ([b220e54](https://github.com/LazyVim/LazyVim/commit/b220e541594a0ef556d1515649cd99d45fe94058))
* **telescope:** replace anonymous functions in mappings by named functions ([#1294](https://github.com/LazyVim/LazyVim/issues/1294)) ([13bf797](https://github.com/LazyVim/LazyVim/commit/13bf7977a4bae39a38ef6a3fad6303366c8b4bea))
* **telescope:** typo ([017582c](https://github.com/LazyVim/LazyVim/commit/017582c05a2d87c73cfe794dd2e296cc0caf86cd))
* **yamlls:** work-around for yaml formatting on Neovim < 0.10. Fixes [#1435](https://github.com/LazyVim/LazyVim/issues/1435) ([7f5051e](https://github.com/LazyVim/LazyVim/commit/7f5051ef72cfe66eb50ddb7c973714aa8aea04ec))
## [6.4.2](https://github.com/LazyVim/LazyVim/compare/v6.4.1...v6.4.2) (2023-09-28)
### Bug Fixes
* **indent-blankline:** upgrade ibl config to v3 ([db86635](https://github.com/LazyVim/LazyVim/commit/db86635e3276451f795da4f8af64eff94391fe48))
## [6.4.1](https://github.com/LazyVim/LazyVim/compare/v6.4.0...v6.4.1) (2023-09-27)
### Bug Fixes
* **dap:** revert loading vscode launch files. Add it to your own config when needed. Fixes [#1503](https://github.com/LazyVim/LazyVim/issues/1503) ([36d6a7f](https://github.com/LazyVim/LazyVim/commit/36d6a7fe4f4e7d5c9ffceca0496655a889df2ebc))
## [6.4.0](https://github.com/LazyVim/LazyVim/compare/v6.3.0...v6.4.0) (2023-09-26)
### Features
* **autocmds:** close InspectTree window with q ([e54d0dd](https://github.com/LazyVim/LazyVim/commit/e54d0dde623c206c4f7ed9a512785c9fc0de3a22))
* **extras:** added simple csharp extra ([afdcec5](https://github.com/LazyVim/LazyVim/commit/afdcec5b4adccd94ff64774340a3ffd33a9d4ecf))
* **java:** support vscode launch json in Java ([#1422](https://github.com/LazyVim/LazyVim/issues/1422)) ([5dc4ce3](https://github.com/LazyVim/LazyVim/commit/5dc4ce3e4a452438838c271330df156fd3640c60))
* **mini-pairs:** add toggle mini pairs keymap and function ([#1456](https://github.com/LazyVim/LazyVim/issues/1456)) ([a7f971f](https://github.com/LazyVim/LazyVim/commit/a7f971f30ec89473482db4ab820d2afb25fa6abf))
### Bug Fixes
* always lazy load keymaps. fixes [#1485](https://github.com/LazyVim/LazyVim/issues/1485) ([f892ba5](https://github.com/LazyVim/LazyVim/commit/f892ba5cffe8fcac724ad6b801e0824b391fa037))
* **dap:** move launchjs code from java to dap ([f1af34e](https://github.com/LazyVim/LazyVim/commit/f1af34e88525cc291b7bacc76d915b642aef192b))
* disable context commentstring autocmd ([0bff29c](https://github.com/LazyVim/LazyVim/commit/0bff29c07a0d5fb4ef36ba4add2b9c4ee243f8a9))
* **mini.comment:** better lua pattern for tags. Fixes [#1413](https://github.com/LazyVim/LazyVim/issues/1413) ([7c79cfe](https://github.com/LazyVim/LazyVim/commit/7c79cfe07314245decd73ec67e7247bba22abaa9))
* **python:** use venv for DAP Python ([#1457](https://github.com/LazyVim/LazyVim/issues/1457)) ([ea930e3](https://github.com/LazyVim/LazyVim/commit/ea930e35457df4a367b537c472af8d5c6e8ae7eb))
## [6.3.0](https://github.com/LazyVim/LazyVim/compare/v6.2.0...v6.3.0) (2023-09-04) ## [6.3.0](https://github.com/LazyVim/LazyVim/compare/v6.2.0...v6.3.0) (2023-09-04)
@ -507,7 +1202,7 @@
* **hipatterns:** default options ([3082436](https://github.com/LazyVim/LazyVim/commit/30824369c2c58647df170566766ea1dbda2730cc)) * **hipatterns:** default options ([3082436](https://github.com/LazyVim/LazyVim/commit/30824369c2c58647df170566766ea1dbda2730cc))
* **neotest:** added some additional filetypes to close with q ([1288f0d](https://github.com/LazyVim/LazyVim/commit/1288f0d5a5cc5f5279678cc3c3d99abe20a1e052)) * **neotest:** added some additional filetypes to close with q ([1288f0d](https://github.com/LazyVim/LazyVim/commit/1288f0d5a5cc5f5279678cc3c3d99abe20a1e052))
* **neotest:** support neotest adapaters that use `setup()` for custom setup ([2a3bac7](https://github.com/LazyVim/LazyVim/commit/2a3bac769045abac76395fcabb36b17b68bc42fc)) * **neotest:** support neotest adapters that use `setup()` for custom setup ([2a3bac7](https://github.com/LazyVim/LazyVim/commit/2a3bac769045abac76395fcabb36b17b68bc42fc))
## [4.2.0](https://github.com/LazyVim/LazyVim/compare/v4.1.1...v4.2.0) (2023-05-26) ## [4.2.0](https://github.com/LazyVim/LazyVim/compare/v4.1.1...v4.2.0) (2023-05-26)
@ -1114,7 +1809,7 @@
### Bug Fixes ### Bug Fixes
* **illuminate:** always set refernce keymaps on the buffer as well to properly overwrite ftplugin mappings. Fixes [#292](https://github.com/LazyVim/LazyVim/issues/292) ([a0cf00c](https://github.com/LazyVim/LazyVim/commit/a0cf00c81b3a4a352cdc26c94112d9a5827881e1)) * **illuminate:** always set reference keymaps on the buffer as well to properly overwrite ftplugin mappings. Fixes [#292](https://github.com/LazyVim/LazyVim/issues/292) ([a0cf00c](https://github.com/LazyVim/LazyVim/commit/a0cf00c81b3a4a352cdc26c94112d9a5827881e1))
* **mini.surround:** don't create empty keymaps. Fixes [#296](https://github.com/LazyVim/LazyVim/issues/296) ([8e84dcf](https://github.com/LazyVim/LazyVim/commit/8e84dcf85c8a73ebcf6ade6b7b77544f468f1dfa)) * **mini.surround:** don't create empty keymaps. Fixes [#296](https://github.com/LazyVim/LazyVim/issues/296) ([8e84dcf](https://github.com/LazyVim/LazyVim/commit/8e84dcf85c8a73ebcf6ade6b7b77544f468f1dfa))
* **treesitter:** disable indent only for python right now ([de6a28b](https://github.com/LazyVim/LazyVim/commit/de6a28b781e8a06e4f70c913539c97260392131a)) * **treesitter:** disable indent only for python right now ([de6a28b](https://github.com/LazyVim/LazyVim/commit/de6a28b781e8a06e4f70c913539c97260392131a))
* **treesitter:** disable treesitter indent by default, since it has too many issues. See [#297](https://github.com/LazyVim/LazyVim/issues/297) ([329a2da](https://github.com/LazyVim/LazyVim/commit/329a2daff493abd2bd5c8fedbf0dfa13039d3931)) * **treesitter:** disable treesitter indent by default, since it has too many issues. See [#297](https://github.com/LazyVim/LazyVim/issues/297) ([329a2da](https://github.com/LazyVim/LazyVim/commit/329a2daff493abd2bd5c8fedbf0dfa13039d3931))
@ -1258,7 +1953,7 @@
### Bug Fixes ### Bug Fixes
* **mini.ai:** load ai on VeryLazy. Keymaps interfer with which-key. [#155](https://github.com/LazyVim/LazyVim/issues/155) ([3b5f363](https://github.com/LazyVim/LazyVim/commit/3b5f36307438ad05beae6796ca005f6b56d6a360)) * **mini.ai:** load ai on VeryLazy. Keymaps interfere with which-key. [#155](https://github.com/LazyVim/LazyVim/issues/155) ([3b5f363](https://github.com/LazyVim/LazyVim/commit/3b5f36307438ad05beae6796ca005f6b56d6a360))
* **noice:** scroll doc window in normal, insert and select mode ([c5b22c0](https://github.com/LazyVim/LazyVim/commit/c5b22c0832603198f571ff68b6fb9d0c17f73d33)) * **noice:** scroll doc window in normal, insert and select mode ([c5b22c0](https://github.com/LazyVim/LazyVim/commit/c5b22c0832603198f571ff68b6fb9d0c17f73d33))
* **nvim-navic:** use kinds icons for navic. Fixes [#164](https://github.com/LazyVim/LazyVim/issues/164) ([b81ecf9](https://github.com/LazyVim/LazyVim/commit/b81ecf9f7ac78e3f87a4d9b305fa0d3cfd6decf2)) * **nvim-navic:** use kinds icons for navic. Fixes [#164](https://github.com/LazyVim/LazyVim/issues/164) ([b81ecf9](https://github.com/LazyVim/LazyVim/commit/b81ecf9f7ac78e3f87a4d9b305fa0d3cfd6decf2))
@ -1433,7 +2128,7 @@
* **lsp:** allow overriding options for vim.lsp.buf.format. Fixes [#51](https://github.com/LazyVim/LazyVim/issues/51) ([40d363c](https://github.com/LazyVim/LazyVim/commit/40d363cf3f468a1cc4ea482eaabbd5c7e224f397)) * **lsp:** allow overriding options for vim.lsp.buf.format. Fixes [#51](https://github.com/LazyVim/LazyVim/issues/51) ([40d363c](https://github.com/LazyVim/LazyVim/commit/40d363cf3f468a1cc4ea482eaabbd5c7e224f397))
* **lsp:** make diagnostics configurable with `{"neovim/nvim-lspconfig", opts = {diagnostics = {}}}`. Fixes [#55](https://github.com/LazyVim/LazyVim/issues/55) ([1efc925](https://github.com/LazyVim/LazyVim/commit/1efc925d16b57659cbb9af5a1579cb1b9ee9643f)) * **lsp:** make diagnostics configurable with `{"neovim/nvim-lspconfig", opts = {diagnostics = {}}}`. Fixes [#55](https://github.com/LazyVim/LazyVim/issues/55) ([1efc925](https://github.com/LazyVim/LazyVim/commit/1efc925d16b57659cbb9af5a1579cb1b9ee9643f))
* **neo-tree:** added `&lt;leader&gt;e` and `<leader>E` to toggle neo-tree ([542920f](https://github.com/LazyVim/LazyVim/commit/542920fb8249d45d1e9ddbf6517a8f8539769eda)) * **neo-tree:** added `&lt;leader&gt;e` and `<leader>E` to toggle neo-tree ([542920f](https://github.com/LazyVim/LazyVim/commit/542920fb8249d45d1e9ddbf6517a8f8539769eda))
* **neo-tree:** load neo-tree when specifying a direcory on the cmdline ([81d798f](https://github.com/LazyVim/LazyVim/commit/81d798fdaa5bf49737969e0f15af4a90621a0a61)) * **neo-tree:** load neo-tree when specifying a directory on the cmdline ([81d798f](https://github.com/LazyVim/LazyVim/commit/81d798fdaa5bf49737969e0f15af4a90621a0a61))
* **notify:** delay notifs till replaced or at most 500ms to prevent more prompts ([701337f](https://github.com/LazyVim/LazyVim/commit/701337fac8cb1de0f3e31400cef30b053762320f)) * **notify:** delay notifs till replaced or at most 500ms to prevent more prompts ([701337f](https://github.com/LazyVim/LazyVim/commit/701337fac8cb1de0f3e31400cef30b053762320f))
* **notify:** lazy-load nvim-notify to show proper notifs before Noice loads ([7406313](https://github.com/LazyVim/LazyVim/commit/74063135d838b0ed9fe1a8d0e777c8cfe83ae28f)) * **notify:** lazy-load nvim-notify to show proper notifs before Noice loads ([7406313](https://github.com/LazyVim/LazyVim/commit/74063135d838b0ed9fe1a8d0e777c8cfe83ae28f))
* **util:** use lazy's notify instead of `vim.notify` ([48d1e8d](https://github.com/LazyVim/LazyVim/commit/48d1e8df12795cf559f704223b63e76259998582)) * **util:** use lazy's notify instead of `vim.notify` ([48d1e8d](https://github.com/LazyVim/LazyVim/commit/48d1e8df12795cf559f704223b63e76259998582))

68
NEWS.md Normal file
View file

@ -0,0 +1,68 @@
# What's new?
## 10.x
- User extras under `lua/plugins/extras` can now also be managed
with **LazyExtras**
- `nvim-ts-autotag` is now included by default
- `nvim-treesitter-context` is now included by default
- Added extra for `symbols-outline.nvim`
- Added extra for `aerial.nvim`
- `nvim-navic` has been removed. If you want to keep using `nvim-navic`,
you can enable the **editor.navic** extra
- New `:LazyExtras` command for managing **LazyVim** extras
- Improved **formatting**:
- **LazyVim** can now work with multiple formatters. Types:
- **primary**: only one primary formatter can be active at a time.
_(conform, none-ls, LSP)_
- **secondary**: multiple secondary formatters can be active _(eslint, ...)_
- **LazyVim** automatically selects the primary formatter based on the
current available sources and priorities.
- New `:LazyFormat` command for formatting the current selection or buffer
- New `:LazyFormatInfo` command for displaying the active formatters
for the current buffer
- Auto-formatting can be disabled with:
```lua
vim.g.autoformat = false -- globally
vim.b.autoformat = false -- buffer-local
```
- `none-ls.nvim` is no longer installed by default
- `conform.nvim` is now the default formatter
- `nvim-lint` is now the default linter
- If you want to keep using `none-ls.nvim`,
you can enable the **lsp.none-ls** extra
- `dashboard.nvim` is the new default dashboard plugin
- If you want to keep using `alpha.nvim`, you can enable the **ui.alpha** extra
- Improved **root detection**:
- New `:LazyRoot` command that shows info about the root dir detection
- Configurable with `vim.g.root_spec`
```lua
-- LazyVim root dir detection
-- Each entry can be:
-- * the name of a detector function like `lsp` or `cwd`
-- * a pattern or array of patterns like `.git` or `lua`.
-- * a function with signature `function(buf) -> string|string[]`
vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" }
-- To disable root detection set to just "cwd"
vim.g.root_spec = { "cwd" }
```

View file

@ -54,7 +54,7 @@ LazyVim 提供了两全其美的方式 - 根据需要调整配置的灵活性,
## ⚡️ 要求 ## ⚡️ 要求
- Neovim >= **0.8.0** (需要用 **LuaJIT** 构建) - Neovim >= **0.9.0** (需要用 **LuaJIT** 构建)
- Git >= **2.19.0** (用于部分克隆支持) - Git >= **2.19.0** (用于部分克隆支持)
- 一个 [Nerd Font](https://www.nerdfonts.com/) 字体 **_(可选)_** - 一个 [Nerd Font](https://www.nerdfonts.com/) 字体 **_(可选)_**
- 一个用于 `nvim-treesitter`**C** 编译器。看 [这里](https://github.com/nvim-treesitter/nvim-treesitter#requirements) - 一个用于 `nvim-treesitter`**C** 编译器。看 [这里](https://github.com/nvim-treesitter/nvim-treesitter#requirements)

View file

@ -56,7 +56,7 @@ to tweak your config as needed, along with the convenience of a pre-configured s
## ⚡️ Requirements ## ⚡️ Requirements
- Neovim >= **0.8.0** (needs to be built with **LuaJIT**) - Neovim >= **0.9.0** (needs to be built with **LuaJIT**)
- Git >= **2.19.0** (for partial clones support) - Git >= **2.19.0** (for partial clones support)
- a [Nerd Font](https://www.nerdfonts.com/) **_(optional)_** - a [Nerd Font](https://www.nerdfonts.com/) **_(optional)_**
- a **C** compiler for `nvim-treesitter`. See [here](https://github.com/nvim-treesitter/nvim-treesitter#requirements) - a **C** compiler for `nvim-treesitter`. See [here](https://github.com/nvim-treesitter/nvim-treesitter#requirements)

View file

@ -1,4 +1,4 @@
*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 September 04 *LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 28
============================================================================== ==============================================================================
Table of Contents *LazyVim-table-of-contents* Table of Contents *LazyVim-table-of-contents*
@ -52,7 +52,7 @@ FEATURES *LazyVim-features*
REQUIREMENTS *LazyVim-requirements* REQUIREMENTS *LazyVim-requirements*
- Neovim >= **0.8.0** (needs to be built with **LuaJIT**) - Neovim >= **0.9.0** (needs to be built with **LuaJIT**)
- Git >= **2.19.0** (for partial clones support) - Git >= **2.19.0** (for partial clones support)
- a Nerd Font <https://www.nerdfonts.com/> **(optional)** - a Nerd Font <https://www.nerdfonts.com/> **(optional)**
- a **C** compiler for `nvim-treesitter`. See here <https://github.com/nvim-treesitter/nvim-treesitter#requirements> - a **C** compiler for `nvim-treesitter`. See here <https://github.com/nvim-treesitter/nvim-treesitter#requirements>

View file

@ -31,12 +31,13 @@ vim.api.nvim_create_autocmd({ "VimResized" }, {
-- go to last loc when opening a buffer -- go to last loc when opening a buffer
vim.api.nvim_create_autocmd("BufReadPost", { vim.api.nvim_create_autocmd("BufReadPost", {
group = augroup("last_loc"), group = augroup("last_loc"),
callback = function() callback = function(event)
local exclude = { "gitcommit" } local exclude = { "gitcommit" }
local buf = vim.api.nvim_get_current_buf() local buf = event.buf
if vim.tbl_contains(exclude, vim.bo[buf].filetype) then if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].lazyvim_last_loc then
return return
end end
vim.b[buf].lazyvim_last_loc = true
local mark = vim.api.nvim_buf_get_mark(buf, '"') local mark = vim.api.nvim_buf_get_mark(buf, '"')
local lcount = vim.api.nvim_buf_line_count(buf) local lcount = vim.api.nvim_buf_line_count(buf)
if mark[1] > 0 and mark[1] <= lcount then if mark[1] > 0 and mark[1] <= lcount then
@ -55,6 +56,7 @@ vim.api.nvim_create_autocmd("FileType", {
"man", "man",
"notify", "notify",
"qf", "qf",
"query",
"spectre_panel", "spectre_panel",
"startuptime", "startuptime",
"tsplayground", "tsplayground",

View file

@ -1,9 +1,11 @@
---@type LazyVimConfig local Util = require("lazyvim.util")
---@class LazyVimConfig: LazyVimOptions
local M = {} local M = {}
M.lazy_version = ">=9.1.0" M.version = "10.7.1" -- x-release-please-version
---@class LazyVimConfig ---@class LazyVimOptions
local defaults = { local defaults = {
-- colorscheme can be a string like `catppuccin` or a function that will load the colorscheme -- colorscheme can be a string like `catppuccin` or a function that will load the colorscheme
---@type string|fun() ---@type string|fun()
@ -17,104 +19,177 @@ local defaults = {
-- lazyvim.config.options can't be configured here since that's loaded before lazyvim setup -- lazyvim.config.options can't be configured here since that's loaded before lazyvim setup
-- if you want to disable loading options, add `package.loaded["lazyvim.config.options"] = true` to the top of your init.lua -- if you want to disable loading options, add `package.loaded["lazyvim.config.options"] = true` to the top of your init.lua
}, },
news = {
-- When enabled, NEWS.md will be shown when changed.
-- This only contains big new features and breaking changes.
lazyvim = true,
-- Same but for Neovim's news.txt
neovim = false,
},
-- icons used by other plugins -- icons used by other plugins
-- stylua: ignore
icons = { icons = {
misc = {
dots = "󰇘",
},
dap = { dap = {
Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" },
Breakpoint = "", Breakpoint = "",
BreakpointCondition = "", BreakpointCondition = "",
BreakpointRejected = { "", "DiagnosticError" }, BreakpointRejected = { "", "DiagnosticError" },
LogPoint = ".>", LogPoint = ".>",
}, },
diagnostics = { diagnostics = {
Error = "", Error = "",
Warn = "", Warn = "",
Hint = "", Hint = "",
Info = "", Info = "",
}, },
git = { git = {
added = "", added = "",
modified = "", modified = "",
removed = "", removed = "",
}, },
kinds = { kinds = {
Array = "", Array = "",
Boolean = "", Boolean = "󰨙 ",
Class = "", Class = "",
Color = "", Codeium = "󰘦 ",
Constant = "", Color = "",
Constructor = "", Control = "",
Copilot = "", Collapsed = "",
Enum = "", Constant = "󰏿 ",
EnumMember = "", Constructor = "",
Event = "", Copilot = "",
Field = "", Enum = "",
File = "", EnumMember = "",
Folder = "", Event = "",
Function = "", Field = "",
Interface = "", File = "",
Key = "", Folder = "",
Keyword = "", Function = "󰊕 ",
Method = "", Interface = "",
Module = "", Key = "",
Namespace = "", Keyword = "",
Null = "", Method = "󰊕 ",
Number = "", Module = "",
Object = "", Namespace = "󰦮 ",
Operator = "", Null = "",
Package = "", Number = "󰎠 ",
Property = "", Object = "",
Reference = "", Operator = "",
Snippet = "", Package = "",
String = "", Property = "",
Struct = "", Reference = "",
Text = "", Snippet = "",
String = "",
Struct = "󰆼 ",
TabNine = "󰏚 ",
Text = "",
TypeParameter = "", TypeParameter = "",
Unit = "", Unit = "",
Value = "", Value = "",
Variable = "", Variable = "󰀫 ",
},
},
---@type table<string, string[]|boolean>?
kind_filter = {
default = {
"Class",
"Constructor",
"Enum",
"Field",
"Function",
"Interface",
"Method",
"Module",
"Namespace",
"Package",
"Property",
"Struct",
"Trait",
},
markdown = false,
help = false,
-- you can specify a different filter for each filetype
lua = {
"Class",
"Constructor",
"Enum",
"Field",
"Function",
"Interface",
"Method",
"Module",
"Namespace",
-- "Package", -- remove package since luals uses it for control flow structures
"Property",
"Struct",
"Trait",
}, },
}, },
} }
M.renames = { M.json = {
["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre", version = 2,
data = {
version = nil, ---@type string?
news = {}, ---@type table<string, string>
extras = {}, ---@type string[]
},
} }
---@type LazyVimConfig function M.json.load()
local path = vim.fn.stdpath("config") .. "/lazyvim.json"
local f = io.open(path, "r")
if f then
local data = f:read("*a")
f:close()
local ok, json = pcall(vim.json.decode, data, { luanil = { object = true, array = true } })
if ok then
M.json.data = vim.tbl_deep_extend("force", M.json.data, json or {})
if M.json.data.version ~= M.json.version then
Util.json.migrate()
end
end
end
end
---@type LazyVimOptions
local options local options
---@param opts? LazyVimConfig ---@param opts? LazyVimOptions
function M.setup(opts) function M.setup(opts)
options = vim.tbl_deep_extend("force", defaults, opts or {}) options = vim.tbl_deep_extend("force", defaults, opts or {}) or {}
if not M.has() then
require("lazy.core.util").error(
"**LazyVim** needs **lazy.nvim** version "
.. M.lazy_version
.. " to work properly.\n"
.. "Please upgrade **lazy.nvim**",
{ title = "LazyVim" }
)
error("Exiting")
end
if vim.fn.argc(-1) == 0 then -- autocmds can be loaded lazily when not opening a file
-- autocmds and keymaps can wait to load local lazy_autocmds = vim.fn.argc(-1) == 0
vim.api.nvim_create_autocmd("User", { if not lazy_autocmds then
group = vim.api.nvim_create_augroup("LazyVim", { clear = true }),
pattern = "VeryLazy",
callback = function()
M.load("autocmds")
M.load("keymaps")
end,
})
else
-- load them now so they affect the opened buffers
M.load("autocmds") M.load("autocmds")
M.load("keymaps")
end end
require("lazy.core.util").try(function() local group = vim.api.nvim_create_augroup("LazyVim", { clear = true })
vim.api.nvim_create_autocmd("User", {
group = group,
pattern = "VeryLazy",
callback = function()
if lazy_autocmds then
M.load("autocmds")
end
M.load("keymaps")
Util.format.setup()
Util.news.setup()
Util.root.setup()
vim.api.nvim_create_user_command("LazyExtras", function()
Util.extras.show()
end, { desc = "Manage LazyVim extras" })
end,
})
Util.track("colorscheme")
Util.try(function()
if type(M.colorscheme) == "function" then if type(M.colorscheme) == "function" then
M.colorscheme() M.colorscheme()
else else
@ -123,34 +198,36 @@ function M.setup(opts)
end, { end, {
msg = "Could not load your colorscheme", msg = "Could not load your colorscheme",
on_error = function(msg) on_error = function(msg)
require("lazy.core.util").error(msg) Util.error(msg)
vim.cmd.colorscheme("habamax") vim.cmd.colorscheme("habamax")
end, end,
}) })
Util.track()
end end
---@param range? string ---@param buf? number
function M.has(range) ---@return string[]?
local Semver = require("lazy.manage.semver") function M.get_kind_filter(buf)
return Semver.range(range or M.lazy_version):matches(require("lazy.core.config").version or "0.0.0") buf = (buf == nil or buf == 0) and vim.api.nvim_get_current_buf() or buf
local ft = vim.bo[buf].filetype
if M.kind_filter == false then
return
end
if M.kind_filter[ft] == false then
return
end
---@diagnostic disable-next-line: return-type-mismatch
return type(M.kind_filter) == "table" and type(M.kind_filter.default) == "table" and M.kind_filter.default or nil
end end
---@param name "autocmds" | "options" | "keymaps" ---@param name "autocmds" | "options" | "keymaps"
function M.load(name) function M.load(name)
local Util = require("lazy.core.util")
local function _load(mod) local function _load(mod)
Util.try(function() if require("lazy.core.cache").find(mod)[1] then
require(mod) Util.try(function()
end, { require(mod)
msg = "Failed loading " .. mod, end, { msg = "Failed loading " .. mod })
on_error = function(msg) end
local info = require("lazy.core.cache").find(mod)
if info == nil or (type(info) == "table" and #info == 0) then
return
end
Util.error(msg)
end,
})
end end
-- always load lazyvim, then user file -- always load lazyvim, then user file
if M.defaults[name] or name == "options" then if M.defaults[name] or name == "options" then
@ -167,24 +244,30 @@ end
M.did_init = false M.did_init = false
function M.init() function M.init()
if not M.did_init then if M.did_init then
M.did_init = true return
-- delay notifications till vim.notify was replaced or after 500ms
require("lazyvim.util").lazy_notify()
-- load options here, before lazy init while sourcing plugin modules
-- this is needed to make sure options will be correctly applied
-- after installing missing plugins
require("lazyvim.config").load("options")
local Plugin = require("lazy.core.plugin")
local add = Plugin.Spec.add
Plugin.Spec.add = function(self, plugin, ...)
if type(plugin) == "table" and M.renames[plugin[1]] then
plugin[1] = M.renames[plugin[1]]
end
return add(self, plugin, ...)
end
end end
M.did_init = true
local plugin = require("lazy.core.config").spec.plugins.LazyVim
if plugin then
vim.opt.rtp:append(plugin.dir)
end
package.preload["lazyvim.plugins.lsp.format"] = function()
Util.deprecate([[require("lazyvim.plugins.lsp.format")]], [[require("lazyvim.util").format]])
return Util.format
end
-- delay notifications till vim.notify was replaced or after 500ms
require("lazyvim.util").lazy_notify()
-- load options here, before lazy init while sourcing plugin modules
-- this is needed to make sure options will be correctly applied
-- after installing missing plugins
M.load("options")
Util.plugin.setup()
M.json.load()
end end
setmetatable(M, { setmetatable(M, {

View file

@ -1,23 +1,15 @@
-- This file is automatically loaded by lazyvim.config.init -- This file is automatically loaded by lazyvim.config.init
local Util = require("lazyvim.util") local Util = require("lazyvim.util")
local function map(mode, lhs, rhs, opts) -- DO NOT USE THIS IN YOU OWN CONFIG!!
local keys = require("lazy.core.handler").handlers.keys -- use `vim.keymap.set` instead
---@cast keys LazyKeysHandler local map = Util.safe_keymap_set
-- do not create the keymap if a lazy keys handler exists
if not keys.active[keys.parse({ lhs, mode = mode }).id] then
opts = opts or {}
opts.silent = opts.silent ~= false
if opts.remap and not vim.g.vscode then
opts.remap = nil
end
vim.keymap.set(mode, lhs, rhs, opts)
end
end
-- better up/down -- better up/down
map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map({ "n", "x" }, "<Down>", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
map({ "n", "x" }, "<Up>", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
-- Move to window using the <ctrl> hjkl keys -- Move to window using the <ctrl> hjkl keys
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window", remap = true }) map("n", "<C-h>", "<C-w>h", { desc = "Go to left window", remap = true })
@ -40,17 +32,10 @@ map("v", "<A-j>", ":m '>+1<cr>gv=gv", { desc = "Move down" })
map("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move up" }) map("v", "<A-k>", ":m '<-2<cr>gv=gv", { desc = "Move up" })
-- buffers -- buffers
if Util.has("bufferline.nvim") then map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
map("n", "<S-h>", "<cmd>BufferLineCyclePrev<cr>", { desc = "Prev buffer" }) map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
map("n", "<S-l>", "<cmd>BufferLineCycleNext<cr>", { desc = "Next buffer" }) map("n", "[b", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
map("n", "[b", "<cmd>BufferLineCyclePrev<cr>", { desc = "Prev buffer" }) map("n", "]b", "<cmd>bnext<cr>", { desc = "Next buffer" })
map("n", "]b", "<cmd>BufferLineCycleNext<cr>", { desc = "Next buffer" })
else
map("n", "<S-h>", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
map("n", "<S-l>", "<cmd>bnext<cr>", { desc = "Next buffer" })
map("n", "[b", "<cmd>bprevious<cr>", { desc = "Prev buffer" })
map("n", "]b", "<cmd>bnext<cr>", { desc = "Next buffer" })
end
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" })
@ -67,10 +52,10 @@ map(
) )
-- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n -- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n
map("n", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) map("n", "n", "'Nn'[v:searchforward].'zv'", { expr = true, desc = "Next search result" })
map("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) map("x", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
map("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" }) map("o", "n", "'Nn'[v:searchforward]", { expr = true, desc = "Next search result" })
map("n", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) map("n", "N", "'nN'[v:searchforward].'zv'", { expr = true, desc = "Prev search result" })
map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) map("x", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) map("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" })
@ -98,44 +83,64 @@ map("n", "<leader>fn", "<cmd>enew<cr>", { desc = "New File" })
map("n", "<leader>xl", "<cmd>lopen<cr>", { desc = "Location List" }) map("n", "<leader>xl", "<cmd>lopen<cr>", { desc = "Location List" })
map("n", "<leader>xq", "<cmd>copen<cr>", { desc = "Quickfix List" }) map("n", "<leader>xq", "<cmd>copen<cr>", { desc = "Quickfix List" })
if not Util.has("trouble.nvim") then map("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" })
map("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" }) map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" })
map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" })
-- formatting
map({ "n", "v" }, "<leader>cf", function()
Util.format({ force = true })
end, { desc = "Format" })
-- diagnostic
local diagnostic_goto = function(next, severity)
local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev
severity = severity and vim.diagnostic.severity[severity] or nil
return function()
go({ severity = severity })
end
end end
map("n", "<leader>cd", vim.diagnostic.open_float, { desc = "Line Diagnostics" })
map("n", "]d", diagnostic_goto(true), { desc = "Next Diagnostic" })
map("n", "[d", diagnostic_goto(false), { desc = "Prev Diagnostic" })
map("n", "]e", diagnostic_goto(true, "ERROR"), { desc = "Next Error" })
map("n", "[e", diagnostic_goto(false, "ERROR"), { desc = "Prev Error" })
map("n", "]w", diagnostic_goto(true, "WARN"), { desc = "Next Warning" })
map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" })
-- stylua: ignore start -- stylua: ignore start
-- toggle options -- toggle options
map("n", "<leader>uf", require("lazyvim.plugins.lsp.format").toggle, { desc = "Toggle format on Save" }) map("n", "<leader>uf", function() Util.format.toggle() end, { desc = "Toggle auto format (global)" })
map("n", "<leader>uF", function() Util.format.toggle(true) end, { desc = "Toggle auto format (buffer)" })
map("n", "<leader>us", function() Util.toggle("spell") end, { desc = "Toggle Spelling" }) map("n", "<leader>us", function() Util.toggle("spell") end, { desc = "Toggle Spelling" })
map("n", "<leader>uw", function() Util.toggle("wrap") end, { desc = "Toggle Word Wrap" }) map("n", "<leader>uw", function() Util.toggle("wrap") end, { desc = "Toggle Word Wrap" })
map("n", "<leader>ul", function() Util.toggle_number() end, { desc = "Toggle Line Numbers" }) map("n", "<leader>uL", function() Util.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" })
map("n", "<leader>ud", Util.toggle_diagnostics, { desc = "Toggle Diagnostics" }) map("n", "<leader>ul", function() Util.toggle.number() end, { desc = "Toggle Line Numbers" })
map("n", "<leader>ud", function() Util.toggle.diagnostics() end, { desc = "Toggle Diagnostics" })
local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3 local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3
map("n", "<leader>uc", function() Util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" }) map("n", "<leader>uc", function() Util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" })
if vim.lsp.inlay_hint then if vim.lsp.inlay_hint then
map("n", "<leader>uh", function() vim.lsp.inlay_hint(0, nil) end, { desc = "Toggle Inlay Hints" }) map("n", "<leader>uh", function() vim.lsp.inlay_hint(0, nil) end, { desc = "Toggle Inlay Hints" })
end end
map("n", "<leader>uT", function() if vim.b.ts_highlight then vim.treesitter.stop() else vim.treesitter.start() end end, { desc = "Toggle Treesitter Highlight" })
-- lazygit -- lazygit
map("n", "<leader>gg", function() Util.float_term({ "lazygit" }, { cwd = Util.get_root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) map("n", "<leader>gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" })
map("n", "<leader>gG", function() Util.float_term({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) map("n", "<leader>gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" })
-- quit -- quit
map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit all" }) map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit all" })
-- highlights under cursor -- highlights under cursor
if vim.fn.has("nvim-0.9.0") == 1 then map("n", "<leader>ui", vim.show_pos, { desc = "Inspect Pos" })
map("n", "<leader>ui", vim.show_pos, { desc = "Inspect Pos" })
end
-- LazyVim Changelog -- LazyVim Changelog
map("n", "<leader>L", Util.changelog, {desc = "LazyVim Changelog"}) map("n", "<leader>L", function() Util.news.changelog() end, { desc = "LazyVim Changelog" })
-- floating terminal -- floating terminal
local lazyterm = function() Util.float_term(nil, { cwd = Util.get_root() }) end local lazyterm = function() Util.terminal(nil, { cwd = Util.root() }) end
map("n", "<leader>ft", lazyterm, { desc = "Terminal (root dir)" }) map("n", "<leader>ft", lazyterm, { desc = "Terminal (root dir)" })
map("n", "<leader>fT", function() Util.float_term() end, { desc = "Terminal (cwd)" }) map("n", "<leader>fT", function() Util.terminal() end, { desc = "Terminal (cwd)" })
map("n", "<c-/>", lazyterm, { desc = "Terminal (root dir)" }) map("n", "<c-/>", lazyterm, { desc = "Terminal (root dir)" })
map("n", "<c-_>", lazyterm, { desc = "which_key_ignore" }) map("n", "<c-_>", lazyterm, { desc = "which_key_ignore" })

View file

@ -2,6 +2,16 @@
vim.g.mapleader = " " vim.g.mapleader = " "
vim.g.maplocalleader = "\\" vim.g.maplocalleader = "\\"
-- Enable LazyVim auto format
vim.g.autoformat = true
-- LazyVim root dir detection
-- Each entry can be:
-- * the name of a detector function like `lsp` or `cwd`
-- * a pattern or array of patterns like `.git` or `lua`.
-- * a function with signature `function(buf) -> string|string[]`
vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" }
local opt = vim.opt local opt = vim.opt
opt.autowrite = true -- Enable auto write opt.autowrite = true -- Enable auto write
@ -16,7 +26,7 @@ opt.grepformat = "%f:%l:%c:%m"
opt.grepprg = "rg --vimgrep" opt.grepprg = "rg --vimgrep"
opt.ignorecase = true -- Ignore case opt.ignorecase = true -- Ignore case
opt.inccommand = "nosplit" -- preview incremental substitute opt.inccommand = "nosplit" -- preview incremental substitute
opt.laststatus = 0 opt.laststatus = 3 -- global statusline
opt.list = true -- Show some invisible characters (tabs... opt.list = true -- Show some invisible characters (tabs...
opt.mouse = "a" -- Enable mouse mode opt.mouse = "a" -- Enable mouse mode
opt.number = true -- Print line number opt.number = true -- Print line number
@ -24,10 +34,10 @@ 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.scrolloff = 4 -- Lines of context opt.scrolloff = 4 -- Lines of context
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" } opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp", "folds" }
opt.shiftround = true -- Round indent opt.shiftround = true -- Round indent
opt.shiftwidth = 2 -- Size of an indent opt.shiftwidth = 2 -- Size of an indent
opt.shortmess:append({ W = true, I = true, c = true }) opt.shortmess:append({ W = true, I = true, c = true, C = true })
opt.showmode = false -- Dont show mode since we have a statusline opt.showmode = false -- Dont show mode since we have a statusline
opt.sidescrolloff = 8 -- Columns of context opt.sidescrolloff = 8 -- Columns of context
opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
@ -35,6 +45,7 @@ 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.splitbelow = true -- Put new windows below current opt.splitbelow = true -- Put new windows below current
opt.splitkeep = "screen"
opt.splitright = true -- Put new windows right of current opt.splitright = true -- Put new windows right of current
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
@ -42,14 +53,41 @@ opt.timeoutlen = 300
opt.undofile = true opt.undofile = true
opt.undolevels = 10000 opt.undolevels = 10000
opt.updatetime = 200 -- Save swap file and trigger CursorHold opt.updatetime = 200 -- Save swap file and trigger CursorHold
opt.virtualedit = "block" -- Allow cursor to move where there is no text in visual block mode
opt.wildmode = "longest:full,full" -- Command-line completion mode opt.wildmode = "longest:full,full" -- Command-line completion mode
opt.winminwidth = 5 -- Minimum window width opt.winminwidth = 5 -- Minimum window width
opt.wrap = false -- Disable line wrap opt.wrap = false -- Disable line wrap
opt.fillchars = {
foldopen = "",
foldclose = "",
-- fold = "⸱",
fold = " ",
foldsep = " ",
diff = "",
eob = " ",
}
if vim.fn.has("nvim-0.10") == 1 then
opt.smoothscroll = true
end
-- Folding
vim.opt.foldlevel = 99
vim.opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()"
if vim.fn.has("nvim-0.9.0") == 1 then if vim.fn.has("nvim-0.9.0") == 1 then
opt.splitkeep = "screen" vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util'.ui.statuscolumn()]]
opt.shortmess:append({ C = true })
end end
-- HACK: causes freezes on <= 0.9, so only enable on >= 0.10 for now
if vim.fn.has("nvim-0.10") == 1 then
vim.opt.foldmethod = "expr"
vim.opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()"
else
vim.opt.foldmethod = "indent"
end
vim.o.formatexpr = "v:lua.require'lazyvim.util'.format.formatexpr()"
-- Fix markdown indentation settings -- Fix markdown indentation settings
vim.g.markdown_recommended_style = 0 vim.g.markdown_recommended_style = 0

View file

@ -8,10 +8,10 @@ local error = vim.health.error or vim.health.report_error
function M.check() function M.check()
start("LazyVim") start("LazyVim")
if vim.fn.has("nvim-0.8.0") == 1 then if vim.fn.has("nvim-0.9.0") == 1 then
ok("Using Neovim >= 0.8.0") ok("Using Neovim >= 0.9.0")
else else
error("Neovim >= 0.8.0 is required") error("Neovim >= 0.9.0 is required")
end end
for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit" }) do for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit" }) do

View file

@ -66,12 +66,17 @@ return {
behavior = cmp.ConfirmBehavior.Replace, behavior = cmp.ConfirmBehavior.Replace,
select = true, select = true,
}), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<C-CR>"] = function(fallback)
cmp.abort()
fallback()
end,
}), }),
sources = cmp.config.sources({ sources = cmp.config.sources({
{ name = "nvim_lsp" }, { name = "nvim_lsp" },
{ name = "luasnip" }, { name = "luasnip" },
{ name = "buffer" },
{ name = "path" }, { name = "path" },
}, {
{ name = "buffer" },
}), }),
formatting = { formatting = {
format = function(_, item) format = function(_, item)
@ -90,6 +95,13 @@ return {
sorting = defaults.sorting, sorting = defaults.sorting,
} }
end, end,
---@param opts cmp.ConfigSchema
config = function(_, opts)
for _, source in ipairs(opts.sources) do
source.group_index = source.group_index or 1
end
require("cmp").setup(opts)
end,
}, },
-- auto pairs -- auto pairs
@ -97,6 +109,21 @@ return {
"echasnovski/mini.pairs", "echasnovski/mini.pairs",
event = "VeryLazy", event = "VeryLazy",
opts = {}, opts = {},
keys = {
{
"<leader>up",
function()
local Util = require("lazy.core.util")
vim.g.minipairs_disable = not vim.g.minipairs_disable
if vim.g.minipairs_disable then
Util.warn("Disabled auto pairs", { title = "Option" })
else
Util.info("Enabled auto pairs", { title = "Option" })
end
end,
desc = "Toggle auto pairs",
},
},
}, },
-- Fast and feature-rich surround actions. For text that includes -- Fast and feature-rich surround actions. For text that includes
@ -125,19 +152,25 @@ return {
end, end,
opts = { opts = {
mappings = { mappings = {
add = "gza", -- Add surrounding in Normal and Visual modes add = "gsa", -- Add surrounding in Normal and Visual modes
delete = "gzd", -- Delete surrounding delete = "gsd", -- Delete surrounding
find = "gzf", -- Find surrounding (to the right) find = "gsf", -- Find surrounding (to the right)
find_left = "gzF", -- Find surrounding (to the left) find_left = "gsF", -- Find surrounding (to the left)
highlight = "gzh", -- Highlight surrounding highlight = "gsh", -- Highlight surrounding
replace = "gzr", -- Replace surrounding replace = "gsr", -- Replace surrounding
update_n_lines = "gzn", -- Update `n_lines` update_n_lines = "gsn", -- Update `n_lines`
}, },
}, },
}, },
-- comments -- comments
{ "JoosepAlviste/nvim-ts-context-commentstring", lazy = true }, {
"JoosepAlviste/nvim-ts-context-commentstring",
lazy = true,
opts = {
enable_autocmd = false,
},
},
{ {
"echasnovski/mini.comment", "echasnovski/mini.comment",
event = "VeryLazy", event = "VeryLazy",
@ -158,7 +191,6 @@ return {
-- { "i", mode = { "x", "o" } }, -- { "i", mode = { "x", "o" } },
-- }, -- },
event = "VeryLazy", event = "VeryLazy",
dependencies = { "nvim-treesitter-textobjects" },
opts = function() opts = function()
local ai = require("mini.ai") local ai = require("mini.ai")
return { return {
@ -170,6 +202,7 @@ return {
}, {}), }, {}),
f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {}), f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {}),
c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }, {}), c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }, {}),
t = { "<([%p%w]-)%f[^<%w][^<>]->.-</%1>", "^<.->().*()</[^/]->$" },
}, },
} }
end, end,

View file

@ -1,6 +0,0 @@
require("lazyvim.config").init()
return {
{ "folke/lazy.nvim", version = "*" },
{ "LazyVim/LazyVim", priority = 10000, lazy = false, config = true, cond = true, version = "*" },
}

View file

@ -11,7 +11,7 @@ return {
{ {
"<leader>fe", "<leader>fe",
function() function()
require("neo-tree.command").execute({ toggle = true, dir = require("lazyvim.util").get_root() }) require("neo-tree.command").execute({ toggle = true, dir = Util.root() })
end, end,
desc = "Explorer NeoTree (root dir)", desc = "Explorer NeoTree (root dir)",
}, },
@ -24,12 +24,26 @@ return {
}, },
{ "<leader>e", "<leader>fe", desc = "Explorer NeoTree (root dir)", remap = true }, { "<leader>e", "<leader>fe", desc = "Explorer NeoTree (root dir)", remap = true },
{ "<leader>E", "<leader>fE", desc = "Explorer NeoTree (cwd)", remap = true }, { "<leader>E", "<leader>fE", desc = "Explorer NeoTree (cwd)", remap = true },
{
"<leader>ge",
function()
require("neo-tree.command").execute({ source = "git_status", toggle = true })
end,
desc = "Git explorer",
},
{
"<leader>be",
function()
require("neo-tree.command").execute({ source = "buffers", toggle = true })
end,
desc = "Buffer explorer",
},
}, },
deactivate = function() deactivate = function()
vim.cmd([[Neotree close]]) vim.cmd([[Neotree close]])
end, end,
init = function() init = function()
if vim.fn.argc() == 1 then if vim.fn.argc(-1) == 1 then
local stat = vim.loop.fs_stat(vim.fn.argv(0)) local stat = vim.loop.fs_stat(vim.fn.argv(0))
if stat and stat.type == "directory" then if stat and stat.type == "directory" then
require("neo-tree") require("neo-tree")
@ -38,7 +52,7 @@ return {
end, end,
opts = { opts = {
sources = { "filesystem", "buffers", "git_status", "document_symbols" }, sources = { "filesystem", "buffers", "git_status", "document_symbols" },
open_files_do_not_replace_types = { "terminal", "Trouble", "qf", "Outline" }, open_files_do_not_replace_types = { "terminal", "Trouble", "trouble", "qf", "Outline" },
filesystem = { filesystem = {
bind_to_cwd = false, bind_to_cwd = false,
follow_current_file = { enabled = true }, follow_current_file = { enabled = true },
@ -59,6 +73,16 @@ return {
}, },
}, },
config = function(_, opts) config = function(_, opts)
local function on_move(data)
Util.lsp.on_rename(data.source, data.destination)
end
local events = require("neo-tree.events")
opts.event_handlers = opts.event_handlers or {}
vim.list_extend(opts.event_handlers, {
{ event = events.FILE_MOVED, handler = on_move },
{ event = events.FILE_RENAMED, handler = on_move },
})
require("neo-tree").setup(opts) require("neo-tree").setup(opts)
vim.api.nvim_create_autocmd("TermClose", { vim.api.nvim_create_autocmd("TermClose", {
pattern = "*lazygit", pattern = "*lazygit",
@ -82,19 +106,38 @@ return {
}, },
}, },
-- fuzzy finder -- Fuzzy finder.
-- The default key bindings to find files will use Telescope's
-- `find_files` or `git_files` depending on whether the
-- directory is a git repo.
{ {
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
commit = vim.fn.has("nvim-0.9.0") == 0 and "057ee0f8783" or nil,
cmd = "Telescope", cmd = "Telescope",
version = false, -- telescope did only one release, so use HEAD for now version = false, -- telescope did only one release, so use HEAD for now
dependencies = {
{
"nvim-telescope/telescope-fzf-native.nvim",
build = "make",
enabled = vim.fn.executable("make") == 1,
config = function()
Util.on_load("telescope.nvim", function()
require("telescope").load_extension("fzf")
end)
end,
},
},
keys = { keys = {
{ "<leader>,", "<cmd>Telescope buffers show_all_buffers=true<cr>", desc = "Switch Buffer" }, {
"<leader>,",
"<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>",
desc = "Switch Buffer",
},
{ "<leader>/", Util.telescope("live_grep"), desc = "Grep (root dir)" }, { "<leader>/", Util.telescope("live_grep"), desc = "Grep (root dir)" },
{ "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" }, { "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" },
{ "<leader><space>", Util.telescope("files"), desc = "Find Files (root dir)" }, { "<leader><space>", Util.telescope("files"), desc = "Find Files (root dir)" },
-- find -- find
{ "<leader>fb", "<cmd>Telescope buffers<cr>", desc = "Buffers" }, { "<leader>fb", "<cmd>Telescope buffers sort_mru=true sort_lastused=true<cr>", desc = "Buffers" },
{ "<leader>fc", Util.telescope.config_files(), desc = "Find Config File" },
{ "<leader>ff", Util.telescope("files"), desc = "Find Files (root dir)" }, { "<leader>ff", Util.telescope("files"), desc = "Find Files (root dir)" },
{ "<leader>fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" }, { "<leader>fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" },
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" }, { "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
@ -126,109 +169,79 @@ return {
{ "<leader>uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" }, { "<leader>uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" },
{ {
"<leader>ss", "<leader>ss",
Util.telescope("lsp_document_symbols", { function()
symbols = { require("telescope.builtin").lsp_document_symbols({
"Class", symbols = require("lazyvim.config").get_kind_filter(),
"Function", })
"Method", end,
"Constructor",
"Interface",
"Module",
"Struct",
"Trait",
"Field",
"Property",
},
}),
desc = "Goto Symbol", desc = "Goto Symbol",
}, },
{ {
"<leader>sS", "<leader>sS",
Util.telescope("lsp_dynamic_workspace_symbols", { function()
symbols = { require("telescope.builtin").lsp_dynamic_workspace_symbols({
"Class", symbols = require("lazyvim.config").get_kind_filter(),
"Function", })
"Method", end,
"Constructor",
"Interface",
"Module",
"Struct",
"Trait",
"Field",
"Property",
},
}),
desc = "Goto Symbol (Workspace)", desc = "Goto Symbol (Workspace)",
}, },
}, },
opts = { opts = function()
defaults = { local actions = require("telescope.actions")
prompt_prefix = "",
selection_caret = "", local open_with_trouble = function(...)
mappings = { return require("trouble.providers.telescope").open_with_trouble(...)
i = { end
["<c-t>"] = function(...) local open_selected_with_trouble = function(...)
return require("trouble.providers.telescope").open_with_trouble(...) return require("trouble.providers.telescope").open_selected_with_trouble(...)
end, end
["<a-t>"] = function(...) local find_files_no_ignore = function()
return require("trouble.providers.telescope").open_selected_with_trouble(...) local action_state = require("telescope.actions.state")
end, local line = action_state.get_current_line()
["<a-i>"] = function() Util.telescope("find_files", { no_ignore = true, default_text = line })()
local action_state = require("telescope.actions.state") end
local line = action_state.get_current_line() local find_files_with_hidden = function()
Util.telescope("find_files", { no_ignore = true, default_text = line })() local action_state = require("telescope.actions.state")
end, local line = action_state.get_current_line()
["<a-h>"] = function() Util.telescope("find_files", { hidden = true, default_text = line })()
local action_state = require("telescope.actions.state") end
local line = action_state.get_current_line()
Util.telescope("find_files", { hidden = true, default_text = line })() return {
end, defaults = {
["<C-Down>"] = function(...) prompt_prefix = "",
return require("telescope.actions").cycle_history_next(...) selection_caret = "",
end, -- open files in the first window that is an actual file.
["<C-Up>"] = function(...) -- use the current window if no other window is available.
return require("telescope.actions").cycle_history_prev(...) get_selection_window = function()
end, local wins = vim.api.nvim_list_wins()
["<C-f>"] = function(...) table.insert(wins, 1, vim.api.nvim_get_current_win())
return require("telescope.actions").preview_scrolling_down(...) for _, win in ipairs(wins) do
end, local buf = vim.api.nvim_win_get_buf(win)
["<C-b>"] = function(...) if vim.bo[buf].buftype == "" then
return require("telescope.actions").preview_scrolling_up(...) return win
end, end
}, end
n = { return 0
["q"] = function(...) end,
return require("telescope.actions").close(...) mappings = {
end, i = {
["<c-t>"] = open_with_trouble,
["<a-t>"] = open_selected_with_trouble,
["<a-i>"] = find_files_no_ignore,
["<a-h>"] = find_files_with_hidden,
["<C-Down>"] = actions.cycle_history_next,
["<C-Up>"] = actions.cycle_history_prev,
["<C-f>"] = actions.preview_scrolling_down,
["<C-b>"] = actions.preview_scrolling_up,
},
n = {
["q"] = actions.close,
},
}, },
}, },
}, }
},
},
-- disable old installations of leap and flit. Optional so it doesn't appear under disabled plugins
{
"ggandor/leap.nvim",
enabled = function()
vim.schedule(function()
local Config = require("lazy.core.config")
if Config.spec.disabled["leap.nvim"] or Config.spec.disabled["flit.nvim"] then
require("lazy.core.util").warn(
[[`flash.nvim` is now the default **LazyVim** jump plugin.
**leap.nvim** and **flit.nvim** have been disabled.
Please remove the plugins from your config.
If you rather use leap/flit instead, you can add the leap extra:
`lazyvim.plugins.extras.editor.leap`
]],
{ title = "LazyVim" }
)
end
end)
return false
end, end,
optional = true,
}, },
{ "ggandor/flit.nvim", enabled = false, optional = true },
-- Flash enhances the built-in search functionality by showing labels -- Flash enhances the built-in search functionality by showing labels
-- at the end of each match, letting you quickly jump to a specific -- at the end of each match, letting you quickly jump to a specific
@ -254,7 +267,7 @@ If you rather use leap/flit instead, you can add the leap extra:
"nvim-telescope/telescope.nvim", "nvim-telescope/telescope.nvim",
optional = true, optional = true,
opts = function(_, opts) opts = function(_, opts)
if not require("lazyvim.util").has("flash.nvim") then if not Util.has("flash.nvim") then
return return
end end
local function flash(prompt_bufnr) local function flash(prompt_bufnr)
@ -291,7 +304,7 @@ If you rather use leap/flit instead, you can add the leap extra:
defaults = { defaults = {
mode = { "n", "v" }, mode = { "n", "v" },
["g"] = { name = "+goto" }, ["g"] = { name = "+goto" },
["gz"] = { name = "+surround" }, ["gs"] = { name = "+surround" },
["]"] = { name = "+next" }, ["]"] = { name = "+next" },
["["] = { name = "+prev" }, ["["] = { name = "+prev" },
["<leader><tab>"] = { name = "+tabs" }, ["<leader><tab>"] = { name = "+tabs" },
@ -319,7 +332,7 @@ If you rather use leap/flit instead, you can add the leap extra:
-- hunks in a commit. -- hunks in a commit.
{ {
"lewis6991/gitsigns.nvim", "lewis6991/gitsigns.nvim",
event = { "BufReadPre", "BufNewFile" }, event = "LazyFile",
opts = { opts = {
signs = { signs = {
add = { text = "" }, add = { text = "" },
@ -358,7 +371,7 @@ If you rather use leap/flit instead, you can add the leap extra:
-- instances. -- instances.
{ {
"RRethy/vim-illuminate", "RRethy/vim-illuminate",
event = { "BufReadPost", "BufNewFile" }, event = "LazyFile",
opts = { opts = {
delay = 200, delay = 200,
large_file_cutoff = 2000, large_file_cutoff = 2000,
@ -396,9 +409,27 @@ If you rather use leap/flit instead, you can add the leap extra:
-- buffer remove -- buffer remove
{ {
"echasnovski/mini.bufremove", "echasnovski/mini.bufremove",
-- stylua: ignore
keys = { keys = {
{ "<leader>bd", function() require("mini.bufremove").delete(0, false) end, desc = "Delete Buffer" }, {
"<leader>bd",
function()
local bd = require("mini.bufremove").delete
if vim.bo.modified then
local choice = vim.fn.confirm(("Save changes to %q?"):format(vim.fn.bufname()), "&Yes\n&No\n&Cancel")
if choice == 1 then -- Yes
vim.cmd.write()
bd(0)
elseif choice == 2 then -- No
bd(0, true)
end
else
bd(0)
end
end,
desc = "Delete Buffer",
},
-- stylua: ignore
{ "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" }, { "<leader>bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" },
}, },
}, },
@ -449,7 +480,7 @@ If you rather use leap/flit instead, you can add the leap extra:
{ {
"folke/todo-comments.nvim", "folke/todo-comments.nvim",
cmd = { "TodoTrouble", "TodoTelescope" }, cmd = { "TodoTrouble", "TodoTelescope" },
event = { "BufReadPost", "BufNewFile" }, event = "LazyFile",
config = true, config = true,
-- stylua: ignore -- stylua: ignore
keys = { keys = {

View file

@ -0,0 +1,33 @@
return {
-- codeium cmp source
{
"nvim-cmp",
dependencies = {
-- codeium
{
"Exafunction/codeium.nvim",
cmd = "Codeium",
build = ":Codeium Auth",
opts = {},
},
},
---@param opts cmp.ConfigSchema
opts = function(_, opts)
table.insert(opts.sources, 1, {
name = "codeium",
group_index = 1,
priority = 100,
})
end,
},
{
"nvim-lualine/lualine.nvim",
optional = true,
event = "VeryLazy",
opts = function(_, opts)
table.insert(opts.sections.lualine_x, 2, require("lazyvim.util").lualine.cmp_source("codeium"))
end,
},
}

View file

@ -21,10 +21,10 @@ return {
opts = function(_, opts) opts = function(_, opts)
local Util = require("lazyvim.util") local Util = require("lazyvim.util")
local colors = { local colors = {
[""] = Util.fg("Special"), [""] = Util.ui.fg("Special"),
["Normal"] = Util.fg("Special"), ["Normal"] = Util.ui.fg("Special"),
["Warning"] = Util.fg("DiagnosticError"), ["Warning"] = Util.ui.fg("DiagnosticError"),
["InProgress"] = Util.fg("DiagnosticWarn"), ["InProgress"] = Util.ui.fg("DiagnosticWarn"),
} }
table.insert(opts.sections.lualine_x, 2, { table.insert(opts.sections.lualine_x, 2, {
function() function()
@ -33,7 +33,13 @@ return {
return icon .. (status.message or "") return icon .. (status.message or "")
end, end,
cond = function() cond = function()
local ok, clients = pcall(vim.lsp.get_active_clients, { name = "copilot", bufnr = 0 }) if not package.loaded["copilot"] then
return
end
local ok, clients = pcall(require("lazyvim.util").lsp.get_clients, { name = "copilot", bufnr = 0 })
if not ok then
return false
end
return ok and #clients > 0 return ok and #clients > 0
end, end,
color = function() color = function()
@ -60,7 +66,7 @@ return {
copilot_cmp.setup(opts) copilot_cmp.setup(opts)
-- attach cmp source whenever copilot attaches -- attach cmp source whenever copilot attaches
-- fixes lazy-loading issues with the copilot cmp source -- fixes lazy-loading issues with the copilot cmp source
require("lazyvim.util").on_attach(function(client) require("lazyvim.util").lsp.on_attach(function(client)
if client.name == "copilot" then if client.name == "copilot" then
copilot_cmp._on_insert_enter({}) copilot_cmp._on_insert_enter({})
end end
@ -70,9 +76,11 @@ return {
}, },
---@param opts cmp.ConfigSchema ---@param opts cmp.ConfigSchema
opts = function(_, opts) opts = function(_, opts)
table.insert(opts.sources, 1, { name = "copilot", group_index = 2 }) table.insert(opts.sources, 1, {
opts.sorting = opts.sorting or require("cmp.config.default")().sorting name = "copilot",
table.insert(opts.sorting.comparators, 1, require("copilot_cmp.comparators").prioritize) group_index = 1,
priority = 100,
})
end, end,
}, },
} }

View file

@ -0,0 +1,51 @@
local Util = require("lazyvim.util")
return {
-- Tabnine cmp source
{
"nvim-cmp",
dependencies = {
{
"tzachar/cmp-tabnine",
build = {
Util.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh",
":CmpTabnineHub",
},
dependencies = "hrsh7th/nvim-cmp",
opts = {
max_lines = 1000,
max_num_results = 3,
sort = true,
},
config = function(_, opts)
require("cmp_tabnine.config"):setup(opts)
end,
},
},
---@param opts cmp.ConfigSchema
opts = function(_, opts)
table.insert(opts.sources, 1, {
name = "cmp_tabnine",
group_index = 1,
priority = 100,
})
opts.formatting.format = Util.inject.args(opts.formatting.format, function(entry, item)
-- Hide percentage in the menu
if entry.source.name == "cmp_tabnine" then
item.menu = ""
end
end)
end,
},
-- Show TabNine status in lualine
{
"nvim-lualine/lualine.nvim",
optional = true,
event = "VeryLazy",
opts = function(_, opts)
local icon = require("lazyvim.config").icons.kinds.TabNine
table.insert(opts.sections.lualine_x, 2, require("lazyvim.util").lualine.cmp_source("cmp_tabnine", icon))
end,
},
}

View file

@ -3,21 +3,10 @@ return {
{ {
"gbprod/yanky.nvim", "gbprod/yanky.nvim",
dependencies = { { "kkharji/sqlite.lua", enabled = not jit.os:find("Windows") } }, dependencies = { { "kkharji/sqlite.lua", enabled = not jit.os:find("Windows") } },
opts = function() opts = {
local mapping = require("yanky.telescope.mapping") highlight = { timer = 250 },
local mappings = mapping.get_defaults() ring = { storage = jit.os:find("Windows") and "shada" or "sqlite" },
mappings.i["<c-p>"] = nil },
return {
highlight = { timer = 200 },
ring = { storage = jit.os:find("Windows") and "shada" or "sqlite" },
picker = {
telescope = {
use_default_mappings = false,
mappings = mappings,
},
},
}
end,
keys = { keys = {
-- stylua: ignore -- stylua: ignore
{ "<leader>p", function() require("telescope").extensions.yank_history.yank_history({ }) end, desc = "Open Yank History" }, { "<leader>p", function() require("telescope").extensions.yank_history.yank_history({ }) end, desc = "Open Yank History" },

View file

@ -1,3 +1,15 @@
---@param config {args?:string[]|fun():string[]?}
local function get_args(config)
local args = type(config.args) == "function" and (config.args() or {}) or config.args or {}
config = vim.deepcopy(config)
---@cast args string[]
config.args = function()
local new_args = vim.fn.input("Run with args: ", table.concat(args, " ")) --[[@as string]]
return vim.split(vim.fn.expand(new_args) --[[@as string]], " ")
end
return config
end
return { return {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
@ -13,6 +25,8 @@ return {
}, },
opts = {}, opts = {},
config = function(_, opts) config = function(_, opts)
-- setup dap config by VsCode launch.json file
-- require("dap.ext.vscode").load_launchjs()
local dap = require("dap") local dap = require("dap")
local dapui = require("dapui") local dapui = require("dapui")
dapui.setup(opts) dapui.setup(opts)
@ -41,7 +55,6 @@ return {
opts = { opts = {
defaults = { defaults = {
["<leader>d"] = { name = "+debug" }, ["<leader>d"] = { name = "+debug" },
["<leader>da"] = { name = "+adapters" },
}, },
}, },
}, },
@ -74,6 +87,7 @@ return {
{ "<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 = "Continue" },
{ "<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)" },
{ "<leader>di", function() require("dap").step_into() end, desc = "Step Into" }, { "<leader>di", function() require("dap").step_into() end, desc = "Step Into" },

View file

@ -1,24 +1,40 @@
return { return {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
dependencies = { dependencies = {
{ {
"jbyuki/one-small-step-for-vimkind", "jbyuki/one-small-step-for-vimkind",
-- stylua: ignore -- stylua: ignore
keys = {
{ "<leader>daL", function() require("osv").launch({ port = 8086 }) end, desc = "Adapter Lua Server" },
{ "<leader>dal", function() require("osv").run_this() end, desc = "Adapter Lua" },
},
config = function() config = function()
local dap = require("dap") local dap = require("dap")
dap.adapters.nlua = function(callback, config) dap.adapters.nlua = function(callback, conf)
callback({ type = "server", host = config.host or "127.0.0.1", port = config.port or 8086 }) local adapter = {
type = "server",
host = conf.host or "127.0.0.1",
port = conf.port or 8086,
}
if conf.start_neovim then
local dap_run = dap.run
dap.run = function(c)
adapter.port = c.port
adapter.host = c.host
end
require("osv").run_this()
dap.run = dap_run
end
callback(adapter)
end end
dap.configurations.lua = { dap.configurations.lua = {
{ {
type = "nlua", type = "nlua",
request = "attach", request = "attach",
name = "Attach to running Neovim instance", name = "Run this file",
start_neovim = {},
},
{
type = "nlua",
request = "attach",
name = "Attach to running Neovim instance (port = 8086)",
port = 8086,
}, },
} }
end, end,

View file

@ -0,0 +1,123 @@
local Config = require("lazyvim.config")
local Util = require("lazyvim.util")
return {
desc = "Aerial Symbol Browser",
{
"stevearc/aerial.nvim",
event = "LazyFile",
opts = function()
local icons = vim.deepcopy(Config.icons.kinds)
-- HACK: fix lua's weird choice for `Package` for control
-- structures like if/else/for/etc.
icons.lua = { Package = icons.Control }
---@type table<string, string[]>|false
local filter_kind = false
if Config.kind_filter then
filter_kind = assert(vim.deepcopy(Config.kind_filter))
filter_kind._ = filter_kind.default
filter_kind.default = nil
end
local opts = {
attach_mode = "global",
backends = { "lsp", "treesitter", "markdown", "man" },
show_guides = true,
layout = {
resize_to_content = false,
win_opts = {
winhl = "Normal:NormalFloat,FloatBorder:NormalFloat,SignColumn:SignColumnSB",
signcolumn = "yes",
statuscolumn = " ",
},
},
icons = icons,
filter_kind = filter_kind,
-- stylua: ignore
guides = {
mid_item = "├╴",
last_item = "└╴",
nested_top = "",
whitespace = " ",
},
}
return opts
end,
keys = {
{ "<leader>cs", "<cmd>AerialToggle<cr>", desc = "Aerial (Symbols)" },
},
},
-- Telescope integration
{
"nvim-telescope/telescope.nvim",
optional = true,
opts = function()
Util.on_load("telescope.nvim", function()
require("telescope").load_extension("aerial")
end)
end,
keys = {
{
"<leader>ss",
"<cmd>Telescope aerial<cr>",
desc = "Goto Symbol (Aerial)",
},
},
},
-- edgy integration
{
"folke/edgy.nvim",
optional = true,
opts = function(_, opts)
local edgy_idx = Util.plugin.extra_idx("ui.edgy")
local aerial_idx = Util.plugin.extra_idx("editor.aerial")
if edgy_idx and edgy_idx > aerial_idx then
Util.warn("The `edgy.nvim` extra must be **imported** before the `aerial.nvim` extra to work properly.", {
title = "LazyVim",
})
end
opts.right = opts.right or {}
table.insert(opts.right, {
title = "Aerial",
ft = "aerial",
pinned = true,
open = "AerialOpen",
})
end,
},
-- lualine integration
{
"nvim-lualine/lualine.nvim",
optional = true,
opts = function(_, opts)
table.insert(opts.sections.lualine_c, {
"aerial",
sep = " ", -- separator between symbols
sep_icon = "", -- separator between icon and symbol
-- The number of symbols to render top-down. In order to render only 'N' last
-- symbols, negative numbers may be supplied. For instance, 'depth = -1' can
-- be used in order to render only current symbol.
depth = 5,
-- When 'dense' mode is on, icons are not rendered near their symbols. Only
-- a single icon that represents the kind of current symbol is rendered at
-- the beginning of status line.
dense = false,
-- The separator to be used to separate symbols in dense mode.
dense_sep = ".",
-- Color the symbol icons.
colored = true,
})
end,
},
}

View file

@ -1,6 +0,0 @@
require("lazy.core.util").warn(
"`flash.nvim` is now the default jump plugin for **LazyVim**.\nPlease remove the `lazyvim.plugins.extras.editor.flash` import from your **lazy** config.",
{ title = "LazyVim" }
)
return {}

View file

@ -35,6 +35,22 @@ return {
end, end,
}, },
-- rename surround mappings from gs to gz to prevent conflict with leap
{
"echasnovski/mini.surround",
opts = {
mappings = {
add = "gza", -- Add surrounding in Normal and Visual modes
delete = "gzd", -- Delete surrounding
find = "gzf", -- Find surrounding (to the right)
find_left = "gzF", -- Find surrounding (to the left)
highlight = "gzh", -- Highlight surrounding
replace = "gzr", -- Replace surrounding
update_n_lines = "gzn", -- Update `n_lines`
},
},
},
-- makes some plugins dot-repeatable like leap -- makes some plugins dot-repeatable like leap
{ "tpope/vim-repeat", event = "VeryLazy" }, { "tpope/vim-repeat", event = "VeryLazy" },
} }

View file

@ -53,5 +53,12 @@ return {
vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id }) vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id })
end, end,
}) })
vim.api.nvim_create_autocmd("User", {
pattern = "MiniFilesActionRename",
callback = function(event)
require("lazyvim.util").lsp.on_rename(event.data.from, event.data.to)
end,
})
end, end,
} }

View file

@ -0,0 +1,42 @@
return {
-- lsp symbol navigation for lualine. This shows where
-- in the code structure you are - within functions, classes,
-- etc - in the statusline.
{
"SmiteshP/nvim-navic",
lazy = true,
init = function()
vim.g.navic_silence = true
require("lazyvim.util").lsp.on_attach(function(client, buffer)
if client.supports_method("textDocument/documentSymbol") then
require("nvim-navic").attach(client, buffer)
end
end)
end,
opts = function()
return {
separator = " ",
highlight = true,
depth_limit = 5,
icons = require("lazyvim.config").icons.kinds,
lazy_update_context = true,
}
end,
},
-- lualine integration
{
"nvim-lualine/lualine.nvim",
optional = true,
opts = function(_, opts)
table.insert(opts.sections.lualine_c, {
function()
return require("nvim-navic").get_location()
end,
cond = function()
return package.loaded["nvim-navic"] and require("nvim-navic").is_available()
end,
})
end,
},
}

View file

@ -0,0 +1,61 @@
local Util = require("lazyvim.util")
return {
{
"simrat39/symbols-outline.nvim",
keys = { { "<leader>cs", "<cmd>SymbolsOutline<cr>", desc = "Symbols Outline" } },
cmd = "SymbolsOutline",
opts = function()
local Config = require("lazyvim.config")
local defaults = require("symbols-outline.config").defaults
local opts = {
symbols = {},
symbol_blacklist = {},
}
local filter = Config.kind_filter
if type(filter) == "table" then
filter = filter.default
if type(filter) == "table" then
for kind, symbol in pairs(defaults.symbols) do
opts.symbols[kind] = {
icon = Config.icons.kinds[kind] or symbol.icon,
hl = symbol.hl,
}
if not vim.tbl_contains(filter, kind) then
table.insert(opts.symbol_blacklist, kind)
end
end
end
end
return opts
end,
},
-- edgy integration
{
"folke/edgy.nvim",
optional = true,
opts = function(_, opts)
local edgy_idx = Util.plugin.extra_idx("ui.edgy")
local symbols_idx = Util.plugin.extra_idx("editor.symbols-outline")
if edgy_idx and edgy_idx > symbols_idx then
Util.warn(
"The `edgy.nvim` extra must be **imported** before the `symbols-outline.nvim` extra to work properly.",
{
title = "LazyVim",
}
)
end
opts.right = opts.right or {}
table.insert(opts.right, {
title = "Symbols Outline",
ft = "Outline",
pinned = true,
open = "SymbolsOutline",
})
end,
},
}

View file

@ -0,0 +1,26 @@
return {
{
"williamboman/mason.nvim",
opts = function(_, opts)
table.insert(opts.ensure_installed, "black")
end,
},
{
"nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = opts.sources or {}
table.insert(opts.sources, nls.builtins.formatting.black)
end,
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
["python"] = { "black" },
},
},
},
}

View file

@ -2,14 +2,40 @@ return {
{ {
"williamboman/mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = function(_, opts)
table.insert(opts.ensure_installed, "prettierd") table.insert(opts.ensure_installed, "prettier")
end, end,
}, },
{ {
"jose-elias-alvarez/null-ls.nvim", "nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts) opts = function(_, opts)
local nls = require("null-ls") local nls = require("null-ls")
table.insert(opts.sources, nls.builtins.formatting.prettierd) opts.sources = opts.sources or {}
table.insert(opts.sources, nls.builtins.formatting.prettier)
end, end,
}, },
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
["javascript"] = { "prettier" },
["javascriptreact"] = { "prettier" },
["typescript"] = { "prettier" },
["typescriptreact"] = { "prettier" },
["vue"] = { "prettier" },
["css"] = { "prettier" },
["scss"] = { "prettier" },
["less"] = { "prettier" },
["html"] = { "prettier" },
["json"] = { "prettier" },
["jsonc"] = { "prettier" },
["yaml"] = { "prettier" },
["markdown"] = { "prettier" },
["markdown.mdx"] = { "prettier" },
["graphql"] = { "prettier" },
["handlebars"] = { "prettier" },
},
},
},
} }

View file

@ -8,20 +8,29 @@ return {
end, end,
}, },
{ {
"jose-elias-alvarez/null-ls.nvim", "nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts) opts = function(_, opts)
local nls = require("null-ls") local nls = require("null-ls")
opts.sources = opts.sources or {} opts.sources = vim.list_extend(opts.sources or {}, {
vim.list_extend(opts.sources, {
nls.builtins.diagnostics.cmake_lint, nls.builtins.diagnostics.cmake_lint,
}) })
end, end,
}, },
{
"mfussenegger/nvim-lint",
optional = true,
opts = {
linters_by_ft = {
cmake = { "cmakelint" },
},
},
},
{ {
"mason.nvim", "mason.nvim",
opts = function(_, opts) opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {} opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "cmakelang" }) vim.list_extend(opts.ensure_installed, { "cmakelang", "cmakelint" })
end, end,
}, },
{ {
@ -35,6 +44,6 @@ return {
{ {
"Civitasv/cmake-tools.nvim", "Civitasv/cmake-tools.nvim",
opts = {}, opts = {},
event = "BufRead", event = "LazyFile",
}, },
} }

View file

@ -8,20 +8,29 @@ return {
end, end,
}, },
{ {
"jose-elias-alvarez/null-ls.nvim", "mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "hadolint" })
end,
},
{
"nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts) opts = function(_, opts)
local nls = require("null-ls") local nls = require("null-ls")
opts.sources = opts.sources or {} opts.sources = vim.list_extend(opts.sources or {}, {
vim.list_extend(opts.sources, {
nls.builtins.diagnostics.hadolint, nls.builtins.diagnostics.hadolint,
}) })
end, end,
dependencies = { },
"mason.nvim", {
opts = function(_, opts) "mfussenegger/nvim-lint",
opts.ensure_installed = opts.ensure_installed or {} optional = true,
vim.list_extend(opts.ensure_installed, { "hadolint" }) opts = {
end, linters_by_ft = {
dockerfile = { "hadolint" },
},
}, },
}, },
{ {

View file

@ -29,4 +29,29 @@ return {
}, },
}, },
}, },
{
"nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts)
if vim.fn.executable("credo") == 0 then
return
end
local nls = require("null-ls")
opts.sources = vim.list_extend(opts.sources or {}, {
nls.builtins.diagnostics.credo,
})
end,
},
{
"mfussenegger/nvim-lint",
optional = true,
opts = function(_, opts)
if vim.fn.executable("credo") == 0 then
return
end
opts.linters_by_ft = {
elixir = { "credo" },
}
end,
},
} }

View file

@ -61,7 +61,7 @@ return {
gopls = function(_, opts) gopls = function(_, opts)
-- workaround for gopls not supporting semanticTokensProvider -- workaround for gopls not supporting semanticTokensProvider
-- https://github.com/golang/go/issues/54531#issuecomment-1464982242 -- https://github.com/golang/go/issues/54531#issuecomment-1464982242
require("lazyvim.util").on_attach(function(client, _) require("lazyvim.util").lsp.on_attach(function(client, _)
if client.name == "gopls" then if client.name == "gopls" then
if not client.server_capabilities.semanticTokensProvider then if not client.server_capabilities.semanticTokensProvider then
local semantic = client.config.capabilities.textDocument.semanticTokens local semantic = client.config.capabilities.textDocument.semanticTokens
@ -83,28 +83,52 @@ return {
}, },
-- Ensure Go tools are installed -- Ensure Go tools are installed
{ {
"jose-elias-alvarez/null-ls.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = function(_, opts)
if type(opts.sources) == "table" then opts.ensure_installed = opts.ensure_installed or {}
local nls = require("null-ls") vim.list_extend(opts.ensure_installed, { "goimports", "gofumpt" })
vim.list_extend(opts.sources, {
nls.builtins.code_actions.gomodifytags,
nls.builtins.code_actions.impl,
nls.builtins.formatting.gofumpt,
nls.builtins.formatting.goimports_reviser,
})
end
end, end,
}, },
{
"nvimtools/none-ls.nvim",
optional = true,
dependencies = {
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl" })
end,
},
},
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = vim.list_extend(opts.sources or {}, {
nls.builtins.code_actions.gomodifytags,
nls.builtins.code_actions.impl,
nls.builtins.formatting.goimports,
nls.builtins.formatting.gofumpt,
})
end,
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
go = { "goimports", "gofumpt" },
},
},
},
{ {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
optional = true, optional = true,
dependencies = { dependencies = {
{ {
"mason.nvim", "williamboman/mason.nvim",
opts = function(_, opts) opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {} opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "gofumpt", "goimports-reviser", "delve" }) vim.list_extend(opts.ensure_installed, { "delve" })
end, end,
}, },
{ {

View file

@ -85,7 +85,7 @@ return {
-- How to run jdtls. This can be overridden to a full java command-line -- How to run jdtls. This can be overridden to a full java command-line
-- if the Python wrapper script doesn't suffice. -- if the Python wrapper script doesn't suffice.
cmd = { "jdtls" }, cmd = { vim.fn.exepath("jdtls") },
full_cmd = function(opts) full_cmd = function(opts)
local fname = vim.api.nvim_buf_get_name(0) local fname = vim.api.nvim_buf_get_name(0)
local root_dir = opts.root_dir(fname) local root_dir = opts.root_dir(fname)

View file

@ -10,13 +10,16 @@ return {
end, end,
}, },
-- yaml schema support
{
"b0o/SchemaStore.nvim",
lazy = true,
version = false, -- last release is way too old
},
-- correctly setup lspconfig -- correctly setup lspconfig
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = {
"b0o/SchemaStore.nvim",
version = false, -- last release is way too old
},
opts = { opts = {
-- make sure mason installs the server -- make sure mason installs the server
servers = { servers = {

View file

@ -0,0 +1,90 @@
return {
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "markdown", "markdown_inline" })
end
end,
},
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "markdownlint", "marksman" })
end,
},
{
"nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = vim.list_extend(opts.sources or {}, {
nls.builtins.diagnostics.markdownlint,
})
end,
},
{
"mfussenegger/nvim-lint",
optional = true,
opts = {
linters_by_ft = {
markdown = { "markdownlint" },
},
},
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
marksman = {},
},
},
},
-- Markdown preview
{
"iamcco/markdown-preview.nvim",
cmd = { "MarkdownPreviewToggle", "MarkdownPreview", "MarkdownPreviewStop" },
build = function()
vim.fn["mkdp#util#install"]()
end,
keys = {
{
"<leader>cp",
ft = "markdown",
"<cmd>MarkdownPreviewToggle<cr>",
desc = "Markdown Preview",
},
},
config = function()
vim.cmd([[do FileType]])
end,
},
{
"lukas-reineke/headlines.nvim",
opts = function()
local opts = {}
for _, ft in ipairs({ "markdown", "norg", "rmd", "org" }) do
opts[ft] = {
headline_highlights = {},
}
for i = 1, 6 do
local hl = "Headline" .. i
vim.api.nvim_set_hl(0, hl, { link = "Headline", default = true })
table.insert(opts[ft].headline_highlights, hl)
end
end
return opts
end,
ft = { "markdown", "norg", "rmd", "org" },
config = function(_, opts)
-- PERF: schedule to prevent headlines slowing down opening a file
vim.schedule(function()
require("headlines").setup(opts)
require("headlines").refresh()
end)
end,
},
}

View file

@ -0,0 +1,68 @@
return {
{ "Hoffs/omnisharp-extended-lsp.nvim", lazy = true },
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "c_sharp" })
end
end,
},
{
"nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = opts.sources or {}
table.insert(opts.sources, nls.builtins.formatting.csharpier)
end,
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
cs = { "csharpier" },
},
formatters = {
csharpier = {
command = "dotnet-csharpier",
args = { "--write-stdout" },
},
},
},
},
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
table.insert(opts.ensure_installed, "csharpier")
end,
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
omnisharp = {
handlers = {
["textDocument/definition"] = function(...)
return require("omnisharp_extended").handler(...)
end,
},
keys = {
{
"gd",
function()
require("omnisharp_extended").telescope_lsp_definitions()
end,
desc = "Goto Definition",
},
},
enable_roslyn_analyzers = true,
organize_imports_on_format = true,
enable_import_completion = true,
},
},
},
},
}

View file

@ -17,13 +17,14 @@ return {
-- Only add style, inherit or link to the LSP's colors -- Only add style, inherit or link to the LSP's colors
vim.cmd([[ vim.cmd([[
highlight! semshiGlobal gui=italic highlight! semshiGlobal gui=italic
highlight! semshiImported gui=bold highlight! link semshiImported @none
highlight! link semshiParameter @lsp.type.parameter highlight! link semshiParameter @lsp.type.parameter
highlight! link semshiParameterUnused DiagnosticUnnecessary highlight! link semshiParameterUnused DiagnosticUnnecessary
highlight! link semshiBuiltin @function.builtin highlight! link semshiBuiltin @function.builtin
highlight! link semshiAttribute @attribute highlight! link semshiAttribute @field
highlight! link semshiSelf @lsp.type.selfKeyword highlight! link semshiSelf @lsp.type.selfKeyword
highlight! link semshiUnresolved @lsp.type.unresolvedReference highlight! link semshiUnresolved @lsp.type.unresolvedReference
highlight! link semshiFree @none
]]) ]])
end, end,
}) })

View file

@ -12,11 +12,27 @@ return {
opts = { opts = {
servers = { servers = {
pyright = {}, pyright = {},
ruff_lsp = {}, ruff_lsp = {
keys = {
{
"<leader>co",
function()
vim.lsp.buf.code_action({
apply = true,
context = {
only = { "source.organizeImports" },
diagnostics = {},
},
})
end,
desc = "Organize Imports",
},
},
},
}, },
setup = { setup = {
ruff_lsp = function() ruff_lsp = function()
require("lazyvim.util").on_attach(function(client, _) require("lazyvim.util").lsp.on_attach(function(client, _)
if client.name == "ruff_lsp" then if client.name == "ruff_lsp" then
-- Disable hover in favor of Pyright -- Disable hover in favor of Pyright
client.server_capabilities.hoverProvider = false client.server_capabilities.hoverProvider = false
@ -49,8 +65,8 @@ return {
"mfussenegger/nvim-dap-python", "mfussenegger/nvim-dap-python",
-- stylua: ignore -- stylua: ignore
keys = { keys = {
{ "<leader>dPt", function() require('dap-python').test_method() end, desc = "Debug Method" }, { "<leader>dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" },
{ "<leader>dPc", function() require('dap-python').test_class() end, desc = "Debug Class" }, { "<leader>dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" },
}, },
config = function() config = function()
local path = require("mason-registry").get_package("debugpy"):get_install_path() local path = require("mason-registry").get_package("debugpy"):get_install_path()
@ -61,14 +77,19 @@ return {
{ {
"linux-cultist/venv-selector.nvim", "linux-cultist/venv-selector.nvim",
cmd = "VenvSelect", cmd = "VenvSelect",
opts = { opts = function(_, opts)
name = { if require("lazyvim.util").has("nvim-dap-python") then
"venv", opts.dap_enabled = true
".venv", end
"env", return vim.tbl_deep_extend("force", opts, {
".env", name = {
}, "venv",
}, ".venv",
"env",
".env",
},
})
end,
keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" } }, keys = { { "<leader>cv", "<cmd>:VenvSelect<cr>", desc = "Select VirtualEnv" } },
}, },
} }

View file

@ -7,7 +7,11 @@ return {
{ {
"Saecki/crates.nvim", "Saecki/crates.nvim",
event = { "BufRead Cargo.toml" }, event = { "BufRead Cargo.toml" },
config = true, opts = {
src = {
cmp = { enabled = true },
},
},
}, },
}, },
---@param opts cmp.ConfigSchema ---@param opts cmp.ConfigSchema

View file

@ -4,16 +4,30 @@ return {
opts = { opts = {
servers = { servers = {
tailwindcss = { tailwindcss = {
-- exclude a filetype from the default_config
filetypes_exclude = { "markdown" }, filetypes_exclude = { "markdown" },
-- add additional filetypes to the default_config
filetypes_include = {},
-- to fully override the default_config, change the below
-- filetypes = {}
}, },
}, },
setup = { setup = {
tailwindcss = function(_, opts) tailwindcss = function(_, opts)
local tw = require("lspconfig.server_configurations.tailwindcss") local tw = require("lspconfig.server_configurations.tailwindcss")
opts.filetypes = opts.filetypes or {}
-- Add default filetypes
vim.list_extend(opts.filetypes, tw.default_config.filetypes)
-- Remove excluded filetypes
--- @param ft string --- @param ft string
opts.filetypes = vim.tbl_filter(function(ft) opts.filetypes = vim.tbl_filter(function(ft)
return not vim.tbl_contains(opts.filetypes_exclude or {}, ft) return not vim.tbl_contains(opts.filetypes_exclude or {}, ft)
end, tw.default_config.filetypes) end, opts.filetypes)
-- Add additional filetypes
vim.list_extend(opts.filetypes, opts.filetypes_include or {})
end, end,
}, },
}, },

View file

@ -25,15 +25,35 @@ return {
}, },
}, },
{ {
"jose-elias-alvarez/null-ls.nvim", "nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts) opts = function(_, opts)
if type(opts.sources) == "table" then local null_ls = require("null-ls")
local null_ls = require("null-ls") opts.sources = vim.list_extend(opts.sources or {}, {
vim.list_extend(opts.sources, { null_ls.builtins.formatting.terraform_fmt,
null_ls.builtins.formatting.terraform_fmt, null_ls.builtins.diagnostics.terraform_validate,
null_ls.builtins.diagnostics.terraform_validate, })
})
end
end, end,
}, },
{
"mfussenegger/nvim-lint",
optional = true,
opts = {
linters_by_ft = {
terraform = { "terraform_validate" },
tf = { "terraform_validate" },
},
},
},
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = {
terraform = { "terraform_fmt" },
tf = { "terraform_fmt" },
["terraform-vars"] = { "terraform_fmt" },
},
},
},
} }

View file

@ -13,15 +13,38 @@ return {
-- correctly setup lspconfig -- correctly setup lspconfig
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = { "jose-elias-alvarez/typescript.nvim" },
opts = { opts = {
-- make sure mason installs the server -- make sure mason installs the server
servers = { servers = {
---@type lspconfig.options.tsserver ---@type lspconfig.options.tsserver
tsserver = { tsserver = {
keys = { keys = {
{ "<leader>co", "<cmd>TypescriptOrganizeImports<CR>", desc = "Organize Imports" }, {
{ "<leader>cR", "<cmd>TypescriptRenameFile<CR>", desc = "Rename File" }, "<leader>co",
function()
vim.lsp.buf.code_action({
apply = true,
context = {
only = { "source.organizeImports.ts" },
diagnostics = {},
},
})
end,
desc = "Organize Imports",
},
{
"<leader>cR",
function()
vim.lsp.buf.code_action({
apply = true,
context = {
only = { "source.removeUnused.ts" },
diagnostics = {},
},
})
end,
desc = "Remove Unused Imports",
},
}, },
settings = { settings = {
typescript = { typescript = {
@ -44,20 +67,8 @@ return {
}, },
}, },
}, },
setup = {
tsserver = function(_, opts)
require("typescript").setup({ server = opts })
return true
end,
},
}, },
}, },
{
"jose-elias-alvarez/null-ls.nvim",
opts = function(_, opts)
table.insert(opts.sources, require("typescript.extensions.null-ls.code-actions"))
end,
},
{ {
"mfussenegger/nvim-dap", "mfussenegger/nvim-dap",
optional = true, optional = true,
@ -88,7 +99,7 @@ return {
}, },
} }
end end
for _, language in ipairs({ "typescript", "javascript" }) do for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do
if not dap.configurations[language] then if not dap.configurations[language] then
dap.configurations[language] = { dap.configurations[language] = {
{ {

View file

@ -10,13 +10,16 @@ return {
end, end,
}, },
-- yaml schema support
{
"b0o/SchemaStore.nvim",
lazy = true,
version = false, -- last release is way too old
},
-- correctly setup lspconfig -- correctly setup lspconfig
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
dependencies = {
"b0o/SchemaStore.nvim",
version = false, -- last release is way too old
},
opts = { opts = {
-- make sure mason installs the server -- make sure mason installs the server
servers = { servers = {
@ -32,8 +35,11 @@ return {
}, },
-- lazy-load schemastore when needed -- lazy-load schemastore when needed
on_new_config = function(new_config) on_new_config = function(new_config)
new_config.settings.yaml.schemas = new_config.settings.yaml.schemas or {} new_config.settings.yaml.schemas = vim.tbl_deep_extend(
vim.list_extend(new_config.settings.yaml.schemas, require("schemastore").yaml.schemas()) "force",
new_config.settings.yaml.schemas or {},
require("schemastore").yaml.schemas()
)
end, end,
settings = { settings = {
redhat = { telemetry = { enabled = false } }, redhat = { telemetry = { enabled = false } },
@ -54,6 +60,18 @@ return {
}, },
}, },
}, },
setup = {
yamlls = function()
-- Neovim < 0.10 does not have dynamic registration for formatting
if vim.fn.has("nvim-0.10") == 0 then
require("lazyvim.util").lsp.on_attach(function(client, _)
if client.name == "yamlls" then
client.server_capabilities.documentFormattingProvider = true
end
end)
end
end,
},
}, },
}, },
} }

View file

@ -14,22 +14,37 @@ return {
}, },
setup = { setup = {
eslint = function() eslint = function()
vim.api.nvim_create_autocmd("BufWritePre", { local function get_client(buf)
callback = function(event) return require("lazyvim.util").lsp.get_clients({ name = "eslint", bufnr = buf })[1]
if not require("lazyvim.plugins.lsp.format").enabled() then end
-- exit early if autoformat is not enabled
return
end
local client = vim.lsp.get_active_clients({ bufnr = event.buf, name = "eslint" })[1] local formatter = require("lazyvim.util").lsp.formatter({
name = "eslint: lsp",
primary = false,
priority = 200,
filter = "eslint",
})
-- Use EslintFixAll on Neovim < 0.10.0
if not pcall(require, "vim.lsp._dynamic") then
formatter.name = "eslint: EslintFixAll"
formatter.sources = function(buf)
local client = get_client(buf)
return client and { "eslint" } or {}
end
formatter.format = function(buf)
local client = get_client(buf)
if client then if client then
local diag = vim.diagnostic.get(event.buf, { namespace = vim.lsp.diagnostic.get_namespace(client.id) }) local diag = vim.diagnostic.get(buf, { namespace = vim.lsp.diagnostic.get_namespace(client.id) })
if #diag > 0 then if #diag > 0 then
vim.cmd("EslintFixAll") vim.cmd("EslintFixAll")
end end
end end
end, end
}) end
-- register the formatter with LazyVim
require("lazyvim.util").format.register(formatter)
end, end,
}, },
}, },

View file

@ -0,0 +1,45 @@
local Util = require("lazyvim.util")
return {
-- none-ls
{
"nvimtools/none-ls.nvim",
event = "LazyFile",
dependencies = { "mason.nvim" },
init = function()
Util.on_very_lazy(function()
-- register the formatter with LazyVim
require("lazyvim.util").format.register({
name = "none-ls.nvim",
priority = 200, -- set higher than conform, the builtin formatter
primary = true,
format = function(buf)
return Util.lsp.format({
bufnr = buf,
filter = function(client)
return client.name == "null-ls"
end,
})
end,
sources = function(buf)
local ret = require("null-ls.sources").get_available(vim.bo[buf].filetype, "NULL_LS_FORMATTING") or {}
return vim.tbl_map(function(source)
return source.name
end, ret)
end,
})
end)
end,
opts = function(_, opts)
local nls = require("null-ls")
opts.root_dir = opts.root_dir
or require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git")
opts.sources = vim.list_extend(opts.sources or {}, {
nls.builtins.formatting.fish_indent,
nls.builtins.diagnostics.fish,
nls.builtins.formatting.stylua,
nls.builtins.formatting.shfmt,
})
end,
},
}

View file

@ -27,7 +27,7 @@ return {
quickfix = { quickfix = {
open = function() open = function()
if require("lazyvim.util").has("trouble.nvim") then if require("lazyvim.util").has("trouble.nvim") then
vim.cmd("Trouble quickfix") require("trouble").open({ mode = "quickfix", focus = false })
else else
vim.cmd("copen") vim.cmd("copen")
end end
@ -46,6 +46,37 @@ return {
}, },
}, neotest_ns) }, neotest_ns)
if require("lazyvim.util").has("trouble.nvim") then
opts.consumers = opts.consumers or {}
-- Refresh and auto close trouble after running tests
---@type neotest.Consumer
opts.consumers.trouble = function(client)
client.listeners.results = function(adapter_id, results, partial)
if partial then
return
end
local tree = assert(client:get_position(nil, { adapter = adapter_id }))
local failed = 0
for pos_id, result in pairs(results) do
if result.status == "failed" and tree:get_key(pos_id) then
failed = failed + 1
end
end
vim.schedule(function()
local trouble = require("trouble")
if trouble.is_open() then
trouble.refresh()
if failed == 0 then
trouble.close()
end
end
end)
return {}
end
end
end
if opts.adapters then if opts.adapters then
local adapters = {} local adapters = {}
for name, config in pairs(opts.adapters or {}) do for name, config in pairs(opts.adapters or {}) do

View file

@ -0,0 +1,79 @@
return {
{ "nvimdev/dashboard-nvim", enabled = false },
{ "echasnovski/mini.starter", enabled = false },
-- Dashboard. This runs when neovim starts, and is what displays
-- the "LAZYVIM" banner.
{
"goolord/alpha-nvim",
event = "VimEnter",
enabled = true,
init = false,
opts = function()
local dashboard = require("alpha.themes.dashboard")
local logo = [[
Z
Z
z
z
]]
dashboard.section.header.val = vim.split(logo, "\n")
-- stylua: ignore
dashboard.section.buttons.val = {
dashboard.button("f", "" .. " Find file", "<cmd> Telescope find_files <cr>"),
dashboard.button("n", "" .. " New file", "<cmd> ene <BAR> startinsert <cr>"),
dashboard.button("r", "" .. " Recent files", "<cmd> Telescope oldfiles <cr>"),
dashboard.button("g", "" .. " Find text", "<cmd> Telescope live_grep <cr>"),
dashboard.button("c", "" .. " Config", "<cmd> lua require('lazyvim.util').telescope.config_files()() <cr>"),
dashboard.button("s", "" .. " Restore Session", [[<cmd> lua require("persistence").load() <cr>]]),
dashboard.button("x", "" .. " Lazy Extras", "<cmd> LazyExtras <cr>"),
dashboard.button("l", "󰒲 " .. " Lazy", "<cmd> Lazy <cr>"),
dashboard.button("q", "" .. " Quit", "<cmd> qa <cr>"),
}
for _, button in ipairs(dashboard.section.buttons.val) do
button.opts.hl = "AlphaButtons"
button.opts.hl_shortcut = "AlphaShortcut"
end
dashboard.section.header.opts.hl = "AlphaHeader"
dashboard.section.buttons.opts.hl = "AlphaButtons"
dashboard.section.footer.opts.hl = "AlphaFooter"
dashboard.opts.layout[1].val = 8
return dashboard
end,
config = function(_, dashboard)
-- close Lazy and re-open when the dashboard is ready
if vim.o.filetype == "lazy" then
vim.cmd.close()
vim.api.nvim_create_autocmd("User", {
once = true,
pattern = "AlphaReady",
callback = function()
require("lazy").show()
end,
})
end
require("alpha").setup(dashboard.opts)
vim.api.nvim_create_autocmd("User", {
once = true,
pattern = "LazyVimStarted",
callback = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
dashboard.section.footer.val = "⚡ Neovim loaded "
.. stats.loaded
.. "/"
.. stats.count
.. " plugins in "
.. ms
.. "ms"
pcall(vim.cmd.AlphaRedraw)
end,
})
end,
},
}

View file

@ -40,6 +40,12 @@ return {
end, end,
}, },
"Trouble", "Trouble",
{
ft = "trouble",
filter = function(buf, win)
return vim.api.nvim_win_get_config(win).relative == ""
end,
},
{ ft = "qf", title = "QuickFix" }, { ft = "qf", title = "QuickFix" },
{ {
ft = "help", ft = "help",
@ -49,7 +55,7 @@ return {
return vim.bo[buf].buftype == "help" return vim.bo[buf].buftype == "help"
end, end,
}, },
{ ft = "spectre_panel", size = { height = 0.4 } }, { title = "Spectre", ft = "spectre_panel", size = { height = 0.4 } },
{ title = "Neotest Output", ft = "neotest-output-panel", size = { height = 15 } }, { title = "Neotest Output", ft = "neotest-output-panel", size = { height = 15 } },
}, },
left = { left = {
@ -105,26 +111,31 @@ return {
end, end,
}, },
} }
local Util = require("lazyvim.util")
if Util.has("symbols-outline.nvim") then
table.insert(opts.left, {
title = "Outline",
ft = "Outline",
pinned = true,
open = "SymbolsOutline",
})
end
return opts return opts
end, end,
}, },
-- use edgy's selection window
{
"nvim-telescope/telescope.nvim",
optional = true,
opts = {
defaults = {
get_selection_window = function()
require("edgy").goto_main()
return 0
end,
},
},
},
-- prevent neo-tree from opening files in edgy windows -- prevent neo-tree from opening files in edgy windows
{ {
"nvim-neo-tree/neo-tree.nvim", "nvim-neo-tree/neo-tree.nvim",
optional = true, optional = true,
opts = function(_, opts) opts = function(_, opts)
opts.open_files_do_not_replace_types = opts.open_files_do_not_replace_types opts.open_files_do_not_replace_types = opts.open_files_do_not_replace_types
or { "terminal", "Trouble", "qf", "Outline" } or { "terminal", "Trouble", "qf", "Outline", "trouble" }
table.insert(opts.open_files_do_not_replace_types, "edgy") table.insert(opts.open_files_do_not_replace_types, "edgy")
end, end,
}, },

View file

@ -2,6 +2,7 @@
return { return {
-- disable alpha -- disable alpha
{ "goolord/alpha-nvim", enabled = false }, { "goolord/alpha-nvim", enabled = false },
{ "nvimdev/dashboard-nvim", enabled = false },
-- enable mini.starter -- enable mini.starter
{ {
@ -28,14 +29,15 @@ return {
evaluate_single = true, evaluate_single = true,
header = logo, header = logo,
items = { items = {
new_section("Find file", "Telescope find_files", "Telescope"), new_section("Find file", "Telescope find_files", "Telescope"),
new_section("Recent files", "Telescope oldfiles", "Telescope"), new_section("Recent files", "Telescope oldfiles", "Telescope"),
new_section("Grep text", "Telescope live_grep", "Telescope"), new_section("Grep text", "Telescope live_grep", "Telescope"),
new_section("init.lua", "e $MYVIMRC", "Config"), new_section("Config", "lua require('lazyvim.util').telescope.config_files()()", "Config"),
new_section("Lazy", "Lazy", "Config"), new_section("Extras", "LazyExtras", "Config"),
new_section("New file", "ene | startinsert", "Built-in"), new_section("Lazy", "Lazy", "Config"),
new_section("Quit", "qa", "Built-in"), new_section("New file", "ene | startinsert", "Built-in"),
new_section("Session restore", [[lua require("persistence").load()]], "Session"), new_section("Quit", "qa", "Built-in"),
new_section("Session restore", [[lua require("persistence").load()]], "Session"),
}, },
content_hooks = { content_hooks = {
starter.gen_hook.adding_bullet(pad .. "", false), starter.gen_hook.adding_bullet(pad .. "", false),

View file

@ -0,0 +1,65 @@
---@type string
local xdg_config = vim.env.XDG_CONFIG_HOME or vim.env.HOME .. "/.config"
---@param path string
local function have(path)
return vim.loop.fs_stat(xdg_config .. "/" .. path) ~= nil
end
return {
-- Add Hyprland Parser
{
"luckasRanarison/tree-sitter-hypr",
enabled = function()
return have("hypr")
end,
event = "BufRead */hypr/*.conf",
build = ":TSUpdate hypr",
config = function()
-- Fix ft detection for hyprland
vim.filetype.add({
pattern = { [".*/hypr/.*%.conf"] = "hypr" },
})
require("nvim-treesitter.parsers").get_parser_configs().hypr = {
install_info = {
url = "https://github.com/luckasRanarison/tree-sitter-hypr",
files = { "src/parser.c" },
branch = "master",
},
filetype = "hypr",
}
end,
},
-- add some stuff to treesitter
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
local function add(lang)
if type(opts.ensure_installed) == "table" then
table.insert(opts.ensure_installed, lang)
end
end
vim.filetype.add({
extension = { rasi = "rasi" },
pattern = {
[".*/waybar/config"] = "jsonc",
[".*/mako/config"] = "dosini",
[".*/kitty/*.conf"] = "bash",
},
})
add("git_config")
if have("fish") then
add("fish")
end
if have("rofi") or have("wofi") then
add("rasi")
end
end,
},
}

View file

@ -5,7 +5,7 @@ M.hl = {}
M.plugin = { M.plugin = {
"echasnovski/mini.hipatterns", "echasnovski/mini.hipatterns",
event = "BufReadPre", event = "LazyFile",
opts = function() opts = function()
local hi = require("mini.hipatterns") local hi = require("mini.hipatterns")
return { return {
@ -67,7 +67,7 @@ M.plugin = {
return hl return hl
end end
end, end,
priority = 2000, extmark_opts = { priority = 2000 },
} }
end end
require("mini.hipatterns").setup(opts) require("mini.hipatterns").setup(opts)

View file

@ -5,11 +5,15 @@ return {
-- project management -- project management
{ {
"ahmedkhalf/project.nvim", "ahmedkhalf/project.nvim",
opts = {}, opts = {
manual_mode = true,
},
event = "VeryLazy", event = "VeryLazy",
config = function(_, opts) config = function(_, opts)
require("project_nvim").setup(opts) require("project_nvim").setup(opts)
require("telescope").load_extension("projects") require("lazyvim.util").on_load("telescope.nvim", function()
require("telescope").load_extension("projects")
end)
end, end,
keys = { keys = {
{ "<leader>fp", "<Cmd>Telescope projects<CR>", desc = "Projects" }, { "<leader>fp", "<Cmd>Telescope projects<CR>", desc = "Projects" },
@ -42,4 +46,21 @@ return {
vim.list_extend(opts.items, items) vim.list_extend(opts.items, items)
end, end,
}, },
{
"nvimdev/dashboard-nvim",
optional = true,
opts = function(_, opts)
local projects = {
action = "Telescope projects",
desc = " Projects",
icon = "",
key = "p",
}
projects.desc = projects.desc .. string.rep(" ", 43 - #projects.desc)
projects.key_format = " %s"
table.insert(opts.config.center, 3, projects)
end,
},
} }

View file

@ -18,7 +18,6 @@ local enabled = {
} }
local Config = require("lazy.core.config") local Config = require("lazy.core.config")
local Plugin = require("lazy.core.plugin")
Config.options.checker.enabled = false Config.options.checker.enabled = false
Config.options.change_detection.enabled = false Config.options.change_detection.enabled = false
Config.options.defaults.cond = function(plugin) Config.options.defaults.cond = function(plugin)

View file

@ -0,0 +1,116 @@
local Util = require("lazyvim.util")
local M = {}
---@param opts ConformOpts
function M.setup(_, opts)
for name, formatter in pairs(opts.formatters or {}) do
if type(formatter) == "table" then
---@diagnostic disable-next-line: undefined-field
if formatter.extra_args then
---@diagnostic disable-next-line: undefined-field
formatter.prepend_args = formatter.extra_args
Util.deprecate(("opts.formatters.%s.extra_args"):format(name), ("opts.formatters.%s.prepend_args"):format(name))
end
end
end
for _, key in ipairs({ "format_on_save", "format_after_save" }) do
if opts[key] then
Util.warn(
("Don't set `opts.%s` for `conform.nvim`.\n**LazyVim** will use the conform formatter automatically"):format(
key
)
)
---@diagnostic disable-next-line: no-unknown
opts[key] = nil
end
end
require("conform").setup(opts)
end
return {
{
"stevearc/conform.nvim",
dependencies = { "mason.nvim" },
lazy = true,
cmd = "ConformInfo",
keys = {
{
"<leader>cF",
function()
require("conform").format({ formatters = { "injected" } })
end,
mode = { "n", "v" },
desc = "Format Injected Langs",
},
},
init = function()
-- Install the conform formatter on VeryLazy
require("lazyvim.util").on_very_lazy(function()
require("lazyvim.util").format.register({
name = "conform.nvim",
priority = 100,
primary = true,
format = function(buf)
local plugin = require("lazy.core.config").plugins["conform.nvim"]
local Plugin = require("lazy.core.plugin")
local opts = Plugin.values(plugin, "opts", false)
require("conform").format(Util.merge(opts.format, { bufnr = buf }))
end,
sources = function(buf)
local ret = require("conform").list_formatters(buf)
---@param v conform.FormatterInfo
return vim.tbl_map(function(v)
return v.name
end, ret)
end,
})
end)
end,
opts = function()
local plugin = require("lazy.core.config").plugins["conform.nvim"]
if plugin.config ~= M.setup then
Util.error({
"Don't set `plugin.config` for `conform.nvim`.\n",
"This will break **LazyVim** formatting.\n",
"Please refer to the docs at https://www.lazyvim.org/plugins/formatting",
}, { title = "LazyVim" })
end
---@class ConformOpts
local opts = {
-- LazyVim will use these options when formatting with the conform.nvim formatter
format = {
timeout_ms = 3000,
async = false, -- not recommended to change
quiet = false, -- not recommended to change
},
---@type table<string, conform.FormatterUnit[]>
formatters_by_ft = {
lua = { "stylua" },
fish = { "fish_indent" },
sh = { "shfmt" },
},
-- The options you set here will be merged with the builtin formatters.
-- You can also define any custom formatters here.
---@type table<string, conform.FormatterConfigOverride|fun(bufnr: integer): nil|conform.FormatterConfigOverride>
formatters = {
injected = { options = { ignore_errors = true } },
-- # Example of using dprint only when a dprint.json file is present
-- dprint = {
-- condition = function(ctx)
-- return vim.fs.find({ "dprint.json" }, { path = ctx.filename, upward = true })[1]
-- end,
-- },
--
-- # Example of using shfmt with extra args
-- shfmt = {
-- prepend_args = { "-i", "2", "-ci" },
-- },
},
}
return opts
end,
config = M.setup,
},
}

View file

@ -0,0 +1,16 @@
if vim.fn.has("nvim-0.9.0") == 0 then
vim.api.nvim_echo({
{ "LazyVim requires Neovim >= 0.9.0\n", "ErrorMsg" },
{ "Press any key to exit", "MoreMsg" },
}, true, {})
vim.fn.getchar()
vim.cmd([[quit]])
return {}
end
require("lazyvim.config").init()
return {
{ "folke/lazy.nvim", version = "*" },
{ "LazyVim/LazyVim", priority = 10000, lazy = false, config = true, cond = true, version = "*" },
}

View file

@ -0,0 +1,93 @@
return {
{
"mfussenegger/nvim-lint",
event = "LazyFile",
opts = {
-- Event to trigger linters
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
linters_by_ft = {
fish = { "fish" },
-- Use the "*" filetype to run linters on all filetypes.
-- ['*'] = { 'global linter' },
-- Use the "_" filetype to run linters on filetypes that don't have other linters configured.
-- ['_'] = { 'fallback linter' },
},
-- LazyVim extension to easily override linter options
-- or add custom linters.
---@type table<string,table>
linters = {
-- -- Example of using selene only when a selene.toml file is present
-- selene = {
-- -- `condition` is another LazyVim extension that allows you to
-- -- dynamically enable/disable linters based on the context.
-- condition = function(ctx)
-- return vim.fs.find({ "selene.toml" }, { path = ctx.filename, upward = true })[1]
-- end,
-- },
},
},
config = function(_, opts)
local Util = require("lazyvim.util")
local M = {}
local lint = require("lint")
for name, linter in pairs(opts.linters) do
if type(linter) == "table" and type(lint.linters[name]) == "table" then
lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter)
else
lint.linters[name] = linter
end
end
lint.linters_by_ft = opts.linters_by_ft
function M.debounce(ms, fn)
local timer = vim.loop.new_timer()
return function(...)
local argv = { ... }
timer:start(ms, 0, function()
timer:stop()
vim.schedule_wrap(fn)(unpack(argv))
end)
end
end
function M.lint()
-- Use nvim-lint's logic first:
-- * checks if linters exist for the full filetype first
-- * otherwise will split filetype by "." and add all those linters
-- * this differs from conform.nvim which only uses the first filetype that has a formatter
local names = lint._resolve_linter_by_ft(vim.bo.filetype)
-- Add fallback linters.
if #names == 0 then
vim.list_extend(names, lint.linters_by_ft["_"] or {})
end
-- Add global linters.
vim.list_extend(names, lint.linters_by_ft["*"] or {})
-- Filter out linters that don't exist or don't match the condition.
local ctx = { filename = vim.api.nvim_buf_get_name(0) }
ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h")
names = vim.tbl_filter(function(name)
local linter = lint.linters[name]
if not linter then
Util.warn("Linter not found: " .. name, { title = "nvim-lint" })
end
return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx))
end, names)
-- Run linters.
if #names > 0 then
lint.try_lint(names)
end
end
vim.api.nvim_create_autocmd(opts.events, {
group = vim.api.nvim_create_augroup("nvim-lint", { clear = true }),
callback = M.debounce(100, M.lint),
})
end,
},
}

View file

@ -1,152 +0,0 @@
local Util = require("lazy.core.util")
local M = {}
---@type PluginLspOpts
M.opts = nil
function M.enabled()
return M.opts.autoformat
end
function M.toggle()
if vim.b.autoformat == false then
vim.b.autoformat = nil
M.opts.autoformat = true
else
M.opts.autoformat = not M.opts.autoformat
end
if M.opts.autoformat then
Util.info("Enabled format on save", { title = "Format" })
else
Util.warn("Disabled format on save", { title = "Format" })
end
end
---@param opts? {force?:boolean}
function M.format(opts)
local buf = vim.api.nvim_get_current_buf()
if vim.b.autoformat == false and not (opts and opts.force) then
return
end
local formatters = M.get_formatters(buf)
local client_ids = vim.tbl_map(function(client)
return client.id
end, formatters.active)
if #client_ids == 0 then
return
end
if M.opts.format_notify then
M.notify(formatters)
end
vim.lsp.buf.format(vim.tbl_deep_extend("force", {
bufnr = buf,
filter = function(client)
return vim.tbl_contains(client_ids, client.id)
end,
}, require("lazyvim.util").opts("nvim-lspconfig").format or {}))
end
---@param formatters LazyVimFormatters
function M.notify(formatters)
local lines = { "# Active:" }
for _, client in ipairs(formatters.active) do
local line = "- **" .. client.name .. "**"
if client.name == "null-ls" then
line = line
.. " ("
.. table.concat(
vim.tbl_map(function(f)
return "`" .. f.name .. "`"
end, formatters.null_ls),
", "
)
.. ")"
end
table.insert(lines, line)
end
if #formatters.available > 0 then
table.insert(lines, "")
table.insert(lines, "# Disabled:")
for _, client in ipairs(formatters.available) do
table.insert(lines, "- **" .. client.name .. "**")
end
end
vim.notify(table.concat(lines, "\n"), vim.log.levels.INFO, {
title = "Formatting",
on_open = function(win)
vim.api.nvim_win_set_option(win, "conceallevel", 3)
vim.api.nvim_win_set_option(win, "spell", false)
local buf = vim.api.nvim_win_get_buf(win)
vim.treesitter.start(buf, "markdown")
end,
})
end
-- Gets all lsp clients that support formatting.
-- When a null-ls formatter is available for the current filetype,
-- only null-ls formatters are returned.
function M.get_formatters(bufnr)
local ft = vim.bo[bufnr].filetype
-- check if we have any null-ls formatters for the current filetype
local null_ls = package.loaded["null-ls"] and require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") or {}
---@class LazyVimFormatters
local ret = {
---@type lsp.Client[]
active = {},
---@type lsp.Client[]
available = {},
null_ls = null_ls,
}
---@type lsp.Client[]
local clients = vim.lsp.get_active_clients({ bufnr = bufnr })
for _, client in ipairs(clients) do
if M.supports_format(client) then
if (#null_ls > 0 and client.name == "null-ls") or #null_ls == 0 then
table.insert(ret.active, client)
else
table.insert(ret.available, client)
end
end
end
return ret
end
-- Gets all lsp clients that support formatting
-- and have not disabled it in their client config
---@param client lsp.Client
function M.supports_format(client)
if
client.config
and client.config.capabilities
and client.config.capabilities.documentFormattingProvider == false
then
return false
end
return client.supports_method("textDocument/formatting") or client.supports_method("textDocument/rangeFormatting")
end
---@param opts PluginLspOpts
function M.setup(opts)
M.opts = opts
vim.api.nvim_create_autocmd("BufWritePre", {
group = vim.api.nvim_create_augroup("LazyVimFormat", {}),
callback = function()
if M.opts.autoformat then
M.format()
end
end,
})
end
return M

View file

@ -1,19 +1,15 @@
local Util = require("lazyvim.util")
return { return {
-- lspconfig -- lspconfig
{ {
"neovim/nvim-lspconfig", "neovim/nvim-lspconfig",
event = { "BufReadPre", "BufNewFile" }, event = "LazyFile",
dependencies = { dependencies = {
{ "folke/neoconf.nvim", cmd = "Neoconf", config = false, dependencies = { "nvim-lspconfig" } }, { "folke/neoconf.nvim", cmd = "Neoconf", config = false, dependencies = { "nvim-lspconfig" } },
{ "folke/neodev.nvim", opts = {} }, { "folke/neodev.nvim", opts = {} },
"mason.nvim", "mason.nvim",
"williamboman/mason-lspconfig.nvim", "williamboman/mason-lspconfig.nvim",
{
"hrsh7th/cmp-nvim-lsp",
cond = function()
return require("lazyvim.util").has("nvim-cmp")
end,
},
}, },
---@class PluginLspOpts ---@class PluginLspOpts
opts = { opts = {
@ -39,11 +35,6 @@ return {
}, },
-- add any global capabilities here -- add any global capabilities here
capabilities = {}, capabilities = {},
-- Automatically format on save
autoformat = true,
-- Enable this to show formatters used in a notification
-- Useful for debugging formatter issues
format_notify = false,
-- options for vim.lsp.buf.format -- options for vim.lsp.buf.format
-- `bufnr` and `filter` is handled by the LazyVim formatter, -- `bufnr` and `filter` is handled by the LazyVim formatter,
-- but can be also overridden when specified -- but can be also overridden when specified
@ -54,12 +45,11 @@ return {
-- LSP Server Settings -- LSP Server Settings
---@type lspconfig.options ---@type lspconfig.options
servers = { servers = {
jsonls = {},
lua_ls = { lua_ls = {
-- mason = false, -- set to false if you don't want this server to be installed with mason -- mason = false, -- set to false if you don't want this server to be installed with mason
-- Use this to add any additional keymaps -- Use this to add any additional keymaps
-- for specific lsp servers -- for specific lsp servers
---@type LazyKeys[] ---@type LazyKeysSpec[]
-- keys = {}, -- keys = {},
settings = { settings = {
Lua = { Lua = {
@ -88,16 +78,22 @@ return {
}, },
---@param opts PluginLspOpts ---@param opts PluginLspOpts
config = function(_, opts) config = function(_, opts)
local Util = require("lazyvim.util")
if Util.has("neoconf.nvim") then if Util.has("neoconf.nvim") then
local plugin = require("lazy.core.config").spec.plugins["neoconf.nvim"] local plugin = require("lazy.core.config").spec.plugins["neoconf.nvim"]
require("neoconf").setup(require("lazy.core.plugin").values(plugin, "opts", false)) require("neoconf").setup(require("lazy.core.plugin").values(plugin, "opts", false))
end end
-- setup autoformat -- setup autoformat
require("lazyvim.plugins.lsp.format").setup(opts) Util.format.register(Util.lsp.formatter())
-- setup formatting and keymaps
Util.on_attach(function(client, buffer) -- deprectaed options
if opts.autoformat ~= nil then
vim.g.autoformat = opts.autoformat
Util.deprecate("nvim-lspconfig.opts.autoformat", "vim.g.autoformat")
end
-- setup keymaps
Util.lsp.on_attach(function(client, buffer)
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
end) end)
@ -122,8 +118,8 @@ return {
local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint
if opts.inlay_hints.enabled and inlay_hint then if opts.inlay_hints.enabled and inlay_hint then
Util.on_attach(function(client, buffer) Util.lsp.on_attach(function(client, buffer)
if client.supports_method('textDocument/inlayHint') then if client.supports_method("textDocument/inlayHint") then
inlay_hint(buffer, true) inlay_hint(buffer, true)
end end
end) end)
@ -194,36 +190,16 @@ return {
mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } }) mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } })
end end
if Util.lsp_get_config("denols") and Util.lsp_get_config("tsserver") then if Util.lsp.get_config("denols") and Util.lsp.get_config("tsserver") then
local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc") local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc")
Util.lsp_disable("tsserver", is_deno) Util.lsp.disable("tsserver", is_deno)
Util.lsp_disable("denols", function(root_dir) Util.lsp.disable("denols", function(root_dir)
return not is_deno(root_dir) return not is_deno(root_dir)
end) end)
end end
end, end,
}, },
-- formatters
{
"jose-elias-alvarez/null-ls.nvim",
event = { "BufReadPre", "BufNewFile" },
dependencies = { "mason.nvim" },
opts = function()
local nls = require("null-ls")
return {
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"),
sources = {
nls.builtins.formatting.fish_indent,
nls.builtins.diagnostics.fish,
nls.builtins.formatting.stylua,
nls.builtins.formatting.shfmt,
-- nls.builtins.diagnostics.flake8,
},
}
end,
},
-- cmdline tools and lsp servers -- cmdline tools and lsp servers
{ {
@ -242,6 +218,15 @@ return {
config = function(_, opts) config = function(_, opts)
require("mason").setup(opts) require("mason").setup(opts)
local mr = require("mason-registry") local mr = require("mason-registry")
mr:on("package:install:success", function()
vim.defer_fn(function()
-- trigger FileType event to possibly load this newly installed LSP server
require("lazy.core.handler.event").trigger({
event = "FileType",
buf = vim.api.nvim_get_current_buf(),
})
end, 100)
end)
local function ensure_installed() local function ensure_installed()
for _, tool in ipairs(opts.ensure_installed) do for _, tool in ipairs(opts.ensure_installed) do
local p = mr.get_package(tool) local p = mr.get_package(tool)

View file

@ -1,18 +1,18 @@
local M = {} local M = {}
---@type PluginLspKeys ---@type LazyKeysLspSpec[]|nil
M._keys = nil M._keys = nil
---@return (LazyKeys|{has?:string})[] ---@alias LazyKeysLspSpec LazyKeysSpec|{has?:string}
---@alias LazyKeysLsp LazyKeys|{has?:string}
---@return LazyKeysLspSpec[]
function M.get() function M.get()
local format = function() if M._keys then
require("lazyvim.plugins.lsp.format").format({ force = true }) return M._keys
end end
if not M._keys then
---@class PluginLspKeys
-- stylua: ignore -- stylua: ignore
M._keys = { M._keys = {
{ "<leader>cd", vim.diagnostic.open_float, desc = "Line Diagnostics" },
{ "<leader>cl", "<cmd>LspInfo<cr>", desc = "Lsp Info" }, { "<leader>cl", "<cmd>LspInfo<cr>", desc = "Lsp Info" },
{ "gd", function() require("telescope.builtin").lsp_definitions({ reuse_win = true }) end, desc = "Goto Definition", has = "definition" }, { "gd", function() require("telescope.builtin").lsp_definitions({ reuse_win = true }) end, desc = "Goto Definition", has = "definition" },
{ "gr", "<cmd>Telescope lsp_references<cr>", desc = "References" }, { "gr", "<cmd>Telescope lsp_references<cr>", desc = "References" },
@ -22,14 +22,6 @@ function M.get()
{ "K", vim.lsp.buf.hover, desc = "Hover" }, { "K", vim.lsp.buf.hover, desc = "Hover" },
{ "gK", vim.lsp.buf.signature_help, desc = "Signature Help", has = "signatureHelp" }, { "gK", vim.lsp.buf.signature_help, 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" },
{ "]d", M.diagnostic_goto(true), desc = "Next Diagnostic" },
{ "[d", M.diagnostic_goto(false), desc = "Prev Diagnostic" },
{ "]e", M.diagnostic_goto(true, "ERROR"), desc = "Next Error" },
{ "[e", M.diagnostic_goto(false, "ERROR"), desc = "Prev Error" },
{ "]w", M.diagnostic_goto(true, "WARN"), desc = "Next Warning" },
{ "[w", M.diagnostic_goto(false, "WARN"), desc = "Prev Warning" },
{ "<leader>cf", format, desc = "Format Document", has = "formatting" },
{ "<leader>cf", format, desc = "Format Range", mode = "v", has = "rangeFormatting" },
{ "<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>cA", "<leader>cA",
@ -47,20 +39,19 @@ function M.get()
has = "codeAction", has = "codeAction",
} }
} }
if require("lazyvim.util").has("inc-rename.nvim") then if require("lazyvim.util").has("inc-rename.nvim") then
M._keys[#M._keys + 1] = { M._keys[#M._keys + 1] = {
"<leader>cr", "<leader>cr",
function() function()
local inc_rename = require("inc_rename") local inc_rename = require("inc_rename")
return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("<cword>") return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("<cword>")
end, end,
expr = true, expr = true,
desc = "Rename", desc = "Rename",
has = "rename", has = "rename",
} }
else else
M._keys[#M._keys + 1] = { "<leader>cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" } M._keys[#M._keys + 1] = { "<leader>cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" }
end
end end
return M._keys return M._keys
end end
@ -68,7 +59,7 @@ end
---@param method string ---@param method string
function M.has(buffer, method) function M.has(buffer, method)
method = method:find("/") and method or "textDocument/" .. method method = method:find("/") and method or "textDocument/" .. method
local clients = vim.lsp.get_active_clients({ bufnr = buffer }) local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer })
for _, client in ipairs(clients) do for _, client in ipairs(clients) do
if client.supports_method(method) then if client.supports_method(method) then
return true return true
@ -77,55 +68,35 @@ function M.has(buffer, method)
return false return false
end end
---@return (LazyKeys|{has?:string})[]
function M.resolve(buffer) function M.resolve(buffer)
local Keys = require("lazy.core.handler.keys") local Keys = require("lazy.core.handler.keys")
local keymaps = {} ---@type table<string,LazyKeys|{has?:string}> if not Keys.resolve then
return {}
local function add(keymap)
local keys = Keys.parse(keymap)
if keys[2] == false then
keymaps[keys.id] = nil
else
keymaps[keys.id] = keys
end
end end
for _, keymap in ipairs(M.get()) do local spec = M.get()
add(keymap)
end
local opts = require("lazyvim.util").opts("nvim-lspconfig") local opts = require("lazyvim.util").opts("nvim-lspconfig")
local clients = vim.lsp.get_active_clients({ bufnr = buffer }) local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer })
for _, client in ipairs(clients) do for _, client in ipairs(clients) do
local maps = opts.servers[client.name] and opts.servers[client.name].keys or {} local maps = opts.servers[client.name] and opts.servers[client.name].keys or {}
for _, keymap in ipairs(maps) do vim.list_extend(spec, maps)
add(keymap)
end
end end
return keymaps return Keys.resolve(spec)
end end
function M.on_attach(client, buffer) function M.on_attach(_, buffer)
local Keys = require("lazy.core.handler.keys") local Keys = require("lazy.core.handler.keys")
local keymaps = M.resolve(buffer) local keymaps = M.resolve(buffer)
for _, keys in pairs(keymaps) do for _, keys in pairs(keymaps) do
if not keys.has or M.has(buffer, keys.has) then if not keys.has or M.has(buffer, keys.has) then
local opts = Keys.opts(keys) local opts = Keys.opts(keys)
---@diagnostic disable-next-line: no-unknown
opts.has = nil opts.has = nil
opts.silent = opts.silent ~= false opts.silent = opts.silent ~= false
opts.buffer = buffer opts.buffer = buffer
vim.keymap.set(keys.mode or "n", keys[1], keys[2], opts) vim.keymap.set(keys.mode or "n", keys.lhs, keys.rhs, opts)
end end
end end
end end
function M.diagnostic_goto(next, severity)
local go = next and vim.diagnostic.goto_next or vim.diagnostic.goto_prev
severity = severity and vim.diagnostic.severity[severity] or nil
return function()
go({ severity = severity })
end
end
return M return M

View file

@ -1,4 +1,3 @@
local load_textobjects = false
return { return {
-- Treesitter is a new parser generator tool that we can -- Treesitter is a new parser generator tool that we can
-- use in Neovim to power faster and more accurate -- use in Neovim to power faster and more accurate
@ -7,35 +6,62 @@ return {
"nvim-treesitter/nvim-treesitter", "nvim-treesitter/nvim-treesitter",
version = false, -- last release is way too old and doesn't work on Windows version = false, -- last release is way too old and doesn't work on Windows
build = ":TSUpdate", build = ":TSUpdate",
event = { "BufReadPost", "BufNewFile" }, event = { "LazyFile", "VeryLazy" },
init = function(plugin)
-- PERF: add nvim-treesitter queries to the rtp and it's custom query predicates early
-- This is needed because a bunch of plugins no longer `require("nvim-treesitter")`, which
-- no longer trigger the **nvim-treeitter** module to be loaded in time.
-- Luckily, the only thins that those plugins need are the custom queries, which we make available
-- during startup.
require("lazy.core.loader").add_to_rtp(plugin)
require("nvim-treesitter.query_predicates")
end,
dependencies = { dependencies = {
{ {
"nvim-treesitter/nvim-treesitter-textobjects", "nvim-treesitter/nvim-treesitter-textobjects",
init = function() config = function()
-- disable rtp plugin, as we only need its queries for mini.ai -- When in diff mode, we want to use the default
-- In case other textobject modules are enabled, we will load them -- vim text objects c & C instead of the treesitter ones.
-- once nvim-treesitter is loaded local move = require("nvim-treesitter.textobjects.move") ---@type table<string,fun(...)>
require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") local configs = require("nvim-treesitter.configs")
load_textobjects = true for name, fn in pairs(move) do
if name:find("goto") == 1 then
move[name] = function(q, ...)
if vim.wo.diff then
local config = configs.get_module("textobjects.move")[name] ---@type table<string,string>
for key, query in pairs(config or {}) do
if q == query and key:find("[%]%[][cC]") then
vim.cmd("normal! " .. key)
return
end
end
end
return fn(q, ...)
end
end
end
end, end,
}, },
}, },
cmd = { "TSUpdateSync" }, cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" },
keys = { keys = {
{ "<c-space>", desc = "Increment selection" }, { "<c-space>", desc = "Increment selection" },
{ "<bs>", desc = "Decrement selection", mode = "x" }, { "<bs>", desc = "Decrement selection", mode = "x" },
}, },
---@type TSConfig ---@type TSConfig
---@diagnostic disable-next-line: missing-fields
opts = { opts = {
highlight = { enable = true }, highlight = { enable = true },
indent = { enable = true }, indent = { enable = true },
ensure_installed = { ensure_installed = {
"bash", "bash",
"c", "c",
"diff",
"html", "html",
"javascript", "javascript",
"jsdoc", "jsdoc",
"json", "json",
"jsonc",
"lua", "lua",
"luadoc", "luadoc",
"luap", "luap",
@ -44,6 +70,7 @@ return {
"python", "python",
"query", "query",
"regex", "regex",
"toml",
"tsx", "tsx",
"typescript", "typescript",
"vim", "vim",
@ -59,6 +86,15 @@ return {
node_decremental = "<bs>", node_decremental = "<bs>",
}, },
}, },
textobjects = {
move = {
enable = true,
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
},
},
}, },
---@param opts TSConfig ---@param opts TSConfig
config = function(_, opts) config = function(_, opts)
@ -74,21 +110,37 @@ return {
end, opts.ensure_installed) end, opts.ensure_installed)
end end
require("nvim-treesitter.configs").setup(opts) require("nvim-treesitter.configs").setup(opts)
if load_textobjects then
-- PERF: no need to load the plugin, if we only need its queries for mini.ai
if opts.textobjects then
for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do
if opts.textobjects[mod] and opts.textobjects[mod].enable then
local Loader = require("lazy.core.loader")
Loader.disabled_rtp_plugins["nvim-treesitter-textobjects"] = nil
local plugin = require("lazy.core.config").plugins["nvim-treesitter-textobjects"]
require("lazy.core.loader").source_runtime(plugin.dir, "plugin")
break
end
end
end
end
end, end,
}, },
-- Show context of the current function
{
"nvim-treesitter/nvim-treesitter-context",
event = "LazyFile",
enabled = true,
opts = { mode = "cursor", max_lines = 3 },
keys = {
{
"<leader>ut",
function()
local Util = require("lazyvim.util")
local tsc = require("treesitter-context")
tsc.toggle()
if Util.inject.get_upvalue(tsc.toggle, "enabled") then
Util.info("Enabled Treesitter Context", { title = "Option" })
else
Util.warn("Disabled Treesitter Context", { title = "Option" })
end
end,
desc = "Toggle Treesitter Context",
},
},
},
-- Automatically add closing tags for HTML and JSX
{
"windwp/nvim-ts-autotag",
event = "LazyFile",
opts = {},
},
} }

View file

@ -1,3 +1,5 @@
local Util = require("lazyvim.util")
return { return {
-- Better `vim.notify()` -- Better `vim.notify()`
{ {
@ -19,10 +21,12 @@ return {
max_width = function() max_width = function()
return math.floor(vim.o.columns * 0.75) return math.floor(vim.o.columns * 0.75)
end, end,
on_open = function(win)
vim.api.nvim_win_set_config(win, { zindex = 100 })
end,
}, },
init = function() init = function()
-- when noice is not enabled, install notify on VeryLazy -- when noice is not enabled, install notify on VeryLazy
local Util = require("lazyvim.util")
if not Util.has("noice.nvim") then if not Util.has("noice.nvim") then
Util.on_very_lazy(function() Util.on_very_lazy(function()
vim.notify = require("notify") vim.notify = require("notify")
@ -57,6 +61,13 @@ return {
keys = { keys = {
{ "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle pin" }, { "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle pin" },
{ "<leader>bP", "<Cmd>BufferLineGroupClose ungrouped<CR>", desc = "Delete non-pinned buffers" }, { "<leader>bP", "<Cmd>BufferLineGroupClose ungrouped<CR>", desc = "Delete non-pinned buffers" },
{ "<leader>bo", "<Cmd>BufferLineCloseOthers<CR>", desc = "Delete other buffers" },
{ "<leader>br", "<Cmd>BufferLineCloseRight<CR>", desc = "Delete buffers to the right" },
{ "<leader>bl", "<Cmd>BufferLineCloseLeft<CR>", desc = "Delete buffers to the left" },
{ "<S-h>", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev buffer" },
{ "<S-l>", "<cmd>BufferLineCycleNext<cr>", desc = "Next buffer" },
{ "[b", "<cmd>BufferLineCyclePrev<cr>", desc = "Prev buffer" },
{ "]b", "<cmd>BufferLineCycleNext<cr>", desc = "Next buffer" },
}, },
opts = { opts = {
options = { options = {
@ -82,26 +93,54 @@ return {
}, },
}, },
}, },
config = function(_, opts)
require("bufferline").setup(opts)
-- Fix bufferline when restoring a session
vim.api.nvim_create_autocmd("BufAdd", {
callback = function()
vim.schedule(function()
pcall(nvim_bufferline)
end)
end,
})
end,
}, },
-- statusline -- statusline
{ {
"nvim-lualine/lualine.nvim", "nvim-lualine/lualine.nvim",
event = "VeryLazy", event = "VeryLazy",
init = function()
vim.g.lualine_laststatus = vim.o.laststatus
if vim.fn.argc(-1) > 0 then
-- set an empty statusline till lualine loads
vim.o.statusline = " "
else
-- hide the statusline on the starter page
vim.o.laststatus = 0
end
end,
opts = function() opts = function()
-- PERF: we don't need this lualine require madness 🤷
local lualine_require = require("lualine_require")
lualine_require.require = require
local icons = require("lazyvim.config").icons local icons = require("lazyvim.config").icons
local Util = require("lazyvim.util")
vim.o.laststatus = vim.g.lualine_laststatus
return { return {
options = { options = {
theme = "auto", theme = "auto",
globalstatus = true, globalstatus = true,
disabled_filetypes = { statusline = { "dashboard", "alpha" } }, disabled_filetypes = { statusline = { "dashboard", "alpha", "starter" } },
}, },
sections = { sections = {
lualine_a = { "mode" }, lualine_a = { "mode" },
lualine_b = { "branch" }, lualine_b = { "branch" },
lualine_c = { lualine_c = {
Util.lualine.root_dir(),
{ {
"diagnostics", "diagnostics",
symbols = { symbols = {
@ -112,33 +151,32 @@ return {
}, },
}, },
{ "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } },
{ "filename", path = 1, symbols = { modified = "", readonly = "", unnamed = "" } }, { Util.lualine.pretty_path() },
-- stylua: ignore
{
function() return require("nvim-navic").get_location() end,
cond = function() return package.loaded["nvim-navic"] and require("nvim-navic").is_available() end,
},
}, },
lualine_x = { lualine_x = {
-- stylua: ignore -- stylua: ignore
{ {
function() return require("noice").api.status.command.get() end, function() return require("noice").api.status.command.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end, cond = function() return package.loaded["noice"] and require("noice").api.status.command.has() end,
color = Util.fg("Statement"), color = Util.ui.fg("Statement"),
}, },
-- stylua: ignore -- stylua: ignore
{ {
function() return require("noice").api.status.mode.get() end, function() return require("noice").api.status.mode.get() end,
cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end,
color = Util.fg("Constant"), color = Util.ui.fg("Constant"),
}, },
-- stylua: ignore -- stylua: ignore
{ {
function() return "" .. require("dap").status() end, function() return "" .. require("dap").status() end,
cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end,
color = Util.fg("Debug"), color = Util.ui.fg("Debug"),
},
{
require("lazy.status").updates,
cond = require("lazy.status").has_updates,
color = Util.ui.fg("Special"),
}, },
{ require("lazy.status").updates, cond = require("lazy.status").has_updates, color = Util.fg("Special") },
{ {
"diff", "diff",
symbols = { symbols = {
@ -146,6 +184,16 @@ return {
modified = icons.git.modified, modified = icons.git.modified,
removed = icons.git.removed, removed = icons.git.removed,
}, },
source = function()
local gitsigns = vim.b.gitsigns_status_dict
if gitsigns then
return {
added = gitsigns.added,
modified = gitsigns.changed,
removed = gitsigns.removed,
}
end
end,
}, },
}, },
lualine_y = { lualine_y = {
@ -166,25 +214,30 @@ return {
-- indent guides for Neovim -- indent guides for Neovim
{ {
"lukas-reineke/indent-blankline.nvim", "lukas-reineke/indent-blankline.nvim",
event = { "BufReadPost", "BufNewFile" }, event = "LazyFile",
opts = { opts = {
-- char = "▏", indent = {
char = "", char = "",
filetype_exclude = { tab_char = "",
"help", },
"alpha", scope = { enabled = false },
"dashboard", exclude = {
"neo-tree", filetypes = {
"Trouble", "help",
"lazy", "alpha",
"mason", "dashboard",
"notify", "neo-tree",
"toggleterm", "Trouble",
"lazyterm", "trouble",
"lazy",
"mason",
"notify",
"toggleterm",
"lazyterm",
},
}, },
show_trailing_blankline_indent = false,
show_current_context = false,
}, },
main = "ibl",
}, },
-- Active indent guide and indent text objects. When you're browsing -- Active indent guide and indent text objects. When you're browsing
@ -193,7 +246,7 @@ return {
{ {
"echasnovski/mini.indentscope", "echasnovski/mini.indentscope",
version = false, -- wait till new 0.7.0 release to put it back on semver version = false, -- wait till new 0.7.0 release to put it back on semver
event = { "BufReadPre", "BufNewFile" }, event = "LazyFile",
opts = { opts = {
-- symbol = "▏", -- symbol = "▏",
symbol = "", symbol = "",
@ -207,6 +260,7 @@ return {
"dashboard", "dashboard",
"neo-tree", "neo-tree",
"Trouble", "Trouble",
"trouble",
"lazy", "lazy",
"mason", "mason",
"notify", "notify",
@ -220,7 +274,7 @@ return {
end, end,
}, },
-- noicer ui -- Displays a popup with possible key bindings of the command you started typing
{ {
"folke/which-key.nvim", "folke/which-key.nvim",
opts = function(_, opts) opts = function(_, opts)
@ -229,6 +283,8 @@ return {
end end
end, end,
}, },
-- Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu.
{ {
"folke/noice.nvim", "folke/noice.nvim",
event = "VeryLazy", event = "VeryLazy",
@ -272,96 +328,86 @@ return {
}, },
}, },
-- Dashboard. This runs when neovim starts, and is what displays -- icons
-- the "LAZYVIM" banner. { "nvim-tree/nvim-web-devicons", lazy = true },
-- ui components
{ "MunifTanjim/nui.nvim", lazy = true },
{ {
"goolord/alpha-nvim", "goolord/alpha-nvim",
optional = true,
enabled = function()
require("lazyvim.util").warn({
"`dashboard.nvim` is now the default LazyVim starter plugin.",
"",
"To keep using `alpha.nvim`, please enable the `lazyvim.plugins.extras.ui.alpha` extra.",
"Or to hide this message, remove the alpha spec from your config.",
})
return false
end,
},
{
"nvimdev/dashboard-nvim",
event = "VimEnter", event = "VimEnter",
opts = function() opts = function()
local dashboard = require("alpha.themes.dashboard")
local logo = [[ local logo = [[
Z Z
Z Z
z z
z z
]] ]]
dashboard.section.header.val = vim.split(logo, "\n") logo = string.rep("\n", 8) .. logo .. "\n\n"
dashboard.section.buttons.val = {
dashboard.button("f", "" .. " Find file", ":Telescope find_files <CR>"), local opts = {
dashboard.button("n", "" .. " New file", ":ene <BAR> startinsert <CR>"), theme = "doom",
dashboard.button("r", "" .. " Recent files", ":Telescope oldfiles <CR>"), hide = {
dashboard.button("g", "" .. " Find text", ":Telescope live_grep <CR>"), -- this is taken care of by lualine
dashboard.button("c", "" .. " Config", ":e $MYVIMRC <CR>"), -- enabling this messes up the actual laststatus setting after loading a file
dashboard.button("s", "" .. " Restore Session", [[:lua require("persistence").load() <cr>]]), statusline = false,
dashboard.button("l", "󰒲 " .. " Lazy", ":Lazy<CR>"), },
dashboard.button("q", "" .. " Quit", ":qa<CR>"), config = {
header = vim.split(logo, "\n"),
-- stylua: ignore
center = {
{ action = "Telescope find_files", desc = " Find file", icon = "", key = "f" },
{ action = "ene | startinsert", desc = " New file", icon = "", key = "n" },
{ action = "Telescope oldfiles", desc = " Recent files", icon = "", key = "r" },
{ action = "Telescope live_grep", desc = " Find text", icon = "", key = "g" },
{ action = [[lua require("lazyvim.util").telescope.config_files()()]], desc = " Config", icon = "", key = "c" },
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = "", key = "s" },
{ action = "LazyExtras", desc = " Lazy Extras", icon = "", key = "x" },
{ action = "Lazy", desc = " Lazy", icon = "󰒲 ", key = "l" },
{ action = "qa", desc = " Quit", icon = "", key = "q" },
},
footer = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
return { "⚡ Neovim loaded " .. stats.loaded .. "/" .. stats.count .. " plugins in " .. ms .. "ms" }
end,
},
} }
for _, button in ipairs(dashboard.section.buttons.val) do
button.opts.hl = "AlphaButtons" for _, button in ipairs(opts.config.center) do
button.opts.hl_shortcut = "AlphaShortcut" button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
button.key_format = " %s"
end end
dashboard.section.header.opts.hl = "AlphaHeader"
dashboard.section.buttons.opts.hl = "AlphaButtons"
dashboard.section.footer.opts.hl = "AlphaFooter"
dashboard.opts.layout[1].val = 8
return dashboard
end,
config = function(_, dashboard)
-- close Lazy and re-open when the dashboard is ready -- close Lazy and re-open when the dashboard is ready
if vim.o.filetype == "lazy" then if vim.o.filetype == "lazy" then
vim.cmd.close() vim.cmd.close()
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "AlphaReady", pattern = "DashboardLoaded",
callback = function() callback = function()
require("lazy").show() require("lazy").show()
end, end,
}) })
end end
require("alpha").setup(dashboard.opts) return opts
vim.api.nvim_create_autocmd("User", {
pattern = "LazyVimStarted",
callback = function()
local stats = require("lazy").stats()
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
dashboard.section.footer.val = "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms"
pcall(vim.cmd.AlphaRedraw)
end,
})
end, end,
}, },
-- lsp symbol navigation for lualine. This shows where
-- in the code structure you are - within functions, classes,
-- etc - in the statusline.
{
"SmiteshP/nvim-navic",
lazy = true,
init = function()
vim.g.navic_silence = true
require("lazyvim.util").on_attach(function(client, buffer)
if client.server_capabilities.documentSymbolProvider then
require("nvim-navic").attach(client, buffer)
end
end)
end,
opts = function()
return {
separator = " ",
highlight = true,
depth_limit = 5,
icons = require("lazyvim.config").icons.kinds,
}
end,
},
-- icons
{ "nvim-tree/nvim-web-devicons", lazy = true },
-- ui components
{ "MunifTanjim/nui.nvim", lazy = true },
} }

View file

@ -15,7 +15,7 @@ return {
{ {
"folke/persistence.nvim", "folke/persistence.nvim",
event = "BufReadPre", event = "BufReadPre",
opts = { options = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp" } }, opts = { options = vim.opt.sessionoptions:get() },
-- stylua: ignore -- stylua: ignore
keys = { keys = {
{ "<leader>qs", function() require("persistence").load() end, desc = "Restore Session" }, { "<leader>qs", function() require("persistence").load() end, desc = "Restore Session" },

View file

@ -0,0 +1,23 @@
local Config = require("lazyvim.config")
-- Some extras need to be loaded before others
local prios = {
["lazyvim.plugins.extras.editor.aerial"] = 100,
["lazyvim.plugins.extras.editor.symbols-outline"] = 100,
["lazyvim.plugins.extras.test.core"] = 1,
["lazyvim.plugins.extras.dap.core"] = 1,
}
table.sort(Config.json.data.extras, function(a, b)
local pa = prios[a] or 10
local pb = prios[b] or 10
if pa == pb then
return a < b
end
return pa < pb
end)
---@param extra string
return vim.tbl_map(function(extra)
return { import = extra }
end, Config.json.data.extras)

243
lua/lazyvim/util/extras.lua Normal file
View file

@ -0,0 +1,243 @@
local Config = require("lazyvim.config")
local Float = require("lazy.view.float")
local LazyConfig = require("lazy.core.config")
local Plugin = require("lazy.core.plugin")
local Text = require("lazy.view.text")
local Util = require("lazyvim.util")
---@class LazyExtraSource
---@field name string
---@field desc? string
---@field module string
---@class LazyExtra
---@field name string
---@field source LazyExtraSource
---@field module string
---@field desc? string
---@field enabled boolean
---@field managed boolean
---@field row? number
---@field plugins string[]
---@field optional string[]
---@class lazyvim.util.extras
local M = {}
---@type LazyExtraSource[]
M.sources = {
{ name = "LazyVim", desc = "LazyVim extras", module = "lazyvim.plugins.extras" },
{ name = "User", desc = "User extras", module = "plugins.extras" },
}
M.ns = vim.api.nvim_create_namespace("lazyvim.extras")
---@type string[]
M.state = nil
---@return LazyExtra[]
function M.get()
M.state = M.state or LazyConfig.spec.modules
local extras = {} ---@type LazyExtra[]
for _, source in ipairs(M.sources) do
local root = Util.find_root(source.module)
if root then
Util.walk(root, function(path, name, type)
if type == "file" and name:match("%.lua$") then
name = path:sub(#root + 2, -5):gsub("/", ".")
local ok, extra = pcall(M.get_extra, source, source.module .. "." .. name)
if ok then
extras[#extras + 1] = extra
end
end
end)
end
end
table.sort(extras, function(a, b)
return a.name < b.name
end)
return extras
end
---@param modname string
---@param source LazyExtraSource
function M.get_extra(source, modname)
local enabled = vim.tbl_contains(M.state, modname)
local spec = Plugin.Spec.new({ import = modname }, { optional = true })
local plugins = {} ---@type string[]
local optional = {} ---@type string[]
for _, p in pairs(spec.plugins) do
if p.optional then
optional[#optional + 1] = p.name
else
plugins[#plugins + 1] = p.name
end
end
table.sort(plugins)
table.sort(optional)
---@type LazyExtra
return {
source = source,
name = modname:sub(#source.module + 2),
module = modname,
enabled = enabled,
desc = require(modname).desc,
managed = vim.tbl_contains(Config.json.data.extras, modname) or not enabled,
plugins = plugins,
optional = optional,
}
end
---@class LazyExtraView
---@field float LazyFloat
---@field text Text
---@field extras LazyExtra[]
---@field diag LazyDiagnostic[]
local X = {}
---@return LazyExtraView
function X.new()
local self = setmetatable({}, { __index = X })
self.float = Float.new({ title = "LazyVim Extras" })
self.float:on_key("x", function()
self:toggle()
end, "Toggle extra")
self.diag = {}
self:update()
return self
end
---@param diag LazyDiagnostic
function X:diagnostic(diag)
diag.row = diag.row or self.text:row()
diag.severity = diag.severity or vim.diagnostic.severity.INFO
table.insert(self.diag, diag)
end
function X:toggle()
local pos = vim.api.nvim_win_get_cursor(self.float.win)
for _, extra in ipairs(self.extras) do
if extra.row == pos[1] then
if not extra.managed then
Util.error(
"Not managed by LazyExtras. Remove from your config to enable/disable here.",
{ title = "LazyExtras" }
)
return
end
extra.enabled = not extra.enabled
Config.json.data.extras = vim.tbl_filter(function(name)
return name ~= extra.module
end, Config.json.data.extras)
M.state = vim.tbl_filter(function(name)
return name ~= extra.module
end, M.state)
if extra.enabled then
table.insert(Config.json.data.extras, extra.module)
M.state[#M.state + 1] = extra.module
end
table.sort(Config.json.data.extras)
Util.json.save()
Util.info(
"`"
.. extra.name
.. "`"
.. " "
.. (extra.enabled and "**enabled**" or "**disabled**")
.. "\nPlease restart LazyVim to apply the changes.",
{ title = "LazyExtras" }
)
self:update()
return
end
end
end
function X:update()
self.diag = {}
self.extras = M.get()
self.text = Text.new()
self.text.padding = 2
self:render()
self.text:trim()
vim.bo[self.float.buf].modifiable = true
self.text:render(self.float.buf)
vim.bo[self.float.buf].modifiable = false
vim.diagnostic.set(
M.ns,
self.float.buf,
---@param diag LazyDiagnostic
vim.tbl_map(function(diag)
diag.col = 0
diag.lnum = diag.row - 1
return diag
end, self.diag),
{ signs = false, virtual_text = true }
)
end
function X:render()
self.text:nl():nl():append("LazyVim Extras", "LazyH1"):nl():nl()
self.text
:append("This is a list of all enabled/disabled LazyVim extras.", "LazyComment")
:nl()
:append("Each extra shows the required and optional plugins it may install.", "LazyComment")
:nl()
:append("Enable/disable extras with the ", "LazyComment")
:append("<x>", "LazySpecial")
:append(" key", "LazyComment")
:nl()
self:section({ enabled = true, title = "Enabled" })
self:section({ enabled = false, title = "Disabled" })
end
---@param extra LazyExtra
function X:extra(extra)
if not extra.managed then
self:diagnostic({
message = "Not managed by LazyExtras (config)",
severity = vim.diagnostic.severity.WARN,
})
end
extra.row = self.text:row()
local hl = extra.managed and "LazySpecial" or "LazyLocal"
if extra.enabled then
self.text:append(" " .. LazyConfig.options.ui.icons.loaded .. " ", hl)
else
self.text:append(" " .. LazyConfig.options.ui.icons.not_loaded .. " ", hl)
end
self.text:append(extra.name)
if extra.source.name ~= "LazyVim" then
self.text:append(" "):append(LazyConfig.options.ui.icons.event .. " " .. extra.source.name, "LazyReasonEvent")
end
for _, plugin in ipairs(extra.plugins) do
self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonPlugin")
end
for _, plugin in ipairs(extra.optional) do
self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonRequire")
end
if extra.desc then
self.text:nl():append(" " .. extra.desc, "LazyComment")
end
self.text:nl()
end
---@param opts {enabled?:boolean, title?:string}
function X:section(opts)
opts = opts or {}
---@type LazyExtra[]
local extras = vim.tbl_filter(function(extra)
return opts.enabled == nil or extra.enabled == opts.enabled
end, self.extras)
self.text:nl():append(opts.title .. ":", "LazyH2"):append(" (" .. #extras .. ")", "LazyComment"):nl()
for _, extra in ipairs(extras) do
self:extra(extra)
end
end
function M.show()
return X.new()
end
return M

173
lua/lazyvim/util/format.lua Normal file
View file

@ -0,0 +1,173 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.format
---@overload fun(opts?: {force?:boolean})
local M = setmetatable({}, {
__call = function(m, ...)
return m.format(...)
end,
})
---@class LazyFormatter
---@field name string
---@field primary? boolean
---@field format fun(bufnr:number)
---@field sources fun(bufnr:number):string[]
---@field priority number
M.formatters = {} ---@type LazyFormatter[]
---@param formatter LazyFormatter
function M.register(formatter)
M.formatters[#M.formatters + 1] = formatter
table.sort(M.formatters, function(a, b)
return a.priority > b.priority
end)
end
function M.formatexpr()
if Util.has("conform.nvim") then
return require("conform").formatexpr()
end
return vim.lsp.formatexpr({ timeout_ms = 3000 })
end
---@param buf? number
---@return (LazyFormatter|{active:boolean,resolved:string[]})[]
function M.resolve(buf)
buf = buf or vim.api.nvim_get_current_buf()
local have_primary = false
---@param formatter LazyFormatter
return vim.tbl_map(function(formatter)
local sources = formatter.sources(buf)
local active = #sources > 0 and (not formatter.primary or not have_primary)
have_primary = have_primary or (active and formatter.primary) or false
return setmetatable({
active = active,
resolved = sources,
}, { __index = formatter })
end, M.formatters)
end
---@param buf? number
function M.info(buf)
buf = buf or vim.api.nvim_get_current_buf()
local gaf = vim.g.autoformat == nil or vim.g.autoformat
local baf = vim.b[buf].autoformat
local enabled = M.enabled(buf)
local lines = {
"# Status",
("- [%s] global **%s**"):format(gaf and "x" or " ", gaf and "enabled" or "disabled"),
("- [%s] buffer **%s**"):format(
enabled and "x" or " ",
baf == nil and "inherit" or baf and "enabled" or "disabled"
),
}
local have = false
for _, formatter in ipairs(M.resolve(buf)) do
if #formatter.resolved > 0 then
have = true
lines[#lines + 1] = "\n# " .. formatter.name .. (formatter.active and " ***(active)***" or "")
for _, line in ipairs(formatter.resolved) do
lines[#lines + 1] = ("- [%s] **%s**"):format(formatter.active and "x" or " ", line)
end
end
end
if not have then
lines[#lines + 1] = "\n***No formatters available for this buffer.***"
end
Util[enabled and "info" or "warn"](
table.concat(lines, "\n"),
{ title = "LazyFormat (" .. (enabled and "enabled" or "disabled") .. ")" }
)
end
---@param buf? number
function M.enabled(buf)
buf = (buf == nil or buf == 0) and vim.api.nvim_get_current_buf() or buf
local gaf = vim.g.autoformat
local baf = vim.b[buf].autoformat
-- If the buffer has a local value, use that
if baf ~= nil then
return baf
end
-- Otherwise use the global value if set, or true by default
return gaf == nil or gaf
end
---@param buf? boolean
function M.toggle(buf)
if buf then
vim.b.autoformat = not M.enabled()
else
vim.g.autoformat = not M.enabled()
vim.b.autoformat = nil
end
M.info()
end
---@param opts? {force?:boolean, buf?:number}
function M.format(opts)
opts = opts or {}
local buf = opts.buf or vim.api.nvim_get_current_buf()
if not ((opts and opts.force) or M.enabled(buf)) then
return
end
local done = false
for _, formatter in ipairs(M.resolve(buf)) do
if formatter.active then
done = true
Util.try(function()
return formatter.format(buf)
end, { msg = "Formatter `" .. formatter.name .. "` failed" })
end
end
if not done and opts and opts.force then
Util.warn("No formatter available", { title = "LazyVim" })
end
end
function M.health()
local Config = require("lazy.core.config")
local has_plugin = Config.spec.plugins["none-ls.nvim"]
local has_extra = vim.tbl_contains(Config.spec.modules, "lazyvim.plugins.extras.lsp.none-ls")
if has_plugin and not has_extra then
Util.warn({
"`conform.nvim` and `nvim-lint` are now the default formatters and linters in LazyVim.",
"",
"You can use those plugins together with `none-ls.nvim`,",
"but you need to enable the `lazyvim.plugins.extras.lsp.none-ls` extra,",
"for formatting to work correctly.",
"",
"In case you no longer want to use `none-ls.nvim`, just remove the spec from your config.",
})
end
end
function M.setup()
M.health()
-- Autoformat autocmd
vim.api.nvim_create_autocmd("BufWritePre", {
group = vim.api.nvim_create_augroup("LazyFormat", {}),
callback = function(event)
M.format({ buf = event.buf })
end,
})
-- Manual format
vim.api.nvim_create_user_command("LazyFormat", function()
M.format({ force = true })
end, { desc = "Format selection or buffer" })
-- Format info
vim.api.nvim_create_user_command("LazyFormatInfo", function()
M.info()
end, { desc = "Show info about the formatters for the current buffer" })
end
return M

View file

@ -1,18 +1,56 @@
local Util = require("lazy.core.util") local LazyUtil = require("lazy.core.util")
---@class lazyvim.util: LazyUtilCore
---@field ui lazyvim.util.ui
---@field lsp lazyvim.util.lsp
---@field root lazyvim.util.root
---@field telescope lazyvim.util.telescope
---@field terminal lazyvim.util.terminal
---@field toggle lazyvim.util.toggle
---@field format lazyvim.util.format
---@field plugin lazyvim.util.plugin
---@field extras lazyvim.util.extras
---@field inject lazyvim.util.inject
---@field news lazyvim.util.news
---@field json lazyvim.util.json
---@field lualine lazyvim.util.lualine
local M = {} local M = {}
M.root_patterns = { ".git", "lua" } ---@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",
}
---@param on_attach fun(client, buffer) setmetatable(M, {
function M.on_attach(on_attach) __index = function(t, k)
vim.api.nvim_create_autocmd("LspAttach", { if LazyUtil[k] then
callback = function(args) return LazyUtil[k]
local buffer = args.buf end
local client = vim.lsp.get_client_by_id(args.data.client_id) local dep = deprecated[k]
on_attach(client, buffer) if dep then
end, local mod = type(dep) == "table" and dep[1] or dep
}) local key = type(dep) == "table" and dep[2] or k
M.deprecate([[require("lazyvim.util").]] .. k, [[require("lazyvim.util").]] .. mod .. "." .. key)
---@diagnostic disable-next-line: no-unknown
t[mod] = require("lazyvim.util." .. mod) -- load here to prevent loops
return t[mod][key]
end
---@diagnostic disable-next-line: no-unknown
t[k] = require("lazyvim.util." .. k)
return t[k]
end,
})
function M.is_win()
return vim.loop.os_uname().sysname:find("Windows") ~= nil
end end
---@param plugin string ---@param plugin string
@ -20,13 +58,6 @@ function M.has(plugin)
return require("lazy.core.config").spec.plugins[plugin] ~= nil return require("lazy.core.config").spec.plugins[plugin] ~= nil
end end
function M.fg(name)
---@type {foreground?:number}?
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true)
local fg = hl and hl.fg or hl.foreground
return fg and { fg = string.format("#%06x", fg) }
end
---@param fn fun() ---@param fn fun()
function M.on_very_lazy(fn) function M.on_very_lazy(fn)
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
@ -47,173 +78,13 @@ function M.opts(name)
return Plugin.values(plugin, "opts", false) return Plugin.values(plugin, "opts", false)
end end
-- returns the root directory based on:
-- * lsp workspace folders
-- * lsp root_dir
-- * root pattern of filename of the current buffer
-- * root pattern of cwd
---@return string
function M.get_root()
---@type string?
local path = vim.api.nvim_buf_get_name(0)
path = path ~= "" and vim.loop.fs_realpath(path) or nil
---@type string[]
local roots = {}
if path then
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
local workspace = client.config.workspace_folders
local paths = workspace and vim.tbl_map(function(ws)
return vim.uri_to_fname(ws.uri)
end, workspace) or client.config.root_dir and { client.config.root_dir } or {}
for _, p in ipairs(paths) do
local r = vim.loop.fs_realpath(p)
if path:find(r, 1, true) then
roots[#roots + 1] = r
end
end
end
end
table.sort(roots, function(a, b)
return #a > #b
end)
---@type string?
local root = roots[1]
if not root then
path = path and vim.fs.dirname(path) or vim.loop.cwd()
---@type string?
root = vim.fs.find(M.root_patterns, { path = path, upward = true })[1]
root = root and vim.fs.dirname(root) or vim.loop.cwd()
end
---@cast root string
return root
end
-- this will return a function that calls telescope.
-- cwd will default to lazyvim.util.get_root
-- for `files`, git_files or find_files will be chosen depending on .git
function M.telescope(builtin, opts)
local params = { builtin = builtin, opts = opts }
return function()
builtin = params.builtin
opts = params.opts
opts = vim.tbl_deep_extend("force", { cwd = M.get_root() }, opts or {})
if builtin == "files" then
if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then
opts.show_untracked = true
builtin = "git_files"
else
builtin = "find_files"
end
end
if opts.cwd and opts.cwd ~= vim.loop.cwd() then
opts.attach_mappings = function(_, map)
map("i", "<a-c>", function()
local action_state = require("telescope.actions.state")
local line = action_state.get_current_line()
M.telescope(
params.builtin,
vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line })
)()
end)
return true
end
end
require("telescope.builtin")[builtin](opts)
end
end
---@type table<string,LazyFloat>
local terminals = {}
-- Opens a floating terminal (interactive by default)
---@param cmd? string[]|string
---@param opts? LazyCmdOptions|{interactive?:boolean, esc_esc?:false, ctrl_hjkl?:false}
function M.float_term(cmd, opts)
opts = vim.tbl_deep_extend("force", {
ft = "lazyterm",
size = { width = 0.9, height = 0.9 },
}, opts or {}, { persistent = true })
---@cast opts LazyCmdOptions|{interactive?:boolean, esc_esc?:false}
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.api.nvim_create_autocmd("BufEnter", {
buffer = buf,
callback = function()
vim.cmd.startinsert()
end,
})
end
return terminals[termkey]
end
---@param silent boolean?
---@param values? {[1]:any, [2]:any}
function M.toggle(option, silent, values)
if values then
if vim.opt_local[option]:get() == values[1] then
vim.opt_local[option] = values[2]
else
vim.opt_local[option] = values[1]
end
return Util.info("Set " .. option .. " to " .. vim.opt_local[option]:get(), { title = "Option" })
end
vim.opt_local[option] = not vim.opt_local[option]:get()
if not silent then
if vim.opt_local[option]:get() then
Util.info("Enabled " .. option, { title = "Option" })
else
Util.warn("Disabled " .. option, { title = "Option" })
end
end
end
local nu = { number = true, relativenumber = true }
function M.toggle_number()
if vim.opt_local.number:get() or vim.opt_local.relativenumber:get() then
nu = { number = vim.opt_local.number:get(), relativenumber = vim.opt_local.relativenumber:get() }
vim.opt_local.number = false
vim.opt_local.relativenumber = false
Util.warn("Disabled line numbers", { title = "Option" })
else
vim.opt_local.number = nu.number
vim.opt_local.relativenumber = nu.relativenumber
Util.info("Enabled line numbers", { title = "Option" })
end
end
local enabled = true
function M.toggle_diagnostics()
enabled = not enabled
if enabled then
vim.diagnostic.enable()
Util.info("Enabled diagnostics", { title = "Diagnostics" })
else
vim.diagnostic.disable()
Util.warn("Disabled diagnostics", { title = "Diagnostics" })
end
end
function M.deprecate(old, new) function M.deprecate(old, new)
Util.warn(("`%s` is deprecated. Please use `%s` instead"):format(old, new), { title = "LazyVim" }) M.warn(("`%s` is deprecated. Please use `%s` instead"):format(old, new), {
title = "LazyVim",
once = true,
stacktrace = true,
stacklevel = 6,
})
end end
-- delay notifications till vim.notify was replaced or after 500ms -- delay notifications till vim.notify was replaced or after 500ms
@ -227,7 +98,7 @@ function M.lazy_notify()
vim.notify = temp vim.notify = temp
local timer = vim.loop.new_timer() local timer = vim.loop.new_timer()
local check = vim.loop.new_check() local check = assert(vim.loop.new_check())
local replay = function() local replay = function()
timer:stop() timer:stop()
@ -253,31 +124,12 @@ function M.lazy_notify()
timer:start(500, 0, replay) timer:start(500, 0, replay)
end end
function M.lsp_get_config(server)
local configs = require("lspconfig.configs")
return rawget(configs, server)
end
---@param server string
---@param cond fun( root_dir, config): boolean
function M.lsp_disable(server, cond)
local util = require("lspconfig.util")
local def = M.lsp_get_config(server)
def.document_config.on_new_config = util.add_hook_before(def.document_config.on_new_config, function(config, root_dir)
if cond(root_dir, config) then
config.enabled = false
end
end)
end
---@param name string ---@param name string
---@param fn fun(name:string) ---@param fn fun(name:string)
function M.on_load(name, fn) function M.on_load(name, fn)
local Config = require("lazy.core.config") local Config = require("lazy.core.config")
if Config.plugins[name] and Config.plugins[name]._.loaded then if Config.plugins[name] and Config.plugins[name]._.loaded then
vim.schedule(function() fn(name)
fn(name)
end)
else else
vim.api.nvim_create_autocmd("User", { vim.api.nvim_create_autocmd("User", {
pattern = "LazyLoad", pattern = "LazyLoad",
@ -291,12 +143,29 @@ function M.on_load(name, fn)
end end
end end
function M.changelog() -- Wrapper around vim.keymap.set that will
local lv = require("lazy.core.config").plugins.LazyVim -- not create a keymap if a lazy key handler exists.
local float = require("lazy.util").open(lv.dir .. "/CHANGELOG.md") -- It will also set `silent` to true by default.
vim.wo[float.win].spell = false function M.safe_keymap_set(mode, lhs, rhs, opts)
vim.wo[float.win].wrap = false local keys = require("lazy.core.handler").handlers.keys
vim.diagnostic.disable(float.buf) ---@cast keys LazyKeysHandler
local modes = type(mode) == "string" and { mode } or mode
---@param m string
modes = vim.tbl_filter(function(m)
return not (keys.have and keys:have(lhs, m))
end, modes)
-- do not create the keymap if a lazy keys handler exists
if #modes > 0 then
opts = opts or {}
opts.silent = opts.silent ~= false
if opts.remap and not vim.g.vscode then
---@diagnostic disable-next-line: no-unknown
opts.remap = nil
end
vim.keymap.set(modes, lhs, rhs, opts)
end
end end
return M return M

View file

@ -0,0 +1,34 @@
---@class lazyvim.util.inject
local M = {}
---@generic A: any
---@generic B: any
---@generic C: any
---@generic F: function
---@param fn F|fun(a:A, b:B, c:C)
---@param wrapper fun(a:A, b:B, c:C): boolean?
---@return F
function M.args(fn, wrapper)
return function(...)
if wrapper(...) == false then
return
end
return fn(...)
end
end
function M.get_upvalue(func, name)
local i = 1
while true do
local n, v = debug.getupvalue(func, i)
if not n then
break
end
if n == name then
return v
end
i = i + 1
end
end
return M

82
lua/lazyvim/util/json.lua Normal file
View file

@ -0,0 +1,82 @@
local Config = require("lazyvim.config")
local Util = require("lazyvim.util")
---@class lazyvim.util.json
local M = {}
---@param value any
---@param indent string
local function encode(value, indent)
local t = type(value)
if t == "string" then
return string.format("%q", value)
elseif t == "number" or t == "boolean" then
return tostring(value)
elseif t == "table" then
local is_list = Util.is_list(value)
local parts = {}
local next_indent = indent .. " "
if is_list then
---@diagnostic disable-next-line: no-unknown
for _, v in ipairs(value) do
local e = encode(v, next_indent)
if e then
table.insert(parts, next_indent .. e)
end
end
return "[\n" .. table.concat(parts, ",\n") .. "\n" .. indent .. "]"
else
local keys = vim.tbl_keys(value)
table.sort(keys)
---@diagnostic disable-next-line: no-unknown
for _, k in ipairs(keys) do
local e = encode(value[k], next_indent)
if e then
table.insert(parts, next_indent .. string.format("%q", k) .. ": " .. e)
end
end
return "{\n" .. table.concat(parts, ",\n") .. "\n" .. indent .. "}"
end
end
end
function M.encode(value)
return encode(value, "")
end
function M.save()
Config.json.data.version = Config.json.version
local path = vim.fn.stdpath("config") .. "/lazyvim.json"
local f = io.open(path, "w")
if f then
f:write(Util.json.encode(Config.json.data))
f:close()
end
end
function M.migrate()
Util.info("Migrating `lazyvim.json` to version `" .. Config.json.version .. "`")
local json = Config.json
-- v0
if not json.data.version then
if json.data.hashes then
---@diagnostic disable-next-line: no-unknown
json.data.hashes = nil
end
json.data.extras = vim.tbl_map(function(extra)
return "lazyvim.plugins.extras." .. extra
end, json.data.extras or {})
elseif json.data.version == 1 then
json.data.extras = vim.tbl_map(function(extra)
-- replace double extras module name
return extra:gsub("^lazyvim%.plugins%.extras%.lazyvim%.plugins%.extras%.", "lazyvim.plugins.extras.")
end, json.data.extras or {})
end
M.save()
end
return M

125
lua/lazyvim/util/lsp.lua Normal file
View file

@ -0,0 +1,125 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.lsp
local M = {}
---@alias lsp.Client.filter {id?: number, bufnr?: number, name?: string, method?: string, filter?:fun(client: lsp.Client):boolean}
---@param opts? lsp.Client.filter
function M.get_clients(opts)
local ret = {} ---@type lsp.Client[]
if vim.lsp.get_clients then
ret = vim.lsp.get_clients(opts)
else
---@diagnostic disable-next-line: deprecated
ret = vim.lsp.get_active_clients(opts)
if opts and opts.method then
---@param client lsp.Client
ret = vim.tbl_filter(function(client)
return client.supports_method(opts.method, { bufnr = opts.bufnr })
end, ret)
end
end
return opts and opts.filter and vim.tbl_filter(opts.filter, ret) or ret
end
---@param on_attach fun(client, buffer)
function M.on_attach(on_attach)
vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args)
local buffer = args.buf ---@type number
local client = vim.lsp.get_client_by_id(args.data.client_id)
on_attach(client, buffer)
end,
})
end
---@param from string
---@param to string
function M.on_rename(from, to)
local clients = M.get_clients()
for _, client in ipairs(clients) do
if client.supports_method("workspace/willRenameFiles") then
---@diagnostic disable-next-line: invisible
local resp = client.request_sync("workspace/willRenameFiles", {
files = {
{
oldUri = vim.uri_from_fname(from),
newUri = vim.uri_from_fname(to),
},
},
}, 1000, 0)
if resp and resp.result ~= nil then
vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding)
end
end
end
end
---@return _.lspconfig.options
function M.get_config(server)
local configs = require("lspconfig.configs")
return rawget(configs, server)
end
---@param server string
---@param cond fun( root_dir, config): boolean
function M.disable(server, cond)
local util = require("lspconfig.util")
local def = M.get_config(server)
---@diagnostic disable-next-line: undefined-field
def.document_config.on_new_config = util.add_hook_before(def.document_config.on_new_config, function(config, root_dir)
if cond(root_dir, config) then
config.enabled = false
end
end)
end
---@param opts? LazyFormatter| {filter?: (string|lsp.Client.filter)}
function M.formatter(opts)
opts = opts or {}
local filter = opts.filter or {}
filter = type(filter) == "string" and { name = filter } or filter
---@cast filter lsp.Client.filter
---@type LazyFormatter
local ret = {
name = "LSP",
primary = true,
priority = 1,
format = function(buf)
M.format(Util.merge(filter, { bufnr = buf }))
end,
sources = function(buf)
local clients = M.get_clients(Util.merge(filter, { bufnr = buf }))
---@param client lsp.Client
local ret = vim.tbl_filter(function(client)
return client.supports_method("textDocument/formatting")
or client.supports_method("textDocument/rangeFormatting")
end, clients)
---@param client lsp.Client
return vim.tbl_map(function(client)
return client.name
end, ret)
end,
}
return Util.merge(ret, opts) --[[@as LazyFormatter]]
end
---@alias lsp.Client.format {timeout_ms?: number, format_options?: table} | lsp.Client.filter
---@param opts? lsp.Client.format
function M.format(opts)
opts = vim.tbl_deep_extend("force", {}, opts or {}, require("lazyvim.util").opts("nvim-lspconfig").format or {})
local ok, conform = pcall(require, "conform")
-- use conform for formatting with LSP when available,
-- since it has better format diffing
if ok then
opts.formatters = {}
opts.lsp_fallback = true
conform.format(opts)
else
vim.lsp.buf.format(opts)
end
end
return M

View file

@ -0,0 +1,143 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.lualine
local M = {}
function M.cmp_source(name, icon)
local started = false
local function status()
if not package.loaded["cmp"] then
return
end
for _, s in ipairs(require("cmp").core.sources) do
if s.name == name then
if s.source:is_available() then
started = true
else
return started and "error" or nil
end
if s.status == s.SourceStatus.FETCHING then
return "pending"
end
return "ok"
end
end
end
local colors = {
ok = Util.ui.fg("Special"),
error = Util.ui.fg("DiagnosticError"),
pending = Util.ui.fg("DiagnosticWarn"),
}
return {
function()
return icon or require("lazyvim.config").icons.kinds[name:sub(1, 1):upper() .. name:sub(2)]
end,
cond = function()
return status() ~= nil
end,
color = function()
return colors[status()] or colors.ok
end,
}
end
---@param component any
---@param text string
---@param hl_group? string
---@return string
function M.format(component, text, hl_group)
if not hl_group then
return text
end
---@type table<string, string>
component.hl_cache = component.hl_cache or {}
local lualine_hl_group = component.hl_cache[hl_group]
if not lualine_hl_group then
local utils = require("lualine.utils.utils")
lualine_hl_group = component:create_hl({ fg = utils.extract_highlight_colors(hl_group, "fg") }, "LV_" .. hl_group)
component.hl_cache[hl_group] = lualine_hl_group
end
return component:format_hl(lualine_hl_group) .. text .. component:get_default_hl()
end
---@param opts? {relative: "cwd"|"root", modified_hl: string?}
function M.pretty_path(opts)
opts = vim.tbl_extend("force", {
relative = "cwd",
modified_hl = "Constant",
}, opts or {})
return function(self)
local path = vim.fn.expand("%:p") --[[@as string]]
if path == "" then
return ""
end
local root = Util.root.get({ normalize = true })
local cwd = Util.root.cwd()
if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then
path = path:sub(#cwd + 2)
else
path = path:sub(#root + 2)
end
local sep = package.config:sub(1, 1)
local parts = vim.split(path, "[\\/]")
if #parts > 3 then
parts = { parts[1], "", parts[#parts - 1], parts[#parts] }
end
if opts.modified_hl and vim.bo.modified then
parts[#parts] = M.format(self, parts[#parts], opts.modified_hl)
end
return table.concat(parts, sep)
end
end
---@param opts? {cwd:false, subdirectory: true, parent: true, other: true, icon?:string}
function M.root_dir(opts)
opts = vim.tbl_extend("force", {
cwd = false,
subdirectory = true,
parent = true,
other = true,
icon = "󱉭 ",
color = Util.ui.fg("Special"),
}, opts or {})
local function get()
local cwd = Util.root.cwd()
local root = Util.root.get({ normalize = true })
local name = vim.fs.basename(root)
if root == cwd then
-- root is cwd
return opts.cwd and name
elseif root:find(cwd, 1, true) == 1 then
-- root is subdirectory of cwd
return opts.subdirectory and name
elseif cwd:find(root, 1, true) == 1 then
-- root is parent directory of cwd
return opts.parent and name
else
-- root and cwd are not related
return opts.other and name
end
end
return {
function()
return (opts.icon and opts.icon .. " ") .. get()
end,
cond = function()
return type(get()) == "string"
end,
color = opts.color,
}
end
return M

90
lua/lazyvim/util/news.lua Normal file
View file

@ -0,0 +1,90 @@
local Config = require("lazyvim.config")
local Util = require("lazyvim.util")
---@class lazyvim.util.news
local M = {}
function M.hash(file)
local stat = vim.loop.fs_stat(file)
if not stat then
return
end
return stat.size .. ""
end
function M.setup()
vim.schedule(function()
if Config.news.lazyvim then
if not Config.json.data.news["NEWS.md"] then
M.welcome()
end
M.lazyvim(true)
end
if Config.news.neovim then
M.neovim(true)
end
end)
end
function M.welcome()
Util.info("Welcome to LazyVim!")
end
function M.changelog()
M.open("CHANGELOG.md", { plugin = "LazyVim" })
end
function M.lazyvim(when_changed)
M.open("NEWS.md", { plugin = "LazyVim", when_changed = when_changed })
end
function M.neovim(when_changed)
M.open("doc/news.txt", { rtp = true, when_changed = when_changed })
end
---@param file string
---@param opts? {plugin?:string, rtp?:boolean, when_changed?:boolean}
function M.open(file, opts)
local ref = file
opts = opts or {}
if opts.plugin then
local plugin = require("lazy.core.config").plugins[opts.plugin] --[[@as LazyPlugin?]]
if not plugin then
return Util.error("plugin not found: " .. opts.plugin)
end
file = plugin.dir .. "/" .. file
elseif opts.rtp then
file = vim.api.nvim_get_runtime_file(file, false)[1]
end
if not file then
return Util.error("File not found")
end
if opts.when_changed then
local is_new = not Config.json.data.news[ref]
local hash = M.hash(file)
if hash == Config.json.data.news[ref] then
return
end
Config.json.data.news[ref] = hash
Util.json.save()
-- don't open if file has never been opened
if is_new then
return
end
end
local float = require("lazy.util").float({
file = file,
size = { width = 0.6, height = 0.6 },
})
vim.opt_local.spell = false
vim.opt_local.wrap = false
vim.opt_local.signcolumn = "yes"
vim.opt_local.statuscolumn = " "
vim.opt_local.conceallevel = 3
vim.diagnostic.disable(float.buf)
end
return M

156
lua/lazyvim/util/plugin.lua Normal file
View file

@ -0,0 +1,156 @@
local Plugin = require("lazy.core.plugin")
local Util = require("lazyvim.util")
---@class lazyvim.util.plugin
local M = {}
M.use_lazy_file = true
M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" }
---@type table<string, string>
M.deprecated_extras = {
["lazyvim.plugins.extras.formatting.conform"] = "`conform.nvim` is now the default **LazyVim** formatter.",
["lazyvim.plugins.extras.linting.nvim-lint"] = "`nvim-lint` is now the default **LazyVim** linter.",
["lazyvim.plugins.extras.ui.dashboard"] = "`dashboard.nvim` is now the default **LazyVim** starter.",
}
M.deprecated_modules = {
["null-ls"] = "lsp.none-ls",
["nvim-navic.lib"] = "editor.navic",
["nvim-navic"] = "editor.navic",
}
---@type table<string, string>
M.renames = {
["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre",
["jose-elias-alvarez/null-ls.nvim"] = "nvimtools/none-ls.nvim",
["null-ls.nvim"] = "none-ls.nvim",
["romgrk/nvim-treesitter-context"] = "nvim-treesitter/nvim-treesitter-context",
["glepnir/dashboard-nvim"] = "nvimdev/dashboard-nvim",
}
function M.setup()
M.fix_imports()
M.fix_renames()
M.lazy_file()
table.insert(package.loaders, function(module)
if M.deprecated_modules[module] then
Util.warn(
("`%s` is no longer included by default in **LazyVim**.\nPlease install the `%s` extra if you still want to use it."):format(
module,
M.deprecated_modules[module]
),
{ title = "LazyVim" }
)
return function() end
end
end)
end
function M.extra_idx(name)
local Config = require("lazy.core.config")
for i, extra in ipairs(Config.spec.modules) do
if extra == "lazyvim.plugins.extras." .. name then
return i
end
end
end
-- Properly load file based plugins without blocking the UI
function M.lazy_file()
M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0
-- Add support for the LazyFile event
local Event = require("lazy.core.handler.event")
if M.use_lazy_file then
-- We'll handle delayed execution of events ourselves
Event.mappings.LazyFile = { id = "LazyFile", event = "User", pattern = "LazyFile" }
Event.mappings["User LazyFile"] = Event.mappings.LazyFile
else
-- Don't delay execution of LazyFile events, but let lazy know about the mapping
Event.mappings.LazyFile = { id = "LazyFile", event = { "BufReadPost", "BufNewFile", "BufWritePre" } }
Event.mappings["User LazyFile"] = Event.mappings.LazyFile
return
end
local events = {} ---@type {event: string, buf: number, data?: any}[]
local done = false
local function load()
if #events == 0 or done then
return
end
done = true
vim.api.nvim_del_augroup_by_name("lazy_file")
---@type table<string,string[]>
local skips = {}
for _, event in ipairs(events) do
skips[event.event] = skips[event.event] or Event.get_augroups(event.event)
end
vim.api.nvim_exec_autocmds("User", { pattern = "LazyFile", modeline = false })
for _, event in ipairs(events) do
if vim.api.nvim_buf_is_valid(event.buf) then
Event.trigger({
event = event.event,
exclude = skips[event.event],
data = event.data,
buf = event.buf,
})
if vim.bo[event.buf].filetype then
Event.trigger({
event = "FileType",
buf = event.buf,
})
end
end
end
vim.api.nvim_exec_autocmds("CursorMoved", { modeline = false })
events = {}
end
-- schedule wrap so that nested autocmds are executed
-- and the UI can continue rendering without blocking
load = vim.schedule_wrap(load)
vim.api.nvim_create_autocmd(M.lazy_file_events, {
group = vim.api.nvim_create_augroup("lazy_file", { clear = true }),
callback = function(event)
table.insert(events, event)
load()
end,
})
end
function M.fix_imports()
Plugin.Spec.import = Util.inject.args(Plugin.Spec.import, function(_, spec)
local dep = M.deprecated_extras[spec and spec.import]
if dep then
dep = dep .. "\n" .. "Please remove the extra to hide this warning."
Util.warn(dep, { title = "LazyVim", once = true, stacktrace = true, stacklevel = 6 })
return false
end
end)
end
function M.fix_renames()
Plugin.Spec.add = Util.inject.args(Plugin.Spec.add, function(self, plugin)
if type(plugin) == "table" then
if M.renames[plugin[1]] then
Util.warn(
("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format(
plugin[1],
M.renames[plugin[1]],
self.importing or "LazyVim"
),
{ title = "LazyVim" }
)
plugin[1] = M.renames[plugin[1]]
end
end
end)
end
return M

181
lua/lazyvim/util/root.lua Normal file
View file

@ -0,0 +1,181 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.root
---@overload fun(): string
local M = setmetatable({}, {
__call = function(m)
return m.get()
end,
})
---@class LazyRoot
---@field paths string[]
---@field spec LazyRootSpec
---@alias LazyRootFn fun(buf: number): (string|string[])
---@alias LazyRootSpec string|string[]|LazyRootFn
---@type LazyRootSpec[]
M.spec = { "lsp", { ".git", "lua" }, "cwd" }
M.detectors = {}
function M.detectors.cwd()
return { vim.loop.cwd() }
end
function M.detectors.lsp(buf)
local bufpath = M.bufpath(buf)
if not bufpath then
return {}
end
local roots = {} ---@type string[]
for _, client in pairs(Util.lsp.get_clients({ bufnr = buf })) do
-- only check workspace folders, since we're not interested in clients
-- running in single file mode
local workspace = client.config.workspace_folders
for _, ws in pairs(workspace or {}) do
roots[#roots + 1] = vim.uri_to_fname(ws.uri)
end
end
return vim.tbl_filter(function(path)
path = Util.norm(path)
return path and bufpath:find(path, 1, true) == 1
end, roots)
end
---@param patterns string[]|string
function M.detectors.pattern(buf, patterns)
patterns = type(patterns) == "string" and { patterns } or patterns
local path = M.bufpath(buf) or vim.loop.cwd()
local pattern = vim.fs.find(patterns, { path = path, upward = true })[1]
return pattern and { vim.fs.dirname(pattern) } or {}
end
function M.bufpath(buf)
return M.realpath(vim.api.nvim_buf_get_name(assert(buf)))
end
function M.cwd()
return M.realpath(vim.loop.cwd()) or ""
end
function M.realpath(path)
if path == "" or path == nil then
return nil
end
path = vim.loop.fs_realpath(path) or path
return Util.norm(path)
end
---@param spec LazyRootSpec
---@return LazyRootFn
function M.resolve(spec)
if M.detectors[spec] then
return M.detectors[spec]
elseif type(spec) == "function" then
return spec
end
return function(buf)
return M.detectors.pattern(buf, spec)
end
end
---@param opts? { buf?: number, spec?: LazyRootSpec[], all?: boolean }
function M.detect(opts)
opts = opts or {}
opts.spec = opts.spec or type(vim.g.root_spec) == "table" and vim.g.root_spec or M.spec
opts.buf = (opts.buf == nil or opts.buf == 0) and vim.api.nvim_get_current_buf() or opts.buf
local ret = {} ---@type LazyRoot[]
for _, spec in ipairs(opts.spec) do
local paths = M.resolve(spec)(opts.buf)
paths = paths or {}
paths = type(paths) == "table" and paths or { paths }
local roots = {} ---@type string[]
for _, p in ipairs(paths) do
local pp = M.realpath(p)
if pp and not vim.tbl_contains(roots, pp) then
roots[#roots + 1] = pp
end
end
table.sort(roots, function(a, b)
return #a > #b
end)
if #roots > 0 then
ret[#ret + 1] = { spec = spec, paths = roots }
if opts.all == false then
break
end
end
end
return ret
end
function M.info()
local spec = type(vim.g.root_spec) == "table" and vim.g.root_spec or M.spec
local roots = M.detect({ all = true })
local lines = {} ---@type string[]
local first = true
for _, root in ipairs(roots) do
for _, path in ipairs(root.paths) do
lines[#lines + 1] = ("- [%s] `%s` **(%s)**"):format(
first and "x" or " ",
path,
type(root.spec) == "table" and table.concat(root.spec, ", ") or root.spec
)
first = false
end
end
lines[#lines + 1] = "```lua"
lines[#lines + 1] = "vim.g.root_spec = " .. vim.inspect(spec)
lines[#lines + 1] = "```"
require("lazyvim.util").info(lines, { title = "LazyVim Roots" })
return roots[1] and roots[1].paths[1] or vim.loop.cwd()
end
---@type table<number, string>
M.cache = {}
function M.setup()
vim.api.nvim_create_user_command("LazyRoot", function()
Util.root.info()
end, { desc = "LazyVim roots for the current buffer" })
vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost" }, {
group = vim.api.nvim_create_augroup("lazyvim_root_cache", { clear = true }),
callback = function(event)
M.cache[event.buf] = nil
end,
})
end
-- returns the root directory based on:
-- * lsp workspace folders
-- * lsp root_dir
-- * root pattern of filename of the current buffer
-- * root pattern of cwd
---@param opts? {normalize?:boolean}
---@return string
function M.get(opts)
local buf = vim.api.nvim_get_current_buf()
local ret = M.cache[buf]
if not ret then
local roots = M.detect({ all = false })
ret = roots[1] and roots[1].paths[1] or vim.loop.cwd()
M.cache[buf] = ret
end
if opts and opts.normalize then
return ret
end
return Util.is_win() and ret:gsub("/", "\\") or ret
end
---@param opts? {hl_last?: string}
function M.pretty_path(opts)
return ""
end
return M

View file

@ -0,0 +1,57 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.telescope.opts
---@field cwd? string|boolean
---@field show_untracked? boolean
---@class lazyvim.util.telescope
---@overload fun(builtin:string, opts?:lazyvim.util.telescope.opts)
local M = setmetatable({}, {
__call = function(m, ...)
return m.telescope(...)
end,
})
-- this will return a function that calls telescope.
-- cwd will default to lazyvim.util.get_root
-- for `files`, git_files or find_files will be chosen depending on .git
---@param builtin string
---@param opts? lazyvim.util.telescope.opts
function M.telescope(builtin, opts)
local params = { builtin = builtin, opts = opts }
return function()
builtin = params.builtin
opts = params.opts
opts = vim.tbl_deep_extend("force", { cwd = Util.root() }, opts or {}) --[[@as lazyvim.util.telescope.opts]]
if builtin == "files" then
if vim.loop.fs_stat((opts.cwd or vim.loop.cwd()) .. "/.git") then
opts.show_untracked = true
builtin = "git_files"
else
builtin = "find_files"
end
end
if opts.cwd and opts.cwd ~= vim.loop.cwd() then
---@diagnostic disable-next-line: inject-field
opts.attach_mappings = function(_, map)
map("i", "<a-c>", function()
local action_state = require("telescope.actions.state")
local line = action_state.get_current_line()
M.telescope(
params.builtin,
vim.tbl_deep_extend("force", {}, params.opts or {}, { cwd = false, default_text = line })
)()
end)
return true
end
end
require("telescope.builtin")[builtin](opts)
end
end
function M.config_files()
return Util.telescope("find_files", { cwd = vim.fn.stdpath("config") })
end
return M

View file

@ -0,0 +1,55 @@
---@class lazyvim.util.terminal
---@overload fun(cmd: string|string[], opts: LazyTermOpts): LazyFloat
local M = setmetatable({}, {
__call = function(m, ...)
return m.open(...)
end,
})
---@type table<string,LazyFloat>
local terminals = {}
---@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 },
}, 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.api.nvim_create_autocmd("BufEnter", {
buffer = buf,
callback = function()
vim.cmd.startinsert()
end,
})
end
return terminals[termkey]
end
return M

View file

@ -0,0 +1,62 @@
local Util = require("lazyvim.util")
---@class lazyvim.util.toggle
local M = {}
---@param silent boolean?
---@param values? {[1]:any, [2]:any}
function M.option(option, silent, values)
if values then
if vim.opt_local[option]:get() == values[1] then
---@diagnostic disable-next-line: no-unknown
vim.opt_local[option] = values[2]
else
---@diagnostic disable-next-line: no-unknown
vim.opt_local[option] = values[1]
end
return Util.info("Set " .. option .. " to " .. vim.opt_local[option]:get(), { title = "Option" })
end
---@diagnostic disable-next-line: no-unknown
vim.opt_local[option] = not vim.opt_local[option]:get()
if not silent then
if vim.opt_local[option]:get() then
Util.info("Enabled " .. option, { title = "Option" })
else
Util.warn("Disabled " .. option, { title = "Option" })
end
end
end
local nu = { number = true, relativenumber = true }
function M.number()
if vim.opt_local.number:get() or vim.opt_local.relativenumber:get() then
nu = { number = vim.opt_local.number:get(), relativenumber = vim.opt_local.relativenumber:get() }
vim.opt_local.number = false
vim.opt_local.relativenumber = false
Util.warn("Disabled line numbers", { title = "Option" })
else
vim.opt_local.number = nu.number
vim.opt_local.relativenumber = nu.relativenumber
Util.info("Enabled line numbers", { title = "Option" })
end
end
local enabled = true
function M.diagnostics()
enabled = not enabled
if enabled then
vim.diagnostic.enable()
Util.info("Enabled diagnostics", { title = "Diagnostics" })
else
vim.diagnostic.disable()
Util.warn("Disabled diagnostics", { title = "Diagnostics" })
end
end
setmetatable(M, {
__call = function(m, ...)
return m.option(...)
end,
})
return M

182
lua/lazyvim/util/ui.lua Normal file
View file

@ -0,0 +1,182 @@
---@class lazyvim.util.ui
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 = vim.tbl_map(function(sign)
---@type Sign
local ret = vim.fn.sign_getdefined(sign.name)[1]
ret.priority = sign.priority
return ret
end, vim.fn.sign_getplaced(buf, { group = "*", lnum = lnum })[1].signs)
-- 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 "",
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()
local ok = pcall(vim.treesitter.get_parser, vim.api.nvim_get_current_buf())
local ret = ok and vim.treesitter.foldtext and vim.treesitter.foldtext()
if not ret or type(ret) == "string" then
ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } }
end
table.insert(ret, { " " .. require("lazyvim.config").icons.misc.dots })
if not vim.treesitter.foldtext then
return table.concat(
vim.tbl_map(function(line)
return line[1]
end, ret),
" "
)
end
return ret
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
if show_signs then
---@type Sign?,Sign?,Sign?
local left, right, fold
for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do
if s.name and s.name:find("GitSign") then
right = s
else
left = s
end
end
if vim.v.virtnum ~= 0 then
left = nil
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 = "Folded" }
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.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
components[2] = "%=" .. components[2] .. " " -- right align
end
return table.concat(components, "")
end
function M.fg(name)
---@type {foreground?:number}?
---@diagnostic disable-next-line: deprecated
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true)
---@diagnostic disable-next-line: undefined-field
local fg = hl and (hl.fg or hl.foreground)
return fg and { fg = string.format("#%06x", fg) } or nil
end
M.skip_foldexpr = {} ---@type table<number,boolean>
local skip_check = assert(vim.loop.new_check())
function M.foldexpr()
local buf = vim.api.nvim_get_current_buf()
-- still in the same tick and no parser
if M.skip_foldexpr[buf] then
return "0"
end
-- don't use treesitter folds for non-file buffers
if vim.bo[buf].buftype ~= "" then
return "0"
end
-- as long as we don't have a filetype, don't bother
-- checking if treesitter is available (it won't)
if vim.bo[buf].filetype == "" then
return "0"
end
local ok = pcall(vim.treesitter.get_parser, buf)
if ok then
return vim.treesitter.foldexpr()
end
-- no parser available, so mark it as skip
-- in the next tick, all skip marks will be reset
M.skip_foldexpr[buf] = true
skip_check:start(function()
M.skip_foldexpr = {}
skip_check:stop()
end)
return "0"
end
return M

View file

@ -0,0 +1,4 @@
;; extends
((identifier) @namespace.builtin
(#eq? @namespace.builtin "vim"))

View file

@ -1,3 +1,6 @@
indent_type = "Spaces" indent_type = "Spaces"
indent_width = 2 indent_width = 2
column_width = 120 column_width = 120
[sort_requires]
enabled = true