diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml new file mode 100644 index 0000000000..3ba13e0cec --- /dev/null +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -0,0 +1 @@ +blank_issues_enabled: false diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 964a780f82..51c475534e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -36,7 +36,7 @@ jobs: uses: kdheepak/panvimdoc@main with: vimdoc: LazyVim - version: "Neovim >= 0.8.0" + version: "Neovim >= 0.9.0" demojify: true treesitter: true - name: Push changes @@ -59,6 +59,8 @@ jobs: with: release-type: simple package-name: LazyVim + extra-files: | + lua/lazyvim/config/init.lua - uses: actions/checkout@v3 - name: tag stable versions if: ${{ steps.release.outputs.release_created }} diff --git a/CHANGELOG.md b/CHANGELOG.md index f148d39473..318c543d42 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,1017 @@ # Changelog +## [10.8.2](https://github.com/LazyVim/LazyVim/compare/v10.8.1...v10.8.2) (2023-11-30) + + +### Bug Fixes + +* **lsp:** fix inlay hints for older nightlies. See [#2007](https://github.com/LazyVim/LazyVim/issues/2007) ([8baf9b5](https://github.com/LazyVim/LazyVim/commit/8baf9b5459a903c783a1d34ad438e64036a8e15e)) + +## [10.8.1](https://github.com/LazyVim/LazyVim/compare/v10.8.0...v10.8.1) (2023-11-30) + + +### Bug Fixes + +* **lsp:** detect if using nvim-0.10 and use new inlay_hint.enable method ([#2007](https://github.com/LazyVim/LazyVim/issues/2007)) ([6853b78](https://github.com/LazyVim/LazyVim/commit/6853b785d9916be6ffe4965aefd8554ed276f802)) +* **lsp:** inlay hints on stable. See [#2007](https://github.com/LazyVim/LazyVim/issues/2007) ([e229988](https://github.com/LazyVim/LazyVim/commit/e229988a98a81b000fda3aadbb4fc404aeaa599e)) +* **ui:** signcolumn signs on nightly. Fixes [#2039](https://github.com/LazyVim/LazyVim/issues/2039) ([11a8a6b](https://github.com/LazyVim/LazyVim/commit/11a8a6bea7a26ca5257fa4cbef90e0abdb22c349)) + +## [10.8.0](https://github.com/LazyVim/LazyVim/compare/v10.7.1...v10.8.0) (2023-11-04) + + +### Features + +* **catppuccin:** enable more integrations ([#1922](https://github.com/LazyVim/LazyVim/issues/1922)) ([4312e5e](https://github.com/LazyVim/LazyVim/commit/4312e5e28348560e018da4535de27dfcc675c32b)) + + +### Bug Fixes + +* **extras:** dont show extras that give errors (user's extras). Fixes [#1895](https://github.com/LazyVim/LazyVim/issues/1895) ([b32b4fd](https://github.com/LazyVim/LazyVim/commit/b32b4fd581018cf14bf30ae4cd8d94cd43552813)) +* **mini.indentscope:** remove duplicated filetype ([#1871](https://github.com/LazyVim/LazyVim/issues/1871)) ([09eafc6](https://github.com/LazyVim/LazyVim/commit/09eafc60eff2ba7d7b78c1717d07ce26b762a8a8)) +* **plugin:** LazyFile now properly deals with deleted buffers. Fixes [#1877](https://github.com/LazyVim/LazyVim/issues/1877) ([4558407](https://github.com/LazyVim/LazyVim/commit/4558407574d0cdbe55720ab349df201bd4d5f5de)) +* **sessions:** added folds to sessions ([e01ad51](https://github.com/LazyVim/LazyVim/commit/e01ad513aa4f50bdb385a7454c9e1ec3a0d5dc94)) +* **spectre:** don't build nvim-spectre ([3986169](https://github.com/LazyVim/LazyVim/commit/39861698235c03d30096b3fb315ce38eeaef95e2)) + +## [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) + + +### Features + +* **clangd:** remove CMakelists root_dir search ([#1230](https://github.com/LazyVim/LazyVim/issues/1230)) ([9264c54](https://github.com/LazyVim/LazyVim/commit/9264c54ae96d1d56f029ad9b561326c7b991c53b)) +* **python:** add more venv names ([#1381](https://github.com/LazyVim/LazyVim/issues/1381)) ([377c0e3](https://github.com/LazyVim/LazyVim/commit/377c0e397c3585cf7bae6afb8bd279a47954be0a)) +* **treesitter:** add jsdoc to ensure_installed ([#1252](https://github.com/LazyVim/LazyVim/issues/1252)) ([566049a](https://github.com/LazyVim/LazyVim/commit/566049aa4a26a86219dd1ad1624f9a1bf18831b6)) + + +### Bug Fixes + +* [#1305](https://github.com/LazyVim/LazyVim/issues/1305) rust debugging not working on windows due to missing liblldb path ([#1390](https://github.com/LazyVim/LazyVim/issues/1390)) ([6045a52](https://github.com/LazyVim/LazyVim/commit/6045a52d82ba4b0dcd0b050688302a22c2fc3991)) +* **autocmds:** restore tabpage on resize ([#1260](https://github.com/LazyVim/LazyVim/issues/1260)) ([f9dadc1](https://github.com/LazyVim/LazyVim/commit/f9dadc11b39fb0b027473caaab2200b35c9f0c8b)) +* **clangd:** update setup from upstream changes ([#1308](https://github.com/LazyVim/LazyVim/issues/1308)) ([73dc5a5](https://github.com/LazyVim/LazyVim/commit/73dc5a503f1f42fc12869688df1359ffd80da5d1)) +* **java:** don't accumulate on_attach, and make more configurable ([#1388](https://github.com/LazyVim/LazyVim/issues/1388)) ([15022f4](https://github.com/LazyVim/LazyVim/commit/15022f4892726f9899ce5eb3aed7a19df29f62ef)) +* **keymaps:** change `v` mode to `x` mode for `save file` ([#1262](https://github.com/LazyVim/LazyVim/issues/1262)) ([ec0ddd4](https://github.com/LazyVim/LazyVim/commit/ec0ddd481c785833c5caac9c9d22889b9e963883)) +* **keymaps:** remove gw keymap ([23e2b07](https://github.com/LazyVim/LazyVim/commit/23e2b073e6fa75dacaa58dc1fe63392af7f54598)) +* **python:** disable ruff hover correctly ([#1365](https://github.com/LazyVim/LazyVim/issues/1365)) ([451bde5](https://github.com/LazyVim/LazyVim/commit/451bde5b41ec410afbb2b5e75e339a3fc44c5587)) +* **yaml:** yaml validate and enable line folding ([#1251](https://github.com/LazyVim/LazyVim/issues/1251)) ([a62a594](https://github.com/LazyVim/LazyVim/commit/a62a5942deb281b9edce3673e656854805297199)) +* **yaml:** yaml: Fix TypeError undefined length ([#1229](https://github.com/LazyVim/LazyVim/issues/1229)) ([d7ca822](https://github.com/LazyVim/LazyVim/commit/d7ca822d41bc65e31dc1019a64d5d3518c8e2470)) + +## [6.2.0](https://github.com/LazyVim/LazyVim/compare/v6.1.0...v6.2.0) (2023-07-25) + + +### Features + +* Enable flash.nvim highlight on catppuccin integration ([#1206](https://github.com/LazyVim/LazyVim/issues/1206)) ([76d33bb](https://github.com/LazyVim/LazyVim/commit/76d33bba2cc8bd691979ee8bc66f8ac36236c3ba)) +* **extra:** add yaml language extension ([#1198](https://github.com/LazyVim/LazyVim/issues/1198)) ([6dc6685](https://github.com/LazyVim/LazyVim/commit/6dc66852b8851f02b372e8a2882fddf04b3b6966)) +* **java:** add test and debug support for Java extension ([#1192](https://github.com/LazyVim/LazyVim/issues/1192)) ([f6d646a](https://github.com/LazyVim/LazyVim/commit/f6d646a3251efb39f7cb5de38b529c5dd1324f28)) + + +### Bug Fixes + +* [#1194](https://github.com/LazyVim/LazyVim/issues/1194) use cmakelang instead of cmakelint ([#1197](https://github.com/LazyVim/LazyVim/issues/1197)) ([b97ccb9](https://github.com/LazyVim/LazyVim/commit/b97ccb9e7390b6e73e3f1a4d63a443f6cec67f07)) +* fixes [#1207](https://github.com/LazyVim/LazyVim/issues/1207) ([#1213](https://github.com/LazyVim/LazyVim/issues/1213)) ([2e09051](https://github.com/LazyVim/LazyVim/commit/2e0905147269d92d58627303bcae60bbcb3807dd)) +* **lang_java:** fixes [#1215](https://github.com/LazyVim/LazyVim/issues/1215) other two entries of `vim.fs.joinpath` as well that were not changed in [#1213](https://github.com/LazyVim/LazyVim/issues/1213) ([#1216](https://github.com/LazyVim/LazyVim/issues/1216)) ([9fe89f5](https://github.com/LazyVim/LazyVim/commit/9fe89f5f8a5a50438276a4d2f757549ea2496ca0)) +* **lsp:** supports_method for checking inlay hint support ([#1195](https://github.com/LazyVim/LazyVim/issues/1195)) ([9a05435](https://github.com/LazyVim/LazyVim/commit/9a0543531d05a417ba63f3dd710530ba5765aca5)) + +## [6.1.0](https://github.com/LazyVim/LazyVim/compare/v6.0.0...v6.1.0) (2023-07-22) + + +### Features + +* **clangd:** better clangd root detection ([#1165](https://github.com/LazyVim/LazyVim/issues/1165)) ([d71ebea](https://github.com/LazyVim/LazyVim/commit/d71ebeab24565bb109adc68253c2da6614eb5dda)) +* **lang:** add cmake support ([#1032](https://github.com/LazyVim/LazyVim/issues/1032)) ([fa898b7](https://github.com/LazyVim/LazyVim/commit/fa898b7293c6c67b0ae2bae1d3be70413bcadd8d)) +* **lang:** add debug adapter plugin for go ([#1115](https://github.com/LazyVim/LazyVim/issues/1115)) ([02d673d](https://github.com/LazyVim/LazyVim/commit/02d673d37c6a097a43db877644e20db84f0880b1)) +* **lang:** add java ([#1132](https://github.com/LazyVim/LazyVim/issues/1132)) ([0411baa](https://github.com/LazyVim/LazyVim/commit/0411baab8985450a15a54a46c48197b704bc24cc)) +* **python:** add semantic highlighting ([#1149](https://github.com/LazyVim/LazyVim/issues/1149)) ([012ca50](https://github.com/LazyVim/LazyVim/commit/012ca50b2801cc1c4e5b886cc26ebe0da532e31d)) +* **telescope:** allow word and selection searches ([#1096](https://github.com/LazyVim/LazyVim/issues/1096)) ([6b2c648](https://github.com/LazyVim/LazyVim/commit/6b2c648878b8df538d719c06394bc430cc3ed48c)) + + +### Bug Fixes + +* **terraform:** configure commentstring ([#1171](https://github.com/LazyVim/LazyVim/issues/1171)) ([e5f53ee](https://github.com/LazyVim/LazyVim/commit/e5f53ee1931fdc8c0f0d3150cbb5742dcb8ff477)) + +## [6.0.0](https://github.com/LazyVim/LazyVim/compare/v5.1.1...v6.0.0) (2023-07-20) + + +### ⚠ BREAKING CHANGES + +* **options:** set default localleader to \ + +### Features + +* add a keybind to search register ([#1170](https://github.com/LazyVim/LazyVim/issues/1170)) ([fc50c05](https://github.com/LazyVim/LazyVim/commit/fc50c055c3db561043e23b53afc270de2231fbb2)) +* **keymaps:** added leader-K to run keywordprg ([a28acf0](https://github.com/LazyVim/LazyVim/commit/a28acf0ce7d00af11e7268c9edff579bd06abf56)) +* **lang:** add tex support ([#1156](https://github.com/LazyVim/LazyVim/issues/1156)) ([abaa6d9](https://github.com/LazyVim/LazyVim/commit/abaa6d90e4fe2c658b869e81a140a74f624d9299)) +* **options:** set default localleader to \ ([258f339](https://github.com/LazyVim/LazyVim/commit/258f339bcf8197ece54d66bf6ed6f351cb6e98cb)) + + +### Bug Fixes + +* **util:** fixed line number toggling. Closes [#1173](https://github.com/LazyVim/LazyVim/issues/1173) ([df08188](https://github.com/LazyVim/LazyVim/commit/df0818880e66086f10982827ea11332b46c3b74f)) + +## [5.1.1](https://github.com/LazyVim/LazyVim/compare/v5.1.0...v5.1.1) (2023-07-16) + + +### Bug Fixes + +* **mason:** add MasonUpdate to build ([b4b27e8](https://github.com/LazyVim/LazyVim/commit/b4b27e867c4d2ba2bddd1df4c144ccdf1b4bfabc)) + +## [5.1.0](https://github.com/LazyVim/LazyVim/compare/v5.0.0...v5.1.0) (2023-07-16) + + +### Features + +* **lang:** add null-ls tools to mason's ensure_installed ([#1133](https://github.com/LazyVim/LazyVim/issues/1133)) ([63e8985](https://github.com/LazyVim/LazyVim/commit/63e898599a00d8b1832de650ed67f63a44bf22e0)) +* **lsp:** add 'reuse_win' for reuse window in lsp definition keymap ([#1131](https://github.com/LazyVim/LazyVim/issues/1131)) ([1b0b6eb](https://github.com/LazyVim/LazyVim/commit/1b0b6eb0e13018196f0110b06149f00f2df5162f)) +* **neo-tree:** update to v3.x and change `follow_current_file` to a … ([#1143](https://github.com/LazyVim/LazyVim/issues/1143)) ([69bb891](https://github.com/LazyVim/LazyVim/commit/69bb89184f9297f1377f77a8b6bee2487df6ac00)) + +## [5.0.0](https://github.com/LazyVim/LazyVim/compare/v4.28.1...v5.0.0) (2023-07-13) + + +### ⚠ BREAKING CHANGES + +* **flash:** Make flash.nvim the default jump plugin for LazyVim + +### Features + +* added `leader-L` to show the LazyVim changelog ([9387ab3](https://github.com/LazyVim/LazyVim/commit/9387ab388ec43cae0689405fcb21bb4ecf67322c)) +* **flash:** Make flash.nvim the default jump plugin for LazyVim ([ae759b9](https://github.com/LazyVim/LazyVim/commit/ae759b947b1ef16d9814fcddfcafe2cdd767bc6a)) + +## [4.28.1](https://github.com/LazyVim/LazyVim/compare/v4.28.0...v4.28.1) (2023-07-12) + + +### Bug Fixes + +* **neoconf:** do neoconf setup in lspconfig setup. Fixes [#1070](https://github.com/LazyVim/LazyVim/issues/1070) ([9e8ce28](https://github.com/LazyVim/LazyVim/commit/9e8ce289d12eb65146be3cb1b3800440e208496d)) + +## [4.28.0](https://github.com/LazyVim/LazyVim/compare/v4.27.0...v4.28.0) (2023-07-12) + + +### Features + +* **catppuccin:** match navic bg with lualine ([#1085](https://github.com/LazyVim/LazyVim/issues/1085)) ([67d1cbf](https://github.com/LazyVim/LazyVim/commit/67d1cbfb01e84083649027a4b6356401f74d2d60)) +* **lang:** add docker support ([#1078](https://github.com/LazyVim/LazyVim/issues/1078)) ([a0c2014](https://github.com/LazyVim/LazyVim/commit/a0c2014b1045243d216b244235c6a545e92471a9)) +* **mini.ai:** decouple mini.ai from which-key. Closes [#1076](https://github.com/LazyVim/LazyVim/issues/1076) ([e212c16](https://github.com/LazyVim/LazyVim/commit/e212c166b4ce91bbd65a9f7fda17403ee91ed19c)) +* **util:** added util.on_load to execute code when a plugin loads ([9fd8970](https://github.com/LazyVim/LazyVim/commit/9fd89701da8bd3a5d9ffeae84fb2174a3f650797)) + + +### Bug Fixes + +* **lsp-config:** lsp-config error when nvim-cmp not enabled. ([#1095](https://github.com/LazyVim/LazyVim/issues/1095)) ([3f68f44](https://github.com/LazyVim/LazyVim/commit/3f68f44d725747339933298cdac02589b37ea76c)) + +## [4.27.0](https://github.com/LazyVim/LazyVim/compare/v4.26.0...v4.27.0) (2023-07-06) + + +### Features + +* **extras:** add terraform extra ([#1030](https://github.com/LazyVim/LazyVim/issues/1030)) ([0db31c2](https://github.com/LazyVim/LazyVim/commit/0db31c2840af662c856d5b9a09d87bc266e7fa40)) +* **flash:** use c-s in the cmdline to toggle flash ([22c9477](https://github.com/LazyVim/LazyVim/commit/22c9477b9642b1a8abc303ffcb44c6989c7a5ca2)) +* **lang:** add python support ([#1031](https://github.com/LazyVim/LazyVim/issues/1031)) ([44cdb5e](https://github.com/LazyVim/LazyVim/commit/44cdb5eac556733db53afeebcdc6ef91408de0c3)) + + +### Bug Fixes + +* **autocmds:** jump to last loc in buffer ([#1061](https://github.com/LazyVim/LazyVim/issues/1061)) ([baa9614](https://github.com/LazyVim/LazyVim/commit/baa96140227a3727b2ea2053f37aa2b7253bb45a)) + +## [4.26.0](https://github.com/LazyVim/LazyVim/compare/v4.25.1...v4.26.0) (2023-07-06) + + +### Features + +* **vscode:** easier way to enable/disable plugins ([ae054ec](https://github.com/LazyVim/LazyVim/commit/ae054ec13c987ff5ce39cfc88917f8243abae72e)) + + +### Bug Fixes + +* **flash:** depraction warning ([299aae3](https://github.com/LazyVim/LazyVim/commit/299aae3545aa7b7a67a6907e089d80cd63938bf6)) +* **util:** use spec to check if a plugin is enabled ([bcff5a1](https://github.com/LazyVim/LazyVim/commit/bcff5a19379e32a85049500de420aa24b271fb72)) + +## [4.25.1](https://github.com/LazyVim/LazyVim/compare/v4.25.0...v4.25.1) (2023-07-04) + + +### Bug Fixes + +* trigger ci ([755419f](https://github.com/LazyVim/LazyVim/commit/755419f39cf0ca0407a3a6a16dad35942c653572)) + +## [4.25.0](https://github.com/LazyVim/LazyVim/compare/v4.24.1...v4.25.0) (2023-07-03) + + +### Features + +* **catppuccin:** enable mason integration ([#1048](https://github.com/LazyVim/LazyVim/issues/1048)) ([27eb461](https://github.com/LazyVim/LazyVim/commit/27eb4610bd0ffd48243f793054c7c9ab5ba08cb1)) +* **lang:** add C/C++ support ([#1025](https://github.com/LazyVim/LazyVim/issues/1025)) ([e5200e6](https://github.com/LazyVim/LazyVim/commit/e5200e6358766f2ba71eb229cb335c4c811902bb)) + + +### Bug Fixes + +* **hipatterns:** remove assert. Fixes [#1045](https://github.com/LazyVim/LazyVim/issues/1045) ([6d58f1d](https://github.com/LazyVim/LazyVim/commit/6d58f1dacf1652ba49ff97631e59fc4ec9ee4faa)) +* leap nvim required by flit ([#1046](https://github.com/LazyVim/LazyVim/issues/1046)) ([dee8dc3](https://github.com/LazyVim/LazyVim/commit/dee8dc318efac8883fe149503ea92924ff4a4de2)) +* **lsp:** update keymaps *after* registering capabilities ([a981682](https://github.com/LazyVim/LazyVim/commit/a981682603480e34b23615433e4ebefe07276dc2)) + +## [4.24.1](https://github.com/LazyVim/LazyVim/compare/v4.24.0...v4.24.1) (2023-07-02) + + +### Bug Fixes + +* **lsp:** fixup lsp keymaps ([8ccc109](https://github.com/LazyVim/LazyVim/commit/8ccc109e920bcbe041c89f7e022bbfb2dbf4a09b)) + +## [4.24.0](https://github.com/LazyVim/LazyVim/compare/v4.23.0...v4.24.0) (2023-07-02) + + +### Features + +* **lsp:** added support to lsp keymaps for dynamic capabilities ([d0bc8b7](https://github.com/LazyVim/LazyVim/commit/d0bc8b7dcea44b7bc46580ce21001c4509d046c3)) +* **lsp:** custom lsp keymaps ([61e3ce8](https://github.com/LazyVim/LazyVim/commit/61e3ce8cdc1159d59e11d92478ca76ea19e44c2a)) +* **rust:** make mason optional ([272f6af](https://github.com/LazyVim/LazyVim/commit/272f6af842eb66b6e6cbdea211b17a1196acdff5)) +* **rust:** make taplo configurable ([eaa0118](https://github.com/LazyVim/LazyVim/commit/eaa0118dd2c91911f1457ea31b976a7c8f93164a)) +* **rust:** refactor to allow easy user customization and keymaps ([a46d476](https://github.com/LazyVim/LazyVim/commit/a46d47653e092f7689203ee39c9f964b1bd2d5f4)) + + +### Bug Fixes + +* **go:** make settings configurable for go ([1e1fc3c](https://github.com/LazyVim/LazyVim/commit/1e1fc3c6a06fb98f305d8753939c6b871ae26e33)) +* **lsp:** resolve keymap capabilities over all buffer clients ([36774c6](https://github.com/LazyVim/LazyVim/commit/36774c605848dc3bee8b9e0e4673e684b47bd89c)) +* **rust:** remove rust-tools dep from lspconfig ([39627ca](https://github.com/LazyVim/LazyVim/commit/39627cab42cdaaab3d70c3013ce82b9caae7c623)) +* **typescript:** use new lsp keymaps config for typescript ([4009620](https://github.com/LazyVim/LazyVim/commit/4009620651c7422b3ce11484916865073e95574d)) + +## [4.23.0](https://github.com/LazyVim/LazyVim/compare/v4.22.0...v4.23.0) (2023-06-30) + + +### Features + +* **go:** add fine-tuned LSP options, add some null-ls sources ([#1024](https://github.com/LazyVim/LazyVim/issues/1024)) ([4ba5086](https://github.com/LazyVim/LazyVim/commit/4ba5086b3d9f9690e8fd7d93102db66173b02638)) + + +### Bug Fixes + +* **lsp:** upstream inlay_hint rename ([089606b](https://github.com/LazyVim/LazyVim/commit/089606b48dc6bb94bac36d1c30e50899a8d6f81f)) + +## [4.22.0](https://github.com/LazyVim/LazyVim/compare/v4.21.0...v4.22.0) (2023-06-30) + + +### Features + +* **rust:** rust improvements ([#1015](https://github.com/LazyVim/LazyVim/issues/1015)) ([79b1c92](https://github.com/LazyVim/LazyVim/commit/79b1c92dd22020b2a5ed1dbd6e6bb86242207785)) + + +### Bug Fixes + +* **lang:** indentation in rust lang extra ([#1017](https://github.com/LazyVim/LazyVim/issues/1017)) ([c992ebe](https://github.com/LazyVim/LazyVim/commit/c992ebec468b2e60f1138fd85055118016c62165)) + +## [4.21.0](https://github.com/LazyVim/LazyVim/compare/v4.20.1...v4.21.0) (2023-06-30) + + +### Features + +* **extra:** Add Elixir support and config ([#993](https://github.com/LazyVim/LazyVim/issues/993)) ([3d0de23](https://github.com/LazyVim/LazyVim/commit/3d0de235eca0ea6987947e4a7c47f1393e42dfb2)) +* **lang:** Add Rust config ([#1012](https://github.com/LazyVim/LazyVim/issues/1012)) ([5a441f8](https://github.com/LazyVim/LazyVim/commit/5a441f897247b130c1ffb78bb37fd3a16d2250de)) + + +### Bug Fixes + +* **autocmds:** dont jump to last loc in gitcommit buffers ([65c70f6](https://github.com/LazyVim/LazyVim/commit/65c70f6ad7e386b54d2aa6dbe137c37ee1d3cb88)) + +## [4.20.1](https://github.com/LazyVim/LazyVim/compare/v4.20.0...v4.20.1) (2023-06-29) + + +### Bug Fixes + +* **catppuccin:** change nvim-tree integration to neo-tree for catppuccin/nvim plugin ([#1003](https://github.com/LazyVim/LazyVim/issues/1003)) ([2f2c7a3](https://github.com/LazyVim/LazyVim/commit/2f2c7a32a4115d06c3bb2b12e6d55f163d701bb3)) +* **yanky:** don't override c-p insert mode telescope mapping. Fixes [#1007](https://github.com/LazyVim/LazyVim/issues/1007) ([8b1e797](https://github.com/LazyVim/LazyVim/commit/8b1e7976a004d7e0cbaec37546d2889ddab48bbb)) + +## [4.20.0](https://github.com/LazyVim/LazyVim/compare/v4.19.1...v4.20.0) (2023-06-28) + + +### Features + +* **extras:** added yanky extra (yank-ring) ([a1820c1](https://github.com/LazyVim/LazyVim/commit/a1820c1b428fc7f72fc31ea8465260b1816349ab)) + + +### Bug Fixes + +* **yanky:** use leader-p for telescope integration ([e83d2c8](https://github.com/LazyVim/LazyVim/commit/e83d2c814f336470fa212cef2f03ceb8ac173012)) + +## [4.19.1](https://github.com/LazyVim/LazyVim/compare/v4.19.0...v4.19.1) (2023-06-27) + + +### Bug Fixes + +* **flash:** don't override `R` in normal mode ([c5759a4](https://github.com/LazyVim/LazyVim/commit/c5759a451f8a5635b5c2d19c82636c8b66676a3b)) +* **mini.files:** changed some window widths ([d1eb9c8](https://github.com/LazyVim/LazyVim/commit/d1eb9c89d3d2959d6d106b0c11c12b21fb3bbf50)) + +## [4.19.0](https://github.com/LazyVim/LazyVim/compare/v4.18.0...v4.19.0) (2023-06-26) + + +### Features + +* **flash:** added treesiter search to show ts node labels around search matches ([5e6a072](https://github.com/LazyVim/LazyVim/commit/5e6a07200c0cc0a21167a341c1f29bf27dc35f02)) + +## [4.18.0](https://github.com/LazyVim/LazyVim/compare/v4.17.0...v4.18.0) (2023-06-25) + + +### Features + +* **flash:** enable flash in vscode ([f6f8436](https://github.com/LazyVim/LazyVim/commit/f6f8436fe8696a8934a28a1fd21bf28409fee7ab)) + + +### Bug Fixes + +* **edgy:** corrected filetype for symbols outline ([d5a9c54](https://github.com/LazyVim/LazyVim/commit/d5a9c54faf2a41355d4e2e14b050af188a49365a)) +* **keymaps:** remove redundant ':' on lazy keymap ([#977](https://github.com/LazyVim/LazyVim/issues/977)) ([e9358d9](https://github.com/LazyVim/LazyVim/commit/e9358d977a379e54d73dd29691d60f7a51ed6923)) + ## [4.17.0](https://github.com/LazyVim/LazyVim/compare/v4.16.0...v4.17.0) (2023-06-24) @@ -222,7 +1234,7 @@ * **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:** 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) @@ -376,7 +1388,7 @@ ### Features -* **noice:** enable the inc_rename preset when inc_rename is availble ([a43d1b7](https://github.com/LazyVim/LazyVim/commit/a43d1b79f29deecc694bd409ab497f8a62091b11)) +* **noice:** enable the inc_rename preset when inc_rename is available ([a43d1b7](https://github.com/LazyVim/LazyVim/commit/a43d1b79f29deecc694bd409ab497f8a62091b11)) ### Bug Fixes @@ -433,7 +1445,7 @@ ### Bug Fixes -* **format:** only do null-ls formatting logic when null-ls is availble. Fixes [#684](https://github.com/LazyVim/LazyVim/issues/684) ([eb143eb](https://github.com/LazyVim/LazyVim/commit/eb143ebe110995fb208fc480958a55858944c5f9)) +* **format:** only do null-ls formatting logic when null-ls is available. Fixes [#684](https://github.com/LazyVim/LazyVim/issues/684) ([eb143eb](https://github.com/LazyVim/LazyVim/commit/eb143ebe110995fb208fc480958a55858944c5f9)) ## [2.12.0](https://github.com/LazyVim/LazyVim/compare/v2.11.0...v2.12.0) (2023-04-24) @@ -829,7 +1841,7 @@ ### 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)) * **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)) @@ -973,7 +1985,7 @@ ### 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)) * **nvim-navic:** use kinds icons for navic. Fixes [#164](https://github.com/LazyVim/LazyVim/issues/164) ([b81ecf9](https://github.com/LazyVim/LazyVim/commit/b81ecf9f7ac78e3f87a4d9b305fa0d3cfd6decf2)) @@ -1148,7 +2160,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:** 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 `<leader>e` and `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:** 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)) diff --git a/NEWS.md b/NEWS.md new file mode 100644 index 0000000000..50b72da377 --- /dev/null +++ b/NEWS.md @@ -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" } + ``` diff --git a/README-CN.md b/README-CN.md index a506d0e35f..395e146ed1 100644 --- a/README-CN.md +++ b/README-CN.md @@ -54,9 +54,10 @@ LazyVim 提供了两全其美的方式 - 根据需要调整配置的灵活性, ## ⚡️ 要求 -- Neovim >= **0.8.0** (需要用 **LuaJIT** 构建) +- Neovim >= **0.9.0** (需要用 **LuaJIT** 构建) - Git >= **2.19.0** (用于部分克隆支持) - 一个 [Nerd Font](https://www.nerdfonts.com/) 字体 **_(可选)_** +- 一个用于 `nvim-treesitter` 的 **C** 编译器。看 [这里](https://github.com/nvim-treesitter/nvim-treesitter#requirements) ## 🚀 入门 diff --git a/README.md b/README.md index f1291cdb4a..ba76377011 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ to tweak your config as needed, along with the convenience of a pre-configured s ## ⚡️ 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) - a [Nerd Font](https://www.nerdfonts.com/) **_(optional)_** - a **C** compiler for `nvim-treesitter`. See [here](https://github.com/nvim-treesitter/nvim-treesitter#requirements) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index b58ba31442..2d805f3bc3 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 June 24 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 November 30 ============================================================================== Table of Contents *LazyVim-table-of-contents* @@ -52,7 +52,7 @@ FEATURES *LazyVim-features* 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) - a Nerd Font **(optional)** - a **C** compiler for `nvim-treesitter`. See here diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index ecbd18a3d4..4cc6f1ec45 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -1,4 +1,4 @@ --- This file is automatically loaded by lazyvim.config.init +-- This file is automatically loaded by lazyvim.config.init. local function augroup(name) return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true }) @@ -22,16 +22,24 @@ vim.api.nvim_create_autocmd("TextYankPost", { vim.api.nvim_create_autocmd({ "VimResized" }, { group = augroup("resize_splits"), callback = function() + local current_tab = vim.fn.tabpagenr() vim.cmd("tabdo wincmd =") + vim.cmd("tabnext " .. current_tab) end, }) -- go to last loc when opening a buffer vim.api.nvim_create_autocmd("BufReadPost", { group = augroup("last_loc"), - callback = function() - local mark = vim.api.nvim_buf_get_mark(0, '"') - local lcount = vim.api.nvim_buf_line_count(0) + callback = function(event) + local exclude = { "gitcommit" } + local buf = event.buf + if vim.tbl_contains(exclude, vim.bo[buf].filetype) or vim.b[buf].lazyvim_last_loc then + return + end + vim.b[buf].lazyvim_last_loc = true + local mark = vim.api.nvim_buf_get_mark(buf, '"') + local lcount = vim.api.nvim_buf_line_count(buf) if mark[1] > 0 and mark[1] <= lcount then pcall(vim.api.nvim_win_set_cursor, 0, mark) end @@ -48,6 +56,7 @@ vim.api.nvim_create_autocmd("FileType", { "man", "notify", "qf", + "query", "spectre_panel", "startuptime", "tsplayground", diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 5c5e70dd1f..a296ef56ff 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -1,9 +1,11 @@ ----@type LazyVimConfig +local Util = require("lazyvim.util") + +---@class LazyVimConfig: LazyVimOptions local M = {} -M.lazy_version = ">=9.1.0" +M.version = "10.8.2" -- x-release-please-version ----@class LazyVimConfig +---@class LazyVimOptions local defaults = { -- colorscheme can be a string like `catppuccin` or a function that will load the colorscheme ---@type string|fun() @@ -17,104 +19,177 @@ local defaults = { -- 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 }, + 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 + -- stylua: ignore icons = { + misc = { + dots = "󰇘", + }, dap = { - Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, - Breakpoint = " ", + Stopped = { "󰁕 ", "DiagnosticWarn", "DapStoppedLine" }, + Breakpoint = " ", BreakpointCondition = " ", - BreakpointRejected = { " ", "DiagnosticError" }, - LogPoint = ".>", + BreakpointRejected = { " ", "DiagnosticError" }, + LogPoint = ".>", }, diagnostics = { Error = " ", - Warn = " ", - Hint = " ", - Info = " ", + Warn = " ", + Hint = " ", + Info = " ", }, git = { - added = " ", + added = " ", modified = " ", - removed = " ", + removed = " ", }, kinds = { - Array = " ", - Boolean = " ", - Class = " ", - Color = " ", - Constant = " ", - Constructor = " ", - Copilot = " ", - Enum = " ", - EnumMember = " ", - Event = " ", - Field = " ", - File = " ", - Folder = " ", - Function = " ", - Interface = " ", - Key = " ", - Keyword = " ", - Method = " ", - Module = " ", - Namespace = " ", - Null = " ", - Number = " ", - Object = " ", - Operator = " ", - Package = " ", - Property = " ", - Reference = " ", - Snippet = " ", - String = " ", - Struct = " ", - Text = " ", + Array = " ", + Boolean = "󰨙 ", + Class = " ", + Codeium = "󰘦 ", + Color = " ", + Control = " ", + Collapsed = " ", + Constant = "󰏿 ", + Constructor = " ", + Copilot = " ", + Enum = " ", + EnumMember = " ", + Event = " ", + Field = " ", + File = " ", + Folder = " ", + Function = "󰊕 ", + Interface = " ", + Key = " ", + Keyword = " ", + Method = "󰊕 ", + Module = " ", + Namespace = "󰦮 ", + Null = " ", + Number = "󰎠 ", + Object = " ", + Operator = " ", + Package = " ", + Property = " ", + Reference = " ", + Snippet = " ", + String = " ", + Struct = "󰆼 ", + TabNine = "󰏚 ", + Text = " ", TypeParameter = " ", - Unit = " ", - Value = " ", - Variable = " ", + Unit = " ", + Value = " ", + Variable = "󰀫 ", + }, + }, + ---@type table? + 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 = { - ["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre", +M.json = { + version = 2, + data = { + version = nil, ---@type string? + news = {}, ---@type table + 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 ----@param opts? LazyVimConfig +---@param opts? LazyVimOptions function M.setup(opts) - options = vim.tbl_deep_extend("force", defaults, opts 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 + options = vim.tbl_deep_extend("force", defaults, opts or {}) or {} - if vim.fn.argc(-1) == 0 then - -- autocmds and keymaps can wait to load - vim.api.nvim_create_autocmd("User", { - 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 + -- autocmds can be loaded lazily when not opening a file + local lazy_autocmds = vim.fn.argc(-1) == 0 + if not lazy_autocmds then M.load("autocmds") - M.load("keymaps") 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 M.colorscheme() else @@ -123,34 +198,36 @@ function M.setup(opts) end, { msg = "Could not load your colorscheme", on_error = function(msg) - require("lazy.core.util").error(msg) + Util.error(msg) vim.cmd.colorscheme("habamax") end, }) + Util.track() end ----@param range? string -function M.has(range) - local Semver = require("lazy.manage.semver") - return Semver.range(range or M.lazy_version):matches(require("lazy.core.config").version or "0.0.0") +---@param buf? number +---@return string[]? +function M.get_kind_filter(buf) + 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 ---@param name "autocmds" | "options" | "keymaps" function M.load(name) - local Util = require("lazy.core.util") local function _load(mod) - Util.try(function() - require(mod) - end, { - msg = "Failed loading " .. mod, - on_error = function(msg) - 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, - }) + if require("lazy.core.cache").find(mod)[1] then + Util.try(function() + require(mod) + end, { msg = "Failed loading " .. mod }) + end end -- always load lazyvim, then user file if M.defaults[name] or name == "options" then @@ -167,24 +244,30 @@ end M.did_init = false function M.init() - if not M.did_init then - M.did_init = true - -- 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 + if M.did_init then + return + 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 setmetatable(M, { diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index feaba08519..f7fe57d6f9 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -1,23 +1,15 @@ -- This file is automatically loaded by lazyvim.config.init local Util = require("lazyvim.util") -local function map(mode, lhs, rhs, opts) - local keys = require("lazy.core.handler").handlers.keys - ---@cast keys LazyKeysHandler - -- 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 +-- DO NOT USE THIS IN YOU OWN CONFIG!! +-- use `vim.keymap.set` instead +local map = Util.safe_keymap_set -- better up/down map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true }) +map({ "n", "x" }, "", "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" }, "", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -- Move to window using the hjkl keys map("n", "", "h", { desc = "Go to left window", remap = true }) @@ -40,17 +32,10 @@ map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) -- buffers -if Util.has("bufferline.nvim") then - map("n", "", "BufferLineCyclePrev", { desc = "Prev buffer" }) - map("n", "", "BufferLineCycleNext", { desc = "Next buffer" }) - map("n", "[b", "BufferLineCyclePrev", { desc = "Prev buffer" }) - map("n", "]b", "BufferLineCycleNext", { desc = "Next buffer" }) -else - map("n", "", "bprevious", { desc = "Prev buffer" }) - map("n", "", "bnext", { desc = "Next buffer" }) - map("n", "[b", "bprevious", { desc = "Prev buffer" }) - map("n", "]b", "bnext", { desc = "Next buffer" }) -end +map("n", "", "bprevious", { desc = "Prev buffer" }) +map("n", "", "bnext", { desc = "Next buffer" }) +map("n", "[b", "bprevious", { desc = "Prev buffer" }) +map("n", "]b", "bnext", { desc = "Next buffer" }) map("n", "bb", "e #", { desc = "Switch to Other Buffer" }) map("n", "`", "e #", { desc = "Switch to Other Buffer" }) @@ -66,13 +51,11 @@ map( { desc = "Redraw / clear hlsearch / diff update" } ) -map({ "n", "x" }, "gw", "*N", { desc = "Search word under cursor" }) - -- 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("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("o", "N", "'nN'[v:searchforward]", { expr = true, desc = "Prev search result" }) @@ -82,14 +65,17 @@ map("i", ".", ".u") map("i", ";", ";u") -- save file -map({ "i", "v", "n", "s" }, "", "w", { desc = "Save file" }) +map({ "i", "x", "n", "s" }, "", "w", { desc = "Save file" }) + +--keywordprg +map("n", "K", "norm! K", { desc = "Keywordprg" }) -- better indenting map("v", "<", "", ">gv") -- lazy -map("n", "l", ":Lazy", { desc = "Lazy" }) +map("n", "l", "Lazy", { desc = "Lazy" }) -- new file map("n", "fn", "enew", { desc = "New File" }) @@ -97,41 +83,64 @@ map("n", "fn", "enew", { desc = "New File" }) map("n", "xl", "lopen", { desc = "Location List" }) map("n", "xq", "copen", { desc = "Quickfix List" }) -if not Util.has("trouble.nvim") then - map("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" }) - map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" }) +map("n", "[q", vim.cmd.cprev, { desc = "Previous quickfix" }) +map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" }) + +-- formatting +map({ "n", "v" }, "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 +map("n", "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 -- toggle options -map("n", "uf", require("lazyvim.plugins.lsp.format").toggle, { desc = "Toggle format on Save" }) +map("n", "uf", function() Util.format.toggle() end, { desc = "Toggle auto format (global)" }) +map("n", "uF", function() Util.format.toggle(true) end, { desc = "Toggle auto format (buffer)" }) map("n", "us", function() Util.toggle("spell") end, { desc = "Toggle Spelling" }) map("n", "uw", function() Util.toggle("wrap") end, { desc = "Toggle Word Wrap" }) -map("n", "ul", function() Util.toggle("relativenumber", true) Util.toggle("number") end, { desc = "Toggle Line Numbers" }) -map("n", "ud", Util.toggle_diagnostics, { desc = "Toggle Diagnostics" }) +map("n", "uL", function() Util.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" }) +map("n", "ul", function() Util.toggle.number() end, { desc = "Toggle Line Numbers" }) +map("n", "ud", function() Util.toggle.diagnostics() end, { desc = "Toggle Diagnostics" }) local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3 map("n", "uc", function() Util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" }) -if vim.lsp.buf.inlay_hint then - map("n", "uh", function() vim.lsp.buf.inlay_hint(0, nil) end, { desc = "Toggle Inlay Hints" }) +if vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint then + map( "n", "uh", function() Util.toggle.inlay_hints() end, { desc = "Toggle Inlay Hints" }) end +map("n", "uT", function() if vim.b.ts_highlight then vim.treesitter.stop() else vim.treesitter.start() end end, { desc = "Toggle Treesitter Highlight" }) -- lazygit -map("n", "gg", function() Util.float_term({ "lazygit" }, { cwd = Util.get_root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) -map("n", "gG", function() Util.float_term({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) +map("n", "gg", function() Util.terminal({ "lazygit" }, { cwd = Util.root(), esc_esc = false, ctrl_hjkl = false }) end, { desc = "Lazygit (root dir)" }) +map("n", "gG", function() Util.terminal({ "lazygit" }, {esc_esc = false, ctrl_hjkl = false}) end, { desc = "Lazygit (cwd)" }) -- quit map("n", "qq", "qa", { desc = "Quit all" }) -- highlights under cursor -if vim.fn.has("nvim-0.9.0") == 1 then - map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) -end +map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) + +-- LazyVim Changelog +map("n", "L", function() Util.news.changelog() end, { desc = "LazyVim Changelog" }) -- 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", "ft", lazyterm, { desc = "Terminal (root dir)" }) -map("n", "fT", function() Util.float_term() end, { desc = "Terminal (cwd)" }) +map("n", "fT", function() Util.terminal() end, { desc = "Terminal (cwd)" }) map("n", "", lazyterm, { desc = "Terminal (root dir)" }) map("n", "", lazyterm, { desc = "which_key_ignore" }) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index c5823302a6..3c9686b130 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -1,6 +1,16 @@ -- This file is automatically loaded by plugins.core 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 @@ -16,7 +26,7 @@ opt.grepformat = "%f:%l:%c:%m" opt.grepprg = "rg --vimgrep" opt.ignorecase = true -- Ignore case opt.inccommand = "nosplit" -- preview incremental substitute -opt.laststatus = 0 +opt.laststatus = 3 -- global statusline opt.list = true -- Show some invisible characters (tabs... opt.mouse = "a" -- Enable mouse mode 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.relativenumber = true -- Relative line numbers 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.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.sidescrolloff = 8 -- Columns of context 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.spelllang = { "en" } opt.splitbelow = true -- Put new windows below current +opt.splitkeep = "screen" opt.splitright = true -- Put new windows right of current opt.tabstop = 2 -- Number of spaces tabs count for opt.termguicolors = true -- True color support @@ -42,14 +53,41 @@ opt.timeoutlen = 300 opt.undofile = true opt.undolevels = 10000 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.winminwidth = 5 -- Minimum window width 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 - opt.splitkeep = "screen" - opt.shortmess:append({ C = true }) + vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util'.ui.statuscolumn()]] +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 vim.g.markdown_recommended_style = 0 diff --git a/lua/lazyvim/health.lua b/lua/lazyvim/health.lua index 810022e580..a23c90f503 100644 --- a/lua/lazyvim/health.lua +++ b/lua/lazyvim/health.lua @@ -8,10 +8,10 @@ local error = vim.health.error or vim.health.report_error function M.check() start("LazyVim") - if vim.fn.has("nvim-0.8.0") == 1 then - ok("Using Neovim >= 0.8.0") + if vim.fn.has("nvim-0.9.0") == 1 then + ok("Using Neovim >= 0.9.0") else - error("Neovim >= 0.8.0 is required") + error("Neovim >= 0.9.0 is required") end for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit" }) do diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index 41085ad2ba..c657143341 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -44,6 +44,7 @@ return { opts = function() vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) local cmp = require("cmp") + local defaults = require("cmp.config.default")() return { completion = { completeopt = "menu,menuone,noinsert", @@ -65,12 +66,17 @@ return { behavior = cmp.ConfirmBehavior.Replace, select = true, }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = function(fallback) + cmp.abort() + fallback() + end, }), sources = cmp.config.sources({ { name = "nvim_lsp" }, { name = "luasnip" }, - { name = "buffer" }, { name = "path" }, + }, { + { name = "buffer" }, }), formatting = { format = function(_, item) @@ -86,8 +92,16 @@ return { hl_group = "CmpGhostText", }, }, + sorting = defaults.sorting, } 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 @@ -95,9 +109,27 @@ return { "echasnovski/mini.pairs", event = "VeryLazy", opts = {}, + keys = { + { + "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", + }, + }, }, - -- surround + -- Fast and feature-rich surround actions. For text that includes + -- surrounding characters like brackets or quotes, this allows you + -- to select the text inside, change or modify the surrounding characters, + -- and more. { "echasnovski/mini.surround", keys = function(_, keys) @@ -120,19 +152,25 @@ return { end, 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` + add = "gsa", -- Add surrounding in Normal and Visual modes + delete = "gsd", -- Delete surrounding + find = "gsf", -- Find surrounding (to the right) + find_left = "gsF", -- Find surrounding (to the left) + highlight = "gsh", -- Highlight surrounding + replace = "gsr", -- Replace surrounding + update_n_lines = "gsn", -- Update `n_lines` }, }, }, -- comments - { "JoosepAlviste/nvim-ts-context-commentstring", lazy = true }, + { + "JoosepAlviste/nvim-ts-context-commentstring", + lazy = true, + opts = { + enable_autocmd = false, + }, + }, { "echasnovski/mini.comment", event = "VeryLazy", @@ -145,7 +183,7 @@ return { }, }, - -- better text-objects + -- Better text-objects { "echasnovski/mini.ai", -- keys = { @@ -153,7 +191,6 @@ return { -- { "i", mode = { "x", "o" } }, -- }, event = "VeryLazy", - dependencies = { "nvim-treesitter-textobjects" }, opts = function() local ai = require("mini.ai") return { @@ -165,13 +202,14 @@ return { }, {}), f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {}), c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }, {}), + t = { "<([%p%w]-)%f[^<%w][^<>]->.-", "^<.->().*()$" }, }, } end, config = function(_, opts) require("mini.ai").setup(opts) -- register all text objects with which-key - if require("lazyvim.util").has("which-key.nvim") then + require("lazyvim.util").on_load("which-key.nvim", function() ---@type table local i = { [" "] = "Whitespace", @@ -212,7 +250,7 @@ return { i = i, a = a, }) - end + end) end, }, } diff --git a/lua/lazyvim/plugins/colorscheme.lua b/lua/lazyvim/plugins/colorscheme.lua index a9d97b41f0..bb63326e5a 100644 --- a/lua/lazyvim/plugins/colorscheme.lua +++ b/lua/lazyvim/plugins/colorscheme.lua @@ -14,12 +14,19 @@ return { name = "catppuccin", opts = { integrations = { + aerial = true, alpha = true, cmp = true, + dashboard = true, + flash = true, gitsigns = true, + headlines = true, illuminate = true, indent_blankline = { enabled = true }, + leap = true, lsp_trouble = true, + mason = true, + markdown = true, mini = true, native_lsp = { enabled = true, @@ -30,14 +37,15 @@ return { information = { "undercurl" }, }, }, - navic = { enabled = true }, + navic = { enabled = true, custom_bg = "lualine" }, neotest = true, + neotree = true, noice = true, notify = true, - nvimtree = true, semantic_tokens = true, telescope = true, treesitter = true, + treesitter_context = true, which_key = true, }, }, diff --git a/lua/lazyvim/plugins/core.lua b/lua/lazyvim/plugins/core.lua deleted file mode 100644 index 847d84700e..0000000000 --- a/lua/lazyvim/plugins/core.lua +++ /dev/null @@ -1,6 +0,0 @@ -require("lazyvim.config").init() - -return { - { "folke/lazy.nvim", version = "*" }, - { "LazyVim/LazyVim", priority = 10000, lazy = false, config = true, cond = true, version = "*" }, -} diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 119bf6c1dd..b5f529e599 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -5,12 +5,13 @@ return { -- file explorer { "nvim-neo-tree/neo-tree.nvim", + branch = "v3.x", cmd = "Neotree", keys = { { "fe", 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, desc = "Explorer NeoTree (root dir)", }, @@ -23,13 +24,26 @@ return { }, { "e", "fe", desc = "Explorer NeoTree (root dir)", remap = true }, { "E", "fE", desc = "Explorer NeoTree (cwd)", remap = true }, + { + "ge", + function() + require("neo-tree.command").execute({ source = "git_status", toggle = true }) + end, + desc = "Git explorer", + }, + { + "be", + function() + require("neo-tree.command").execute({ source = "buffers", toggle = true }) + end, + desc = "Buffer explorer", + }, }, deactivate = function() vim.cmd([[Neotree close]]) end, init = function() - vim.g.neo_tree_remove_legacy_commands = 1 - if vim.fn.argc() == 1 then + if vim.fn.argc(-1) == 1 then local stat = vim.loop.fs_stat(vim.fn.argv(0)) if stat and stat.type == "directory" then require("neo-tree") @@ -38,10 +52,10 @@ return { end, opts = { 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 = { bind_to_cwd = false, - follow_current_file = true, + follow_current_file = { enabled = true }, use_libuv_file_watcher = true, }, window = { @@ -56,19 +70,19 @@ return { expander_expanded = "", expander_highlight = "NeoTreeExpander", }, - icon = { - folder_empty = "󰜌", - folder_empty_open = "󰜌", - }, - git_status = { - symbols = { - renamed = "󰁕", - unstaged = "󰄱", - }, - }, }, }, 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) vim.api.nvim_create_autocmd("TermClose", { pattern = "*lazygit", @@ -84,6 +98,7 @@ return { -- search/replace in multiple files { "nvim-pack/nvim-spectre", + build = false, cmd = "Spectre", opts = { open_cmd = "noswapfile vnew" }, -- stylua: ignore @@ -92,19 +107,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", - commit = vim.fn.has("nvim-0.9.0") == 0 and "057ee0f8783" or nil, cmd = "Telescope", 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 = { - { ",", "Telescope buffers show_all_buffers=true", desc = "Switch Buffer" }, + { + ",", + "Telescope buffers sort_mru=true sort_lastused=true", + desc = "Switch Buffer", + }, { "/", Util.telescope("live_grep"), desc = "Grep (root dir)" }, { ":", "Telescope command_history", desc = "Command History" }, { "", Util.telescope("files"), desc = "Find Files (root dir)" }, -- find - { "fb", "Telescope buffers", desc = "Buffers" }, + { "fb", "Telescope buffers sort_mru=true sort_lastused=true", desc = "Buffers" }, + { "fc", Util.telescope.config_files(), desc = "Find Config File" }, { "ff", Util.telescope("files"), desc = "Find Files (root dir)" }, { "fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" }, { "fr", "Telescope oldfiles", desc = "Recent" }, @@ -113,6 +147,7 @@ return { { "gc", "Telescope git_commits", desc = "commits" }, { "gs", "Telescope git_status", desc = "status" }, -- search + { 's"', "Telescope registers", desc = "Registers" }, { "sa", "Telescope autocommands", desc = "Auto Commands" }, { "sb", "Telescope current_buffer_fuzzy_find", desc = "Buffer" }, { "sc", "Telescope command_history", desc = "Command History" }, @@ -128,123 +163,140 @@ return { { "sm", "Telescope marks", desc = "Jump to Mark" }, { "so", "Telescope vim_options", desc = "Options" }, { "sR", "Telescope resume", desc = "Resume" }, - { "sw", Util.telescope("grep_string"), desc = "Word (root dir)" }, - { "sW", Util.telescope("grep_string", { cwd = false }), desc = "Word (cwd)" }, + { "sw", Util.telescope("grep_string", { word_match = "-w" }), desc = "Word (root dir)" }, + { "sW", Util.telescope("grep_string", { cwd = false, word_match = "-w" }), desc = "Word (cwd)" }, + { "sw", Util.telescope("grep_string"), mode = "v", desc = "Selection (root dir)" }, + { "sW", Util.telescope("grep_string", { cwd = false }), mode = "v", desc = "Selection (cwd)" }, { "uC", Util.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with preview" }, { "ss", - Util.telescope("lsp_document_symbols", { - symbols = { - "Class", - "Function", - "Method", - "Constructor", - "Interface", - "Module", - "Struct", - "Trait", - "Field", - "Property", - }, - }), + function() + require("telescope.builtin").lsp_document_symbols({ + symbols = require("lazyvim.config").get_kind_filter(), + }) + end, desc = "Goto Symbol", }, { "sS", - Util.telescope("lsp_dynamic_workspace_symbols", { - symbols = { - "Class", - "Function", - "Method", - "Constructor", - "Interface", - "Module", - "Struct", - "Trait", - "Field", - "Property", - }, - }), + function() + require("telescope.builtin").lsp_dynamic_workspace_symbols({ + symbols = require("lazyvim.config").get_kind_filter(), + }) + end, desc = "Goto Symbol (Workspace)", }, }, - opts = { - defaults = { - prompt_prefix = " ", - selection_caret = " ", - mappings = { - i = { - [""] = function(...) - return require("trouble.providers.telescope").open_with_trouble(...) - end, - [""] = function(...) - return require("trouble.providers.telescope").open_selected_with_trouble(...) - end, - [""] = function() - local action_state = require("telescope.actions.state") - local line = action_state.get_current_line() - Util.telescope("find_files", { no_ignore = true, default_text = line })() - end, - [""] = function() - local action_state = require("telescope.actions.state") - local line = action_state.get_current_line() - Util.telescope("find_files", { hidden = true, default_text = line })() - end, - [""] = function(...) - return require("telescope.actions").cycle_history_next(...) - end, - [""] = function(...) - return require("telescope.actions").cycle_history_prev(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_down(...) - end, - [""] = function(...) - return require("telescope.actions").preview_scrolling_up(...) - end, - }, - n = { - ["q"] = function(...) - return require("telescope.actions").close(...) - end, - }, - }, - }, - }, - }, + opts = function() + local actions = require("telescope.actions") - -- easily jump to any location and enhanced f/t motions for Leap - { - "ggandor/flit.nvim", - keys = function() - ---@type LazyKeys[] - local ret = {} - for _, key in ipairs({ "f", "F", "t", "T" }) do - ret[#ret + 1] = { key, mode = { "n", "x", "o" }, desc = key } + local open_with_trouble = function(...) + return require("trouble.providers.telescope").open_with_trouble(...) end - return ret + local open_selected_with_trouble = function(...) + return require("trouble.providers.telescope").open_selected_with_trouble(...) + end + local find_files_no_ignore = function() + local action_state = require("telescope.actions.state") + local line = action_state.get_current_line() + Util.telescope("find_files", { no_ignore = true, default_text = line })() + end + local find_files_with_hidden = function() + local action_state = require("telescope.actions.state") + local line = action_state.get_current_line() + Util.telescope("find_files", { hidden = true, default_text = line })() + end + + return { + defaults = { + prompt_prefix = " ", + selection_caret = " ", + -- open files in the first window that is an actual file. + -- use the current window if no other window is available. + get_selection_window = function() + local wins = vim.api.nvim_list_wins() + table.insert(wins, 1, vim.api.nvim_get_current_win()) + for _, win in ipairs(wins) do + local buf = vim.api.nvim_win_get_buf(win) + if vim.bo[buf].buftype == "" then + return win + end + end + return 0 + end, + mappings = { + i = { + [""] = open_with_trouble, + [""] = open_selected_with_trouble, + [""] = find_files_no_ignore, + [""] = find_files_with_hidden, + [""] = actions.cycle_history_next, + [""] = actions.cycle_history_prev, + [""] = actions.preview_scrolling_down, + [""] = actions.preview_scrolling_up, + }, + n = { + ["q"] = actions.close, + }, + }, + }, + } end, - opts = { labeled_modes = "nx" }, }, + + -- Flash enhances the built-in search functionality by showing labels + -- at the end of each match, letting you quickly jump to a specific + -- location. { - "ggandor/leap.nvim", + "folke/flash.nvim", + event = "VeryLazy", + vscode = true, + ---@type Flash.Config + opts = {}, + -- stylua: ignore keys = { - { "s", mode = { "n", "x", "o" }, desc = "Leap forward to" }, - { "S", mode = { "n", "x", "o" }, desc = "Leap backward to" }, - { "gs", mode = { "n", "x", "o" }, desc = "Leap from windows" }, + { "s", mode = { "n", "x", "o" }, function() require("flash").jump() end, desc = "Flash" }, + { "S", mode = { "n", "o", "x" }, function() require("flash").treesitter() end, desc = "Flash Treesitter" }, + { "r", mode = "o", function() require("flash").remote() end, desc = "Remote Flash" }, + { "R", mode = { "o", "x" }, function() require("flash").treesitter_search() end, desc = "Treesitter Search" }, + { "", mode = { "c" }, function() require("flash").toggle() end, desc = "Toggle Flash Search" }, }, - config = function(_, opts) - local leap = require("leap") - for k, v in pairs(opts) do - leap.opts[k] = v + }, + + -- Flash Telescope config + { + "nvim-telescope/telescope.nvim", + optional = true, + opts = function(_, opts) + if not Util.has("flash.nvim") then + return + end + local function flash(prompt_bufnr) + require("flash").jump({ + pattern = "^", + label = { after = { 0, 0 } }, + search = { + mode = "search", + exclude = { + function(win) + return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= "TelescopeResults" + end, + }, + }, + action = function(match) + local picker = require("telescope.actions.state").get_current_picker(prompt_bufnr) + picker:set_selection(match.pos[1] - 1) + end, + }) end - leap.add_default_mappings(true) - vim.keymap.del({ "x", "o" }, "x") - vim.keymap.del({ "x", "o" }, "X") + opts.defaults = vim.tbl_deep_extend("force", opts.defaults or {}, { + mappings = { n = { s = flash }, i = { [""] = flash } }, + }) end, }, - -- which-key + -- which-key helps you remember key bindings by showing a popup + -- with the active keybindings of the command you started typing. { "folke/which-key.nvim", event = "VeryLazy", @@ -253,7 +305,7 @@ return { defaults = { mode = { "n", "v" }, ["g"] = { name = "+goto" }, - ["gz"] = { name = "+surround" }, + ["gs"] = { name = "+surround" }, ["]"] = { name = "+next" }, ["["] = { name = "+prev" }, [""] = { name = "+tabs" }, @@ -276,10 +328,12 @@ return { end, }, - -- git signs + -- git signs highlights text that has changed since the list + -- git commit, and also lets you interactively stage & unstage + -- hunks in a commit. { "lewis6991/gitsigns.nvim", - event = { "BufReadPre", "BufNewFile" }, + event = "LazyFile", opts = { signs = { add = { text = "▎" }, @@ -313,10 +367,12 @@ return { }, }, - -- references + -- Automatically highlights other instances of the word under your cursor. + -- This works with LSP, Treesitter, and regexp matching to find the other + -- instances. { "RRethy/vim-illuminate", - event = { "BufReadPost", "BufNewFile" }, + event = "LazyFile", opts = { delay = 200, large_file_cutoff = 2000, @@ -354,9 +410,27 @@ return { -- buffer remove { "echasnovski/mini.bufremove", - -- stylua: ignore + keys = { - { "bd", function() require("mini.bufremove").delete(0, false) end, desc = "Delete Buffer" }, + { + "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 { "bD", function() require("mini.bufremove").delete(0, true) end, desc = "Delete Buffer (Force)" }, }, }, @@ -402,11 +476,12 @@ return { }, }, - -- todo comments + -- Finds and lists all of the TODO, HACK, BUG, etc comment + -- in your project and loads them into a browsable list. { "folke/todo-comments.nvim", cmd = { "TodoTrouble", "TodoTelescope" }, - event = { "BufReadPost", "BufNewFile" }, + event = "LazyFile", config = true, -- stylua: ignore keys = { diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua new file mode 100644 index 0000000000..a9f40624b4 --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -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, + }, +} diff --git a/lua/lazyvim/plugins/extras/coding/copilot.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index 764537f492..279a974f0a 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/copilot.lua @@ -21,10 +21,10 @@ return { opts = function(_, opts) local Util = require("lazyvim.util") local colors = { - [""] = Util.fg("Special"), - ["Normal"] = Util.fg("Special"), - ["Warning"] = Util.fg("DiagnosticError"), - ["InProgress"] = Util.fg("DiagnosticWarn"), + [""] = Util.ui.fg("Special"), + ["Normal"] = Util.ui.fg("Special"), + ["Warning"] = Util.ui.fg("DiagnosticError"), + ["InProgress"] = Util.ui.fg("DiagnosticWarn"), } table.insert(opts.sections.lualine_x, 2, { function() @@ -33,7 +33,13 @@ return { return icon .. (status.message or "") end, 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 end, color = function() @@ -60,7 +66,7 @@ return { copilot_cmp.setup(opts) -- attach cmp source whenever copilot attaches -- 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 copilot_cmp._on_insert_enter({}) end @@ -70,28 +76,11 @@ return { }, ---@param opts cmp.ConfigSchema opts = function(_, opts) - local cmp = require("cmp") - - table.insert(opts.sources, 1, { name = "copilot", group_index = 2 }) - - opts.sorting = { - priority_weight = 2, - comparators = { - require("copilot_cmp.comparators").prioritize, - - -- Below is the default comparitor list and order for nvim-cmp - cmp.config.compare.offset, - -- cmp.config.compare.scopes, --this is commented in nvim-cmp too - cmp.config.compare.exact, - cmp.config.compare.score, - cmp.config.compare.recently_used, - cmp.config.compare.locality, - cmp.config.compare.kind, - cmp.config.compare.sort_text, - cmp.config.compare.length, - cmp.config.compare.order, - }, - } + table.insert(opts.sources, 1, { + name = "copilot", + group_index = 1, + priority = 100, + }) end, }, } diff --git a/lua/lazyvim/plugins/extras/coding/tabnine.lua b/lua/lazyvim/plugins/extras/coding/tabnine.lua new file mode 100644 index 0000000000..aac8519e09 --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/tabnine.lua @@ -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, + }, +} diff --git a/lua/lazyvim/plugins/extras/coding/yanky.lua b/lua/lazyvim/plugins/extras/coding/yanky.lua new file mode 100644 index 0000000000..00b675e9f4 --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/yanky.lua @@ -0,0 +1,32 @@ +return { + -- better yank/paste + { + "gbprod/yanky.nvim", + dependencies = { { "kkharji/sqlite.lua", enabled = not jit.os:find("Windows") } }, + opts = { + highlight = { timer = 250 }, + ring = { storage = jit.os:find("Windows") and "shada" or "sqlite" }, + }, + keys = { + -- stylua: ignore + { "p", function() require("telescope").extensions.yank_history.yank_history({ }) end, desc = "Open Yank History" }, + { "y", "(YankyYank)", mode = { "n", "x" }, desc = "Yank text" }, + { "p", "(YankyPutAfter)", mode = { "n", "x" }, desc = "Put yanked text after cursor" }, + { "P", "(YankyPutBefore)", mode = { "n", "x" }, desc = "Put yanked text before cursor" }, + { "gp", "(YankyGPutAfter)", mode = { "n", "x" }, desc = "Put yanked text after selection" }, + { "gP", "(YankyGPutBefore)", mode = { "n", "x" }, desc = "Put yanked text before selection" }, + { "[y", "(YankyCycleForward)", desc = "Cycle forward through yank history" }, + { "]y", "(YankyCycleBackward)", desc = "Cycle backward through yank history" }, + { "]p", "(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" }, + { "[p", "(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" }, + { "]P", "(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" }, + { "[P", "(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" }, + { ">p", "(YankyPutIndentAfterShiftRight)", desc = "Put and indent right" }, + { "(YankyPutIndentAfterShiftLeft)", desc = "Put and indent left" }, + { ">P", "(YankyPutIndentBeforeShiftRight)", desc = "Put before and indent right" }, + { "(YankyPutIndentBeforeShiftLeft)", desc = "Put before and indent left" }, + { "=p", "(YankyPutAfterFilter)", desc = "Put after applying a filter" }, + { "=P", "(YankyPutBeforeFilter)", desc = "Put before applying a filter" }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/dap/core.lua b/lua/lazyvim/plugins/extras/dap/core.lua index e228afac07..c9aa291a5f 100644 --- a/lua/lazyvim/plugins/extras/dap/core.lua +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -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 { "mfussenegger/nvim-dap", @@ -13,6 +25,8 @@ return { }, opts = {}, config = function(_, opts) + -- setup dap config by VsCode launch.json file + -- require("dap.ext.vscode").load_launchjs() local dap = require("dap") local dapui = require("dapui") dapui.setup(opts) @@ -41,7 +55,6 @@ return { opts = { defaults = { ["d"] = { name = "+debug" }, - ["da"] = { name = "+adapters" }, }, }, }, @@ -74,6 +87,7 @@ return { { "dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" }, { "db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" }, { "dc", function() require("dap").continue() end, desc = "Continue" }, + { "da", function() require("dap").continue({ before = get_args }) end, desc = "Run with Args" }, { "dC", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" }, { "dg", function() require("dap").goto_() end, desc = "Go to line (no execute)" }, { "di", function() require("dap").step_into() end, desc = "Step Into" }, diff --git a/lua/lazyvim/plugins/extras/dap/nlua.lua b/lua/lazyvim/plugins/extras/dap/nlua.lua index 1d9eb65048..9cf0e63d7a 100644 --- a/lua/lazyvim/plugins/extras/dap/nlua.lua +++ b/lua/lazyvim/plugins/extras/dap/nlua.lua @@ -1,24 +1,40 @@ return { "mfussenegger/nvim-dap", - dependencies = { { "jbyuki/one-small-step-for-vimkind", -- stylua: ignore - keys = { - { "daL", function() require("osv").launch({ port = 8086 }) end, desc = "Adapter Lua Server" }, - { "dal", function() require("osv").run_this() end, desc = "Adapter Lua" }, - }, config = function() local dap = require("dap") - dap.adapters.nlua = function(callback, config) - callback({ type = "server", host = config.host or "127.0.0.1", port = config.port or 8086 }) + dap.adapters.nlua = function(callback, conf) + 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 dap.configurations.lua = { { type = "nlua", 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, diff --git a/lua/lazyvim/plugins/extras/editor/aerial.lua b/lua/lazyvim/plugins/extras/editor/aerial.lua new file mode 100644 index 0000000000..440c9fdae9 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/aerial.lua @@ -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|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 = { + { "cs", "AerialToggle", 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 = { + { + "ss", + "Telescope aerial", + 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, + }, +} diff --git a/lua/lazyvim/plugins/extras/editor/flash.lua b/lua/lazyvim/plugins/extras/editor/flash.lua deleted file mode 100644 index 1a64383a1f..0000000000 --- a/lua/lazyvim/plugins/extras/editor/flash.lua +++ /dev/null @@ -1,66 +0,0 @@ -return { - { "ggandor/leap.nvim", enabled = false }, - { "ggandor/flit.nvim", enabled = false }, - { - "folke/flash.nvim", - event = "VeryLazy", - ---@type Flash.Config - opts = {}, - keys = { - { - "s", - mode = { "n", "x", "o" }, - function() - require("flash").jump() - end, - desc = "Flash", - }, - { - "S", - mode = { "n", "o", "x" }, - function() - require("flash").treesitter() - end, - desc = "Flash Treesitter", - }, - { - "r", - mode = "o", - function() - require("flash").remote() - end, - desc = "Remote Flash", - }, - }, - }, - { - "nvim-telescope/telescope.nvim", - optional = true, - opts = function(_, opts) - local function flash(prompt_bufnr) - require("flash").jump({ - pattern = "^", - highlight = { label = { after = { 0, 0 } } }, - search = { - mode = "search", - exclude = { - function(win) - return vim.bo[vim.api.nvim_win_get_buf(win)].filetype ~= "TelescopeResults" - end, - }, - }, - action = function(match) - local picker = require("telescope.actions.state").get_current_picker(prompt_bufnr) - picker:set_selection(match.pos[1] - 1) - end, - }) - end - opts.defaults = vim.tbl_deep_extend("force", opts.defaults or {}, { - mappings = { - n = { s = flash }, - i = { [""] = flash }, - }, - }) - end, - }, -} diff --git a/lua/lazyvim/plugins/extras/editor/leap.lua b/lua/lazyvim/plugins/extras/editor/leap.lua new file mode 100644 index 0000000000..ab422abf3f --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/leap.lua @@ -0,0 +1,56 @@ +return { + -- disable flash + { "folke/flash.nvim", enabled = false, optional = true }, + + -- easily jump to any location and enhanced f/t motions for Leap + { + "ggandor/flit.nvim", + enabled = true, + keys = function() + ---@type LazyKeys[] + local ret = {} + for _, key in ipairs({ "f", "F", "t", "T" }) do + ret[#ret + 1] = { key, mode = { "n", "x", "o" }, desc = key } + end + return ret + end, + opts = { labeled_modes = "nx" }, + }, + { + "ggandor/leap.nvim", + enabled = true, + keys = { + { "s", mode = { "n", "x", "o" }, desc = "Leap forward to" }, + { "S", mode = { "n", "x", "o" }, desc = "Leap backward to" }, + { "gs", mode = { "n", "x", "o" }, desc = "Leap from windows" }, + }, + config = function(_, opts) + local leap = require("leap") + for k, v in pairs(opts) do + leap.opts[k] = v + end + leap.add_default_mappings(true) + vim.keymap.del({ "x", "o" }, "x") + vim.keymap.del({ "x", "o" }, "X") + 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 + { "tpope/vim-repeat", event = "VeryLazy" }, +} diff --git a/lua/lazyvim/plugins/extras/editor/mini-files.lua b/lua/lazyvim/plugins/extras/editor/mini-files.lua index 0c2333a6a4..55fc768c38 100644 --- a/lua/lazyvim/plugins/extras/editor/mini-files.lua +++ b/lua/lazyvim/plugins/extras/editor/mini-files.lua @@ -3,6 +3,8 @@ return { opts = { windows = { preview = true, + width_focus = 30, + width_preview = 30, }, options = { -- Whether to use for editing directories @@ -30,8 +32,12 @@ return { require("mini.files").setup(opts) local show_dotfiles = true - local filter_show = function(fs_entry) return true end - local filter_hide = function(fs_entry) return not vim.startswith(fs_entry.name, ".") end + local filter_show = function(fs_entry) + return true + end + local filter_hide = function(fs_entry) + return not vim.startswith(fs_entry.name, ".") + end local toggle_dotfiles = function() show_dotfiles = not show_dotfiles @@ -47,5 +53,12 @@ return { vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id }) 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, } diff --git a/lua/lazyvim/plugins/extras/editor/navic.lua b/lua/lazyvim/plugins/extras/editor/navic.lua new file mode 100644 index 0000000000..359c42d4ca --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/navic.lua @@ -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, + }, +} diff --git a/lua/lazyvim/plugins/extras/editor/symbols-outline.lua b/lua/lazyvim/plugins/extras/editor/symbols-outline.lua new file mode 100644 index 0000000000..32cdd17f94 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/symbols-outline.lua @@ -0,0 +1,61 @@ +local Util = require("lazyvim.util") + +return { + { + "simrat39/symbols-outline.nvim", + keys = { { "cs", "SymbolsOutline", 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, + }, +} diff --git a/lua/lazyvim/plugins/extras/formatting/black.lua b/lua/lazyvim/plugins/extras/formatting/black.lua new file mode 100644 index 0000000000..769c300904 --- /dev/null +++ b/lua/lazyvim/plugins/extras/formatting/black.lua @@ -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" }, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/formatting/prettier.lua b/lua/lazyvim/plugins/extras/formatting/prettier.lua index e16b980562..a93f6ecfb0 100644 --- a/lua/lazyvim/plugins/extras/formatting/prettier.lua +++ b/lua/lazyvim/plugins/extras/formatting/prettier.lua @@ -2,14 +2,40 @@ return { { "williamboman/mason.nvim", opts = function(_, opts) - table.insert(opts.ensure_installed, "prettierd") + table.insert(opts.ensure_installed, "prettier") end, }, { - "jose-elias-alvarez/null-ls.nvim", + "nvimtools/none-ls.nvim", + optional = true, opts = function(_, opts) 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, }, + { + "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" }, + }, + }, + }, } diff --git a/lua/lazyvim/plugins/extras/lang/clangd.lua b/lua/lazyvim/plugins/extras/lang/clangd.lua new file mode 100644 index 0000000000..0801770064 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/clangd.lua @@ -0,0 +1,154 @@ +return { + + -- Add C/C++ to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "c", "cpp" }) + end + end, + }, + + { + "p00f/clangd_extensions.nvim", + lazy = true, + config = function() end, + opts = { + inlay_hints = { + inline = false, + }, + ast = { + --These require codicons (https://github.com/microsoft/vscode-codicons) + role_icons = { + type = "", + declaration = "", + expression = "", + specifier = "", + statement = "", + ["template argument"] = "", + }, + kind_icons = { + Compound = "", + Recovery = "", + TranslationUnit = "", + PackExpansion = "", + TemplateTypeParm = "", + TemplateTemplateParm = "", + TemplateParamObject = "", + }, + }, + }, + }, + + -- Correctly setup lspconfig for clangd 🚀 + { + "neovim/nvim-lspconfig", + opts = { + servers = { + -- Ensure mason installs the server + clangd = { + keys = { + { "cR", "ClangdSwitchSourceHeader", desc = "Switch Source/Header (C/C++)" }, + }, + root_dir = function(fname) + return require("lspconfig.util").root_pattern( + "Makefile", + "configure.ac", + "configure.in", + "config.h.in", + "meson.build", + "meson_options.txt", + "build.ninja" + )(fname) or require("lspconfig.util").root_pattern("compile_commands.json", "compile_flags.txt")( + fname + ) or require("lspconfig.util").find_git_ancestor(fname) + end, + capabilities = { + offsetEncoding = { "utf-16" }, + }, + cmd = { + "clangd", + "--background-index", + "--clang-tidy", + "--header-insertion=iwyu", + "--completion-style=detailed", + "--function-arg-placeholders", + "--fallback-style=llvm", + }, + init_options = { + usePlaceholders = true, + completeUnimported = true, + clangdFileStatus = true, + }, + }, + }, + setup = { + clangd = function(_, opts) + local clangd_ext_opts = require("lazyvim.util").opts("clangd_extensions.nvim") + require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts })) + return false + end, + }, + }, + }, + + { + "nvim-cmp", + opts = function(_, opts) + table.insert(opts.sorting.comparators, 1, require("clangd_extensions.cmp_scores")) + end, + }, + + { + "mfussenegger/nvim-dap", + optional = true, + dependencies = { + -- Ensure C/C++ debugger is installed + "williamboman/mason.nvim", + optional = true, + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "codelldb" }) + end + end, + }, + opts = function() + local dap = require("dap") + if not dap.adapters["codelldb"] then + require("dap").adapters["codelldb"] = { + type = "server", + host = "localhost", + port = "${port}", + executable = { + command = "codelldb", + args = { + "--port", + "${port}", + }, + }, + } + end + for _, lang in ipairs({ "c", "cpp" }) do + dap.configurations[lang] = { + { + type = "codelldb", + request = "launch", + name = "Launch file", + program = function() + return vim.fn.input("Path to executable: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + }, + { + type = "codelldb", + request = "attach", + name = "Attach to process", + processId = require("dap.utils").pick_process, + cwd = "${workspaceFolder}", + }, + } + end + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua new file mode 100644 index 0000000000..e95dbfddfe --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/cmake.lua @@ -0,0 +1,49 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "cmake" }) + end + 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.cmake_lint, + }) + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + cmake = { "cmakelint" }, + }, + }, + }, + { + "mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "cmakelang", "cmakelint" }) + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + neocmake = {}, + }, + }, + }, + { + "Civitasv/cmake-tools.nvim", + opts = {}, + event = "LazyFile", + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/docker.lua b/lua/lazyvim/plugins/extras/lang/docker.lua new file mode 100644 index 0000000000..da9605ec14 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/docker.lua @@ -0,0 +1,45 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "dockerfile" }) + end + end, + }, + { + "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) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.diagnostics.hadolint, + }) + end, + }, + { + "mfussenegger/nvim-lint", + optional = true, + opts = { + linters_by_ft = { + dockerfile = { "hadolint" }, + }, + }, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + dockerls = {}, + docker_compose_language_service = {}, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/elixir.lua b/lua/lazyvim/plugins/extras/lang/elixir.lua new file mode 100644 index 0000000000..f60dc18ed2 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/elixir.lua @@ -0,0 +1,57 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed, { + "elixir", + "heex", + "eex", + }) + end, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed, { + "elixir-ls", + }) + end, + }, + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + "jfpedroza/neotest-elixir", + }, + opts = { + adapters = { + ["neotest-elixir"] = {}, + }, + }, + }, + { + "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, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index e4036185e2..aaad0128b2 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -15,18 +15,53 @@ return { opts = { servers = { gopls = { + keys = { + -- Workaround for the lack of a DAP strategy in neotest-go: https://github.com/nvim-neotest/neotest-go/issues/12 + { "td", "lua require('dap-go').debug_test()", desc = "Debug Nearest (Go)" }, + }, settings = { gopls = { + gofumpt = true, + codelenses = { + gc_details = false, + generate = true, + regenerate_cgo = true, + run_govulncheck = true, + test = true, + tidy = true, + upgrade_dependency = true, + vendor = true, + }, + hints = { + assignVariableTypes = true, + compositeLiteralFields = true, + compositeLiteralTypes = true, + constantValues = true, + functionTypeParameters = true, + parameterNames = true, + rangeVariableTypes = true, + }, + analyses = { + fieldalignment = true, + nilness = true, + unusedparams = true, + unusedwrite = true, + useany = true, + }, + usePlaceholders = true, + completeUnimported = true, + staticcheck = true, + directoryFilters = { "-.git", "-.vscode", "-.idea", "-.vscode-test", "-node_modules" }, semanticTokens = true, }, }, }, }, setup = { - gopls = function() - -- workaround for gopls not supporting semantictokensprovider + gopls = function(_, opts) + -- workaround for gopls not supporting semanticTokensProvider -- 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 not client.server_capabilities.semanticTokensProvider then local semantic = client.config.capabilities.textDocument.semanticTokens @@ -46,17 +81,60 @@ return { }, }, }, + -- Ensure Go tools are installed + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "goimports", "gofumpt" }) + 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", optional = true, dependencies = { { - "mason.nvim", + "williamboman/mason.nvim", opts = function(_, opts) opts.ensure_installed = opts.ensure_installed or {} - table.insert(opts.ensure_installed, "delve") + vim.list_extend(opts.ensure_installed, { "delve" }) end, }, + { + "leoluz/nvim-dap-go", + config = true, + }, }, }, { diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua new file mode 100644 index 0000000000..f7e7ca5f7d --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -0,0 +1,227 @@ +local Util = require("lazyvim.util") + +-- This is the same as in lspconfig.server_configurations.jdtls, but avoids +-- needing to require that when this module loads. +local java_filetypes = { "java" } + +-- Utility function to extend or override a config table, similar to the way +-- that Plugin.opts works. +---@param config table +---@param custom function | table | nil +local function extend_or_override(config, custom, ...) + if type(custom) == "function" then + config = custom(config, ...) or config + elseif custom then + config = vim.tbl_deep_extend("force", config, custom) --[[@as table]] + end + return config +end + +return { + -- Add java to treesitter. + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "java" }) + end, + }, + + -- Ensure java debugger and test packages are installed. + { + "mfussenegger/nvim-dap", + optional = true, + dependencies = { + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "java-test", "java-debug-adapter" }) + end, + }, + }, + }, + + -- Configure nvim-lspconfig to install the server automatically via mason, but + -- defer actually starting it to our configuration of nvim-jtdls below. + { + "neovim/nvim-lspconfig", + opts = { + -- make sure mason installs the server + servers = { + jdtls = {}, + }, + setup = { + jdtls = function() + return true -- avoid duplicate servers + end, + }, + }, + }, + + -- Set up nvim-jdtls to attach to java files. + { + "mfussenegger/nvim-jdtls", + dependencies = { "folke/which-key.nvim" }, + ft = java_filetypes, + opts = function() + return { + -- How to find the root dir for a given filename. The default comes from + -- lspconfig which provides a function specifically for java projects. + root_dir = require("lspconfig.server_configurations.jdtls").default_config.root_dir, + + -- How to find the project name for a given root dir. + project_name = function(root_dir) + return root_dir and vim.fs.basename(root_dir) + end, + + -- Where are the config and workspace dirs for a project? + jdtls_config_dir = function(project_name) + return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/config" + end, + jdtls_workspace_dir = function(project_name) + return vim.fn.stdpath("cache") .. "/jdtls/" .. project_name .. "/workspace" + end, + + -- How to run jdtls. This can be overridden to a full java command-line + -- if the Python wrapper script doesn't suffice. + cmd = { vim.fn.exepath("jdtls") }, + full_cmd = function(opts) + local fname = vim.api.nvim_buf_get_name(0) + local root_dir = opts.root_dir(fname) + local project_name = opts.project_name(root_dir) + local cmd = vim.deepcopy(opts.cmd) + if project_name then + vim.list_extend(cmd, { + "-configuration", + opts.jdtls_config_dir(project_name), + "-data", + opts.jdtls_workspace_dir(project_name), + }) + end + return cmd + end, + + -- These depend on nvim-dap, but can additionally be disabled by setting false here. + dap = { hotcodereplace = "auto", config_overrides = {} }, + test = true, + } + end, + config = function() + local opts = Util.opts("nvim-jdtls") or {} + + -- Find the extra bundles that should be passed on the jdtls command-line + -- if nvim-dap is enabled with java debug/test. + local mason_registry = require("mason-registry") + local bundles = {} ---@type string[] + if opts.dap and Util.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then + local java_dbg_pkg = mason_registry.get_package("java-debug-adapter") + local java_dbg_path = java_dbg_pkg:get_install_path() + local jar_patterns = { + java_dbg_path .. "/extension/server/com.microsoft.java.debug.plugin-*.jar", + } + -- java-test also depends on java-debug-adapter. + if opts.test and mason_registry.is_installed("java-test") then + local java_test_pkg = mason_registry.get_package("java-test") + local java_test_path = java_test_pkg:get_install_path() + vim.list_extend(jar_patterns, { + java_test_path .. "/extension/server/*.jar", + }) + end + for _, jar_pattern in ipairs(jar_patterns) do + for _, bundle in ipairs(vim.split(vim.fn.glob(jar_pattern), "\n")) do + table.insert(bundles, bundle) + end + end + end + + local function attach_jdtls() + local fname = vim.api.nvim_buf_get_name(0) + + -- Configuration can be augmented and overridden by opts.jdtls + local config = extend_or_override({ + cmd = opts.full_cmd(opts), + root_dir = opts.root_dir(fname), + init_options = { + bundles = bundles, + }, + -- enable CMP capabilities + capabilities = require("cmp_nvim_lsp").default_capabilities(), + }, opts.jdtls) + + -- Existing server will be reused if the root_dir matches. + require("jdtls").start_or_attach(config) + -- not need to require("jdtls.setup").add_commands(), start automatically adds commands + end + + -- Attach the jdtls for each java buffer. HOWEVER, this plugin loads + -- depending on filetype, so this autocmd doesn't run for the first file. + -- For that, we call directly below. + vim.api.nvim_create_autocmd("FileType", { + pattern = java_filetypes, + callback = attach_jdtls, + }) + + -- Setup keymap and dap after the lsp is fully attached. + -- https://github.com/mfussenegger/nvim-jdtls#nvim-dap-configuration + -- https://neovim.io/doc/user/lsp.html#LspAttach + vim.api.nvim_create_autocmd("LspAttach", { + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + if client and client.name == "jdtls" then + local wk = require("which-key") + wk.register({ + ["cx"] = { name = "+extract" }, + ["cxv"] = { require("jdtls").extract_variable_all, "Extract Variable" }, + ["cxc"] = { require("jdtls").extract_constant, "Extract Constant" }, + ["gs"] = { require("jdtls").super_implementation, "Goto Super" }, + ["gS"] = { require("jdtls.tests").goto_subjects, "Goto Subjects" }, + ["co"] = { require("jdtls").organize_imports, "Organize Imports" }, + }, { mode = "n", buffer = args.buf }) + wk.register({ + ["c"] = { name = "+code" }, + ["cx"] = { name = "+extract" }, + ["cxm"] = { + [[lua require('jdtls').extract_method(true)]], + "Extract Method", + }, + ["cxv"] = { + [[lua require('jdtls').extract_variable_all(true)]], + "Extract Variable", + }, + ["cxc"] = { + [[lua require('jdtls').extract_constant(true)]], + "Extract Constant", + }, + }, { mode = "v", buffer = args.buf }) + + if opts.dap and Util.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then + -- custom init for Java debugger + require("jdtls").setup_dap(opts.dap) + require("jdtls.dap").setup_dap_main_class_configs() + + -- Java Test require Java debugger to work + if opts.test and mason_registry.is_installed("java-test") then + -- custom keymaps for Java test runner (not yet compatible with neotest) + wk.register({ + ["t"] = { name = "+test" }, + ["tt"] = { require("jdtls.dap").test_class, "Run All Test" }, + ["tr"] = { require("jdtls.dap").test_nearest_method, "Run Nearest Test" }, + ["tT"] = { require("jdtls.dap").pick_test, "Run Test" }, + }, { mode = "n", buffer = args.buf }) + end + end + + -- User can set additional keymaps in opts.on_attach + if opts.on_attach then + opts.on_attach(args) + end + end + end, + }) + + -- Avoid race condition by calling attach the first time, since the autocmd won't fire. + attach_jdtls() + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/json.lua b/lua/lazyvim/plugins/extras/lang/json.lua index d4dab0db6a..ff41ba4fea 100644 --- a/lua/lazyvim/plugins/extras/lang/json.lua +++ b/lua/lazyvim/plugins/extras/lang/json.lua @@ -10,13 +10,16 @@ return { end, }, + -- yaml schema support + { + "b0o/SchemaStore.nvim", + lazy = true, + version = false, -- last release is way too old + }, + -- correctly setup lspconfig { "neovim/nvim-lspconfig", - dependencies = { - "b0o/SchemaStore.nvim", - version = false, -- last release is way too old - }, opts = { -- make sure mason installs the server servers = { diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua new file mode 100644 index 0000000000..5aa9dc331a --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -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 = { + { + "cp", + ft = "markdown", + "MarkdownPreviewToggle", + 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, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/omnisharp.lua b/lua/lazyvim/plugins/extras/lang/omnisharp.lua new file mode 100644 index 0000000000..31162e0c04 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua @@ -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, + }, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/python-semshi.lua b/lua/lazyvim/plugins/extras/lang/python-semshi.lua new file mode 100644 index 0000000000..e4e32c10e7 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/python-semshi.lua @@ -0,0 +1,32 @@ +return { + -- "numiras/semshi", + "wookayin/semshi", -- use a maintained fork + ft = "python", + build = ":UpdateRemotePlugins", + init = function() + -- Disabled these features better provided by LSP or other more general plugins + vim.g["semshi#error_sign"] = false + vim.g["semshi#simplify_markup"] = false + vim.g["semshi#mark_selected_nodes"] = false + vim.g["semshi#update_delay_factor"] = 0.001 + + -- This autocmd must be defined in init to take effect + vim.api.nvim_create_autocmd({ "VimEnter", "ColorScheme" }, { + group = vim.api.nvim_create_augroup("SemanticHighlight", {}), + callback = function() + -- Only add style, inherit or link to the LSP's colors + vim.cmd([[ + highlight! semshiGlobal gui=italic + highlight! link semshiImported @none + highlight! link semshiParameter @lsp.type.parameter + highlight! link semshiParameterUnused DiagnosticUnnecessary + highlight! link semshiBuiltin @function.builtin + highlight! link semshiAttribute @field + highlight! link semshiSelf @lsp.type.selfKeyword + highlight! link semshiUnresolved @lsp.type.unresolvedReference + highlight! link semshiFree @none + ]]) + end, + }) + end, +} diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua new file mode 100644 index 0000000000..cc9bc52ea7 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -0,0 +1,95 @@ +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "ninja", "python", "rst", "toml" }) + end + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + pyright = {}, + ruff_lsp = { + keys = { + { + "co", + function() + vim.lsp.buf.code_action({ + apply = true, + context = { + only = { "source.organizeImports" }, + diagnostics = {}, + }, + }) + end, + desc = "Organize Imports", + }, + }, + }, + }, + setup = { + ruff_lsp = function() + require("lazyvim.util").lsp.on_attach(function(client, _) + if client.name == "ruff_lsp" then + -- Disable hover in favor of Pyright + client.server_capabilities.hoverProvider = false + end + end) + end, + }, + }, + }, + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + "nvim-neotest/neotest-python", + }, + opts = { + adapters = { + ["neotest-python"] = { + -- Here you can specify the settings for the adapter, i.e. + -- runner = "pytest", + -- python = ".venv/bin/python", + }, + }, + }, + }, + { + "mfussenegger/nvim-dap", + optional = true, + dependencies = { + "mfussenegger/nvim-dap-python", + -- stylua: ignore + keys = { + { "dPt", function() require('dap-python').test_method() end, desc = "Debug Method", ft = "python" }, + { "dPc", function() require('dap-python').test_class() end, desc = "Debug Class", ft = "python" }, + }, + config = function() + local path = require("mason-registry").get_package("debugpy"):get_install_path() + require("dap-python").setup(path .. "/venv/bin/python") + end, + }, + }, + { + "linux-cultist/venv-selector.nvim", + cmd = "VenvSelect", + opts = function(_, opts) + if require("lazyvim.util").has("nvim-dap-python") then + opts.dap_enabled = true + end + return vim.tbl_deep_extend("force", opts, { + name = { + "venv", + ".venv", + "env", + ".env", + }, + }) + end, + keys = { { "cv", ":VenvSelect", desc = "Select VirtualEnv" } }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua new file mode 100644 index 0000000000..1e6e059469 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -0,0 +1,162 @@ +return { + + -- Extend auto completion + { + "hrsh7th/nvim-cmp", + dependencies = { + { + "Saecki/crates.nvim", + event = { "BufRead Cargo.toml" }, + opts = { + src = { + cmp = { enabled = true }, + }, + }, + }, + }, + ---@param opts cmp.ConfigSchema + opts = function(_, opts) + local cmp = require("cmp") + opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { + { name = "crates" }, + })) + end, + }, + + -- Add Rust & related to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "ron", "rust", "toml" }) + end + end, + }, + + -- Ensure Rust debugger is installed + { + "williamboman/mason.nvim", + optional = true, + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "codelldb" }) + end + end, + }, + + { + "simrat39/rust-tools.nvim", + lazy = true, + opts = function() + local ok, mason_registry = pcall(require, "mason-registry") + local adapter ---@type any + if ok then + -- rust tools configuration for debugging support + local codelldb = mason_registry.get_package("codelldb") + local extension_path = codelldb:get_install_path() .. "/extension/" + local codelldb_path = extension_path .. "adapter/codelldb" + local liblldb_path = "" + if vim.loop.os_uname().sysname:find("Windows") then + liblldb_path = extension_path .. "lldb\\bin\\liblldb.dll" + elseif vim.fn.has("mac") == 1 then + liblldb_path = extension_path .. "lldb/lib/liblldb.dylib" + else + liblldb_path = extension_path .. "lldb/lib/liblldb.so" + end + adapter = require("rust-tools.dap").get_codelldb_adapter(codelldb_path, liblldb_path) + end + return { + dap = { + adapter = adapter, + }, + tools = { + on_initialized = function() + vim.cmd([[ + augroup RustLSP + autocmd CursorHold *.rs silent! lua vim.lsp.buf.document_highlight() + autocmd CursorMoved,InsertEnter *.rs silent! lua vim.lsp.buf.clear_references() + autocmd BufEnter,CursorHold,InsertLeave *.rs silent! lua vim.lsp.codelens.refresh() + augroup END + ]]) + end, + }, + } + end, + config = function() end, + }, + + -- Correctly setup lspconfig for Rust 🚀 + { + "neovim/nvim-lspconfig", + opts = { + servers = { + -- Ensure mason installs the server + rust_analyzer = { + keys = { + { "K", "RustHoverActions", desc = "Hover Actions (Rust)" }, + { "cR", "RustCodeAction", desc = "Code Action (Rust)" }, + { "dr", "RustDebuggables", desc = "Run Debuggables (Rust)" }, + }, + settings = { + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + runBuildScripts = true, + }, + -- Add clippy lints for Rust. + checkOnSave = { + allFeatures = true, + command = "clippy", + extraArgs = { "--no-deps" }, + }, + procMacro = { + enable = true, + ignored = { + ["async-trait"] = { "async_trait" }, + ["napi-derive"] = { "napi" }, + ["async-recursion"] = { "async_recursion" }, + }, + }, + }, + }, + }, + taplo = { + keys = { + { + "K", + function() + if vim.fn.expand("%:t") == "Cargo.toml" and require("crates").popup_available() then + require("crates").show_popup() + else + vim.lsp.buf.hover() + end + end, + desc = "Show Crate Documentation", + }, + }, + }, + }, + setup = { + rust_analyzer = function(_, opts) + local rust_tools_opts = require("lazyvim.util").opts("rust-tools.nvim") + require("rust-tools").setup(vim.tbl_deep_extend("force", rust_tools_opts or {}, { server = opts })) + return true + end, + }, + }, + }, + + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + "rouge8/neotest-rust", + }, + opts = { + adapters = { + ["neotest-rust"] = {}, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/tailwind.lua b/lua/lazyvim/plugins/extras/lang/tailwind.lua index bed7e6c055..795449ee3f 100644 --- a/lua/lazyvim/plugins/extras/lang/tailwind.lua +++ b/lua/lazyvim/plugins/extras/lang/tailwind.lua @@ -4,16 +4,30 @@ return { opts = { servers = { tailwindcss = { + -- exclude a filetype from the default_config filetypes_exclude = { "markdown" }, + -- add additional filetypes to the default_config + filetypes_include = {}, + -- to fully override the default_config, change the below + -- filetypes = {} }, }, setup = { tailwindcss = function(_, opts) 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 opts.filetypes = vim.tbl_filter(function(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, }, }, diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua new file mode 100644 index 0000000000..ea7bd5ded6 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -0,0 +1,59 @@ +vim.api.nvim_create_autocmd("FileType", { + pattern = { "hcl", "terraform" }, + desc = "terraform/hcl commentstring configuration", + command = "setlocal commentstring=#\\ %s", +}) + +return { + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { + "terraform", + "hcl", + }) + end + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + terraformls = {}, + }, + }, + }, + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local null_ls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + null_ls.builtins.formatting.terraform_fmt, + null_ls.builtins.diagnostics.terraform_validate, + }) + 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" }, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/tex.lua b/lua/lazyvim/plugins/extras/lang/tex.lua new file mode 100644 index 0000000000..e8d4fefffe --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/tex.lua @@ -0,0 +1,58 @@ +return { + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["l"] = { name = "+vimtex" }, + }, + }, + }, + + -- Add BibTeX/LaTeX to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "bibtex", "latex" }) + end + if type(opts.highlight.disable) == "table" then + vim.list_extend(opts.highlight.disable, { "latex" }) + else + opts.highlight.disable = { "latex" } + end + end, + }, + + { + "lervag/vimtex", + lazy = false, -- lazy-loading will disable inverse search + config = function() + vim.api.nvim_create_autocmd({ "FileType" }, { + group = vim.api.nvim_create_augroup("lazyvim_vimtex_conceal", { clear = true }), + pattern = { "bib", "tex" }, + callback = function() + vim.wo.conceallevel = 2 + end, + }) + + vim.g.vimtex_mappings_disable = { ["n"] = { "K" } } -- disable `K` as it conflicts with LSP hover + vim.g.vimtex_quickfix_method = vim.fn.executable("pplatex") == 1 and "pplatex" or "latexlog" + end, + }, + + -- Correctly setup lspconfig for LaTeX 🚀 + { + "neovim/nvim-lspconfig", + optional = true, + opts = { + servers = { + texlab = { + keys = { + { "K", "(vimtex-doc-package)", desc = "Vimtex Docs", silent = true }, + }, + }, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 4aeaf5f93f..4f53ae8c80 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -13,12 +13,39 @@ return { -- correctly setup lspconfig { "neovim/nvim-lspconfig", - dependencies = { "jose-elias-alvarez/typescript.nvim" }, opts = { -- make sure mason installs the server servers = { ---@type lspconfig.options.tsserver tsserver = { + keys = { + { + "co", + function() + vim.lsp.buf.code_action({ + apply = true, + context = { + only = { "source.organizeImports.ts" }, + diagnostics = {}, + }, + }) + end, + desc = "Organize Imports", + }, + { + "cR", + function() + vim.lsp.buf.code_action({ + apply = true, + context = { + only = { "source.removeUnused.ts" }, + diagnostics = {}, + }, + }) + end, + desc = "Remove Unused Imports", + }, + }, settings = { typescript = { format = { @@ -40,28 +67,8 @@ return { }, }, }, - setup = { - tsserver = function(_, opts) - require("lazyvim.util").on_attach(function(client, buffer) - if client.name == "tsserver" then - -- stylua: ignore - vim.keymap.set("n", "co", "TypescriptOrganizeImports", { buffer = buffer, desc = "Organize Imports" }) - -- stylua: ignore - vim.keymap.set("n", "cR", "TypescriptRenameFile", { desc = "Rename File", buffer = buffer }) - end - end) - 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", optional = true, @@ -92,7 +99,7 @@ return { }, } end - for _, language in ipairs({ "typescript", "javascript" }) do + for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do if not dap.configurations[language] then dap.configurations[language] = { { diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua new file mode 100644 index 0000000000..5afe1b8300 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/yaml.lua @@ -0,0 +1,77 @@ +return { + + -- add yaml specific modules to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "yaml" }) + end + end, + }, + + -- yaml schema support + { + "b0o/SchemaStore.nvim", + lazy = true, + version = false, -- last release is way too old + }, + + -- correctly setup lspconfig + { + "neovim/nvim-lspconfig", + opts = { + -- make sure mason installs the server + servers = { + yamlls = { + -- Have to add this for yamlls to understand that we support line folding + capabilities = { + textDocument = { + foldingRange = { + dynamicRegistration = false, + lineFoldingOnly = true, + }, + }, + }, + -- lazy-load schemastore when needed + on_new_config = function(new_config) + new_config.settings.yaml.schemas = vim.tbl_deep_extend( + "force", + new_config.settings.yaml.schemas or {}, + require("schemastore").yaml.schemas() + ) + end, + settings = { + redhat = { telemetry = { enabled = false } }, + yaml = { + keyOrdering = false, + format = { + enable = true, + }, + validate = true, + schemaStore = { + -- Must disable built-in schemaStore support to use + -- schemas from SchemaStore.nvim plugin + enable = false, + -- Avoid TypeError: Cannot read properties of undefined (reading 'length') + url = "", + }, + }, + }, + }, + }, + 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, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/linting/eslint.lua b/lua/lazyvim/plugins/extras/linting/eslint.lua index 32498cb59b..9537303d59 100644 --- a/lua/lazyvim/plugins/extras/linting/eslint.lua +++ b/lua/lazyvim/plugins/extras/linting/eslint.lua @@ -14,22 +14,37 @@ return { }, setup = { eslint = function() - vim.api.nvim_create_autocmd("BufWritePre", { - callback = function(event) - if not require("lazyvim.plugins.lsp.format").enabled() then - -- exit early if autoformat is not enabled - return - end + local function get_client(buf) + return require("lazyvim.util").lsp.get_clients({ name = "eslint", bufnr = buf })[1] + end + + local formatter = require("lazyvim.util").lsp.formatter({ + name = "eslint: lsp", + primary = false, + priority = 200, + filter = "eslint", + }) - local client = vim.lsp.get_active_clients({ bufnr = event.buf, name = "eslint" })[1] + -- 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 - 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 vim.cmd("EslintFixAll") end end - end, - }) + end + end + + -- register the formatter with LazyVim + require("lazyvim.util").format.register(formatter) end, }, }, diff --git a/lua/lazyvim/plugins/extras/lsp/none-ls.lua b/lua/lazyvim/plugins/extras/lsp/none-ls.lua new file mode 100644 index 0000000000..aa907b8e28 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lsp/none-ls.lua @@ -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, + }, +} diff --git a/lua/lazyvim/plugins/extras/test/core.lua b/lua/lazyvim/plugins/extras/test/core.lua index d22e52059f..321955abd1 100644 --- a/lua/lazyvim/plugins/extras/test/core.lua +++ b/lua/lazyvim/plugins/extras/test/core.lua @@ -27,7 +27,7 @@ return { quickfix = { open = function() if require("lazyvim.util").has("trouble.nvim") then - vim.cmd("Trouble quickfix") + require("trouble").open({ mode = "quickfix", focus = false }) else vim.cmd("copen") end @@ -46,6 +46,37 @@ return { }, }, 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 local adapters = {} for name, config in pairs(opts.adapters or {}) do diff --git a/lua/lazyvim/plugins/extras/ui/alpha.lua b/lua/lazyvim/plugins/extras/ui/alpha.lua new file mode 100644 index 0000000000..8feee18802 --- /dev/null +++ b/lua/lazyvim/plugins/extras/ui/alpha.lua @@ -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", " Telescope find_files "), + dashboard.button("n", " " .. " New file", " ene startinsert "), + dashboard.button("r", " " .. " Recent files", " Telescope oldfiles "), + dashboard.button("g", " " .. " Find text", " Telescope live_grep "), + dashboard.button("c", " " .. " Config", " lua require('lazyvim.util').telescope.config_files()() "), + dashboard.button("s", " " .. " Restore Session", [[ lua require("persistence").load() ]]), + dashboard.button("x", " " .. " Lazy Extras", " LazyExtras "), + dashboard.button("l", "󰒲 " .. " Lazy", " Lazy "), + dashboard.button("q", " " .. " Quit", " qa "), + } + 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, + }, +} diff --git a/lua/lazyvim/plugins/extras/ui/edgy.lua b/lua/lazyvim/plugins/extras/ui/edgy.lua index 262d5500b2..e25138284b 100644 --- a/lua/lazyvim/plugins/extras/ui/edgy.lua +++ b/lua/lazyvim/plugins/extras/ui/edgy.lua @@ -40,6 +40,12 @@ return { end, }, "Trouble", + { + ft = "trouble", + filter = function(buf, win) + return vim.api.nvim_win_get_config(win).relative == "" + end, + }, { ft = "qf", title = "QuickFix" }, { ft = "help", @@ -49,7 +55,7 @@ return { return vim.bo[buf].buftype == "help" 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 } }, }, left = { @@ -105,26 +111,31 @@ return { 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 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 { "nvim-neo-tree/neo-tree.nvim", optional = true, opts = function(_, opts) 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") end, }, diff --git a/lua/lazyvim/plugins/extras/ui/mini-starter.lua b/lua/lazyvim/plugins/extras/ui/mini-starter.lua index ee35fc687c..5f5ec9c541 100644 --- a/lua/lazyvim/plugins/extras/ui/mini-starter.lua +++ b/lua/lazyvim/plugins/extras/ui/mini-starter.lua @@ -2,6 +2,7 @@ return { -- disable alpha { "goolord/alpha-nvim", enabled = false }, + { "nvimdev/dashboard-nvim", enabled = false }, -- enable mini.starter { @@ -28,14 +29,15 @@ return { evaluate_single = true, header = logo, items = { - new_section("Find file", "Telescope find_files", "Telescope"), - new_section("Recent files", "Telescope oldfiles", "Telescope"), - new_section("Grep text", "Telescope live_grep", "Telescope"), - new_section("init.lua", "e $MYVIMRC", "Config"), - new_section("Lazy", "Lazy", "Config"), - new_section("New file", "ene | startinsert", "Built-in"), - new_section("Quit", "qa", "Built-in"), - new_section("Session restore", [[lua require("persistence").load()]], "Session"), + new_section("Find file", "Telescope find_files", "Telescope"), + new_section("Recent files", "Telescope oldfiles", "Telescope"), + new_section("Grep text", "Telescope live_grep", "Telescope"), + new_section("Config", "lua require('lazyvim.util').telescope.config_files()()", "Config"), + new_section("Extras", "LazyExtras", "Config"), + new_section("Lazy", "Lazy", "Config"), + new_section("New file", "ene | startinsert", "Built-in"), + new_section("Quit", "qa", "Built-in"), + new_section("Session restore", [[lua require("persistence").load()]], "Session"), }, content_hooks = { starter.gen_hook.adding_bullet(pad .. "░ ", false), diff --git a/lua/lazyvim/plugins/extras/util/dot.lua b/lua/lazyvim/plugins/extras/util/dot.lua new file mode 100644 index 0000000000..c25e0f6c30 --- /dev/null +++ b/lua/lazyvim/plugins/extras/util/dot.lua @@ -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, + }, +} diff --git a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua index 18f1e1aa6e..2add9c2f2c 100644 --- a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua +++ b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua @@ -5,7 +5,7 @@ M.hl = {} M.plugin = { "echasnovski/mini.hipatterns", - event = "BufReadPre", + event = "LazyFile", opts = function() local hi = require("mini.hipatterns") return { @@ -54,7 +54,7 @@ M.plugin = { local match = m.full_match ---@type string, number local color, shade = match:match("[%w-]+%-([a-z%-]+)%-(%d+)") - shade = assert(tonumber(shade)) + shade = tonumber(shade) local bg = vim.tbl_get(M.colors, color, shade) if bg then local hl = "MiniHipatternsTailwind" .. color .. shade @@ -67,7 +67,7 @@ M.plugin = { return hl end end, - priority = 2000, + extmark_opts = { priority = 2000 }, } end require("mini.hipatterns").setup(opts) diff --git a/lua/lazyvim/plugins/extras/util/project.lua b/lua/lazyvim/plugins/extras/util/project.lua index 82234c4d7a..3936c96a2f 100644 --- a/lua/lazyvim/plugins/extras/util/project.lua +++ b/lua/lazyvim/plugins/extras/util/project.lua @@ -5,11 +5,15 @@ return { -- project management { "ahmedkhalf/project.nvim", - opts = {}, + opts = { + manual_mode = true, + }, event = "VeryLazy", config = function(_, 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, keys = { { "fp", "Telescope projects", desc = "Projects" }, @@ -42,4 +46,21 @@ return { vim.list_extend(opts.items, items) 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, + }, } diff --git a/lua/lazyvim/plugins/extras/vscode.lua b/lua/lazyvim/plugins/extras/vscode.lua index c8adc0368b..6f78fd9f8e 100644 --- a/lua/lazyvim/plugins/extras/vscode.lua +++ b/lua/lazyvim/plugins/extras/vscode.lua @@ -18,26 +18,10 @@ local enabled = { } local Config = require("lazy.core.config") -local Plugin = require("lazy.core.plugin") Config.options.checker.enabled = false Config.options.change_detection.enabled = false - --- HACK: disable all plugins except the ones we want -local fix_disabled = Plugin.Spec.fix_disabled -function Plugin.Spec.fix_disabled(self) - for _, plugin in pairs(self.plugins) do - if not (vim.tbl_contains(enabled, plugin.name) or plugin.vscode) then - plugin.enabled = false - end - end - fix_disabled(self) -end - --- HACK: don't clean plugins in vscode -local update_state = Plugin.update_state -function Plugin.update_state() - update_state() - Config.to_clean = {} +Config.options.defaults.cond = function(plugin) + return vim.tbl_contains(enabled, plugin.name) or plugin.vscode end -- Add some vscode specific keymaps diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua new file mode 100644 index 0000000000..eb2dd1a83f --- /dev/null +++ b/lua/lazyvim/plugins/formatting.lua @@ -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 = { + { + "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 + 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 + 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, + }, +} diff --git a/lua/lazyvim/plugins/init.lua b/lua/lazyvim/plugins/init.lua new file mode 100644 index 0000000000..8c7b5fa139 --- /dev/null +++ b/lua/lazyvim/plugins/init.lua @@ -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 = "*" }, +} diff --git a/lua/lazyvim/plugins/linting.lua b/lua/lazyvim/plugins/linting.lua new file mode 100644 index 0000000000..2d2527c1a4 --- /dev/null +++ b/lua/lazyvim/plugins/linting.lua @@ -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 + 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, + }, +} diff --git a/lua/lazyvim/plugins/lsp/format.lua b/lua/lazyvim/plugins/lsp/format.lua deleted file mode 100644 index 64c4becfa1..0000000000 --- a/lua/lazyvim/plugins/lsp/format.lua +++ /dev/null @@ -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 diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index 260abcaecc..3b60d14b63 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -1,19 +1,15 @@ +local Util = require("lazyvim.util") + return { -- lspconfig { "neovim/nvim-lspconfig", - event = { "BufReadPre", "BufNewFile" }, + event = "LazyFile", dependencies = { - { "folke/neoconf.nvim", cmd = "Neoconf", config = true }, + { "folke/neoconf.nvim", cmd = "Neoconf", config = false, dependencies = { "nvim-lspconfig" } }, { "folke/neodev.nvim", opts = {} }, "mason.nvim", "williamboman/mason-lspconfig.nvim", - { - "hrsh7th/cmp-nvim-lsp", - cond = function() - return require("lazyvim.util").has("nvim-cmp") - end, - }, }, ---@class PluginLspOpts opts = { @@ -39,11 +35,6 @@ return { }, -- add any global capabilities here 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 -- `bufnr` and `filter` is handled by the LazyVim formatter, -- but can be also overridden when specified @@ -54,9 +45,12 @@ return { -- LSP Server Settings ---@type lspconfig.options servers = { - jsonls = {}, lua_ls = { -- mason = false, -- set to false if you don't want this server to be installed with mason + -- Use this to add any additional keymaps + -- for specific lsp servers + ---@type LazyKeysSpec[] + -- keys = {}, settings = { Lua = { workspace = { @@ -84,24 +78,47 @@ return { }, ---@param opts PluginLspOpts config = function(_, opts) - local Util = require("lazyvim.util") + if Util.has("neoconf.nvim") then + local plugin = require("lazy.core.config").spec.plugins["neoconf.nvim"] + require("neoconf").setup(require("lazy.core.plugin").values(plugin, "opts", false)) + end + -- setup autoformat - require("lazyvim.plugins.lsp.format").setup(opts) - -- setup formatting and keymaps - Util.on_attach(function(client, buffer) + Util.format.register(Util.lsp.formatter()) + + -- 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) end) + local register_capability = vim.lsp.handlers["client/registerCapability"] + + vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx) + local ret = register_capability(err, res, ctx) + local client_id = ctx.client_id + ---@type lsp.Client + local client = vim.lsp.get_client_by_id(client_id) + local buffer = vim.api.nvim_get_current_buf() + require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) + return ret + end + -- diagnostics for name, icon in pairs(require("lazyvim.config").icons.diagnostics) do name = "DiagnosticSign" .. name vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) end - if opts.inlay_hints.enabled and vim.lsp.buf.inlay_hint then - Util.on_attach(function(client, buffer) - if client.server_capabilities.inlayHintProvider then - vim.lsp.buf.inlay_hint(buffer, true) + if opts.inlay_hints.enabled then + Util.lsp.on_attach(function(client, buffer) + if client.supports_method("textDocument/inlayHint") then + Util.toggle.inlay_hints(buffer, true) end end) end @@ -121,11 +138,12 @@ return { vim.diagnostic.config(vim.deepcopy(opts.diagnostics)) local servers = opts.servers + local has_cmp, cmp_nvim_lsp = pcall(require, "cmp_nvim_lsp") local capabilities = vim.tbl_deep_extend( "force", {}, vim.lsp.protocol.make_client_capabilities(), - require("cmp_nvim_lsp").default_capabilities(), + has_cmp and cmp_nvim_lsp.default_capabilities() or {}, opts.capabilities or {} ) @@ -146,7 +164,7 @@ return { require("lspconfig")[server].setup(server_opts) end - -- get all the servers that are available thourgh mason-lspconfig + -- get all the servers that are available through mason-lspconfig local have_mason, mlsp = pcall(require, "mason-lspconfig") local all_mslp_servers = {} if have_mason then @@ -170,42 +188,23 @@ return { mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } }) 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") - Util.lsp_disable("tsserver", is_deno) - Util.lsp_disable("denols", function(root_dir) + Util.lsp.disable("tsserver", is_deno) + Util.lsp.disable("denols", function(root_dir) return not is_deno(root_dir) 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 { "williamboman/mason.nvim", cmd = "Mason", keys = { { "cm", "Mason", desc = "Mason" } }, + build = ":MasonUpdate", opts = { ensure_installed = { "stylua", @@ -217,6 +216,15 @@ return { config = function(_, opts) require("mason").setup(opts) 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() for _, tool in ipairs(opts.ensure_installed) do local p = mr.get_package(tool) diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index de97d08d70..10e5d86f85 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -1,35 +1,27 @@ local M = {} ----@type PluginLspKeys +---@type LazyKeysLspSpec[]|nil M._keys = nil ----@return (LazyKeys|{has?:string})[] +---@alias LazyKeysLspSpec LazyKeysSpec|{has?:string} +---@alias LazyKeysLsp LazyKeys|{has?:string} + +---@return LazyKeysLspSpec[] function M.get() - local format = function() - require("lazyvim.plugins.lsp.format").format({ force = true }) + if M._keys then + return M._keys end - if not M._keys then - ---@class PluginLspKeys -- stylua: ignore M._keys = { - { "cd", vim.diagnostic.open_float, desc = "Line Diagnostics" }, { "cl", "LspInfo", desc = "Lsp Info" }, - { "gd", "Telescope lsp_definitions", desc = "Goto Definition", has = "definition" }, + { "gd", function() require("telescope.builtin").lsp_definitions({ reuse_win = true }) end, desc = "Goto Definition", has = "definition" }, { "gr", "Telescope lsp_references", desc = "References" }, { "gD", vim.lsp.buf.declaration, desc = "Goto Declaration" }, - { "gI", "Telescope lsp_implementations", desc = "Goto Implementation" }, - { "gy", "Telescope lsp_type_definitions", desc = "Goto T[y]pe Definition" }, + { "gI", function() require("telescope.builtin").lsp_implementations({ reuse_win = true }) end, desc = "Goto Implementation" }, + { "gy", function() require("telescope.builtin").lsp_type_definitions({ reuse_win = true }) end, desc = "Goto T[y]pe Definition" }, { "K", vim.lsp.buf.hover, desc = "Hover" }, { "gK", vim.lsp.buf.signature_help, desc = "Signature Help", has = "signatureHelp" }, { "", 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" }, - { "cf", format, desc = "Format Document", has = "documentFormatting" }, - { "cf", format, desc = "Format Range", mode = "v", has = "documentRangeFormatting" }, { "ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" }, { "cA", @@ -47,55 +39,64 @@ function M.get() has = "codeAction", } } - if require("lazyvim.util").has("inc-rename.nvim") then - M._keys[#M._keys + 1] = { - "cr", - function() - local inc_rename = require("inc_rename") - return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("") - end, - expr = true, - desc = "Rename", - has = "rename", - } - else - M._keys[#M._keys + 1] = { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" } - end + if require("lazyvim.util").has("inc-rename.nvim") then + M._keys[#M._keys + 1] = { + "cr", + function() + local inc_rename = require("inc_rename") + return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("") + end, + expr = true, + desc = "Rename", + has = "rename", + } + else + M._keys[#M._keys + 1] = { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" } end return M._keys end -function M.on_attach(client, buffer) - local Keys = require("lazy.core.handler.keys") - local keymaps = {} ---@type table - - for _, value in ipairs(M.get()) do - local keys = Keys.parse(value) - if keys[2] == vim.NIL or keys[2] == false then - keymaps[keys.id] = nil - else - keymaps[keys.id] = keys +---@param method string +function M.has(buffer, method) + method = method:find("/") and method or "textDocument/" .. method + local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer }) + for _, client in ipairs(clients) do + if client.supports_method(method) then + return true end end + return false +end + +---@return (LazyKeys|{has?:string})[] +function M.resolve(buffer) + local Keys = require("lazy.core.handler.keys") + if not Keys.resolve then + return {} + end + local spec = M.get() + local opts = require("lazyvim.util").opts("nvim-lspconfig") + local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer }) + for _, client in ipairs(clients) do + local maps = opts.servers[client.name] and opts.servers[client.name].keys or {} + vim.list_extend(spec, maps) + end + return Keys.resolve(spec) +end + +function M.on_attach(_, buffer) + local Keys = require("lazy.core.handler.keys") + local keymaps = M.resolve(buffer) for _, keys in pairs(keymaps) do - if not keys.has or client.server_capabilities[keys.has .. "Provider"] then + if not keys.has or M.has(buffer, keys.has) then local opts = Keys.opts(keys) - ---@diagnostic disable-next-line: no-unknown opts.has = nil opts.silent = opts.silent ~= false 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 -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 diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index c37de8dddb..e66725c061 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -1,37 +1,67 @@ -local load_textobjects = false return { + -- Treesitter is a new parser generator tool that we can + -- use in Neovim to power faster and more accurate + -- syntax highlighting. { "nvim-treesitter/nvim-treesitter", version = false, -- last release is way too old and doesn't work on Windows 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 = { { "nvim-treesitter/nvim-treesitter-textobjects", - init = function() - -- disable rtp plugin, as we only need its queries for mini.ai - -- In case other textobject modules are enabled, we will load them - -- once nvim-treesitter is loaded - require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects") - load_textobjects = true + config = function() + -- When in diff mode, we want to use the default + -- vim text objects c & C instead of the treesitter ones. + local move = require("nvim-treesitter.textobjects.move") ---@type table + local configs = require("nvim-treesitter.configs") + 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 + 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, }, }, - cmd = { "TSUpdateSync" }, + cmd = { "TSUpdateSync", "TSUpdate", "TSInstall" }, keys = { { "", desc = "Increment selection" }, { "", desc = "Decrement selection", mode = "x" }, }, ---@type TSConfig + ---@diagnostic disable-next-line: missing-fields opts = { highlight = { enable = true }, indent = { enable = true }, ensure_installed = { "bash", "c", + "diff", "html", "javascript", + "jsdoc", "json", + "jsonc", "lua", "luadoc", "luap", @@ -40,6 +70,7 @@ return { "python", "query", "regex", + "toml", "tsx", "typescript", "vim", @@ -55,6 +86,15 @@ return { node_decremental = "", }, }, + 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 config = function(_, opts) @@ -70,21 +110,37 @@ return { end, opts.ensure_installed) end require("nvim-treesitter.configs").setup(opts) + end, + }, - 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 + -- Show context of the current function + { + "nvim-treesitter/nvim-treesitter-context", + event = "LazyFile", + enabled = true, + opts = { mode = "cursor", max_lines = 3 }, + keys = { + { + "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 - end - end, + end, + desc = "Toggle Treesitter Context", + }, + }, + }, + + -- Automatically add closing tags for HTML and JSX + { + "windwp/nvim-ts-autotag", + event = "LazyFile", + opts = {}, }, } diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index b978b02892..50efb153f1 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -1,3 +1,5 @@ +local Util = require("lazyvim.util") + return { -- Better `vim.notify()` { @@ -19,10 +21,12 @@ return { max_width = function() return math.floor(vim.o.columns * 0.75) end, + on_open = function(win) + vim.api.nvim_win_set_config(win, { zindex = 100 }) + end, }, init = function() -- when noice is not enabled, install notify on VeryLazy - local Util = require("lazyvim.util") if not Util.has("noice.nvim") then Util.on_very_lazy(function() vim.notify = require("notify") @@ -49,13 +53,21 @@ return { end, }, - -- bufferline + -- This is what powers LazyVim's fancy-looking + -- tabs, which include filetype icons and close buttons. { "akinsho/bufferline.nvim", event = "VeryLazy", keys = { { "bp", "BufferLineTogglePin", desc = "Toggle pin" }, { "bP", "BufferLineGroupClose ungrouped", desc = "Delete non-pinned buffers" }, + { "bo", "BufferLineCloseOthers", desc = "Delete other buffers" }, + { "br", "BufferLineCloseRight", desc = "Delete buffers to the right" }, + { "bl", "BufferLineCloseLeft", desc = "Delete buffers to the left" }, + { "", "BufferLineCyclePrev", desc = "Prev buffer" }, + { "", "BufferLineCycleNext", desc = "Next buffer" }, + { "[b", "BufferLineCyclePrev", desc = "Prev buffer" }, + { "]b", "BufferLineCycleNext", desc = "Next buffer" }, }, opts = { options = { @@ -81,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 { "nvim-lualine/lualine.nvim", 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() + -- 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 Util = require("lazyvim.util") + + vim.o.laststatus = vim.g.lualine_laststatus return { options = { theme = "auto", globalstatus = true, - disabled_filetypes = { statusline = { "dashboard", "alpha" } }, + disabled_filetypes = { statusline = { "dashboard", "alpha", "starter" } }, }, sections = { lualine_a = { "mode" }, lualine_b = { "branch" }, + lualine_c = { + Util.lualine.root_dir(), { "diagnostics", symbols = { @@ -111,33 +151,32 @@ return { }, }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, - { "filename", path = 1, symbols = { modified = "  ", readonly = "", unnamed = "" } }, - -- stylua: ignore - { - function() return require("nvim-navic").get_location() end, - cond = function() return package.loaded["nvim-navic"] and require("nvim-navic").is_available() end, - }, + { Util.lualine.pretty_path() }, }, lualine_x = { -- stylua: ignore { function() return require("noice").api.status.command.get() 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 { function() return require("noice").api.status.mode.get() 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 { function() return " " .. 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", symbols = { @@ -145,6 +184,16 @@ return { modified = icons.git.modified, 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 = { @@ -165,32 +214,39 @@ return { -- indent guides for Neovim { "lukas-reineke/indent-blankline.nvim", - event = { "BufReadPost", "BufNewFile" }, + event = "LazyFile", opts = { - -- char = "▏", - char = "│", - filetype_exclude = { - "help", - "alpha", - "dashboard", - "neo-tree", - "Trouble", - "lazy", - "mason", - "notify", - "toggleterm", - "lazyterm", + indent = { + char = "│", + tab_char = "│", + }, + scope = { enabled = false }, + exclude = { + filetypes = { + "help", + "alpha", + "dashboard", + "neo-tree", + "Trouble", + "trouble", + "lazy", + "mason", + "notify", + "toggleterm", + "lazyterm", + }, }, - show_trailing_blankline_indent = false, - show_current_context = false, }, + main = "ibl", }, - -- active indent guide and indent text objects + -- Active indent guide and indent text objects. When you're browsing + -- code, this highlights the current level of indentation, and animates + -- the highlighting. { "echasnovski/mini.indentscope", version = false, -- wait till new 0.7.0 release to put it back on semver - event = { "BufReadPre", "BufNewFile" }, + event = "LazyFile", opts = { -- symbol = "▏", symbol = "│", @@ -204,6 +260,7 @@ return { "dashboard", "neo-tree", "Trouble", + "trouble", "lazy", "mason", "notify", @@ -217,7 +274,7 @@ return { end, }, - -- noicer ui + -- Displays a popup with possible key bindings of the command you started typing { "folke/which-key.nvim", opts = function(_, opts) @@ -226,6 +283,8 @@ return { end end, }, + + -- Highly experimental plugin that completely replaces the UI for messages, cmdline and the popupmenu. { "folke/noice.nvim", event = "VeryLazy", @@ -269,93 +328,86 @@ return { }, }, - -- dashboard + -- icons + { "nvim-tree/nvim-web-devicons", lazy = true }, + + -- ui components + { "MunifTanjim/nui.nvim", lazy = true }, + { "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", opts = function() - local dashboard = require("alpha.themes.dashboard") local logo = [[ ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z - ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ - ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ + ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ + ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ]] - dashboard.section.header.val = vim.split(logo, "\n") - dashboard.section.buttons.val = { - dashboard.button("f", " " .. " Find file", ":Telescope find_files "), - dashboard.button("n", " " .. " New file", ":ene startinsert "), - dashboard.button("r", " " .. " Recent files", ":Telescope oldfiles "), - dashboard.button("g", " " .. " Find text", ":Telescope live_grep "), - dashboard.button("c", " " .. " Config", ":e $MYVIMRC "), - dashboard.button("s", " " .. " Restore Session", [[:lua require("persistence").load() ]]), - dashboard.button("l", "󰒲 " .. " Lazy", ":Lazy"), - dashboard.button("q", " " .. " Quit", ":qa"), + logo = string.rep("\n", 8) .. logo .. "\n\n" + + local opts = { + theme = "doom", + hide = { + -- this is taken care of by lualine + -- enabling this messes up the actual laststatus setting after loading a file + statusline = false, + }, + 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" - button.opts.hl_shortcut = "AlphaShortcut" + + for _, button in ipairs(opts.config.center) do + button.desc = button.desc .. string.rep(" ", 43 - #button.desc) + button.key_format = " %s" 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", { - pattern = "AlphaReady", + pattern = "DashboardLoaded", callback = function() require("lazy").show() end, }) end - require("alpha").setup(dashboard.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, - }, - - -- lsp symbol navigation for lualine - { - "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, - } + return opts end, }, - - -- icons - { "nvim-tree/nvim-web-devicons", lazy = true }, - - -- ui components - { "MunifTanjim/nui.nvim", lazy = true }, } diff --git a/lua/lazyvim/plugins/util.lua b/lua/lazyvim/plugins/util.lua index e2de18d83a..c387088902 100644 --- a/lua/lazyvim/plugins/util.lua +++ b/lua/lazyvim/plugins/util.lua @@ -9,11 +9,13 @@ return { end, }, - -- session management + -- Session management. This saves your session in the background, + -- keeping track of open buffers, window arrangement, and more. + -- You can restore sessions when returning through the dashboard. { "folke/persistence.nvim", event = "BufReadPre", - opts = { options = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp" } }, + opts = { options = vim.opt.sessionoptions:get() }, -- stylua: ignore keys = { { "qs", function() require("persistence").load() end, desc = "Restore Session" }, @@ -24,7 +26,4 @@ return { -- library used by other plugins { "nvim-lua/plenary.nvim", lazy = true }, - - -- makes some plugins dot-repeatable like leap - { "tpope/vim-repeat", event = "VeryLazy" }, } diff --git a/lua/lazyvim/plugins/xtras.lua b/lua/lazyvim/plugins/xtras.lua new file mode 100644 index 0000000000..4eb73804b0 --- /dev/null +++ b/lua/lazyvim/plugins/xtras.lua @@ -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) diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua new file mode 100644 index 0000000000..4e2f0bc155 --- /dev/null +++ b/lua/lazyvim/util/extras.lua @@ -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("", "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 diff --git a/lua/lazyvim/util/format.lua b/lua/lazyvim/util/format.lua new file mode 100644 index 0000000000..fa9722966c --- /dev/null +++ b/lua/lazyvim/util/format.lua @@ -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 diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 5db01fef1b..24fd0a1b9f 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -1,30 +1,61 @@ -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 = {} -M.root_patterns = { ".git", "lua" } - ----@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 - local client = vim.lsp.get_client_by_id(args.data.client_id) - on_attach(client, buffer) - end, - }) +---@type table +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", +} + +setmetatable(M, { + __index = function(t, k) + if LazyUtil[k] then + return LazyUtil[k] + end + local dep = deprecated[k] + if dep then + 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 ---@param plugin string function M.has(plugin) - return require("lazy.core.config").plugins[plugin] ~= nil -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) } + return require("lazy.core.config").spec.plugins[plugin] ~= nil end ---@param fn fun() @@ -47,159 +78,13 @@ function M.opts(name) return Plugin.values(plugin, "opts", false) 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", "", 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 -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", "", "", { buffer = buf, nowait = true }) - end - if opts.ctrl_hjkl == false then - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) - vim.keymap.set("t", "", "", { 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 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) - 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 -- delay notifications till vim.notify was replaced or after 500ms @@ -213,7 +98,7 @@ function M.lazy_notify() vim.notify = temp local timer = vim.loop.new_timer() - local check = vim.loop.new_check() + local check = assert(vim.loop.new_check()) local replay = function() timer:stop() @@ -239,21 +124,48 @@ function M.lazy_notify() timer:start(500, 0, replay) end -function M.lsp_get_config(server) - local configs = require("lspconfig.configs") - return rawget(configs, server) +---@param name string +---@param fn fun(name:string) +function M.on_load(name, fn) + local Config = require("lazy.core.config") + if Config.plugins[name] and Config.plugins[name]._.loaded then + fn(name) + else + vim.api.nvim_create_autocmd("User", { + pattern = "LazyLoad", + callback = function(event) + if event.data == name then + fn(name) + return true + end + end, + }) + end 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 +-- Wrapper around vim.keymap.set that will +-- not create a keymap if a lazy key handler exists. +-- It will also set `silent` to true by default. +function M.safe_keymap_set(mode, lhs, rhs, opts) + local keys = require("lazy.core.handler").handlers.keys + ---@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 - end) + vim.keymap.set(modes, lhs, rhs, opts) + end end return M diff --git a/lua/lazyvim/util/inject.lua b/lua/lazyvim/util/inject.lua new file mode 100644 index 0000000000..81e0f57a66 --- /dev/null +++ b/lua/lazyvim/util/inject.lua @@ -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 diff --git a/lua/lazyvim/util/json.lua b/lua/lazyvim/util/json.lua new file mode 100644 index 0000000000..d98d038262 --- /dev/null +++ b/lua/lazyvim/util/json.lua @@ -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 diff --git a/lua/lazyvim/util/lsp.lua b/lua/lazyvim/util/lsp.lua new file mode 100644 index 0000000000..b34a2afeb9 --- /dev/null +++ b/lua/lazyvim/util/lsp.lua @@ -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 diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua new file mode 100644 index 0000000000..3e3cdb9a58 --- /dev/null +++ b/lua/lazyvim/util/lualine.lua @@ -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 + 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 diff --git a/lua/lazyvim/util/news.lua b/lua/lazyvim/util/news.lua new file mode 100644 index 0000000000..4c212470cc --- /dev/null +++ b/lua/lazyvim/util/news.lua @@ -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 diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua new file mode 100644 index 0000000000..7ab691349a --- /dev/null +++ b/lua/lazyvim/util/plugin.lua @@ -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 +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 +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 + 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 diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua new file mode 100644 index 0000000000..2958197570 --- /dev/null +++ b/lua/lazyvim/util/root.lua @@ -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 +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 diff --git a/lua/lazyvim/util/telescope.lua b/lua/lazyvim/util/telescope.lua new file mode 100644 index 0000000000..1d816b80b9 --- /dev/null +++ b/lua/lazyvim/util/telescope.lua @@ -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", "", 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 diff --git a/lua/lazyvim/util/terminal.lua b/lua/lazyvim/util/terminal.lua new file mode 100644 index 0000000000..7787615b92 --- /dev/null +++ b/lua/lazyvim/util/terminal.lua @@ -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 +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", "", "", { buffer = buf, nowait = true }) + end + if opts.ctrl_hjkl == false then + vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) + vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) + vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) + vim.keymap.set("t", "", "", { 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 diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua new file mode 100644 index 0000000000..db41c82515 --- /dev/null +++ b/lua/lazyvim/util/toggle.lua @@ -0,0 +1,76 @@ +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 + +---@param buf? number +---@param value? boolean +function M.inlay_hints(buf, value) + local ih = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint + if type(ih) == "function" then + ih(buf, value) + elseif type(ih) == "table" and ih.enable then + if value == nil then + value = not ih.is_enabled(buf) + end + ih.enable(buf, value) + end +end + +setmetatable(M, { + __call = function(m, ...) + return m.option(...) + end, +}) + +return M diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua new file mode 100644 index 0000000000..ce8b4780d3 --- /dev/null +++ b/lua/lazyvim/util/ui.lua @@ -0,0 +1,189 @@ +---@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 = {} + + if vim.fn.has("nvim-0.10") == 0 then + -- Only needed for Neovim <0.10 + -- Newer versions include legacy signs in nvim_buf_get_extmarks + for _, sign in ipairs(vim.fn.sign_getplaced(buf, { group = "*", lnum = lnum })[1].signs) do + local ret = vim.fn.sign_getdefined(sign.name)[1] --[[@as Sign]] + if ret then + ret.priority = sign.priority + signs[#signs + 1] = ret + end + end + end + + -- Get extmark signs + local extmarks = vim.api.nvim_buf_get_extmarks( + buf, + -1, + { lnum - 1, 0 }, + { lnum - 1, -1 }, + { details = true, type = "sign" } + ) + for _, extmark in pairs(extmarks) do + signs[#signs + 1] = { + name = extmark[4].sign_hl_group or "", + 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 +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 diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm new file mode 100644 index 0000000000..829b2b0875 --- /dev/null +++ b/queries/lua/highlights.scm @@ -0,0 +1,4 @@ +;; extends + +((identifier) @namespace.builtin + (#eq? @namespace.builtin "vim")) diff --git a/stylua.toml b/stylua.toml index 5d6c50dce9..9732fe647a 100644 --- a/stylua.toml +++ b/stylua.toml @@ -1,3 +1,6 @@ indent_type = "Spaces" indent_width = 2 -column_width = 120 \ No newline at end of file +column_width = 120 +[sort_requires] +enabled = true +