diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 00000000..9e3f87b8 --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,19 @@ +core: + - all: + - changed-files: + - any-glob-to-any-file: "lua/lazyvim/**" + - all-globs-to-all-files: "!lua/lazyvim/plugins/**" + +core-plugins: + - all: + - changed-files: + - any-glob-to-any-file: "lua/lazyvim/plugins/**" + - all-globs-to-all-files: "!lua/lazyvim/plugins/extras/**" + +extras: + - changed-files: + - any-glob-to-any-file: "lua/lazyvim/plugins/extras/**" + +extras-lang: + - changed-files: + - any-glob-to-any-file: "lua/lazyvim/plugins/extras/lang/**" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 51c47553..a1c6670f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,6 +4,22 @@ on: pull_request: jobs: + commit_msg: + name: Conventional Commit Messages + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: webiny/action-conventional-commits@v1.3.0 + stylua: + name: Stylua Formatting + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: JohnnyMorganz/stylua-action@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} + version: latest + args: --check . tests: strategy: matrix: @@ -11,7 +27,7 @@ jobs: os: [ubuntu-latest] runs-on: ${{ matrix.os }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install Neovim shell: bash run: | @@ -31,7 +47,7 @@ jobs: needs: tests if: ${{ github.ref == 'refs/heads/main' }} steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: panvimdoc uses: kdheepak/panvimdoc@main with: @@ -40,7 +56,7 @@ jobs: demojify: true treesitter: true - name: Push changes - uses: stefanzweifel/git-auto-commit-action@v4 + uses: stefanzweifel/git-auto-commit-action@v5 with: commit_message: "chore(build): auto-generate vimdoc" commit_user_name: "github-actions[bot]" @@ -54,14 +70,11 @@ jobs: - tests runs-on: ubuntu-latest steps: - - uses: google-github-actions/release-please-action@v3 + - uses: googleapis/release-please-action@v4 id: release with: release-type: simple - package-name: LazyVim - extra-files: | - lua/lazyvim/config/init.lua - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: tag stable versions if: ${{ steps.release.outputs.release_created }} run: | diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml new file mode 100644 index 00000000..52474c6a --- /dev/null +++ b/.github/workflows/labeler.yml @@ -0,0 +1,12 @@ +name: "Pull Request Labeler" +on: + - pull_request_target + +jobs: + labeler: + permissions: + contents: read + pull-requests: write + runs-on: ubuntu-latest + steps: + - uses: actions/labeler@v5 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml new file mode 100644 index 00000000..9ebbb312 --- /dev/null +++ b/.github/workflows/stale.yml @@ -0,0 +1,27 @@ +name: Close stale issues and PRs + +on: + workflow_dispatch: + schedule: + - cron: "30 1 * * *" + +jobs: + stale: + runs-on: ubuntu-latest + steps: + - uses: actions/stale@v9 + with: + operations-per-run: 300 + # default stale time + days-before-stale: 30 + days-before-close: 7 + # never stale pull requests + # days-before-pr-stale: -1 + days-before-pr-close: -1 + # exclude issues with certain labels + exempt-issue-labels: pinned,wip,security,notice + # never stale issues attached to a milestone + # exempt-all-milestones: true + stale-issue-message: "This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 7 days." + stale-pr-message: "This PR is stale because it has been open 60 days with no activity." + close-issue-message: "This issue was closed because it has been stalled for 7 days with no activity." diff --git a/CHANGELOG.md b/CHANGELOG.md index a6de0da5..4e2899c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,840 @@ # Changelog +## [12.4.0](https://github.com/LazyVim/LazyVim/compare/v12.3.0...v12.4.0) (2024-06-04) + + +### Features + +* **hipatterns:** added vue/astro ([d6c59d9](https://github.com/LazyVim/LazyVim/commit/d6c59d9a411a96fab22df03368b16740ea19da04)) +* **lazydev:** new lazydev config based on trigger words ([39da851](https://github.com/LazyVim/LazyVim/commit/39da8514d32c9eba40efa045c2d12d2170e206cf)) + + +### Bug Fixes + +* fixup for nvim-snippets compat on 0.9. Fixes [#3426](https://github.com/LazyVim/LazyVim/issues/3426) ([83c0c94](https://github.com/LazyVim/LazyVim/commit/83c0c9405acf4682d473188dd2ce3126c1261ea9)) +* hack for dashboard.nvim so that it shows errors when exiting ([6c3fd9f](https://github.com/LazyVim/LazyVim/commit/6c3fd9fedfa83bac9e63c04d24ff2760569b845e)) +* **hipatterns:** update mini-hipatterns.lua config to add support for heex, rust and svelte files ([#3430](https://github.com/LazyVim/LazyVim/issues/3430)) ([1731e45](https://github.com/LazyVim/LazyVim/commit/1731e455d41a9baa6c80bbc9e89e23c104479431)) +* **lazydev:** easier way of defining library plugin paths ([bb66618](https://github.com/LazyVim/LazyVim/commit/bb66618f1fc265c7a702f3d13d704ffbb1066178)) +* **luasnip:** move mappings to cmp spec so that they dont conflict with native snippets ([da7b773](https://github.com/LazyVim/LazyVim/commit/da7b7738eb84b00c949f48afabebd39266e61d75)) +* **todo-comments:** use toggle for Trouble todo commands ([#3424](https://github.com/LazyVim/LazyVim/issues/3424)) ([028d5bc](https://github.com/LazyVim/LazyVim/commit/028d5bcac5b2a9b6ceb23e2df9c92bdc7d711674)) +* **todo-comments:** use trouble filters for showing only todo/fix/fixmes ([6da95ee](https://github.com/LazyVim/LazyVim/commit/6da95ee7d35f7eab4297c2229d8d79d43f5d12bc)) +* **ui:** fix incorrect colors on change colorscheme (lualine) ([#3431](https://github.com/LazyVim/LazyVim/issues/3431)) ([4d706f1](https://github.com/LazyVim/LazyVim/commit/4d706f1bdc687f1d4d4cd962ec166c65c453633e)) + +## [12.3.0](https://github.com/LazyVim/LazyVim/compare/v12.2.0...v12.3.0) (2024-06-02) + + +### Features + +* **coding:** use `lazydev.nvim` instead of `neodev.nvim` ([5e76948](https://github.com/LazyVim/LazyVim/commit/5e76948d58d3ccae57b1cc09474a1f8b36d100ce)) +* **extras:** show extras imported in other extras ([b2858a2](https://github.com/LazyVim/LazyVim/commit/b2858a297a465546e9f34d5c3e9d42b9716048eb)) +* **extras:** split enabled in enabled plugins/languages ([45b92aa](https://github.com/LazyVim/LazyVim/commit/45b92aa381243417462fb4aac92478ce50b4e126)) +* moved neoconf.nvim to extras ([c14d21c](https://github.com/LazyVim/LazyVim/commit/c14d21ce7534ff302c1ccf0b22f46160ea98ccf1)) +* **util:** utility methods for lazy plugins ([596c439](https://github.com/LazyVim/LazyVim/commit/596c439db572c8b37c442a1f425b3f452607fd36)) + + +### Bug Fixes + +* **dot:** added dot to recommended ([c69553e](https://github.com/LazyVim/LazyVim/commit/c69553e1942a646917c92f3643a2ca78eeb19adf)) +* **json:** added *.json to recommended ([c98fbef](https://github.com/LazyVim/LazyVim/commit/c98fbef3b56fe6ba709254cdc90c8c46c078d555)) +* **util:** make sure doc gen works ([c33d657](https://github.com/LazyVim/LazyVim/commit/c33d6578a8b2ce03cab58d5952d717064125ef5d)) + +## [12.2.0](https://github.com/LazyVim/LazyVim/compare/v12.1.0...v12.2.0) (2024-06-01) + + +### Features + +* **astro:** added support for ts-plugin, but won't work till mason-registry PR is merged. See [#3364](https://github.com/LazyVim/LazyVim/issues/3364) ([683aaeb](https://github.com/LazyVim/LazyVim/commit/683aaeb75b46f182f2a2dca3b8416151de296626)) +* **extras:** added extra for svelte. Full support will be enabled once my mason PR gets merged ([7598a75](https://github.com/LazyVim/LazyVim/commit/7598a7503df0fd7912e81fdc9a0eb7635795605b)) +* **typescript:** add keymap for remove unused imports ([#3376](https://github.com/LazyVim/LazyVim/issues/3376)) ([0a93737](https://github.com/LazyVim/LazyVim/commit/0a9373733f79be5edb4ccb8d9268a700c1e3faad)) + + +### Bug Fixes + +* **aerial:** disable trouble leader-cs keymap when aerial extra is enabled ([1351503](https://github.com/LazyVim/LazyVim/commit/135150307b53a5b51f2f0c149ca7f426a67eb8f1)) +* **copilot-chat:** no need to schedule which-key keys. just use default ([6678af3](https://github.com/LazyVim/LazyVim/commit/6678af37ee3100882b4c08451fa8aaa37e37fd69)) +* **extras:** `underline = false` for setting diagnostics ([#3379](https://github.com/LazyVim/LazyVim/issues/3379)) ([060f56d](https://github.com/LazyVim/LazyVim/commit/060f56d6d429c5ee3fd35f4fa0c152f4a42781ca)) +* **health:** remove old deprecated module checks ([4e62df4](https://github.com/LazyVim/LazyVim/commit/4e62df4269a9300c17f6bf23acfcb9dd0729b6c3)) +* **lsp:** better way of extending deeply nested lists. Fixes [#3398](https://github.com/LazyVim/LazyVim/issues/3398) ([9f2cc30](https://github.com/LazyVim/LazyVim/commit/9f2cc302463e3be0ca3a42845c0fc34e49e75bca)) +* rename `+a` which-key group to `ai`. Fixes [#3392](https://github.com/LazyVim/LazyVim/issues/3392) ([a474aea](https://github.com/LazyVim/LazyVim/commit/a474aea1f9fcf0c7601914b1e53260067f621799)) +* **rust:** let rustaceans.nvim setup rust_analyzer ([#3389](https://github.com/LazyVim/LazyVim/issues/3389)) ([3fadf6a](https://github.com/LazyVim/LazyVim/commit/3fadf6af8f4adc1788fb8adec1fd9850d12feaf8)) +* **trouble:** don't enable symbols keymap when `outline.nvim` enabled ([#3408](https://github.com/LazyVim/LazyVim/issues/3408)) ([146c87c](https://github.com/LazyVim/LazyVim/commit/146c87cd786854b9225ad49ad39acbcb4b7fff0b)) +* **ui:** allow to disable the trouble lualine component with `vim.g.trouble_lualine = false` ([#3391](https://github.com/LazyVim/LazyVim/issues/3391)) ([d02b73d](https://github.com/LazyVim/LazyVim/commit/d02b73d72a85d72a57c3bcf0cfaef0cd50c81c37)) +* **ui:** remove old alpha.nvim warning ([abc6554](https://github.com/LazyVim/LazyVim/commit/abc6554e24ff97bfc630fe1d91827e02f826b1fa)) +* **util:** make sure mason is loaded when getting package paths ([a6df15a](https://github.com/LazyVim/LazyVim/commit/a6df15a63fdeaf25895fb2d97910e3e099a95d0c)) +* **vue:** correctly add plugins. See [#3401](https://github.com/LazyVim/LazyVim/issues/3401) ([e7430b0](https://github.com/LazyVim/LazyVim/commit/e7430b0776c13e9ab3f42a1b9aee84561bd07c0a)) + +## [12.1.0](https://github.com/LazyVim/LazyVim/compare/v12.0.0...v12.1.0) (2024-05-30) + + +### Features + +* **copilot-chat:** add cmp integration ([2a7d163](https://github.com/LazyVim/LazyVim/commit/2a7d163a8a6de2a5ad58b240770d90e6e5947638)) +* **extras:** simple extra for astro ([e7d4b39](https://github.com/LazyVim/LazyVim/commit/e7d4b397b291ec8854673e813ae67103bc75e15d)) +* trouble v3 ([95d055d](https://github.com/LazyVim/LazyVim/commit/95d055dcf7bbad34f6b8aaf94d285314ceaf6f0c)) +* **typescript:** vtls add select ts version ([#3366](https://github.com/LazyVim/LazyVim/issues/3366)) ([b285a46](https://github.com/LazyVim/LazyVim/commit/b285a46dfcde44aa2ab4f5acbbc4a2a18cc1f16b)) + + +### Bug Fixes + +* **clangd:** switch source/header is now leader-ch. Fixes [#3363](https://github.com/LazyVim/LazyVim/issues/3363) ([a224ef2](https://github.com/LazyVim/LazyVim/commit/a224ef2a73dd1e8b358179aab8fa36c1b6745b26)) +* **extras:** show recommended languages above enabled plugins ([c4b7505](https://github.com/LazyVim/LazyVim/commit/c4b75059697a85c77e4d85e18e37ebb6f278cf2a)) +* remove lazygit log gl keymap when on gitui ([#3371](https://github.com/LazyVim/LazyVim/issues/3371)) ([c2ef092](https://github.com/LazyVim/LazyVim/commit/c2ef09227ee59692f931fd7d4183759d1a82ac02)) +* **root:** escape glob expressions ([7414e84](https://github.com/LazyVim/LazyVim/commit/7414e84af96941fbe74555951ca6f5a58530775d)) +* **typescript:** allow easier merging of ts plugins ([cf6775a](https://github.com/LazyVim/LazyVim/commit/cf6775a959de7df314a8db1c208daed33a70f0c4)) +* **typescript:** vtsls server expe settings ([#3372](https://github.com/LazyVim/LazyVim/issues/3372)) ([ae098d6](https://github.com/LazyVim/LazyVim/commit/ae098d67d6842ccc097f5a10616369b60dfe6701)) + +## [12.0.0](https://github.com/LazyVim/LazyVim/compare/v11.11.0...v12.0.0) (2024-05-29) + + +### ⚠ BREAKING CHANGES + +* **typescript:** the typescript extra now uses vtsls instead of tsserver. You may want to update your lsp settings. + +### Features + +* **keymaps:** new keymap to toggle mazimize of current window leader-m or leader-wm ([3ace827](https://github.com/LazyVim/LazyVim/commit/3ace8277e54370c0aa3d17e61018cf039c42d69b)) +* **lsp:** added leader-cR to rename the current file and to lsp rename operations ([b949dba](https://github.com/LazyVim/LazyVim/commit/b949dba489abae54ba28540da06f360d6fb2788d)) +* **typescript:** added `gR` to goto file references ([38b8736](https://github.com/LazyVim/LazyVim/commit/38b8736b81870a01f4464c9dd07d545ea57b95fc)) +* **typescript:** the typescript extra now uses vtsls instead of tsserver. You may want to update your lsp settings. ([fba06ce](https://github.com/LazyVim/LazyVim/commit/fba06ce9f522b91be8a342f9c028948c2733132d)) +* **vscode:** added ts-comments to allow list for vscode ([0975eeb](https://github.com/LazyVim/LazyVim/commit/0975eeb9add54b1dc65f4c3874edd8e35e527099)) + + +### Bug Fixes + +* **lsp:** added support for `has` as array for lsp keymaps ([01e6718](https://github.com/LazyVim/LazyVim/commit/01e6718e034d4a66bbdecef35f12c71bbde519fe)) +* **lsp:** create `gr` with `nowait=true` ([4dfd5c2](https://github.com/LazyVim/LazyVim/commit/4dfd5c2596ff427a1232e6624add093d5b4da82e)) +* **lsp:** fix LazyVim's `on_file_rename` to work according to the lsp spec ([4bbeb37](https://github.com/LazyVim/LazyVim/commit/4bbeb37a18b02fc0c1bb5050dce4358b51583968)) +* **lsp:** fix ts/deno both attaching ([f6bcf6f](https://github.com/LazyVim/LazyVim/commit/f6bcf6f12c9a9f5ac256b394155d8a9649c6beda)) +* **lsp:** remove duplicate keymap ([8047562](https://github.com/LazyVim/LazyVim/commit/804756209e314d9bd466584e75aee37912b75223)) +* **trouble_v3:** set correct lualine section background color ([a13457e](https://github.com/LazyVim/LazyVim/commit/a13457eea3edf9b409e93e0391a5c206e0260022)) + +## [11.11.0](https://github.com/LazyVim/LazyVim/compare/v11.10.0...v11.11.0) (2024-05-28) + + +### Features + +* **snippets:** try to use the snippet parse to get a preview ([eb0da3c](https://github.com/LazyVim/LazyVim/commit/eb0da3c92f2aee00ce951410ec820ce2f63490d8)) + + +### Bug Fixes + +* **nvim-snippets:** no longer needed to set global_snippets ([9149358](https://github.com/LazyVim/LazyVim/commit/91493588a8580cc216ee63cdc98b4462c54b45a7)) +* **snippets:** fix snippets with multiple placeholders for the same tabstop ([1b86d7b](https://github.com/LazyVim/LazyVim/commit/1b86d7b2ade1dc934165fb1de8e5a3b211bc5ee0)) +* **snippets:** show actual error for failed snippet ([425dade](https://github.com/LazyVim/LazyVim/commit/425dadef72e2af17eb45faf7bf45f7d74276ad72)) + +## [11.10.0](https://github.com/LazyVim/LazyVim/compare/v11.9.0...v11.10.0) (2024-05-28) + + +### Features + +* **keymaps:** add comment above/below current line with gco/gcO ([47a8736](https://github.com/LazyVim/LazyVim/commit/47a8736278d246769069dd1013560f1a122b0316)) +* **lang:** add R ([#3272](https://github.com/LazyVim/LazyVim/issues/3272)) ([80c9dca](https://github.com/LazyVim/LazyVim/commit/80c9dcaabe97a2e07d4fbc060820d8eb3ae6a044)) +* **lsp:** config option to exclude certain filetypes from inlay hints. Closes [#3202](https://github.com/LazyVim/LazyVim/issues/3202) ([e68ff68](https://github.com/LazyVim/LazyVim/commit/e68ff6897eb8e90ec08f7400d3271a8b4fb1da1e)) +* **scala-extra:** Use noice for progress and add minimal keybinding ([#3348](https://github.com/LazyVim/LazyVim/issues/3348)) ([de57894](https://github.com/LazyVim/LazyVim/commit/de5789415855eafa24f399ee11a5e96bee7c6f9e)) +* **snippets:** re-number tabstops for invalid snippets ([cf43748](https://github.com/LazyVim/LazyVim/commit/cf4374867d39b590f1add8c654dbb2d3578cf24f)) + + +### Bug Fixes + +* **copilot-chat:** enhanced chat view is now merged upstream, so update your plugins! ([08481c2](https://github.com/LazyVim/LazyVim/commit/08481c2c9272b8863611d5f3e79876674bfc570e)) +* **nvim-snippets:** also enable for tsx/jsx files ([025ba33](https://github.com/LazyVim/LazyVim/commit/025ba33dc3e7899b26233f05cb650dbecb234441)) +* **nvim-snippets:** load js snippets for ts. See [#3344](https://github.com/LazyVim/LazyVim/issues/3344) ([99f0a1c](https://github.com/LazyVim/LazyVim/commit/99f0a1cb40cbfc099503bfa05fbd6c26370cada3)) +* **nvim-snippets:** remove extra filetypes since thats no longer needed with merged PR ([a6e6d4d](https://github.com/LazyVim/LazyVim/commit/a6e6d4dabd60ab12546f56989811e58b19efb5a1)) + +## [11.9.0](https://github.com/LazyVim/LazyVim/compare/v11.8.0...v11.9.0) (2024-05-27) + + +### Features + +* **copilot-chat:** enhanced rendering of the chat window ([a23e8c1](https://github.com/LazyVim/LazyVim/commit/a23e8c15f50a176f0decf054ecbfc38c7570b9b0)) +* **copilot-chat:** make keymaps work in visual mode ([2695fc7](https://github.com/LazyVim/LazyVim/commit/2695fc7dfc9972da9c3d7e1d3b4a138f54f1dcbb)) + + +### Bug Fixes + +* **copilot-chat:** clear -> reset ([02b240c](https://github.com/LazyVim/LazyVim/commit/02b240cea56a5547f2b0729e09decfc228475c8b)) +* **edgy:** load edgy spec early ([163f7ea](https://github.com/LazyVim/LazyVim/commit/163f7ea3036caf48eed9e9c7b0da8680475612a7)) +* **lsp:** double check for documentHighlight. See [#3246](https://github.com/LazyVim/LazyVim/issues/3246) ([0a63734](https://github.com/LazyVim/LazyVim/commit/0a63734b783509407530eae789258fcf9a6f2219)) +* **terminal:** make `gf` behave. Fixes [#3335](https://github.com/LazyVim/LazyVim/issues/3335) ([eb1c04b](https://github.com/LazyVim/LazyVim/commit/eb1c04bd31d518377538ac228788b6a0be194c1b)) +* **typescript:** invalid value in inlayHints options ([#3331](https://github.com/LazyVim/LazyVim/issues/3331)) ([54d7cea](https://github.com/LazyVim/LazyVim/commit/54d7cea30567577bf926765e9282d7736e951941)) + +## [11.8.0](https://github.com/LazyVim/LazyVim/compare/v11.7.0...v11.8.0) (2024-05-27) + + +### Features + +* **extras:** added extra for CopilotChat.nvim ([4678552](https://github.com/LazyVim/LazyVim/commit/46785526a63b401d812de79fbbecca26414dc8e8)) +* **git:** Change Commit Log to use Lazygit ([#2959](https://github.com/LazyVim/LazyVim/issues/2959)) ([9ccdbf6](https://github.com/LazyVim/LazyVim/commit/9ccdbf644cc6f38ade7fdd7e554e8da8b38091ac)) + + +### Bug Fixes + +* **lang/rust:** Remove `rust-analyzer` from `nvim-lspconfig` ([#2755](https://github.com/LazyVim/LazyVim/issues/2755)) ([f48d55a](https://github.com/LazyVim/LazyVim/commit/f48d55a653cc829e7dfecc3c01bf1ccbdf337257)) +* **laygit:** normalize paths. Fixes [#3327](https://github.com/LazyVim/LazyVim/issues/3327) ([dbed614](https://github.com/LazyVim/LazyVim/commit/dbed614655fdf13436654356c0ba156d45ee7cc4)) +* **laygit:** use correct .git root for git blame ([d23e857](https://github.com/LazyVim/LazyVim/commit/d23e8572e8ccc96b686ef8187aadf56ad47edd67)) +* **rust:** show error when rust-analyzer not found ([d3500a4](https://github.com/LazyVim/LazyVim/commit/d3500a4a33ab87c6225d991302a72012c54b26fe)) +* **snippet:** always use top-level snippet session. Fixes [#3199](https://github.com/LazyVim/LazyVim/issues/3199) ([5391174](https://github.com/LazyVim/LazyVim/commit/53911748ddc7f92793c6fec6348a9cde32159ef3)) + +## [11.7.0](https://github.com/LazyVim/LazyVim/compare/v11.6.1...v11.7.0) (2024-05-26) + + +### Features + +* lazyrc files are now a lazy.nvim feature ([3a30070](https://github.com/LazyVim/LazyVim/commit/3a30070a4cd4465699d1fdd384d95bdb9935376b)) + + +### Bug Fixes + +* **illuminate:** s/enabed/enabled ([#3313](https://github.com/LazyVim/LazyVim/issues/3313)) ([c9ab822](https://github.com/LazyVim/LazyVim/commit/c9ab8224f54fb6e93050fab1043b9d1efb917c23)) +* **lsp:** added a-n, a-p for document highlights and cycling. Closes [#3320](https://github.com/LazyVim/LazyVim/issues/3320) ([b3373f3](https://github.com/LazyVim/LazyVim/commit/b3373f3428f8ded19f8162a46bf9f2784299b43b)) +* **lspconfig:** make `opts` a function ([#3311](https://github.com/LazyVim/LazyVim/issues/3311)) ([7aa3706](https://github.com/LazyVim/LazyVim/commit/7aa37064a2421f044c61d4baf42f71a923fab94b)) +* **lsp:** correct previous reference keymap description ([#3314](https://github.com/LazyVim/LazyVim/issues/3314)) ([cdff9de](https://github.com/LazyVim/LazyVim/commit/cdff9de17226701f37069744a402b7afd9942f66)) +* **lsp:** properly get buffer for dynamic capabilities ([#3315](https://github.com/LazyVim/LazyVim/issues/3315)) ([07a1371](https://github.com/LazyVim/LazyVim/commit/07a137199cde87f089776b3f992bd9ed08889cac)) + +## [11.6.1](https://github.com/LazyVim/LazyVim/compare/v11.6.0...v11.6.1) (2024-05-23) + + +### Bug Fixes + +* **lsp:** use proper buffer for dynamic capabilities. Fixes [#3246](https://github.com/LazyVim/LazyVim/issues/3246) ([10ed308](https://github.com/LazyVim/LazyVim/commit/10ed3082a415b525628dfaebdcd007c7e96a5b87)) + +## [11.6.0](https://github.com/LazyVim/LazyVim/compare/v11.5.0...v11.6.0) (2024-05-23) + + +### Features + +* **markdown:** add formatter for mdx ([ae6d8f1](https://github.com/LazyVim/LazyVim/commit/ae6d8f1a34fff49f9f1abf9fdd8a559c95b85cf3)) +* **markdown:** configure conform for markdown files ([#2308](https://github.com/LazyVim/LazyVim/issues/2308)) ([9eec03d](https://github.com/LazyVim/LazyVim/commit/9eec03d890f7846e6f47e12ebbe369c7177fd5f1)) +* **telescope:** add telescope jumplist keymap ([#3268](https://github.com/LazyVim/LazyVim/issues/3268)) ([79608fb](https://github.com/LazyVim/LazyVim/commit/79608fbc4fe7d5fbd2d238e8d8ebfce7d576b7c2)) + + +### Bug Fixes + +* **lsp:** only enableinlay hints for when buffer is an actual file. See [#3284](https://github.com/LazyVim/LazyVim/issues/3284) ([46cf534](https://github.com/LazyVim/LazyVim/commit/46cf5347b5649e856a69b9f52ccad8a671ddefc6)) +* **python:** extras.lang.python to enable venv select keys on ft ([#3280](https://github.com/LazyVim/LazyVim/issues/3280)) ([f9b3137](https://github.com/LazyVim/LazyVim/commit/f9b31372aef9f1f862bf24879ba388f0d89c2349)) +* set markdown for LICENSE file ([#3276](https://github.com/LazyVim/LazyVim/issues/3276)) ([1eea516](https://github.com/LazyVim/LazyVim/commit/1eea51606e1ec1035c440a4ca9b3eab053337a7d)) + +## [11.5.0](https://github.com/LazyVim/LazyVim/compare/v11.4.1...v11.5.0) (2024-05-21) + + +### Features + +* **comments:** use ts-comments.nvim instead of nvim-ts-context-commentstring on Neovim 0.10 ([8ba7c64](https://github.com/LazyVim/LazyVim/commit/8ba7c64a7da9e46f2ac601919508803824208935)) +* **telescope:** add quickfix and telescope keymaps ([#3077](https://github.com/LazyVim/LazyVim/issues/3077)) ([ab4e57a](https://github.com/LazyVim/LazyVim/commit/ab4e57a4bfe6107c21a25450292ef69537a2b37b)) + + +### Bug Fixes + +* **cmp:** fix cmp's broken snippet parsing functionality. Fixes [#3266](https://github.com/LazyVim/LazyVim/issues/3266) ([2bae438](https://github.com/LazyVim/LazyVim/commit/2bae438570aa96904836e56d8dad7f33eb3204ee)) +* **lsp:** sometimes lsp client is not fully initialized and doesnt yet have client.supports_method on 0.9.5. Fixes [#3263](https://github.com/LazyVim/LazyVim/issues/3263) ([8c94842](https://github.com/LazyVim/LazyVim/commit/8c94842b4a613995bf4c0c79febcd74c310439d0)) +* **neo-tree:** better icons for git staged/unstaged ([e46dd4e](https://github.com/LazyVim/LazyVim/commit/e46dd4e9b2ac68a5058447ef73b413605d15ae62)) +* **nvim-snippets:** enable global friendly-snippets. See [#3240](https://github.com/LazyVim/LazyVim/issues/3240) ([55b07de](https://github.com/LazyVim/LazyVim/commit/55b07dee21ee5306624e16dd90c2b3c9c0f3ddde)) +* **snippets:** fixes custom snippets. use my branch till nvim-snippets PR is merged. Fixes [#3240](https://github.com/LazyVim/LazyVim/issues/3240) ([cb1e1b9](https://github.com/LazyVim/LazyVim/commit/cb1e1b9c82b405fa277f1869cd04dcd9c4507412)) +* **snippets:** make friendly snippets a dep of nvim-snippets ([d73397c](https://github.com/LazyVim/LazyVim/commit/d73397c4aaac74d95970ac06caffa25abd7c2af4)) +* **snippets:** my nvim-snippets PR is merged, so remove work-around. That was quick :) ([027d6bc](https://github.com/LazyVim/LazyVim/commit/027d6bc2e896d453153f48a8c15db2a627698dc8)) + +## [11.4.1](https://github.com/LazyVim/LazyVim/compare/v11.4.0...v11.4.1) (2024-05-20) + + +### Bug Fixes + +* **java:** properly pass settings to jdtls ([8e67bb1](https://github.com/LazyVim/LazyVim/commit/8e67bb124009e0dbf29f8e78d701d07756670278)) + +## [11.4.0](https://github.com/LazyVim/LazyVim/compare/v11.3.2...v11.4.0) (2024-05-20) + + +### Features + +* **cmp:** add missing documentation to snippets when needed ([24a2a9f](https://github.com/LazyVim/LazyVim/commit/24a2a9fb0ba60e0e7c6c8c4ee95a5db7ea0e123e)) +* **cmp:** better error handling and automatic fixing of snippets that fail to parse with native Neovim snippets ([97862f4](https://github.com/LazyVim/LazyVim/commit/97862f425997bf89f581e6aeceed9aac85d90432)) +* **cmp:** move cmp autobracket support to util class ([39f3ebc](https://github.com/LazyVim/LazyVim/commit/39f3ebcadf49b285d8ae06270ed0c2098e7f03bd)) +* **cmp:** resolve placeholders in generated missing snippet documentation ([7d72436](https://github.com/LazyVim/LazyVim/commit/7d72436193b3624a9198a5e57ec1bd7e90260c00)) +* **extras.lang:** Add kotlin ([#2890](https://github.com/LazyVim/LazyVim/issues/2890)) ([94c9f4c](https://github.com/LazyVim/LazyVim/commit/94c9f4cf379e472fbd1a342ef28687dfa418dec0)) +* **java:** enable inlay hints. Fixes [#3244](https://github.com/LazyVim/LazyVim/issues/3244) ([e5ea8ab](https://github.com/LazyVim/LazyVim/commit/e5ea8abd38c4b93edccd69c9ef4462377103a9c3)) +* **kotlin:** added recommended checks ([dd417c3](https://github.com/LazyVim/LazyVim/commit/dd417c36cd14b5b347b4f82e9e7683b085c768fb)) +* **lang:** add toml ([#3022](https://github.com/LazyVim/LazyVim/issues/3022)) ([e0c67f6](https://github.com/LazyVim/LazyVim/commit/e0c67f6776a5e6f1b72852567ce4fec16598b2da)) +* **lsp:** properly update certain Neovim functionlity based on dynamic capabilities. See [#3244](https://github.com/LazyVim/LazyVim/issues/3244). Fixes [#3246](https://github.com/LazyVim/LazyVim/issues/3246) ([20e002f](https://github.com/LazyVim/LazyVim/commit/20e002f9f0e9bfdff1ffc638987fbd46b31e5f9b)) +* **toml:** also recommend toml when theres toml files in the cwd ([c264253](https://github.com/LazyVim/LazyVim/commit/c264253d8fd4f068c7c2ddb5ea3c63596ab5d23f)) +* **vscode:** enable more compatible plugins ([#3250](https://github.com/LazyVim/LazyVim/issues/3250)) ([5726f39](https://github.com/LazyVim/LazyVim/commit/5726f3966df7c1e9b350d24aa94f621d0ea484da)) + + +### Bug Fixes + +* **bufferline:** unpin bufferline with 0.9.x compatibility ([#3252](https://github.com/LazyVim/LazyVim/issues/3252)) ([ea1c3ad](https://github.com/LazyVim/LazyVim/commit/ea1c3ad6b46dfaeca9ff4564499b4cdc8f839610)) +* **cmp:** no need to setup native snippets with latest cmp ([57a31c3](https://github.com/LazyVim/LazyVim/commit/57a31c3920bcb9baec9a6d3915506a638b0801b8)) +* **cmp:** use better cmp.confirm ([2961162](https://github.com/LazyVim/LazyVim/commit/2961162ebaef96e4ffbc1e6c97dba0dc32efbbb0)) +* **config:** add some extra LazyVim keys to lazy health ([76033c6](https://github.com/LazyVim/LazyVim/commit/76033c6aa92e633de968b515d3fd5f9e0447a74f)) + +## [11.3.2](https://github.com/LazyVim/LazyVim/compare/v11.3.1...v11.3.2) (2024-05-19) + + +### Bug Fixes + +* **bufferline:** pin bufferline to older version on 0.9.x for now ([573aa22](https://github.com/LazyVim/LazyVim/commit/573aa226f9f9b9fb9c9886381d3fd06746b7ae6a)) +* **cmp:** only complete on `<cr>` when cmp is really visible. Dont wait till it might be visible. Faster and more correct imho ([ad22ada](https://github.com/LazyVim/LazyVim/commit/ad22adab7d446018875de2dc96168295cad9298e)) +* **git:** off-by-one issue in lazygit blame line ([#3230](https://github.com/LazyVim/LazyVim/issues/3230)) ([4208a09](https://github.com/LazyVim/LazyVim/commit/4208a09df8cd20fe491a5fdcc722c12fb07588dc)) +* **gitui:** properly delete lazygit keymap at the correct time. Fixes [#3227](https://github.com/LazyVim/LazyVim/issues/3227) ([e346d17](https://github.com/LazyVim/LazyVim/commit/e346d17812de516ad0789ede49b49a8b7ba213fe)) +* show refactored success msg ([#3233](https://github.com/LazyVim/LazyVim/issues/3233)) ([4a41012](https://github.com/LazyVim/LazyVim/commit/4a41012483e67ffe5ff65f31934ed668325ea131)) +* **yanky:** load yanky earlier to avoid losing deleted lines ([#3234](https://github.com/LazyVim/LazyVim/issues/3234)) ([93c156a](https://github.com/LazyVim/LazyVim/commit/93c156a0a54e5400436a950263dd140ca591d3e5)) + +## [11.3.1](https://github.com/LazyVim/LazyVim/compare/v11.3.0...v11.3.1) (2024-05-18) + + +### Bug Fixes + +* **util:** fixup ([3a4672d](https://github.com/LazyVim/LazyVim/commit/3a4672de3f8b6410de9fbd5b7134d5108d86f46c)) + +## [11.3.0](https://github.com/LazyVim/LazyVim/compare/v11.2.0...v11.3.0) (2024-05-18) + + +### Features + +* **cmp:** create undo point right before confirming a completion ([673975e](https://github.com/LazyVim/LazyVim/commit/673975ebbe9870ded302bf3621e249bb4cd5f4f8)) +* **mini.ai:** `mini.ai` is back in core with some improved features. Removing it was a mistake. ([d8644c4](https://github.com/LazyVim/LazyVim/commit/d8644c47158fd28b88f5e3a90af6e5e6a0df2eba)) +* **util:** added Util.is_loaded ([4105c0a](https://github.com/LazyVim/LazyVim/commit/4105c0ad3a441da3a31cc7d8e53305a6117f6ee5)) + + +### Bug Fixes + +* **ibl:** remove ibl fix since it's been fixed upstream ([4614666](https://github.com/LazyVim/LazyVim/commit/4614666d1ee5864e95a08eb5b85808d7834ce85f)) +* **keymaps:** delete lazygit keymap when using gitui ([#2986](https://github.com/LazyVim/LazyVim/issues/2986)) ([649fa9d](https://github.com/LazyVim/LazyVim/commit/649fa9d52188e0c28733402f2f65014fa73308bc)) +* **lsp:** move next/prev reference keymaps to lsp keymaps. See [#3220](https://github.com/LazyVim/LazyVim/issues/3220) ([a4d8352](https://github.com/LazyVim/LazyVim/commit/a4d83524a7179274c17414ebeb0a4e4b8d9a8706)) +* **mini.starter:** changes based on echasnovski's recommendation ([#3223](https://github.com/LazyVim/LazyVim/issues/3223)) ([eb6c9fb](https://github.com/LazyVim/LazyVim/commit/eb6c9fb5784a8001c876203de174cd79e96bb637)) +* **plugin:** typo ([#3225](https://github.com/LazyVim/LazyVim/issues/3225)) ([96aa4b8](https://github.com/LazyVim/LazyVim/commit/96aa4b8877faa2fea30d2d4e2d3d117d9d3851f8)) +* **treesitter:** refactored treesitter code and fixed nvim-treesitter-textobjects ([fe55285](https://github.com/LazyVim/LazyVim/commit/fe552853f5c065df2d79092c0cbac6745f8ea8fc)) + +## [11.2.0](https://github.com/LazyVim/LazyVim/compare/v11.1.2...v11.2.0) (2024-05-18) + + +### Features + +* **extras:** added a recommended plugin/language section to `:LazyExtras` ([16eb3d9](https://github.com/LazyVim/LazyVim/commit/16eb3d947321992ebcddff6b997d403b41bd7411)) +* **extras:** added recommended detectors for all languages ([c292134](https://github.com/LazyVim/LazyVim/commit/c29213416b5e29fc56c465234dfd717f78a9e09f)) +* **extras:** added trouble-v3 and mini-hipatterns to recommended ([d514e2f](https://github.com/LazyVim/LazyVim/commit/d514e2fa93a449329c2de64d569846102f24de0e)) +* **extras:** tags some extras as recommended ([ef3bd3b](https://github.com/LazyVim/LazyVim/commit/ef3bd3bd027209812c41b1d772e766c0ef18c503)) +* **root:** added support for `*.xxx` root patterns ([03ea7f6](https://github.com/LazyVim/LazyVim/commit/03ea7f6f98a874e26d258dbfe5b196c2d7c6971f)) + + +### Bug Fixes + +* **bufferline:** force update bufferline after `BufDelete`. Closes [#3197](https://github.com/LazyVim/LazyVim/issues/3197) ([72abb89](https://github.com/LazyVim/LazyVim/commit/72abb893acc866ce574c66af7d9de861440a3a1f)) +* **comments:** better way of using ts-context-commentstring with native comments ([1d23c98](https://github.com/LazyVim/LazyVim/commit/1d23c98da138494fafdad6735d70c3d3375bb7b2)) +* **extras:** remove treesitter-rewrite extra for now ([180d951](https://github.com/LazyVim/LazyVim/commit/180d9516fd68ca8b881cf1028eeb65aa9c2e25b7)) +* **indent-blankline:** temp fix for `tbl_flatten` on `0.9.x` ([3a193d3](https://github.com/LazyVim/LazyVim/commit/3a193d3aa89c8ff0327abb3e60600eab154af93a)) +* **leap:** add label to renamed surround mappings key group ([#3211](https://github.com/LazyVim/LazyVim/issues/3211)) ([9c212d6](https://github.com/LazyVim/LazyVim/commit/9c212d655a05c42331443f5d0d6dcc982108ed0e)) +* **mini.starter:** buf_id in refresh() is not an identifier of valid … ([#3209](https://github.com/LazyVim/LazyVim/issues/3209)) ([dc66887](https://github.com/LazyVim/LazyVim/commit/dc66887b57ecdee8d33b5e07ca031288260e2971)) +* **refactoring:** add label to refactoring key group ([#3201](https://github.com/LazyVim/LazyVim/issues/3201)) ([39bec71](https://github.com/LazyVim/LazyVim/commit/39bec71ce9489eee288544dca22015147636ae4d)) +* **treesitter:** disable treesitter-rewrite extra for now. not ready yet ([87bb766](https://github.com/LazyVim/LazyVim/commit/87bb76612318f0c0b4fca675500e3afd0a9c6771)) +* **trouble-v3:** add neovim version check ([0892542](https://github.com/LazyVim/LazyVim/commit/08925421e840ac21f3feac28ee8b57319f0a4e59)) +* **util.toggle:** correctly toggle `inlay_hints` ([#3202](https://github.com/LazyVim/LazyVim/issues/3202)) ([23374f1](https://github.com/LazyVim/LazyVim/commit/23374f160a5b1b947681d55add56ab6ab15e219e)) + + +### Performance Improvements + +* **comments:** `vim.schedule` ts-context-commentstring integration ([c653c4a](https://github.com/LazyVim/LazyVim/commit/c653c4a9a5c0a3cd5101ce86a3640ee12067ffcd)) +* **yanky:** switch to shada backend. It seems much faster than sqlite ([4348836](https://github.com/LazyVim/LazyVim/commit/434883632cd6bc884f36da0282073307d585d6a1)) + +## [11.1.2](https://github.com/LazyVim/LazyVim/compare/v11.1.1...v11.1.2) (2024-05-17) + + +### Bug Fixes + +* **util:** use `bdelete` for buf remove ([19674e8](https://github.com/LazyVim/LazyVim/commit/19674e804787e205c587d153e8e9c4a3988e7f6c)) + +## [11.1.1](https://github.com/LazyVim/LazyVim/compare/v11.1.0...v11.1.1) (2024-05-17) + + +### Bug Fixes + +* **bufferline:** correctly configure bufferline to use the new bufremove util ([2e1c945](https://github.com/LazyVim/LazyVim/commit/2e1c945f61821eec818a1512bc05b45366c0dfeb)) + + +### Performance Improvements + +* **coding:** dont load `vim.snippet` early ([289c2f8](https://github.com/LazyVim/LazyVim/commit/289c2f81c43d39b31a8b46a4a84ab9feb61bb235)) + +## [11.1.0](https://github.com/LazyVim/LazyVim/compare/v11.0.1...v11.1.0) (2024-05-17) + + +### Features + +* **lsp:** document highlights now use native lsp. `vim-illuminate` is available as an extra ([cc99b21](https://github.com/LazyVim/LazyVim/commit/cc99b219ded16ec60120698d6e8f453c2f37132c)) +* **options:** new option to disable deprecation warnings. warnings will be hidden bydefault ([f8de965](https://github.com/LazyVim/LazyVim/commit/f8de965d3ec5712444a643b507bc9ddc7cb19d01)) +* **util:** `mini.bufremove` is no longer needed ([779de26](https://github.com/LazyVim/LazyVim/commit/779de263f173f7e6f181d1e8faa475be8b05167d)) + + +### Bug Fixes + +* deprecation warning on diagnostic.is_disabled ([960ec80](https://github.com/LazyVim/LazyVim/commit/960ec8079bb5960a510595dff21725ff403b2753)) +* **lsp:** dont try to highlight refs for deleted buffers ([87493af](https://github.com/LazyVim/LazyVim/commit/87493af2378fac7b518fd2c4db903cd3a2c27095)) +* **treesitter-rewrite:** add missed local Config ([#3188](https://github.com/LazyVim/LazyVim/issues/3188)) ([ec673a8](https://github.com/LazyVim/LazyVim/commit/ec673a83ff387e29ca42367b3aab3c311950a024)) +* **util.lsp:** add `desc` for keymaps reference ([#3193](https://github.com/LazyVim/LazyVim/issues/3193)) ([b1ea356](https://github.com/LazyVim/LazyVim/commit/b1ea356e6c676571907ce654ec3878c530c636ad)) + +## [11.0.1](https://github.com/LazyVim/LazyVim/compare/v11.0.0...v11.0.1) (2024-05-16) + + +### Bug Fixes + +* **news.md:** correct phrase to disable `inlay_hints` ([58cf6f9](https://github.com/LazyVim/LazyVim/commit/58cf6f971b78170aef5f26ccb79149213f4a692d)) +* **treesitter-rewrite:** show error in Extras only when enabled ([#3178](https://github.com/LazyVim/LazyVim/issues/3178)) ([639dfce](https://github.com/LazyVim/LazyVim/commit/639dfce0101cc6c0174e116872df91ccb30cb597)) +* **util:** get opts from parsing specs instead of plugins ([14872fa](https://github.com/LazyVim/LazyVim/commit/14872fa816fd770eba0f2b5efc69d5b29d4073fb)) + +## [11.0.0](https://github.com/LazyVim/LazyVim/compare/v10.25.0...v11.0.0) (2024-05-16) + + +### ⚠ BREAKING CHANGES + +* **util:** move `vim-startuptime` to an extra +* **coding:** move `mini.ai` to an extra +* **mini.surround:** move `mini.surround` to an extra +* **ui:** move `mini.indentscope` to an extra +* **ui:** moved treesitter-context to an extra. No longer a core plugin +* **coding:** native snippets are now the default on Neovim 0.10. Install the luasnip extra to get luasnip back +* **coding:** use native comments on 0.10, with support for ts_context_commentstring + +### Features + +* **coding:** move `mini.ai` to an extra ([4f4911f](https://github.com/LazyVim/LazyVim/commit/4f4911ff95bc35438a2b8dd2d058b15f105f2ff1)) +* **coding:** native snippets are now the default on Neovim 0.10. Install the luasnip extra to get luasnip back ([3c4ebd5](https://github.com/LazyVim/LazyVim/commit/3c4ebd522e7c475cfedcee5dfa7a008e798c404c)) +* **coding:** use native comments on 0.10, with support for ts_context_commentstring ([d999be7](https://github.com/LazyVim/LazyVim/commit/d999be7401783e0f3a610319fa1b327d38fa3e52)) +* **extras:** added extra for the `nvim-treesitter` rewrite. Some plugins are not compatible and will be disabled. ([2008146](https://github.com/LazyVim/LazyVim/commit/20081460b65bc7a117933b0dcebbcaa4dcb82b23)) +* **keymaps:** added leader-uI to open InspectTree ([3b74ef7](https://github.com/LazyVim/LazyVim/commit/3b74ef793fb7cd8964231393a57b9e3c846b7d1e)) +* **lsp:** enable inlay hints by default on Neovim 0.10 ([960e958](https://github.com/LazyVim/LazyVim/commit/960e958548adce7d96ff2e0c014ce2249897125e)) +* **mini.surround:** move `mini.surround` to an extra ([e37a699](https://github.com/LazyVim/LazyVim/commit/e37a699096ccb209c1babc29c1d5eeeab74102a1)) +* **ui:** move `mini.indentscope` to an extra ([69e6daa](https://github.com/LazyVim/LazyVim/commit/69e6daae2ccb4b7b7180e439c1b05d72d3c64e11)) +* **ui:** moved treesitter-context to an extra. No longer a core plugin ([03704e2](https://github.com/LazyVim/LazyVim/commit/03704e22998be9db17f114acc4060d714fe652fb)) +* **util:** move `vim-startuptime` to an extra ([66dc9c0](https://github.com/LazyVim/LazyVim/commit/66dc9c09d6356ddc7e5870a4aa74824d3623d315)) +* **util:** set_upvalue ([f02507b](https://github.com/LazyVim/LazyVim/commit/f02507b1598379250baab293c423f79c393e28e5)) + + +### Bug Fixes + +* **cmp:** never auto bracket for snippets and correct prev char check. Fixes [#2949](https://github.com/LazyVim/LazyVim/issues/2949) ([6e7ba50](https://github.com/LazyVim/LazyVim/commit/6e7ba50141b1cda415c9391fd345a1e428bad9b6)) +* **dap:** add debugger to filetypes mapping for launch.json ([#3165](https://github.com/LazyVim/LazyVim/issues/3165)) ([183d6ee](https://github.com/LazyVim/LazyVim/commit/183d6eea606556c8bd7f80a70660c54670e04649)) +* **dap:** use jsonc support from plenary. Same as the code from neoconf. Fixes [#3174](https://github.com/LazyVim/LazyVim/issues/3174) ([8dae76c](https://github.com/LazyVim/LazyVim/commit/8dae76c1fd6fb90199b56cda8b6ec21576d02eb5)) +* **health:** add warning when not using 0.10.0 ([9fe8b15](https://github.com/LazyVim/LazyVim/commit/9fe8b15928077cb0c20aeea111b42f9698c78330)) +* **treesitter-rewrite:** disable vim-illuminate ([b739eb3](https://github.com/LazyVim/LazyVim/commit/b739eb35033acaf20423920d103d5ad3e8350f23)) + +## [10.25.0](https://github.com/LazyVim/LazyVim/compare/v10.24.0...v10.25.0) (2024-05-15) + + +### Features + +* **extras:** add refactoring.nvim ([#3040](https://github.com/LazyVim/LazyVim/issues/3040)) ([73de8dd](https://github.com/LazyVim/LazyVim/commit/73de8dde2bb513337426d5ead862e4fc6dbb8fdf)) +* **lua_ls:** configure default lua_ls inlay hint settings ([91ead22](https://github.com/LazyVim/LazyVim/commit/91ead221167a722a8dd8651cb5c53bf5db4d1b4d)) +* **lua:** added `LazyVim` as a treesitter builtin ([a97fa3b](https://github.com/LazyVim/LazyVim/commit/a97fa3b7563eb2c5305c8f32461bb150d17e45ae)) +* **noice:** added keymap `<leader>snt` to show Noice messages in telescope. Fixes [#1306](https://github.com/LazyVim/LazyVim/issues/1306) ([914ca4a](https://github.com/LazyVim/LazyVim/commit/914ca4a455169916da4614d76c15d1d1bf22e9bc)) +* **omnisharp:** support neotest dotnet ([#3051](https://github.com/LazyVim/LazyVim/issues/3051)) ([a8659d0](https://github.com/LazyVim/LazyVim/commit/a8659d02b954ca320088aab48aad8a95b3bbb86c)) +* **snippet:** add friendly-snippets to native extra ([#2944](https://github.com/LazyVim/LazyVim/issues/2944)) ([12a48b8](https://github.com/LazyVim/LazyVim/commit/12a48b8ce1521fcac01b89099a4ca8bbc3547769)) +* **terraform:** ensure tflint is installed ([#2336](https://github.com/LazyVim/LazyVim/issues/2336)) ([16e6c86](https://github.com/LazyVim/LazyVim/commit/16e6c86b2778ba35696de5067ff033cc5bdbe6db)) +* **typescript:** configure inlayHint ([#2995](https://github.com/LazyVim/LazyVim/issues/2995)) ([2c86da7](https://github.com/LazyVim/LazyVim/commit/2c86da7c2df61c23366e4073312ab12fa6d7e424)) +* **vue:** add Vue.js support to LazyVim ([#3094](https://github.com/LazyVim/LazyVim/issues/3094)) ([f449025](https://github.com/LazyVim/LazyVim/commit/f4490252fb2262208923ba197eb521732a602ac1)) + + +### Bug Fixes + +* **ansible:** ansiblels not loading, keymap desc. ([#2739](https://github.com/LazyVim/LazyVim/issues/2739)) ([abb1ff0](https://github.com/LazyVim/LazyVim/commit/abb1ff0d600b3446b612390f0482cf92bdc84ab0)) +* **autocmds:** remove query from q-to-quit autocmd ([#2838](https://github.com/LazyVim/LazyVim/issues/2838)) ([9337db1](https://github.com/LazyVim/LazyVim/commit/9337db17c2f6082e10c97456185d8ba3fa473769)) +* **clangd:** update the attribute name for process ID ([#3047](https://github.com/LazyVim/LazyVim/issues/3047)) ([3c04789](https://github.com/LazyVim/LazyVim/commit/3c04789ef15bba15e8c0c71ef31db38c76b2ad67)) +* **cmp:** dont add autobrackets if prev char is a bracket. Closes [#2949](https://github.com/LazyVim/LazyVim/issues/2949) ([c70a78e](https://github.com/LazyVim/LazyVim/commit/c70a78e63137ec48e1c78b23413332716f572590)) +* **dap:** load vscode launch files with jsonc parser ([#1839](https://github.com/LazyVim/LazyVim/issues/1839)) ([543dead](https://github.com/LazyVim/LazyVim/commit/543dead590a949255fbbada9e1775c31ad654682)) +* **dial:** Fix dial commands in Visual line+block ([#2933](https://github.com/LazyVim/LazyVim/issues/2933)) ([1df3c5d](https://github.com/LazyVim/LazyVim/commit/1df3c5d70b2265f8582b0ed414f085e9066960da)) +* **dot:** remove `.env` => `sh` since this is already the default ([a0afe8f](https://github.com/LazyVim/LazyVim/commit/a0afe8fef9dc76b469a78435cdd3f2c5ee01f282)) +* **dot:** use syntax `sh` for dotenv files. Closes [#3145](https://github.com/LazyVim/LazyVim/issues/3145) ([42010d1](https://github.com/LazyVim/LazyVim/commit/42010d1dfbb0ba9c74c1ec0c93c5c9db21ebee47)) +* **extras.lang.typescript:** support `node` debug type along with `pwa-node` ([#2983](https://github.com/LazyVim/LazyVim/issues/2983)) ([d36e3a5](https://github.com/LazyVim/LazyVim/commit/d36e3a5c73c07f54b31c4ec5334f68ed5492123e)) +* **fzf-native:** try rebuilding fzf-native when needed. Fixes [#2464](https://github.com/LazyVim/LazyVim/issues/2464) ([39901c1](https://github.com/LazyVim/LazyVim/commit/39901c1f00eca36beb211978164744ae41be7781)) +* **gitsigns:** update deprecated hunk nav mappings ([#2935](https://github.com/LazyVim/LazyVim/issues/2935)) ([fc5ee49](https://github.com/LazyVim/LazyVim/commit/fc5ee49495093fe8e63b1648f81af371c2930129)) +* **keymaps:** better up/down keymaps description ([#1909](https://github.com/LazyVim/LazyVim/issues/1909)) ([36802fe](https://github.com/LazyVim/LazyVim/commit/36802fea198f536ac20c0e2514fc4f54cee2904b)) +* **lazyfile:** exclude `filetypedetect` from skips ([#3004](https://github.com/LazyVim/LazyVim/issues/3004)) ([c54eeb5](https://github.com/LazyVim/LazyVim/commit/c54eeb53905e8da27814f52eaf1ad63aeff4cbe4)) +* **lsp:** check if `diagnostics.signs` is disabled by user ([#2897](https://github.com/LazyVim/LazyVim/issues/2897)) ([6a25450](https://github.com/LazyVim/LazyVim/commit/6a2545025eb6fcc78998b8a4c6d121729980925b)) +* **pretty_path:** properly escape `%` characters ([e89653f](https://github.com/LazyVim/LazyVim/commit/e89653f4107724f53964a379337947490117a7dc)) +* **rust:** update creates.nvim src option to completion ([#3149](https://github.com/LazyVim/LazyVim/issues/3149)) ([8087283](https://github.com/LazyVim/LazyVim/commit/8087283fea62e5673764dfa13906eadb24110622)) + + +### Performance Improvements + +* **startup:** render a file opened from the cmdline as soon as possible and get rid of lazy_file logic ([965a469](https://github.com/LazyVim/LazyVim/commit/965a469ca8cb1d58b49c4e5d8b85430e8c6c0a25)) +* **treesitter:** dont let nvim-treesitter-textobjects stall loading treesitter ([8301096](https://github.com/LazyVim/LazyVim/commit/8301096c31f9855c74d5b732367b679bc8721b5e)) +* **treesitter:** load treesitter early during startup when opening a file from the cmdline ([b29d169](https://github.com/LazyVim/LazyVim/commit/b29d169afb7560ed4a9276e4379e28ffaed1a171)) +* **yanky:** `schedule_wrap` sqlite push to history to prevent blocking Neovim on copy/paste ([9047d04](https://github.com/LazyVim/LazyVim/commit/9047d041a8296e34ed7236e5344f5b927cd28f8b)) +* **yanky:** remove performance optim for sqlite since it has been merged upstream ([f25ac50](https://github.com/LazyVim/LazyVim/commit/f25ac504b896a522c645d456766adac2afa28801)) + +## [10.24.0](https://github.com/LazyVim/LazyVim/compare/v10.23.0...v10.24.0) (2024-05-12) + + +### Features + +* **mason-lspconfig:** allow `opts.ensure_installed` to be taken into account ([#3134](https://github.com/LazyVim/LazyVim/issues/3134)) ([8968c9e](https://github.com/LazyVim/LazyVim/commit/8968c9e9ea76f3a7616d9e249a3c9307a75fffad)) + + +### Bug Fixes + +* **neo-tree:** correctly set up `cwd` ([#3097](https://github.com/LazyVim/LazyVim/issues/3097)) ([30ce84f](https://github.com/LazyVim/LazyVim/commit/30ce84f7a7fb4e88b47ddf2f569b2ea9b7d56717)) +* **ui:** don't lazy-load dashboard-nvim ([#3107](https://github.com/LazyVim/LazyVim/issues/3107)) ([30c9e47](https://github.com/LazyVim/LazyVim/commit/30c9e4718a127f7d5a32f11c4d8dbba6b01f9858)) + +## [10.23.0](https://github.com/LazyVim/LazyVim/compare/v10.22.0...v10.23.0) (2024-05-03) + + +### Features + +* **lualine:** make path trimming configurable by user ([#3062](https://github.com/LazyVim/LazyVim/issues/3062)) ([b8475f5](https://github.com/LazyVim/LazyVim/commit/b8475f51949acf195729a1c4d057a06208a9add9)) + + +### Bug Fixes + +* **dot:** can't match kitty conf file ([#3042](https://github.com/LazyVim/LazyVim/issues/3042)) ([5fb4cf0](https://github.com/LazyVim/LazyVim/commit/5fb4cf0d365b65cb9b7afa8be047973b5fc1747a)) +* **dot:** install when list is empty ([#3052](https://github.com/LazyVim/LazyVim/issues/3052)) ([3086bf0](https://github.com/LazyVim/LazyVim/commit/3086bf03e96bfc0048e5b27f8d65a9170bca3f67)) +* **extras:** Rust-Analyzer cargo option ([#3061](https://github.com/LazyVim/LazyVim/issues/3061)) ([a96348d](https://github.com/LazyVim/LazyVim/commit/a96348d7b076819f7580ea0c0ce467630bfc7cc5)) +* **native_snippets:** Fix native_snippets for `vim.snippet api` changes ([#3083](https://github.com/LazyVim/LazyVim/issues/3083)) ([6004e8d](https://github.com/LazyVim/LazyVim/commit/6004e8d4f60549bd2c5d6f3187a28d72b21e3261)) +* **python:** make both `ruff` and `ruff_lsp` available to user ([#3060](https://github.com/LazyVim/LazyVim/issues/3060)) ([34183a2](https://github.com/LazyVim/LazyVim/commit/34183a2759828001b08679659f7d5170d7ec367e)) + +## [10.22.0](https://github.com/LazyVim/LazyVim/compare/v10.21.1...v10.22.0) (2024-04-22) + + +### Features + +* **dot:** add bashls and shellcheck ([#2879](https://github.com/LazyVim/LazyVim/issues/2879)) ([97480dc](https://github.com/LazyVim/LazyVim/commit/97480dc5d2dbb717b45a351e0b04835f138a9094)) +* **dot:** add more filetypes ([#2987](https://github.com/LazyVim/LazyVim/issues/2987)) ([15b09e8](https://github.com/LazyVim/LazyVim/commit/15b09e800ba7fb0c9ca8270a77e71083396e9db1)) +* **git:** `<leader>gb` for Git Blame Line ([9e3af10](https://github.com/LazyVim/LazyVim/commit/9e3af1070fc1932da322105708ebb32a2cd9572b)) +* **python:** use new `ruff` instead of `ruff_lsp` ([#3016](https://github.com/LazyVim/LazyVim/issues/3016)) ([cd04b58](https://github.com/LazyVim/LazyVim/commit/cd04b58fe3f7299fbca75e7eb47287617ac23fcf)) + + +### Bug Fixes + +* **edgy:** proper way of opening neo-tree. Fixes [#2984](https://github.com/LazyVim/LazyVim/issues/2984) ([6fdbc62](https://github.com/LazyVim/LazyVim/commit/6fdbc623e0a59220e754800df3b86788eca0813d)) +* **harpoon:** harpoon2 deprecated message ([#2920](https://github.com/LazyVim/LazyVim/issues/2920)) ([79fed97](https://github.com/LazyVim/LazyVim/commit/79fed97f2357b2969cb23d106137978ca7cdffb4)) +* **harpoon:** optimizes harpoon keys ([#2877](https://github.com/LazyVim/LazyVim/issues/2877)) ([50b7f42](https://github.com/LazyVim/LazyVim/commit/50b7f426f287ecfc542dd9c197e430b0aca8af04)) +* **mini.pairs:** better default for ```` ([32eacde](https://github.com/LazyVim/LazyVim/commit/32eacde793fddcca0bcfbbd494b6aa8b2c870d0f)) +* **toggle:** use new `inlay_hint.enable()` signature ([#3013](https://github.com/LazyVim/LazyVim/issues/3013)) ([5f92dc5](https://github.com/LazyVim/LazyVim/commit/5f92dc5304b99a3e76dca878d9b47557fb64f384)) +* **trouble_v3:** keymap `previous` is deprecated, use `prev` instead ([#2968](https://github.com/LazyVim/LazyVim/issues/2968)) ([0fa6360](https://github.com/LazyVim/LazyVim/commit/0fa63603afcb9b478c49a54d94314d20af00ae95)) +* **trouble_v3:** show error only when `trouble_v3` is enabled ([#2989](https://github.com/LazyVim/LazyVim/issues/2989)) ([ceb4855](https://github.com/LazyVim/LazyVim/commit/ceb4855b434c8e7095bbf47cfc3b3647532d6a2c)) +* **trouble-v3:** fix telescope integration ([9da13ef](https://github.com/LazyVim/LazyVim/commit/9da13ef7e8a0b6c07e8e35f7c93dc77f3408d38b)) + +## [10.21.1](https://github.com/LazyVim/LazyVim/compare/v10.21.0...v10.21.1) (2024-03-29) + + +### Bug Fixes + +* **lsp:** better support for diagnostics icons on Neovim nightly/stable ([aaa10e7](https://github.com/LazyVim/LazyVim/commit/aaa10e717dbe76c5b6b0ab302698f1d151863dc6)) +* **lsp:** dont define diagnostics signs on >= 0.10.0 ([64f8614](https://github.com/LazyVim/LazyVim/commit/64f86147f9f4c67548185798f755c80e03c2098a)) +* merge conflict ([349ae03](https://github.com/LazyVim/LazyVim/commit/349ae03f0997d20aa6b4a23315e62dfeab77d559)) +* **native_snippets:** don't try to enable native snippets on Neovim < 0.10.0 and show warning ([f308867](https://github.com/LazyVim/LazyVim/commit/f3088675703986b6d37061ebcf0a417c132fd45f)) + +## [10.21.0](https://github.com/LazyVim/LazyVim/compare/v10.20.1...v10.21.0) (2024-03-29) + + +### Features + +* **trouble:** added `<leader>cS` to open a trouble list of all references / definitions / ... of the item under the cursor ([7544675](https://github.com/LazyVim/LazyVim/commit/754467525b420c85150f13b2cd9e280570c7556c)) +* **trouble:** enabled edgy ([80a8b18](https://github.com/LazyVim/LazyVim/commit/80a8b18be6577dcea35748eb563ebef7cf1b3c15)) + + +### Bug Fixes + +* **mini.move:** default mini.move setup already maps the correct keys ([3166236](https://github.com/LazyVim/LazyVim/commit/3166236ff88a13e7e5b7579ae780b682f2356d62)) +* **tex:** don't override conceallevel for tex. Not sure why that was added ([914f26d](https://github.com/LazyVim/LazyVim/commit/914f26d04e6b9a61f7d4fc80ad433d75dac3f14b)) + +## [10.20.1](https://github.com/LazyVim/LazyVim/compare/v10.20.0...v10.20.1) (2024-03-28) + + +### Bug Fixes + +* **trouble-v3:** use the filtered symbols list for lualine ([4ca0bf6](https://github.com/LazyVim/LazyVim/commit/4ca0bf69dd1e4a359af6894490f794bd5fc12cf0)) + +## [10.20.0](https://github.com/LazyVim/LazyVim/compare/v10.19.0...v10.20.0) (2024-03-28) + + +### Features + +* **cmp:** added option `auto_brackets` that adds brackets to functions/methods in configured filetypes ([bf8ce80](https://github.com/LazyVim/LazyVim/commit/bf8ce8076e283ecabce6b2f2a04995b3deeeb593)) +* **extras:** added extra for mini.diff ([e29c7ac](https://github.com/LazyVim/LazyVim/commit/e29c7acd2d149da8166f2f44c920cc7d5c89971a)) +* **extras:** added extra for the `trouble.nvim` v3 beta ([bb6aa98](https://github.com/LazyVim/LazyVim/commit/bb6aa98cbfe0547150be89dc42f35e3b3eef8b5d)) +* **extras:** use mini.move instead of native move ([#2865](https://github.com/LazyVim/LazyVim/issues/2865)) ([8f1fb60](https://github.com/LazyVim/LazyVim/commit/8f1fb60f0a78cb2e83b485e1f946822812c5ff50)) +* **python:** enable auto_brackets for python, since pyright and basedpyright dont support this natively ([d95c2ba](https://github.com/LazyVim/LazyVim/commit/d95c2ba1dc75307b154c870aa808f322debc6070)) + + +### Bug Fixes + +* **config:** type filter was broken for telescope symbols ([e3075b0](https://github.com/LazyVim/LazyVim/commit/e3075b05ef9646e07639ae896bd8896f68ad5d5f)) +* **nvim-lint:** don't duplicate linters. Fixes [#2852](https://github.com/LazyVim/LazyVim/issues/2852) ([cfbd358](https://github.com/LazyVim/LazyVim/commit/cfbd3582736286433ee5532e1ea3a8d05a1e2649)) +* **statuscolumn:** right align signs when virtnum > 0 ([a786c47](https://github.com/LazyVim/LazyVim/commit/a786c471df5c048690618b6ff17fa2bc9648891d)) +* **trouble:** show message if use hasnt updated with Lazy yet after enabling the extra ([9a2f773](https://github.com/LazyVim/LazyVim/commit/9a2f7730907fd9124ec536f8dc2ad0a253f18f36)) + +## [10.19.0](https://github.com/LazyVim/LazyVim/compare/v10.18.0...v10.19.0) (2024-03-27) + + +### Features + +* **lazygit:** allow customizing the lazygit theme. Check the code to change the hl group mapping. Fixes [#2846](https://github.com/LazyVim/LazyVim/issues/2846) ([bb1480a](https://github.com/LazyVim/LazyVim/commit/bb1480a6b9ca9e524450192423eac88ba2a32e18)) + + +### Bug Fixes + +* **autocmds:** auto create directory on windows for uris. Fixes [#2442](https://github.com/LazyVim/LazyVim/issues/2442) ([7d570fa](https://github.com/LazyVim/LazyVim/commit/7d570fad7949288711c6238468add594963cabaa)) +* **keymaps:** update all keymap descriptions to be Title Case ([#2844](https://github.com/LazyVim/LazyVim/issues/2844)) ([eb9f9a8](https://github.com/LazyVim/LazyVim/commit/eb9f9a8862983abe1c7dd51f5f6bf2bd6978346f)) +* **lazygit:** error handling for getting lazygit's config path ([ce5917a](https://github.com/LazyVim/LazyVim/commit/ce5917a58965b47ed09462ddb5d160dee2b130ae)) +* **lazygit:** use `Visual` instead of `CursorLine` for selected line. Fixes [#2846](https://github.com/LazyVim/LazyVim/issues/2846) ([6ed771d](https://github.com/LazyVim/LazyVim/commit/6ed771de9dd3b14de78e83ed1c62b4f4fcee3c03)) +* **python-semshi:** better highlights ([#2839](https://github.com/LazyVim/LazyVim/issues/2839)) ([d945137](https://github.com/LazyVim/LazyVim/commit/d945137a323c6c0200af50444981c7d05ed93f3f)) + +## [10.18.0](https://github.com/LazyVim/LazyVim/compare/v10.17.3...v10.18.0) (2024-03-26) + + +### Features + +* **extras:** add dial extra ([#2798](https://github.com/LazyVim/LazyVim/issues/2798)) ([76b037d](https://github.com/LazyVim/LazyVim/commit/76b037dcc1105f23b92fe6211d747f97705413fa)) +* **lazygit:** configure lazygit nvim-remote as editor and enable nerdfont icons ([426cd3e](https://github.com/LazyVim/LazyVim/commit/426cd3ed91b90e5304802904d14dc3826da317c9)) + + +### Bug Fixes + +* **terminal:** dont use backdrop for edgy terminal windows ([fd0677f](https://github.com/LazyVim/LazyVim/commit/fd0677fb9a512c4a4a6bae534a018f361a9bfe30)) + +## [10.17.3](https://github.com/LazyVim/LazyVim/compare/v10.17.2...v10.17.3) (2024-03-26) + + +### Performance Improvements + +* **notify:** disable animation notifications. too big impact on performance for too little benefit ([f3655c3](https://github.com/LazyVim/LazyVim/commit/f3655c33a3239b67ce9c5e5a8cc384691fd8126c)) + +## [10.17.2](https://github.com/LazyVim/LazyVim/compare/v10.17.1...v10.17.2) (2024-03-26) + + +### Bug Fixes + +* **lazygit:** dont error when setting ansi color fails. Fixes [#2829](https://github.com/LazyVim/LazyVim/issues/2829) ([a26ca7b](https://github.com/LazyVim/LazyVim/commit/a26ca7bf56790f6bc35134a5037df0405437a1be)) + +## [10.17.1](https://github.com/LazyVim/LazyVim/compare/v10.17.0...v10.17.1) (2024-03-26) + + +### Bug Fixes + +* **lazygit:** allow overriding default terminal options ([bfe8c60](https://github.com/LazyVim/LazyVim/commit/bfe8c608a33255511fa3e79bf77fd7257022a525)) + +## [10.17.0](https://github.com/LazyVim/LazyVim/compare/v10.16.0...v10.17.0) (2024-03-26) + + +### Features + +* **lazygit:** lazygit now automatically uses colors from your Neovim colorscheme ([7d0dbc6](https://github.com/LazyVim/LazyVim/commit/7d0dbc6dedc2d6cb4c3bc77fa296dc07ce5927c9)) +* **neo-tree:** add mapping "O" to open with system default ([#2758](https://github.com/LazyVim/LazyVim/issues/2758)) ([b74ef23](https://github.com/LazyVim/LazyVim/commit/b74ef23a27dc4efc1cf76f14eb5ecced963d694d)) +* **options:** Disable foldtext for nightly ([#2447](https://github.com/LazyVim/LazyVim/issues/2447)) ([7ab6285](https://github.com/LazyVim/LazyVim/commit/7ab628501150b6dbaa6daae4a8ac7b864318677f)) +* **python:** allow configuring other python lsp servers than pyright, basedpyright ([3e5a5dd](https://github.com/LazyVim/LazyVim/commit/3e5a5dd621438cff4dbe29df227585b46ede7e44)) +* **util:** added util function to get a fg/bg color from the active colorscheme ([c00e3aa](https://github.com/LazyVim/LazyVim/commit/c00e3aa6b1d053e5bea7bfdfbfd3b5aedb6cb5be)) + +## [10.16.0](https://github.com/LazyVim/LazyVim/compare/v10.15.0...v10.16.0) (2024-03-22) + + +### Features + +* added LazyVim global. Will refactor specs later to use that ([6e57e86](https://github.com/LazyVim/LazyVim/commit/6e57e86c9952986a0e90055e13aa86dcde5e478e)) +* **lazyterm:** optional shell setup, mainly for pwsh. Fixes [#2151](https://github.com/LazyVim/LazyVim/issues/2151) ([3d4ab4e](https://github.com/LazyVim/LazyVim/commit/3d4ab4eb2634c9280676a7efdfb2753e5b2f8536)) +* **telescope-fzf-native:** added support for building with cmake. Fixes [#2132](https://github.com/LazyVim/LazyVim/issues/2132) ([1c13a5c](https://github.com/LazyVim/LazyVim/commit/1c13a5c10b745f741ebbb08d3963862e9d4e307e)) +* use `vim.uv` everywhere instead of `vim.loop` ([3a87c08](https://github.com/LazyVim/LazyVim/commit/3a87c08cdadb23ae88bd6eb193e8392e986df6bb)) +* use LazyVim everywhere instead of `require("lazyvim.util")` ([7a5dbea](https://github.com/LazyVim/LazyVim/commit/7a5dbeae75b553b489af8074e9a87207edf1395c)) + + +### Bug Fixes + +* add shim for vim.uv just in case someone upgrades lazyvim before lazy ([4b8fe44](https://github.com/LazyVim/LazyVim/commit/4b8fe44c08610be7a0603d84ae03ca81a98cbeee)) +* **cmake:** lazy load cmake-tools. Fixes [#2767](https://github.com/LazyVim/LazyVim/issues/2767) ([69aedc2](https://github.com/LazyVim/LazyVim/commit/69aedc265724c71711753333e3b7506fbeab78ef)) +* **format:** Don't leak bufnr into opts tables ([#2794](https://github.com/LazyVim/LazyVim/issues/2794)) ([213493e](https://github.com/LazyVim/LazyVim/commit/213493e766df7a5405050205f6050ff24e5a2d6d)) +* **java:** dont error when not using cmp. Fixes [#2038](https://github.com/LazyVim/LazyVim/issues/2038) ([8d31bf2](https://github.com/LazyVim/LazyVim/commit/8d31bf230cf9ad872ad50251d405ed628c9e69ae)) +* **python:** basedpyright is now supported by mason-lspconfig ([4187417](https://github.com/LazyVim/LazyVim/commit/4187417158a22ff80a059a73f2eddb113f59c113)) +* **util.telescope:** make `show_untracked` configurable ([#2789](https://github.com/LazyVim/LazyVim/issues/2789)) ([1661759](https://github.com/LazyVim/LazyVim/commit/1661759d3358dbaa4be834f0022d53071b6fb21c)) + +## [10.15.0](https://github.com/LazyVim/LazyVim/compare/v10.14.0...v10.15.0) (2024-03-20) + + +### Features + +* **python:** added option to configure basedpyright as lsp. Check the python extra docs. Fixes [#2787](https://github.com/LazyVim/LazyVim/issues/2787) ([f055265](https://github.com/LazyVim/LazyVim/commit/f055265bff24f047320bca1a402ab55a32b35111)) + + +### Bug Fixes + +* **lsp:** dont auto install disabled lsp servers ([fa0e538](https://github.com/LazyVim/LazyVim/commit/fa0e538838f2bd3b429a98a6d676dacb7b0916af)) + +## [10.14.0](https://github.com/LazyVim/LazyVim/compare/v10.13.0...v10.14.0) (2024-03-19) + + +### Features + +* **lualine:** add `modified_sign` to `pretty_path` ([#2754](https://github.com/LazyVim/LazyVim/issues/2754)) ([ed44b24](https://github.com/LazyVim/LazyVim/commit/ed44b246b443939ca7755bef1522c68df94c2a76)) +* **mini.ai:** add more objects d,e,g,u,U ([#2769](https://github.com/LazyVim/LazyVim/issues/2769)) ([f655139](https://github.com/LazyVim/LazyVim/commit/f65513928127ec4e2e4187af36ec49255bd0f5fb)) + + +### Bug Fixes + +* **extras:** accept symlinks in User `extras` directory ([#2745](https://github.com/LazyVim/LazyVim/issues/2745)) ([6a37171](https://github.com/LazyVim/LazyVim/commit/6a37171df6391482a3440cf607c173525bc875ba)) +* **format:** format injected langs does not wait 300ms ([#2737](https://github.com/LazyVim/LazyVim/issues/2737)) ([52ee7ef](https://github.com/LazyVim/LazyVim/commit/52ee7ef6962f499114f8e91230ef5558444e3a0c)) +* **git:** use compatible function for windows and linux ([#2740](https://github.com/LazyVim/LazyVim/issues/2740)) ([42a7e79](https://github.com/LazyVim/LazyVim/commit/42a7e79d5a09936ee521cab29d601d336c396c18)) +* **lazygit:** make sure we start lazygit in a valid git root ([d8d380a](https://github.com/LazyVim/LazyVim/commit/d8d380a60e7dc396fcf2fee90ace77760585d685)) +* **neotest:** add required nvim-nio to test and dap extra (neotest and nvim-dap-ui respectively) ([#2763](https://github.com/LazyVim/LazyVim/issues/2763)) ([393a9c7](https://github.com/LazyVim/LazyVim/commit/393a9c7c7ab2c37a69a9b5da609c27fa2fd3816c)) + +## [10.13.0](https://github.com/LazyVim/LazyVim/compare/v10.12.1...v10.13.0) (2024-03-14) + + +### Features + +* **git:** add <leader>gf for lazygit commit history on current file ([#2728](https://github.com/LazyVim/LazyVim/issues/2728)) ([0ec7a90](https://github.com/LazyVim/LazyVim/commit/0ec7a9040b60943597649940619f23bfa4b46990)) +* **lualine:** add more hl options to pretty_path ([#2687](https://github.com/LazyVim/LazyVim/issues/2687)) ([d3761ed](https://github.com/LazyVim/LazyVim/commit/d3761eded733b5f00e1ee14fef3fb2ce0dfb7dd0)) + + +### Bug Fixes + +* **conform:** make `lsp_fallback` option user configurable ([#2616](https://github.com/LazyVim/LazyVim/issues/2616)) ([afca0b7](https://github.com/LazyVim/LazyVim/commit/afca0b7876abf9022ee0754270f603e981ea42a5)) +* **markdown:** disable headlines.nvim bullets for now ([843032e](https://github.com/LazyVim/LazyVim/commit/843032ef1c751abf732b6f1d989584c199f049fb)) +* **markdown:** disable headlines.nvim in insert mode. Fixes [#2717](https://github.com/LazyVim/LazyVim/issues/2717) ([0ba731a](https://github.com/LazyVim/LazyVim/commit/0ba731a87977e98f2420e2c6d2c4cabbcedaff60)) +* **mini.files:** description for `g.` keybinding in mini.files ([#2693](https://github.com/LazyVim/LazyVim/issues/2693)) ([9915234](https://github.com/LazyVim/LazyVim/commit/991523431ff779b3bfe8ae133fa8109d8950d361)) +* **options:** dont set clipboard in an SSH session, so that OSC52 can be enabled (when supported) ([1c9f416](https://github.com/LazyVim/LazyVim/commit/1c9f4160a22dbdca2db36169460fcf28641607e7)) +* **rust:** don't overwrite `vim.g.rustaceanvim` if it is defined ([#2720](https://github.com/LazyVim/LazyVim/issues/2720)) ([2a666ac](https://github.com/LazyVim/LazyVim/commit/2a666ac5f2d91f0a1f1b711281dd72725f9759a1)) +* **terraform-extra:** Drop unnecessary commentstring config for terraform ([#2680](https://github.com/LazyVim/LazyVim/issues/2680)) ([b12e742](https://github.com/LazyVim/LazyVim/commit/b12e7424580d4b524755eec33006d4517fa3182e)) +* **which-key:** add group description for folds ([#2496](https://github.com/LazyVim/LazyVim/issues/2496)) ([623297e](https://github.com/LazyVim/LazyVim/commit/623297efa688283b54f1b9ad169feca69aaaae67)) + +## [10.12.1](https://github.com/LazyVim/LazyVim/compare/v10.12.0...v10.12.1) (2024-03-08) + + +### Bug Fixes + +* **extras:** automatically rename extra symbols-outline => outline. Fixes [#2675](https://github.com/LazyVim/LazyVim/issues/2675) ([ee2e876](https://github.com/LazyVim/LazyVim/commit/ee2e876252c82458d47617b6d87d827ea442ddcd)) +* **extras:** prevent duplicate extra imports ([935bc22](https://github.com/LazyVim/LazyVim/commit/935bc2283f9968a8fb1fc2466a14618a838cb904)) +* **haskell:** Make Haskell-snippets lazy load for performance ([#2676](https://github.com/LazyVim/LazyVim/issues/2676)) ([04bc571](https://github.com/LazyVim/LazyVim/commit/04bc5718a51364dddf365ba9163b2a1c7d74071d)) +* **hi-patterns:** correct regex for shorthand hex colors. See #[#2562](https://github.com/LazyVim/LazyVim/issues/2562) ([7415231](https://github.com/LazyVim/LazyVim/commit/7415231855f8173e9664c035a1a631da8c664948)) + +## [10.12.0](https://github.com/LazyVim/LazyVim/compare/v10.11.1...v10.12.0) (2024-03-07) + + +### Features + +* **lang:** replace rust-tools.nvim with rustacean.nvim [#2198](https://github.com/LazyVim/LazyVim/issues/2198) ([139c41c](https://github.com/LazyVim/LazyVim/commit/139c41c18ed7bde8dbaf5ef18afc063a96092954)) + + +### Bug Fixes + +* **extras:** set correct priority for outline extra. Fixes [#2666](https://github.com/LazyVim/LazyVim/issues/2666) ([4745314](https://github.com/LazyVim/LazyVim/commit/474531407454cb69f1d09e4bc1120b9571dc8697)) + +## [10.11.1](https://github.com/LazyVim/LazyVim/compare/v10.11.0...v10.11.1) (2024-03-07) + + +### Bug Fixes + +* **extras:** show rename of symbols-outline => outline ([c6736ef](https://github.com/LazyVim/LazyVim/commit/c6736ef2b8962a9b0a8d5cb5916f1b11835ac090)) + +## [10.11.0](https://github.com/LazyVim/LazyVim/compare/v10.10.0...v10.11.0) (2024-03-07) + + +### Features + +* **autocmds:** added support for copy/paste through ssh. Needs Neovim >= 0.10.0 ([21ca466](https://github.com/LazyVim/LazyVim/commit/21ca466db13e68740aa3348c7406369c53062a9e)) +* **extras:** add harpoon2 ([#2455](https://github.com/LazyVim/LazyVim/issues/2455)) ([cae22ba](https://github.com/LazyVim/LazyVim/commit/cae22baf082dcf68c5a4074ca4f6534589d80f8d)) +* **extras:** Add scala support using nvim-metals ([#1347](https://github.com/LazyVim/LazyVim/issues/1347)) ([d250261](https://github.com/LazyVim/LazyVim/commit/d2502613ff0fe8116a3a8891006b1a880834be15)) +* **extras:** Enable project-specific plugin specs using local .lazy.lua ([#2115](https://github.com/LazyVim/LazyVim/issues/2115)) ([b949835](https://github.com/LazyVim/LazyVim/commit/b949835de50555b8a1c15b24361d6abb73d30808)) +* **hipatterns:** add shorthand hex color support ([#2562](https://github.com/LazyVim/LazyVim/issues/2562)) ([a8eeb1b](https://github.com/LazyVim/LazyVim/commit/a8eeb1b75d9df360f2b63f0f52708f24172990e5)) +* **java:** allow opts for setup_dap_main_class_configs() ([#2581](https://github.com/LazyVim/LazyVim/issues/2581)) ([a7c16f8](https://github.com/LazyVim/LazyVim/commit/a7c16f8efd145122869ffb272d70a1229907a823)) +* **lang:** add ansible support ([#1218](https://github.com/LazyVim/LazyVim/issues/1218)) ([b7da44c](https://github.com/LazyVim/LazyVim/commit/b7da44caaed0bf7da0fd81d56f00428ff8df59d2)) +* **lang:** add Haskell config ([#2052](https://github.com/LazyVim/LazyVim/issues/2052)) ([c6c584f](https://github.com/LazyVim/LazyVim/commit/c6c584f7c3263e685e064fb84f69e58d9b625f23)) +* **lang:** add support for helm chart templates ([#2273](https://github.com/LazyVim/LazyVim/issues/2273)) ([de01a37](https://github.com/LazyVim/LazyVim/commit/de01a37cb68c3ddfb64e9576df0878a4373a6dcb)) +* **lang:** add telescope terraform integrations ([#2235](https://github.com/LazyVim/LazyVim/issues/2235)) ([d57817d](https://github.com/LazyVim/LazyVim/commit/d57817d79b18a2e9aa39db129056be3adf3c8371)) +* **lsp:** added native codelens support. Enable in lsp settings. (disabled by default). Fixes [#2656](https://github.com/LazyVim/LazyVim/issues/2656) ([780b9bb](https://github.com/LazyVim/LazyVim/commit/780b9bb337dc57bcd7f2bf4dc8bb5be62a6ce92b)) +* **omnisharp:** add `nvim-dap` configuration ([#2532](https://github.com/LazyVim/LazyVim/issues/2532)) ([f23d3ce](https://github.com/LazyVim/LazyVim/commit/f23d3cee422a8b77572a8db6fe915d374625453f)) +* **symbols-outline:** use outline.nvim instead of symbols-outline.nvim ([#2535](https://github.com/LazyVim/LazyVim/issues/2535)) ([a48b14e](https://github.com/LazyVim/LazyVim/commit/a48b14eb3e4ff03e55796dc50e08b6c8a42cccf4)) +* **treesitter:** add xml to `ensure_installed` ([#1962](https://github.com/LazyVim/LazyVim/issues/1962)) ([1b0b899](https://github.com/LazyVim/LazyVim/commit/1b0b899ab361cdabf74395449ff3c622ef74dcb1)) +* **ui:** dashboard files searches git files if in git repo ([#2240](https://github.com/LazyVim/LazyVim/issues/2240)) ([66b3c0a](https://github.com/LazyVim/LazyVim/commit/66b3c0a19fe3024d4bf1da563f7ca5a9aff58dec)) + + +### Bug Fixes + +* **ansible:** incorrect key spec ([b2a0ae6](https://github.com/LazyVim/LazyVim/commit/b2a0ae6d0d03270697359399bc33418493079a3d)) +* **autocmds:** nvim already binds q to close for man-files ([#2594](https://github.com/LazyVim/LazyVim/issues/2594)) ([16d6ac2](https://github.com/LazyVim/LazyVim/commit/16d6ac234a3fa813ed920d5e3a5fb2a8e35c20d6)) +* **dot:** remove hyprlang plugin ([#2623](https://github.com/LazyVim/LazyVim/issues/2623)) ([796112e](https://github.com/LazyVim/LazyVim/commit/796112e1707ce1a693cd76a95b84dda5529fc990)) +* **go:** adding opts recursive_run ([#2520](https://github.com/LazyVim/LazyVim/issues/2520)) ([e8e7d22](https://github.com/LazyVim/LazyVim/commit/e8e7d22f56f2a2dc2ca0c28b02884c0356df2015)) +* **lang:** Change `rustacean` keymaps to `vim.keymap.set` instead of `which-key` ([#2660](https://github.com/LazyVim/LazyVim/issues/2660)) ([ed135e6](https://github.com/LazyVim/LazyVim/commit/ed135e6ffdd8dc9a43dabe62573688934e7a1bb0)) +* **neo-tree:** Add description to "Y" in Neo-Tree ([#2642](https://github.com/LazyVim/LazyVim/issues/2642)) ([1a41743](https://github.com/LazyVim/LazyVim/commit/1a417430fc388b9a0b063017188a92d8ad14534f)) +* **options:** don't lower timeoutlen when in VS Code ([#2568](https://github.com/LazyVim/LazyVim/issues/2568)) ([29ed06e](https://github.com/LazyVim/LazyVim/commit/29ed06e0007d645d7c26b22df1346150b8e28b7f)) +* **telescope:** anonymous keymap ([#1879](https://github.com/LazyVim/LazyVim/issues/1879)) ([36ae421](https://github.com/LazyVim/LazyVim/commit/36ae4213b89191e040405c5515c24d8021f277d2)) +* **telescope:** dont use git_files when .ignore or .rgignore file is present ([e7a58d9](https://github.com/LazyVim/LazyVim/commit/e7a58d94847e6f1b282a6a717794cc454fe51faa)) +* **util.ui.fg:** Add `link=false` to show effective definition ([#2542](https://github.com/LazyVim/LazyVim/issues/2542)) ([5012d7d](https://github.com/LazyVim/LazyVim/commit/5012d7d839beede3d223c361449d0d8cb00fa098)) +* **util:** clear buffer root cache when cwd change ([#2502](https://github.com/LazyVim/LazyVim/issues/2502)) ([8386d23](https://github.com/LazyVim/LazyVim/commit/8386d23c817a3e3e4ee6302bd8e2902f7e297cf5)) +* **yanky:** properly disable sqlite.lua on Windows ([#2543](https://github.com/LazyVim/LazyVim/issues/2543)) ([d9f5e6d](https://github.com/LazyVim/LazyVim/commit/d9f5e6db165167c80fe80ede68b0e1815a81cc43)) + +## [10.10.0](https://github.com/LazyVim/LazyVim/compare/v10.9.1...v10.10.0) (2024-01-23) + + +### Features + +* added `LazyHealth` that loads all plugins and runs `:checkhealth` ([d928739](https://github.com/LazyVim/LazyVim/commit/d9287391b7ca7153320d4654e148c33463eba3a6)) +* **snippets:** added extra to use native snippets instead of LuaSnip. ([7f92191](https://github.com/LazyVim/LazyVim/commit/7f9219162b54a717b7da5cb543ab1e778c9a124b)) +* **telescope:** add <leader>fg for finding files using git-files ([#2353](https://github.com/LazyVim/LazyVim/issues/2353)) ([54ae77e](https://github.com/LazyVim/LazyVim/commit/54ae77e164e62ae9f45e864dfd727bfe1809a419)) +* **toggle:** use `vim.diagnostic.is_disabled` when available ([#2217](https://github.com/LazyVim/LazyVim/issues/2217)) ([93342f1](https://github.com/LazyVim/LazyVim/commit/93342f15badc6e7a3c213e27979b2ff31e0b393e)) + + +### Bug Fixes + +* **autocmds:** apply conceal level change to local buffer options ([#2409](https://github.com/LazyVim/LazyVim/issues/2409)) ([591f850](https://github.com/LazyVim/LazyVim/commit/591f850f8a30a08066022392fe3b23eb217dbb81)) +* **autocmds:** avoid checktime when buftype=nofile ([#2270](https://github.com/LazyVim/LazyVim/issues/2270)) ([8e2046f](https://github.com/LazyVim/LazyVim/commit/8e2046f3d02a80558802b6cbcd4c8f7d44f7b6b4)) +* **hyprlang:** use lazyvim way to install ([#2404](https://github.com/LazyVim/LazyVim/issues/2404)) ([1dffb1d](https://github.com/LazyVim/LazyVim/commit/1dffb1d853df39e2232fd39d3cf47ba3da2e8b6c)) +* **neo-tree:** better copy file name with `Y` ([eccf3b5](https://github.com/LazyVim/LazyVim/commit/eccf3b5e68035516c879b3e2b4d6bf8512c87976)) +* **options:** change default conceal level to 2 ([#2053](https://github.com/LazyVim/LazyVim/issues/2053)) ([a43d8cf](https://github.com/LazyVim/LazyVim/commit/a43d8cf35857fae4aaf1ebbd3c280cdf5b5f9d10)) +* **rust:** avoid resetting cmp group_index to 1 ([#2332](https://github.com/LazyVim/LazyVim/issues/2332)) ([f799b39](https://github.com/LazyVim/LazyVim/commit/f799b39eafedf58cdd7b123870a2c87d96eddb68)) +* **typescript:** don't hardcode values in lua table ([#2254](https://github.com/LazyVim/LazyVim/issues/2254)) ([cbd9d70](https://github.com/LazyVim/LazyVim/commit/cbd9d700dc964cf8c90759f8482911d03c72edc4)) + +## [10.9.1](https://github.com/LazyVim/LazyVim/compare/v10.9.0...v10.9.1) (2024-01-21) + + +### Bug Fixes + +* fixup for [#2137](https://github.com/LazyVim/LazyVim/issues/2137) ([fbe478a](https://github.com/LazyVim/LazyVim/commit/fbe478ae3f84ff842d18ff880af5842a50ee8e50)) + +## [10.9.0](https://github.com/LazyVim/LazyVim/compare/v10.8.2...v10.9.0) (2024-01-21) + + +### Features + +* **autocmds:** dont use conceal for json files ([23fe52a](https://github.com/LazyVim/LazyVim/commit/23fe52acd78c8e8f7c35c3ce4c1bae830adfa357)) +* **gitsigns:** update gitsigns.nvim preview command ([#2178](https://github.com/LazyVim/LazyVim/issues/2178)) ([f4ddb16](https://github.com/LazyVim/LazyVim/commit/f4ddb16b262e5ba14b417dc53bfd09d5b21f8a73)) +* **keymaps:** add function to toggle between light/dark backgrounds ([#2088](https://github.com/LazyVim/LazyVim/issues/2088)) ([fa6158a](https://github.com/LazyVim/LazyVim/commit/fa6158a59500c816b652e0fcb4c343270be54b6c)) +* **lsp:** add diagnostic signs to lsp options ([#2192](https://github.com/LazyVim/LazyVim/issues/2192)) ([33830f1](https://github.com/LazyVim/LazyVim/commit/33830f1e7d2e5a54fec676ce6e43a4a61882aaa9)) +* **neo-tree:** Adds copy file name command to Neo-Tree with 'Y' binding ([#2137](https://github.com/LazyVim/LazyVim/issues/2137)) ([5296d42](https://github.com/LazyVim/LazyVim/commit/5296d42e6ab4f6df80e801542382a3d774298364)) +* **test:** Add <leader>tl to neotest.run_last() ([#1968](https://github.com/LazyVim/LazyVim/issues/1968)) ([b71feb7](https://github.com/LazyVim/LazyVim/commit/b71feb7e45420a6e6dcac2f4491b73b70c32e5c7)) + + +### Bug Fixes + +* **dot:** treesitter for hypr was renamed to hyprlang ([979bb95](https://github.com/LazyVim/LazyVim/commit/979bb952a69d7dafac125da69cb27b70d5403f52)) +* **eslint:** correct working directories name ([#2071](https://github.com/LazyVim/LazyVim/issues/2071)) ([71a73e8](https://github.com/LazyVim/LazyVim/commit/71a73e8334a3692c549a09169e0f7a33923520f1)) + +## [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) diff --git a/NEWS.md b/NEWS.md index 50b72da3..05a1ddce 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,7 +1,95 @@ # What's new? +## 11.x + +- **Neovim >= 0.10** now uses the much faster [lazydev.nvim](https://github.com/folke/lazydev.nvim) + instead of `neodev.nvim` + +- moved `neoconf.nvim` to extras. Project specific LSP settings + can be done with a `.lazy.lua` file instead. + +- `mini.ai` is back as a default plugin! Removing it was a mistake. + It's a great plugin that enhances the native text objects. + +- `:LazyExtras` now has multiple new sections: + + - **Enabled**: extras that are currently enabled + - **Recommended Languages**: language extras recommended for the current buffer / directory + - **Recommended Plugins**: extras that are recommended for most users + - **Plugins**: other plugin extras + - **Languages**: other language extras + +- new option `vim.g.deprecation_warnings` to disable deprecation warnings + Defaults to `false`. To enable deprecation warnings, set it to `true` in your `options.lua` + +- `vim-illuminate` move to extras + Document highlights now use native lsp functionality by default + +Since Neovim 0.10 has been released, I've been working on a new version of **LazyVim** +that is fully compatible with all the latest Neovim features. + +Additionally, some core plugins have been moved to extras. + +- `native snippets` are now the default on Neovim 0.10 + Older versions of Neovim will use the new `luasnip` extra. + +- `native comments` are now the default on Neovim 0.10 + Older versions of Neovim will use the new `mini-comment` extra. + `nvim-ts-context-commentstring` has been integrated in the native comments. + +- `inlay hints` have been in **LazyVim** for a while, but are now + enabled by default. To disable them: + + ```lua + { + "nvim-lspconfig", + opts = { + inlay_hints = { enabled = false }, + } + } + ``` + +- plugins moved to extras: + + - `mini.surround` + - `mini.indentscope` scopes are now also highlighted with `indent-blankline` + - `nvim-treesitter-context` + ## 10.x +- added new extra for [mini.diff](https://github.com/echasnovski/mini.nvim/blob/main/readmes/mini-diff.md) + This is a plugin similar to gitsigns but with a neat diff overlay + that can be toggled with `go`. + +- **trouble.nvim** has been rewritten from scratch and is now in beta. + I've added a new extra for it (`trouble-v3`) for those of you who want to try it out. + You can find the updated docs [here](https://github.com/folke/trouble.nvim/tree/dev) + +- The **lazygit** integration now configures: + + - the theme based on the colorscheme + - nerd font icons (v3) + - editor preset is set to `nvim-remote` for better interop with Neovim + +- The option `vim.g.lazygit_theme` was renamed to `vim.g.lazygit_config` + +- **lazygit** now automatically uses the colors of your current colorscheme. + This is enabled by default. To disable, add the below to your `options.lua`: + + ```lua + vim.g.lazygit_config = false + ``` + +- Added support for `basedpyright` to the **python** extra. + Enable in your `options.lua` with: + + ```lua + vim.g.lazyvim_python_lsp = "basedpyright" + ``` + + Be aware that `basedpyright` is still in development and + may not work exactly the same as `pyright`. + - User extras under `lua/plugins/extras` can now also be managed with **LazyExtras** diff --git a/README-DE.md.txt b/README-DE.md similarity index 78% rename from README-DE.md.txt rename to README-DE.md index e104f174..a9522c84 100644 --- a/README-DE.md.txt +++ b/README-DE.md @@ -1,138 +1,138 @@ -
- -
- -
- -

- Install - · - Configure - · - Docs -

- -

- - Latest release - - - Last commit - - - License - - - Stars - - - Issues - - - Repo Size - - - follow on Twitter - -

- -LazyVim ist ein Neovim setup aufgebaut auf [💤 lazy.nvim](https://github.com/folke/lazy.nvim). -Es erleichter das Anpassen und erweitern von Ihrer Konfiguration. -Anstatt von vorne anzufangen oder eine vorgefertigte Distro zu verwenden, gibt LazyVim das beste aus -beiden Welten - die Flexibilität Ihre Konfiguration zu verändern und einzustellen wie Sie es wollen -und die Einfachheit von einem vorgefertigten Setup. - -![image](https://user-images.githubusercontent.com/292349/213447056-92290767-ea16-430c-8727-ce994c93e9cc.png) - -![image](https://user-images.githubusercontent.com/292349/211285846-0b7bb3bf-0462-4029-b64c-4ee1d037fc1c.png) - -## ✨ Features - -- 🔥 Transformiere dein Neovim in eine komplette IDE -- 💤 Passe deine Konfiguration einfach an und erweitere diese mit [lazy.nvim](https://github.com/folke/lazy.nvim) -- 🚀 Extrem schnell -- 🧹 Logische Voreinstellungen für optionen, autocmds und keymaps -- 📦 Kommt mit einem Haufen vor Konfigurierten, ready to use Plugins - -## ⚡️ Vorraussetzungen - -- Neovim >= **0.8.0** (gebraucht um mit **LuaJIT** zu bauen) -- Git >= **2.19.0** (um Teil-Klone zu unterstützen) -- eine [Nerd Font](https://www.nerdfonts.com/) **_(optional)_** - -## 🚀 Einstieg - -Sie können eine Startvorlage für **LazyVim** [hier](https://github.com/LazyVim/starter) finden - -
Versuchen Sie's mit Docker - -```sh -docker run -w /root -it --rm alpine:edge sh -uelic ' - apk add git lazygit neovim ripgrep alpine-sdk --update - git clone https://github.com/LazyVim/starter ~/.config/nvim - cd ~/.config/nvim - nvim -' -``` - -
- -
Installieren von LazyVim Starter - -- Neovim Files sichern: - - ```sh - mv ~/.config/nvim ~/.config/nvim.bak - mv ~/.local/share/nvim ~/.local/share/nvim.bak - ``` - -- Den Starter Klonen: - - ```sh - git clone https://github.com/LazyVim/starter ~/.config/nvim - ``` - -- Den `.git` Folder löschen, um die Konfiguration zu einer eigenen distro hinzuzufügen: - - ```sh - rm -rf ~/.config/nvim/.git - ``` - -- Neovim starten! - - ```sh - nvim - ``` - - Refer to the comments in the files on how to customize **LazyVim**. - -
- -## 📂 File Structure - -The files under config will be automatically loaded at the appropriate time, -so you don't need to require those files manually. -**LazyVim** comes with a set of default config files that will be loaded -**_before_** your own. See [here](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/config) - -You can add your custom plugin specs under `lua/plugins/`. All files there -will be automatically loaded by [lazy.nvim](https://github.com/folke/lazy.nvim) - -
-~/.config/nvim
-├── lua
-│   ├── config
-│   │   ├── autocmds.lua
-│   │   ├── keymaps.lua
-│   │   ├── lazy.lua
-│   │   └── options.lua
-│   └── plugins
-│       ├── spec1.lua
-│       ├── **
-│       └── spec2.lua
-└── init.toml
-
- -## ⚙️ Configuration - -Refer to the [docs](https://lazyvim.github.io) +
+ +
+ +
+ +

+ Installieren + · + Konfigurieren + · + Dokumentation +

+ +

+ + Latest release + + + Last commit + + + License + + + Stars + + + Issues + + + Repo Size + + + follow on Twitter + +

+ +LazyVim ist ein Neovim-Setup aufgebaut auf [💤 lazy.nvim](https://github.com/folke/lazy.nvim). +Es erleichtert das Anpassen und Erweitern von Ihrer Konfiguration. +Anstatt von vorne anzufangen oder eine vorgefertigte Distro zu verwenden, gibt LazyVim das beste aus +beiden Welten - die Flexibilität Ihre Konfiguration zu verändern und einzustellen wie Sie es wollen +und die Einfachheit von einem vorgefertigten Setup. + +![image](https://user-images.githubusercontent.com/292349/213447056-92290767-ea16-430c-8727-ce994c93e9cc.png) + +![image](https://user-images.githubusercontent.com/292349/211285846-0b7bb3bf-0462-4029-b64c-4ee1d037fc1c.png) + +## ✨ Features + +- 🔥 Transformiere dein Neovim in eine komplette IDE +- 💤 Passe deine Konfiguration einfach an und erweitere diese mit [lazy.nvim](https://github.com/folke/lazy.nvim) +- 🚀 Extrem schnell +- 🧹 Logische Voreinstellungen für optionen, autocmds und keymaps +- 📦 Kommt mit einem Haufen vorkonfigurierter, ready-to-use Plugins + +## ⚡️ Vorraussetzungen + +- Neovim >= **0.8.0** (gebraucht um mit **LuaJIT** zu bauen) +- Git >= **2.19.0** (um Teil-Klone zu unterstützen) +- eine [Nerd Font](https://www.nerdfonts.com/) **_(optional)_** + +## 🚀 Einstieg + +Sie können eine Startvorlage für **LazyVim** [hier](https://github.com/LazyVim/starter) finden + +
Versuchen Sie's mit Docker + +```sh +docker run -w /root -it --rm alpine:edge sh -uelic ' + apk add git lazygit neovim ripgrep alpine-sdk --update + git clone https://github.com/LazyVim/starter ~/.config/nvim + cd ~/.config/nvim + nvim +' +``` + +
+ +
Installieren von LazyVim Starter + +- Neovim Files sichern: + + ```sh + mv ~/.config/nvim ~/.config/nvim.bak + mv ~/.local/share/nvim ~/.local/share/nvim.bak + ``` + +- Den Starter Klonen: + + ```sh + git clone https://github.com/LazyVim/starter ~/.config/nvim + ``` + +- Den `.git` Folder löschen, um die Konfiguration zu einer eigenen distro hinzuzufügen: + + ```sh + rm -rf ~/.config/nvim/.git + ``` + +- Neovim starten! + + ```sh + nvim + ``` + + Refer to the comments in the files on how to customize **LazyVim**. + +
+ +## 📂 Dateistruktur + +Die Dateien unter `config` werden automatisch und zur richtigen Zeit geladen, +sodass ein manuelles `require` nicht nötig ist. +**LazyVim** bringt Konfigurationsdatein mit, die **_vor_** Ihren eigenen geladen werden - +siehe [hier](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/config) +Sie können eigene Plugins unter `lua/plugins/` hinzufügen. Alle Dateien innerhalb +dieses Ordners werden automatisch mit [lazy.nvim](https://github.com/folke/lazy.nvim) +geladen. + +
+~/.config/nvim
+├── lua
+│   ├── config
+│   │   ├── autocmds.lua
+│   │   ├── keymaps.lua
+│   │   ├── lazy.lua
+│   │   └── options.lua
+│   └── plugins
+│       ├── spec1.lua
+│       ├── **
+│       └── spec2.lua
+└── init.toml
+
+ +## ⚙️ Konfiguration + +Siehe [Dokumentation](https://lazyvim.github.io). diff --git a/README-JP.md b/README-JP.md new file mode 100644 index 00000000..316ede80 --- /dev/null +++ b/README-JP.md @@ -0,0 +1,139 @@ +
+ +
+ +
+ +

+ インストール + · + 設定 + · + ドキュメント +

+ +

+ + Latest release + + + Last commit + + + License + + + Stars + + + Issues + + + Repo Size + + + follow on Twitter + +

+ +LazyVimは、設定の拡張と変更を容易にするために[💤 lazy.nvim](https://github.com/folke/lazy.nvim)によって提供されるNeovimセットアップです。 +LazyVimは、ゼロから始めるか、あらかじめ作成されたディストリビューションを使用するかの選択を迫ることなく、 +必要に応じて設定を調整する柔軟性と、事前に設定されたセットアップの利便性を両方叶える最高の世界を提供します。 + +![image](https://user-images.githubusercontent.com/292349/211285846-0b7bb3bf-0462-4029-b64c-4ee1d037fc1c.png) + +![image](https://user-images.githubusercontent.com/292349/213447056-92290767-ea16-430c-8727-ce994c93e9cc.png) + +## ✨ 機能 + +- 🔥 Neovimを本格的なIDEへと変身させます +- 💤 [lazy.nvim](https://github.com/folke/lazy.nvim)で簡単にカスタマイズと拡張が可能 +- 🚀 驚くほどの高速さ +- 🧹 Options, autocmds, そしてkeymapsのための合理的なデフォルト設定 +- 📦 事前に設定がされ、使用可能なプラグインが豊富についてきます + +## ⚡️ 必要要件 + +- Neovim >= **0.9.0** (**LuaJIT**でビルドされている必要があります) +- Git >= **2.19.0** (部分的なcloneサポートのため) +- [Nerd Font](https://www.nerdfonts.com/) **_(任意)_** +- `nvim-treesitter`用の**C**コンパイラ。詳細は[こちら](https://github.com/nvim-treesitter/nvim-treesitter#requirements) + +## 🚀 Getting Started + +**lazyvim**のスターターテンプレートは[こちら](https://github.com/lazyvim/starter)。 + +
Dockerで試す + +```sh +docker run -w /root -it --rm alpine:edge sh -uelic ' + apk add git lazygit neovim ripgrep alpine-sdk --update + git clone https://github.com/LazyVim/starter ~/.config/nvim + cd ~/.config/nvim + nvim +' +``` + +
+ +
LazyVim Starterをインストール + +- 既存のNeovimファイルのバックアップを作成します。 + + ```sh + mv ~/.config/nvim ~/.config/nvim.bak + mv ~/.local/share/nvim ~/.local/share/nvim.bak + ``` + +- スターターをcloneします。 + + ```sh + git clone https://github.com/LazyVim/starter ~/.config/nvim + ``` + +- 後ほど自分のリポジトリに加えられるように、`.git`フォルダを削除します。 + ```sh + rm -rf ~/.config/nvim/.git + ``` + +- Neovimを起動します! + + ```sh + nvim + ``` + + **LazyVim**をカスタマイズするために、ファイルのコメントを参照してください。 + +
+ +--- + +[@elijahmanor](https://github.com/elijahmanor)氏によって作成された始めるにあたっての概要動画があります。 + +[![動画を見る](https://img.youtube.com/vi/N93cTbtLCIM/hqdefault.jpg)](https://www.youtube.com/watch?v=N93cTbtLCIM) + +## 📂 ファイル構造 + +config配下にあるファイルは適切なタイミングで自動的にロードされる為、 +手動でそれらのファイルをrequireする必要はありません。 +LazyVimには、自分で設定したものより先にロードされるデフォルトの設定ファイルが付属しています。詳しくは[こちら](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/config)。 +カスタムプラグインをlua/plugins/の下に追加することができます。lua/plugins/配下の全てのファイルは[lazy.nvim](https://github.com/folke/lazy.nvim)によって自動的にロードされます。 + +
+~/.config/nvim
+├── lua
+│   ├── config
+│   │   ├── autocmds.lua
+│   │   ├── keymaps.lua
+│   │   ├── lazy.lua
+│   │   └── options.lua
+│   └── plugins
+│       ├── spec1.lua
+│       ├── **
+│       └── spec2.lua
+└── init.lua
+
+ +## ⚙️ 設定 + +こちらの[ドキュメント](https://lazyvim.github.io)を参照してください。 diff --git a/README-KO.md b/README-KO.md new file mode 100644 index 00000000..eb5cdb1d --- /dev/null +++ b/README-KO.md @@ -0,0 +1,139 @@ +
+ +
+ +
+ +

+ 설치하기 + · + 설정하기 + · + 문서 +

+ +

+ + 최신 업데이트 + + + 마지막 커밋 + + + 라이센스 + + + 스타 + + + 이슈 + + + 레파지토리 크기 + + + 트위터 + +

+ +LazyVim은 [💤 lazy.nvim](https://github.com/folke/lazy.nvim)를 기반으로 작동하는 Neovim 셋업입니다. 더 커스터마이징 가능하고, 설정들을 바꾸는 것을 쉽게 만들기위해 시작되었죠. 그저 처음부터 모든 설정들을 만지고 시작하는 방법, 또는 이미 만들어진 배포용 설정을 사용하는 방법이 있지만, LazyVIM은 이미 잘 설정된 환경과, 필요에 따라 쉽게 바꿀 수 있는 유연성을 모두 포괄합니다. 이를 통해 훨신 쉽고 편리한, 전에는 만나보실 수 없었던 새로운 Nvim의 세계를 경험하실 수 있으실 겁니다. + +![image](https://user-images.githubusercontent.com/292349/211285846-0b7bb3bf-0462-4029-b64c-4ee1d037fc1c.png) + +![image](https://user-images.githubusercontent.com/292349/213447056-92290767-ea16-430c-8727-ce994c93e9cc.png) + +## ✨ 기능 + +- 🔥 Neovim을 완벽한 IDE로 바꾸어보세요. +- 💤 lazy.vim과 함께 쉽게 커스터마이징하고, 확장하세요. +- 🚀 완전히 빠른 속도를 경험해보세요. +- 🧹 기본적으로 만져져있는 옵션, 자동커멘드, 그리고 단축키들을 아무런 추가적인 설정없이 사용해보세요. +- 📦 안정적이고 미리 설정되어져있는 플러그인들과 함게 코딩하세요. + +## ⚡️ 요구사항 + +- **0.9.0**이상의 Neovim (LuaJIT과 함께 개발이 되어져있어야함니다.) +- **2.19.0**이상의 Git (이것은 부분적인 클론기능을 지원하기 위함입니다.) +- [Nerd Font](https://www.nerdfonts.com/) **_(옵션)_** +- `nvim-treesitter`를 위한 **C** 컴파일러. [이 문서](https://github.com/nvim-treesitter/nvim-treesitter#requirements)를 확인해주시기바랍니다. + +## 🚀 시작하기 + +[이 깃헙 레파지토리](https://github.com/LazyVim/starter)에서 스타터 템플릿을 찾으실 수 있습니다. + +
도커와 함께 시작해보기 + +```sh +docker run -w /root -it --rm alpine:edge sh -uelic ' + apk add git lazygit neovim ripgrep alpine-sdk --update + git clone https://github.com/LazyVim/starter ~/.config/nvim + cd ~/.config/nvim + nvim +' +``` + +
+ +
LazyVim 스타터와 함께 시작해보기 + +- 현재 Neovim 파일들을 미리 백업: + + ```sh + mv ~/.config/nvim ~/.config/nvim.bak + mv ~/.local/share/nvim ~/.local/share/nvim.bak + ``` + +- Lazyvim 스타터 깃헙 레파지토리 복제: + + ```sh + git clone https://github.com/LazyVim/starter ~/.config/nvim + ``` + +- 나중에 본인의 레파지토리에 저장할 경우를 대비해 .git 폴더 지우기 + + ```sh + rm -rf ~/.config/nvim/.git + ``` + +- Neovim! + + ```sh + nvim + ``` + + LazyVim를 커스터마이징 하는 법에 대해 다룬 설명을 참조해주시기 바랍니다. + +
+ +--- + +유튜브에 LazyVim시작하기에 대해 [@elijahmanor](https://github.com/elijahmanor)에 의해 만들어진 영상이 있으니, 시청해 보시는 것을 추천드립니다. + +[![Watch the video](https://img.youtube.com/vi/N93cTbtLCIM/hqdefault.jpg)](https://www.youtube.com/watch?v=N93cTbtLCIM) + +## 📂 파일 구조 + +config 폴더 안에 있는 모든 파일들은 적절한 시간내에 자동으로 로드가 되기에, 아무 파일도 require를 하지 않아도 됩니다. **LazyVim**은 config폴더 안에 있는 모든 기본 파일들을 당신의 config 파일들 **전**에 불어옵니다. 이것에 대해서는, [이 문서](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/config)를 확인해 보시기 바랍니다. + +추가적인 플러그인을 설치하시거나, 미리 설치되고 설정된 플러그인들을 또 덮어서 설정을 바꾸거나, 지우거나, 추가하고 싶으실 경우에는, 그에 해당하는 lua 파일들을 `lua/plugins` 폴더 안에 추가하시면, lazy.nvim이 자동적으로 그 파일들을 로드 할 것입니다. + +
+~/.config/nvim
+├── lua
+│   ├── config
+│   │   ├── autocmds.lua
+│   │   ├── keymaps.lua
+│   │   ├── lazy.lua
+│   │   └── options.lua
+│   └── plugins
+│       ├── spec1.lua
+│       ├── **
+│       └── spec2.lua
+└── init.lua
+
+ +## ⚙️ 설정 + +[Lazyvim 공식문서](https://lazyvim.github.io)를 확인해 주시기 바랍니다. + +LazyVim 공식문서의 한국어 지원은 현재 번역 중에 있습니다. diff --git a/README-PT.md b/README-PT.md new file mode 100644 index 00000000..7fb8572e --- /dev/null +++ b/README-PT.md @@ -0,0 +1,146 @@ +
+ +
+ +
+ +

+ Instalar + · + Configurar + · + Documentação +

+ +

+ + Latest release + + + Last commit + + + License + + + Stars + + + Issues + + + Repo Size + + + follow on Twitter + +

+ +LazyVim é uma configuração de Neovim potenciada por [💤 lazy.nvim](https://github.com/folke/lazy.nvim) +para tornar fácil customizar e extender a tua configuração. +Em vez de ter de escolher entre começar de raiz ou usar +uma distribuição pré-feita, LazyVim oferece o melhor +dos dois mundos - a flexibilidade de alterar a tua configuração +como necessário, junto com a conveniência de um setup pré-configurado. + +![imagem](https://user-images.githubusercontent.com/292349/211285846-0b7bb3bf-0462-4029-b64c-4ee1d037fc1c.png) + +![imagem](https://user-images.githubusercontent.com/292349/213447056-92290767-ea16-430c-8727-ce994c93e9cc.png) + +## ✨ Características + +- 🔥 Transforma o teu Neovim num IDE completo. +- 💤 Customiza e extende a tua configuração facilmente com [lazy.nvim](https://github.com/folke/lazy.nvim) +- 🚀 Super rápido +- 🧹 Definições comuns para options, autocms e keymaps +- 📦 Contém uma variedade de plugins pré-configurados e preparados a usar + +## ⚡️ Requesitos + +- Neovim >= **0.9.0** (preciso fazer build com **LuaJIT**) +- Git >= **2.19.0** (para suporte parcial de clones) +- uma [Nerd Font](https://www.nerdfonts.com/) **_(opcional)_** +- um compilador de **C** para `nvim-treesitter`. Mais informações [aqui](https://github.com/nvim-treesitter/nvim-treesitter#requirements) + +## 🚀 Como Começar + +Podes encontrar uma template **LazyVim** starter para começar, [aqui](https://github.com/LazyVim/starter) + +
Experimenta com docker + +```sh +docker run -w /root -it --rm alpine:edge sh -uelic ' + apk add git lazygit neovim ripgrep alpine-sdk --update + git clone https://github.com/LazyVim/starter ~/.config/nvim + cd ~/.config/nvim + nvim +' +``` + +
+ +
Instala a template LazyVim Starter + +- Faz um backup da tua configuração atual de Neovim: + + ```sh + mv ~/.config/nvim ~/.config/nvim.bak + mv ~/.local/share/nvim ~/.local/share/nvim.bak + ``` + +- Clona a template + + ```sh + git clone https://github.com/LazyVim/starter ~/.config/nvim + ``` + +- Remove o diretório `.git`, para poderes adicionar ao teu próprio repositório mais tarde + + ```sh + rm -rf ~/.config/nvim/.git + ``` + +- Inicia o Neovim! + + ```sh + nvim + ``` + + Consulta os comentários nos ficheiros sobre como customizar **LazyVim**. + +
+ +--- + +Existe um excelente video criado por [@elijahmanor](https://github.com/elijahmanor) com um passo a passo para começar. + +[![Vê o video](https://img.youtube.com/vi/N93cTbtLCIM/hqdefault.jpg)](https://www.youtube.com/watch?v=N93cTbtLCIM) + +## 📂 Extrutura de ficheiros + +Os ficheiros no diretório **config** serão carregados automaticamente +no momento apropriado, por isso não é necessário carregar os plugins manualmente. +**LazyVim** vem com um conjunto de ficheiros +que serão carregados **_antes_** dos teus. Lẽ mais [aqui](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/config) + +Tu podes acrescentar a tua configuração em `lua/plugins`. Todos os ficheiros +neste diretório serão carregados automaticamente por [lazy.nvim](https://github.com/folke/lazy.nvim) + +
+~/.config/nvim
+├── lua
+│   ├── config
+│   │   ├── autocmds.lua
+│   │   ├── keymaps.lua
+│   │   ├── lazy.lua
+│   │   └── options.lua
+│   └── plugins
+│       ├── spec1.lua
+│       ├── **
+│       └── spec2.lua
+└── init.lua
+
+ +## ⚙️ Configuração + +Consulta a [documentação](https://lazyvim.github.io) diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index bb2c94cd..c8522a17 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 October 28 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2024 June 05 ============================================================================== Table of Contents *LazyVim-table-of-contents* @@ -8,6 +8,7 @@ Table of Contents *LazyVim-table-of-contents* - Getting Started |LazyVim-getting-started| - File Structure |LazyVim-file-structure| - Configuration |LazyVim-configuration| +1. Links |LazyVim-links| Install · diff --git a/lua/lazyvim/config/autocmds.lua b/lua/lazyvim/config/autocmds.lua index 4cc6f1ec..b2135870 100644 --- a/lua/lazyvim/config/autocmds.lua +++ b/lua/lazyvim/config/autocmds.lua @@ -7,7 +7,11 @@ end -- Check if we need to reload the file when it changed vim.api.nvim_create_autocmd({ "FocusGained", "TermClose", "TermLeave" }, { group = augroup("checktime"), - command = "checktime", + callback = function() + if vim.o.buftype ~= "nofile" then + vim.cmd("checktime") + end + end, }) -- Highlight on yank @@ -53,10 +57,8 @@ vim.api.nvim_create_autocmd("FileType", { "PlenaryTestPopup", "help", "lspinfo", - "man", "notify", "qf", - "query", "spectre_panel", "startuptime", "tsplayground", @@ -71,6 +73,15 @@ vim.api.nvim_create_autocmd("FileType", { end, }) +-- make it easier to close man-files when opened inline +vim.api.nvim_create_autocmd("FileType", { + group = augroup("man_unlisted"), + pattern = { "man" }, + callback = function(event) + vim.bo[event.buf].buflisted = false + end, +}) + -- wrap and check for spell in text filetypes vim.api.nvim_create_autocmd("FileType", { group = augroup("wrap_spell"), @@ -81,14 +92,23 @@ vim.api.nvim_create_autocmd("FileType", { end, }) +-- Fix conceallevel for json files +vim.api.nvim_create_autocmd({ "FileType" }, { + group = augroup("json_conceal"), + pattern = { "json", "jsonc", "json5" }, + callback = function() + vim.opt_local.conceallevel = 0 + end, +}) + -- Auto create dir when saving a file, in case some intermediate directory does not exist vim.api.nvim_create_autocmd({ "BufWritePre" }, { group = augroup("auto_create_dir"), callback = function(event) - if event.match:match("^%w%w+://") then + if event.match:match("^%w%w+:[\\/][\\/]") then return end - local file = vim.loop.fs_realpath(event.match) or event.match + local file = vim.uv.fs_realpath(event.match) or event.match vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p") end, }) diff --git a/lua/lazyvim/config/init.lua b/lua/lazyvim/config/init.lua index 12d49ed6..5cd3283e 100644 --- a/lua/lazyvim/config/init.lua +++ b/lua/lazyvim/config/init.lua @@ -1,9 +1,10 @@ -local Util = require("lazyvim.util") +_G.LazyVim = require("lazyvim.util") ---@class LazyVimConfig: LazyVimOptions local M = {} -M.version = "10.7.1" -- x-release-please-version +M.version = "10.21.1" -- x-release-please-version +LazyVim.config = M ---@class LazyVimOptions local defaults = { @@ -131,7 +132,7 @@ local defaults = { } M.json = { - version = 2, + version = 6, data = { version = nil, ---@type string? news = {}, ---@type table @@ -149,7 +150,7 @@ function M.json.load() 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() + LazyVim.json.migrate() end end end @@ -178,18 +179,30 @@ function M.setup(opts) end M.load("keymaps") - Util.format.setup() - Util.news.setup() - Util.root.setup() + LazyVim.format.setup() + LazyVim.news.setup() + LazyVim.root.setup() vim.api.nvim_create_user_command("LazyExtras", function() - Util.extras.show() + LazyVim.extras.show() end, { desc = "Manage LazyVim extras" }) + + vim.api.nvim_create_user_command("LazyHealth", function() + vim.cmd([[Lazy! load all]]) + vim.cmd([[checkhealth]]) + end, { desc = "Load all plugins and run :checkhealth" }) + + local health = require("lazy.health") + vim.list_extend(health.valid, { + "recommended", + "desc", + "vscode", + }) end, }) - Util.track("colorscheme") - Util.try(function() + LazyVim.track("colorscheme") + LazyVim.try(function() if type(M.colorscheme) == "function" then M.colorscheme() else @@ -198,11 +211,11 @@ function M.setup(opts) end, { msg = "Could not load your colorscheme", on_error = function(msg) - Util.error(msg) + LazyVim.error(msg) vim.cmd.colorscheme("habamax") end, }) - Util.track() + LazyVim.track() end ---@param buf? number @@ -216,6 +229,9 @@ function M.get_kind_filter(buf) if M.kind_filter[ft] == false then return end + if type(M.kind_filter[ft]) == "table" then + return M.kind_filter[ft] + 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 @@ -224,7 +240,7 @@ end function M.load(name) local function _load(mod) if require("lazy.core.cache").find(mod)[1] then - Util.try(function() + LazyVim.try(function() require(mod) end, { msg = "Failed loading " .. mod }) end @@ -254,19 +270,23 @@ function M.init() end package.preload["lazyvim.plugins.lsp.format"] = function() - Util.deprecate([[require("lazyvim.plugins.lsp.format")]], [[require("lazyvim.util").format]]) - return Util.format + LazyVim.deprecate([[require("lazyvim.plugins.lsp.format")]], [[LazyVim.format]]) + return LazyVim.format end -- delay notifications till vim.notify was replaced or after 500ms - require("lazyvim.util").lazy_notify() + LazyVim.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() + if vim.g.deprecation_warnings == false then + vim.deprecate = function() end + end + + LazyVim.plugin.setup() M.json.load() end diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index c5f70016..768a41b8 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -1,46 +1,47 @@ -- This file is automatically loaded by lazyvim.config.init -local Util = require("lazyvim.util") --- DO NOT USE THIS IN YOU OWN CONFIG!! +-- DO NOT USE `LazyVim.safe_keymap_set` IN YOUR OWN CONFIG!! -- use `vim.keymap.set` instead -local map = Util.safe_keymap_set +local map = LazyVim.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 }) +map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gj' : 'j'", { desc = "Down", expr = true, silent = true }) +map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { desc = "Up", expr = true, silent = true }) +map({ "n", "x" }, "", "v:count == 0 ? 'gk' : 'k'", { desc = "Up", expr = true, silent = true }) -- Move to window using the hjkl keys -map("n", "", "h", { desc = "Go to left window", remap = true }) -map("n", "", "j", { desc = "Go to lower window", remap = true }) -map("n", "", "k", { desc = "Go to upper window", remap = true }) -map("n", "", "l", { desc = "Go to right window", remap = true }) +map("n", "", "h", { desc = "Go to Left Window", remap = true }) +map("n", "", "j", { desc = "Go to Lower Window", remap = true }) +map("n", "", "k", { desc = "Go to Upper Window", remap = true }) +map("n", "", "l", { desc = "Go to Right Window", remap = true }) -- Resize window using arrow keys -map("n", "", "resize +2", { desc = "Increase window height" }) -map("n", "", "resize -2", { desc = "Decrease window height" }) -map("n", "", "vertical resize -2", { desc = "Decrease window width" }) -map("n", "", "vertical resize +2", { desc = "Increase window width" }) +map("n", "", "resize +2", { desc = "Increase Window Height" }) +map("n", "", "resize -2", { desc = "Decrease Window Height" }) +map("n", "", "vertical resize -2", { desc = "Decrease Window Width" }) +map("n", "", "vertical resize +2", { desc = "Increase Window Width" }) -- Move Lines -map("n", "", "m .+1==", { desc = "Move down" }) -map("n", "", "m .-2==", { desc = "Move up" }) -map("i", "", "m .+1==gi", { desc = "Move down" }) -map("i", "", "m .-2==gi", { desc = "Move up" }) -map("v", "", ":m '>+1gv=gv", { desc = "Move down" }) -map("v", "", ":m '<-2gv=gv", { desc = "Move up" }) +map("n", "", "m .+1==", { desc = "Move Down" }) +map("n", "", "m .-2==", { desc = "Move Up" }) +map("i", "", "m .+1==gi", { desc = "Move Down" }) +map("i", "", "m .-2==gi", { desc = "Move Up" }) +map("v", "", ":m '>+1gv=gv", { desc = "Move Down" }) +map("v", "", ":m '<-2gv=gv", { desc = "Move Up" }) -- buffers -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", "", "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" }) +map("n", "bd", LazyVim.ui.bufremove, { desc = "Delete Buffer" }) +map("n", "bD", ":bd", { desc = "Delete Buffer and Window" }) -- Clear search with -map({ "i", "n" }, "", "noh", { desc = "Escape and clear hlsearch" }) +map({ "i", "n" }, "", "noh", { desc = "Escape and Clear hlsearch" }) -- Clear search, diff update and redraw -- taken from runtime/lua/_editor.lua @@ -48,16 +49,16 @@ map( "n", "ur", "nohlsearchdiffupdatenormal! ", - { desc = "Redraw / clear hlsearch / diff update" } + { desc = "Redraw / Clear hlsearch / Diff Update" } ) -- https://github.com/mhinz/vim-galore#saner-behavior-of-n-and-n -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].'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" }) +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].'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" }) -- Add undo break-points map("i", ",", ",u") @@ -65,7 +66,7 @@ map("i", ".", ".u") map("i", ";", ";u") -- save file -map({ "i", "x", "n", "s" }, "", "w", { desc = "Save file" }) +map({ "i", "x", "n", "s" }, "", "w", { desc = "Save File" }) --keywordprg map("n", "K", "norm! K", { desc = "Keywordprg" }) @@ -74,6 +75,10 @@ map("n", "K", "norm! K", { desc = "Keywordprg" }) map("v", "<", "", ">gv") +-- commenting +map("n", "gco", "oVcxnormal gccfxa", { desc = "Add Comment Below" }) +map("n", "gcO", "OVcxnormal gccfxa", { desc = "Add Comment Above" }) + -- lazy map("n", "l", "Lazy", { desc = "Lazy" }) @@ -83,12 +88,12 @@ map("n", "fn", "enew", { desc = "New File" }) map("n", "xl", "lopen", { desc = "Location List" }) map("n", "xq", "copen", { desc = "Quickfix List" }) -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 }) + LazyVim.format({ force = true }) end, { desc = "Format" }) -- diagnostic @@ -110,59 +115,77 @@ map("n", "[w", diagnostic_goto(false, "WARN"), { desc = "Prev Warning" }) -- stylua: ignore start -- toggle options -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") 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" }) +map("n", "uf", function() LazyVim.format.toggle() end, { desc = "Toggle Auto Format (Global)" }) +map("n", "uF", function() LazyVim.format.toggle(true) end, { desc = "Toggle Auto Format (Buffer)" }) +map("n", "us", function() LazyVim.toggle("spell") end, { desc = "Toggle Spelling" }) +map("n", "uw", function() LazyVim.toggle("wrap") end, { desc = "Toggle Word Wrap" }) +map("n", "uL", function() LazyVim.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" }) +map("n", "ul", function() LazyVim.toggle.number() end, { desc = "Toggle Line Numbers" }) +map("n", "ud", function() LazyVim.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.inlay_hint then - map("n", "uh", function() vim.lsp.inlay_hint(0, nil) end, { desc = "Toggle Inlay Hints" }) +map("n", "uc", function() LazyVim.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" }) +if vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint then + map( "n", "uh", function() LazyVim.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" }) +map("n", "ub", function() LazyVim.toggle("background", false, {"light", "dark"}) end, { desc = "Toggle Background" }) -- lazygit -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)" }) +map("n", "gg", function() LazyVim.lazygit( { cwd = LazyVim.root.git() }) end, { desc = "Lazygit (Root Dir)" }) +map("n", "gG", function() LazyVim.lazygit() end, { desc = "Lazygit (cwd)" }) +map("n", "gb", LazyVim.lazygit.blame_line, { desc = "Git Blame Line" }) + +map("n", "gf", function() + local git_path = vim.api.nvim_buf_get_name(0) + LazyVim.lazygit({args = { "-f", vim.trim(git_path) }}) +end, { desc = "Lazygit Current File History" }) + +map("n", "gl", function() + LazyVim.lazygit({ args = { "log" }, cwd = LazyVim.root.git() }) +end, { desc = "Lazygit Log" }) +map("n", "gL", function() + LazyVim.lazygit({ args = { "log" } }) +end, { desc = "Lazygit Log (cwd)" }) -- quit -map("n", "qq", "qa", { desc = "Quit all" }) +map("n", "qq", "qa", { desc = "Quit All" }) -- highlights under cursor map("n", "ui", vim.show_pos, { desc = "Inspect Pos" }) +map("n", "uI", "InspectTree", { desc = "Inspect Tree" }) -- LazyVim Changelog -map("n", "L", function() Util.news.changelog() end, { desc = "LazyVim Changelog" }) +map("n", "L", function() LazyVim.news.changelog() end, { desc = "LazyVim Changelog" }) -- floating terminal -local lazyterm = function() Util.terminal(nil, { cwd = Util.root() }) end -map("n", "ft", lazyterm, { desc = "Terminal (root dir)" }) -map("n", "fT", function() Util.terminal() end, { desc = "Terminal (cwd)" }) -map("n", "", lazyterm, { desc = "Terminal (root dir)" }) +local lazyterm = function() LazyVim.terminal(nil, { cwd = LazyVim.root() }) end +map("n", "ft", lazyterm, { desc = "Terminal (Root Dir)" }) +map("n", "fT", function() LazyVim.terminal() end, { desc = "Terminal (cwd)" }) +map("n", "", lazyterm, { desc = "Terminal (Root Dir)" }) map("n", "", lazyterm, { desc = "which_key_ignore" }) -- Terminal Mappings map("t", "", "", { desc = "Enter Normal Mode" }) -map("t", "", "wincmd h", { desc = "Go to left window" }) -map("t", "", "wincmd j", { desc = "Go to lower window" }) -map("t", "", "wincmd k", { desc = "Go to upper window" }) -map("t", "", "wincmd l", { desc = "Go to right window" }) +map("t", "", "wincmd h", { desc = "Go to Left Window" }) +map("t", "", "wincmd j", { desc = "Go to Lower Window" }) +map("t", "", "wincmd k", { desc = "Go to Upper Window" }) +map("t", "", "wincmd l", { desc = "Go to Right Window" }) map("t", "", "close", { desc = "Hide Terminal" }) map("t", "", "close", { desc = "which_key_ignore" }) -- windows -map("n", "ww", "p", { desc = "Other window", remap = true }) -map("n", "wd", "c", { desc = "Delete window", remap = true }) -map("n", "w-", "s", { desc = "Split window below", remap = true }) -map("n", "w|", "v", { desc = "Split window right", remap = true }) -map("n", "-", "s", { desc = "Split window below", remap = true }) -map("n", "|", "v", { desc = "Split window right", remap = true }) +map("n", "ww", "p", { desc = "Other Window", remap = true }) +map("n", "wd", "c", { desc = "Delete Window", remap = true }) +map("n", "w-", "s", { desc = "Split Window Below", remap = true }) +map("n", "w|", "v", { desc = "Split Window Right", remap = true }) +map("n", "-", "s", { desc = "Split Window Below", remap = true }) +map("n", "|", "v", { desc = "Split Window Right", remap = true }) +map("n", "wm", function() LazyVim.toggle.maximize() end, { desc = "Maximize Toggle" }) +map("n", "m", function() LazyVim.toggle.maximize() end, { desc = "Maximize Toggle" }) -- tabs map("n", "l", "tablast", { desc = "Last Tab" }) +map("n", "o", "tabonly", { desc = "Close Other Tabs" }) map("n", "f", "tabfirst", { desc = "First Tab" }) map("n", "", "tabnew", { desc = "New Tab" }) map("n", "]", "tabnext", { desc = "Next Tab" }) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 3c9686b1..4480d5c5 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -2,7 +2,7 @@ vim.g.mapleader = " " vim.g.maplocalleader = "\\" --- Enable LazyVim auto format +-- LazyVim auto format vim.g.autoformat = true -- LazyVim root dir detection @@ -12,15 +12,52 @@ vim.g.autoformat = true -- * a function with signature `function(buf) -> string|string[]` vim.g.root_spec = { "lsp", { ".git", "lua" }, "cwd" } +-- LazyVim automatically configures lazygit: +-- * theme, based on the active colorscheme. +-- * editorPreset to nvim-remote +-- * enables nerd font icons +-- Set to false to disable. +vim.g.lazygit_config = true + +-- Options for the LazyVim statuscolumn +vim.g.lazyvim_statuscolumn = { + folds_open = false, -- show fold sign when fold is open + folds_githl = false, -- highlight fold sign with git sign color +} + +-- Optionally setup the terminal to use +-- This sets `vim.o.shell` and does some additional configuration for: +-- * pwsh +-- * powershell +-- LazyVim.terminal.setup("pwsh") + +-- Hide deprecation warnings +vim.g.deprecation_warnings = false + +-- Show the current document symbols location from Trouble in lualine +vim.g.trouble_lualine = true + local opt = vim.opt opt.autowrite = true -- Enable auto write -opt.clipboard = "unnamedplus" -- Sync with system clipboard +-- only set clipboard if not in ssh, to make sure the OSC 52 +-- integration works automatically. Requires Neovim >= 0.10.0 +opt.clipboard = vim.env.SSH_TTY and "" or "unnamedplus" -- Sync with system clipboard opt.completeopt = "menu,menuone,noselect" -opt.conceallevel = 3 -- Hide * markup for bold and italic +opt.conceallevel = 2 -- Hide * markup for bold and italic, but not markers with substitutions opt.confirm = true -- Confirm to save changes before exiting modified buffer opt.cursorline = true -- Enable highlighting of the current line opt.expandtab = true -- Use spaces instead of tabs +opt.fillchars = { + foldopen = "", + foldclose = "", + fold = " ", + foldsep = " ", + diff = "╱", + eob = " ", +} +opt.foldlevel = 99 +opt.formatexpr = "v:lua.require'lazyvim.util'.format.formatexpr()" opt.formatoptions = "jcroqlnt" -- tcqj opt.grepformat = "%f:%l:%c:%m" opt.grepprg = "rg --vimgrep" @@ -47,9 +84,10 @@ opt.spelllang = { "en" } opt.splitbelow = true -- Put new windows below current opt.splitkeep = "screen" opt.splitright = true -- Put new windows right of current +opt.statuscolumn = [[%!v:lua.require'lazyvim.util'.ui.statuscolumn()]] opt.tabstop = 2 -- Number of spaces tabs count for opt.termguicolors = true -- True color support -opt.timeoutlen = 300 +opt.timeoutlen = vim.g.vscode and 1000 or 300 -- Lower than default (1000) to quickly trigger which-key opt.undofile = true opt.undolevels = 10000 opt.updatetime = 200 -- Save swap file and trigger CursorHold @@ -57,37 +95,16 @@ opt.virtualedit = "block" -- Allow cursor to move where there is no text in visu 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 - 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()" + opt.foldexpr = "v:lua.require'lazyvim.util'.ui.foldexpr()" + opt.foldmethod = "expr" + opt.foldtext = "" else - vim.opt.foldmethod = "indent" + opt.foldmethod = "indent" + opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()" 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 a23c90f5..4822de86 100644 --- a/lua/lazyvim/health.lua +++ b/lua/lazyvim/health.lua @@ -10,6 +10,9 @@ function M.check() if vim.fn.has("nvim-0.9.0") == 1 then ok("Using Neovim >= 0.9.0") + if vim.fn.has("nvim-0.10.0") == 0 then + warn("Use Neovim >= 0.10.0 for the best experience") + end else error("Neovim >= 0.9.0 is required") end diff --git a/lua/lazyvim/init.lua b/lua/lazyvim/init.lua index dceae58d..a7287aa2 100644 --- a/lua/lazyvim/init.lua +++ b/lua/lazyvim/init.lua @@ -1,3 +1,5 @@ +vim.uv = vim.uv or vim.loop + local M = {} ---@param opts? LazyVimConfig diff --git a/lua/lazyvim/plugins/coding.lua b/lua/lazyvim/plugins/coding.lua index c6571433..0e903ba0 100644 --- a/lua/lazyvim/plugins/coding.lua +++ b/lua/lazyvim/plugins/coding.lua @@ -1,35 +1,5 @@ return { - -- snippets - { - "L3MON4D3/LuaSnip", - build = (not jit.os:find("Windows")) - and "echo 'NOTE: jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp" - or nil, - dependencies = { - "rafamadriz/friendly-snippets", - config = function() - require("luasnip.loaders.from_vscode").lazy_load() - end, - }, - opts = { - history = true, - delete_check_events = "TextChanged", - }, - -- stylua: ignore - keys = { - { - "", - function() - return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" - end, - expr = true, silent = true, mode = "i", - }, - { "", function() require("luasnip").jump(1) end, mode = "s" }, - { "", function() require("luasnip").jump(-1) end, mode = { "i", "s" } }, - }, - }, - -- auto completion { "hrsh7th/nvim-cmp", @@ -39,21 +9,26 @@ return { "hrsh7th/cmp-nvim-lsp", "hrsh7th/cmp-buffer", "hrsh7th/cmp-path", - "saadparwaiz1/cmp_luasnip", }, + -- Not all LSP servers add brackets when completing a function. + -- To better deal with this, LazyVim adds a custom option to cmp, + -- that you can configure. For example: + -- + -- ```lua + -- opts = { + -- auto_brackets = { "python" } + -- } + -- ``` + opts = function() vim.api.nvim_set_hl(0, "CmpGhostText", { link = "Comment", default = true }) local cmp = require("cmp") local defaults = require("cmp.config.default")() return { + auto_brackets = {}, -- configure any filetype to auto add brackets completion = { completeopt = "menu,menuone,noinsert", }, - snippet = { - expand = function(args) - require("luasnip").lsp_expand(args.body) - end, - }, mapping = cmp.mapping.preset.insert({ [""] = cmp.mapping.select_next_item({ behavior = cmp.SelectBehavior.Insert }), [""] = cmp.mapping.select_prev_item({ behavior = cmp.SelectBehavior.Insert }), @@ -61,11 +36,8 @@ return { [""] = cmp.mapping.scroll_docs(4), [""] = cmp.mapping.complete(), [""] = cmp.mapping.abort(), - [""] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. - [""] = cmp.mapping.confirm({ - behavior = cmp.ConfirmBehavior.Replace, - select = true, - }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. + [""] = LazyVim.cmp.confirm(), + [""] = LazyVim.cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items. [""] = function(fallback) cmp.abort() fallback() @@ -73,7 +45,6 @@ return { }), sources = cmp.config.sources({ { name = "nvim_lsp" }, - { name = "luasnip" }, { name = "path" }, }, { { name = "buffer" }, @@ -95,162 +66,160 @@ return { sorting = defaults.sorting, } end, - ---@param opts cmp.ConfigSchema + ---@param opts cmp.ConfigSchema | {auto_brackets?: string[]} config = function(_, opts) for _, source in ipairs(opts.sources) do source.group_index = source.group_index or 1 end - require("cmp").setup(opts) + + local parse = require("cmp.utils.snippet").parse + require("cmp.utils.snippet").parse = function(input) + local ok, ret = pcall(parse, input) + if ok then + return ret + end + return LazyVim.cmp.snippet_preview(input) + end + + local cmp = require("cmp") + cmp.setup(opts) + cmp.event:on("confirm_done", function(event) + if vim.tbl_contains(opts.auto_brackets or {}, vim.bo.filetype) then + LazyVim.cmp.auto_brackets(event.entry) + end + end) + cmp.event:on("menu_opened", function(event) + LazyVim.cmp.add_missing_snippet_docs(event.window) + end) end, }, + -- snippets + { + "nvim-cmp", + dependencies = { + { + "garymjr/nvim-snippets", + opts = { + friendly_snippets = true, + }, + dependencies = { "rafamadriz/friendly-snippets" }, + }, + }, + opts = function(_, opts) + opts.snippet = { + expand = function(item) + return LazyVim.cmp.expand(item.body) + end, + } + table.insert(opts.sources, { name = "snippets" }) + end, + keys = { + { + "", + function() + return vim.snippet.active({ direction = 1 }) and "lua vim.snippet.jump(1)" or "" + end, + expr = true, + silent = true, + mode = { "i", "s" }, + }, + { + "", + function() + return vim.snippet.active({ direction = -1 }) and "lua vim.snippet.jump(-1)" or "" + end, + expr = true, + silent = true, + mode = { "i", "s" }, + }, + }, + }, + -- auto pairs { "echasnovski/mini.pairs", event = "VeryLazy", - opts = {}, + opts = { + mappings = { + ["`"] = { action = "closeopen", pair = "``", neigh_pattern = "[^\\`].", register = { cr = false } }, + }, + }, 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" }) + LazyVim.warn("Disabled auto pairs", { title = "Option" }) else - Util.info("Enabled auto pairs", { title = "Option" }) + LazyVim.info("Enabled auto pairs", { title = "Option" }) end end, - desc = "Toggle auto pairs", - }, - }, - }, - - -- 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) - -- Populate the keys based on the user's options - local plugin = require("lazy.core.config").spec.plugins["mini.surround"] - local opts = require("lazy.core.plugin").values(plugin, "opts", false) - local mappings = { - { opts.mappings.add, desc = "Add surrounding", mode = { "n", "v" } }, - { opts.mappings.delete, desc = "Delete surrounding" }, - { opts.mappings.find, desc = "Find right surrounding" }, - { opts.mappings.find_left, desc = "Find left surrounding" }, - { opts.mappings.highlight, desc = "Highlight surrounding" }, - { opts.mappings.replace, desc = "Replace surrounding" }, - { opts.mappings.update_n_lines, desc = "Update `MiniSurround.config.n_lines`" }, - } - mappings = vim.tbl_filter(function(m) - return m[1] and #m[1] > 0 - end, mappings) - return vim.list_extend(mappings, keys) - end, - opts = { - mappings = { - 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` + desc = "Toggle Auto Pairs", }, }, }, -- comments { - "JoosepAlviste/nvim-ts-context-commentstring", - lazy = true, - opts = { - enable_autocmd = false, - }, - }, - { - "echasnovski/mini.comment", + "folke/ts-comments.nvim", event = "VeryLazy", - opts = { - options = { - custom_commentstring = function() - return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring - end, - }, - }, + opts = {}, }, -- Better text-objects { "echasnovski/mini.ai", - -- keys = { - -- { "a", mode = { "x", "o" } }, - -- { "i", mode = { "x", "o" } }, - -- }, event = "VeryLazy", opts = function() + LazyVim.on_load("which-key.nvim", function() + vim.schedule(LazyVim.mini.ai_whichkey) + end) local ai = require("mini.ai") return { n_lines = 500, custom_textobjects = { - o = ai.gen_spec.treesitter({ + o = ai.gen_spec.treesitter({ -- code block a = { "@block.outer", "@conditional.outer", "@loop.outer" }, i = { "@block.inner", "@conditional.inner", "@loop.inner" }, - }, {}), - 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][^<>]->.-", "^<.->().*()$" }, + }), + f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }), -- function + c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }), -- class + t = { "<([%p%w]-)%f[^<%w][^<>]->.-", "^<.->().*()$" }, -- tags + d = { "%f[%d]%d+" }, -- digits + e = { -- Word with case + { "%u[%l%d]+%f[^%l%d]", "%f[%S][%l%d]+%f[^%l%d]", "%f[%P][%l%d]+%f[^%l%d]", "^[%l%d]+%f[^%l%d]" }, + "^().*()$", + }, + i = LazyVim.mini.ai_indent, -- indent + g = LazyVim.mini.ai_buffer, -- buffer + u = ai.gen_spec.function_call(), -- u for "Usage" + U = ai.gen_spec.function_call({ name_pattern = "[%w_]" }), -- without dot in function name }, } end, - config = function(_, opts) - require("mini.ai").setup(opts) - -- register all text objects with which-key - require("lazyvim.util").on_load("which-key.nvim", function() - ---@type table - local i = { - [" "] = "Whitespace", - ['"'] = 'Balanced "', - ["'"] = "Balanced '", - ["`"] = "Balanced `", - ["("] = "Balanced (", - [")"] = "Balanced ) including white-space", - [">"] = "Balanced > including white-space", - [""] = "Balanced <", - ["]"] = "Balanced ] including white-space", - ["["] = "Balanced [", - ["}"] = "Balanced } including white-space", - ["{"] = "Balanced {", - ["?"] = "User Prompt", - _ = "Underscore", - a = "Argument", - b = "Balanced ), ], }", - c = "Class", - f = "Function", - o = "Block, conditional, loop", - q = "Quote `, \", '", - t = "Tag", - } - local a = vim.deepcopy(i) - for k, v in pairs(a) do - a[k] = v:gsub(" including.*", "") - end + }, - local ic = vim.deepcopy(i) - local ac = vim.deepcopy(a) - for key, name in pairs({ n = "Next", l = "Last" }) do - i[key] = vim.tbl_extend("force", { name = "Inside " .. name .. " textobject" }, ic) - a[key] = vim.tbl_extend("force", { name = "Around " .. name .. " textobject" }, ac) - end - require("which-key").register({ - mode = { "o", "x" }, - i = i, - a = a, - }) - end) + { + "folke/lazydev.nvim", + ft = "lua", + cmd = "LazyDev", + opts = { + library = { + { path = "luvit-meta/library", words = { "vim%.uv" } }, + { path = "LazyVim", words = { "LazyVim" } }, + { path = "lazy.nvim", words = { "LazyVim" } }, + }, + }, + }, + -- Manage libuv types with lazy. Plugin will never be loaded + { "Bilal2453/luvit-meta", lazy = true }, + -- Add lazydev source to cmp + { + "hrsh7th/nvim-cmp", + opts = function(_, opts) + table.insert(opts.sources, { name = "lazydev", group_index = 0 }) end, }, } diff --git a/lua/lazyvim/plugins/colorscheme.lua b/lua/lazyvim/plugins/colorscheme.lua index 8ed12bbd..bb63326e 100644 --- a/lua/lazyvim/plugins/colorscheme.lua +++ b/lua/lazyvim/plugins/colorscheme.lua @@ -14,14 +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, @@ -34,12 +39,13 @@ return { }, navic = { enabled = true, custom_bg = "lualine" }, neotest = true, + neotree = true, noice = true, notify = true, - neotree = true, semantic_tokens = true, telescope = true, treesitter = true, + treesitter_context = true, which_key = true, }, }, diff --git a/lua/lazyvim/plugins/compat/nvim-0_9.lua b/lua/lazyvim/plugins/compat/nvim-0_9.lua new file mode 100644 index 00000000..6488952b --- /dev/null +++ b/lua/lazyvim/plugins/compat/nvim-0_9.lua @@ -0,0 +1,29 @@ +-- Compatibility with Neovim 0.9 +return { + -- Use LuaSnip instead of native snippets + { "garymjr/nvim-snippets", enabled = false }, + { import = "lazyvim.plugins.extras.coding.luasnip" }, + + -- Use mini.comment instead of ts-comments + { "folke/ts-comments.nvim", enabled = false }, + { import = "lazyvim.plugins.extras.coding.mini-comment" }, + + -- Use neodev-types with lazydev + { "folke/neodev.nvim", config = function() end }, + { + "folke/lazydev.nvim", + opts = function(_, opts) + opts.library = opts.library or {} + table.insert(opts.library, { "neodev.nvim/types/stable" }) + end, + config = function(_, opts) + -- force lazydev to load on Neovim 0.9 + require("lazydev.config").have_0_10 = true + require("lazydev").setup(opts) + end, + }, + { + "neovim/nvim-lspconfig", + dependencies = {}, + }, +} diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index 8c34f357..b434ded1 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -1,4 +1,5 @@ -local Util = require("lazyvim.util") +local have_make = vim.fn.executable("make") == 1 +local have_cmake = vim.fn.executable("cmake") == 1 return { @@ -11,44 +12,55 @@ return { { "fe", function() - require("neo-tree.command").execute({ toggle = true, dir = Util.root() }) + require("neo-tree.command").execute({ toggle = true, dir = LazyVim.root() }) end, - desc = "Explorer NeoTree (root dir)", + desc = "Explorer NeoTree (Root Dir)", }, { "fE", function() - require("neo-tree.command").execute({ toggle = true, dir = vim.loop.cwd() }) + require("neo-tree.command").execute({ toggle = true, dir = vim.uv.cwd() }) end, desc = "Explorer NeoTree (cwd)", }, - { "e", "fe", desc = "Explorer NeoTree (root dir)", remap = true }, + { "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", + desc = "Git Explorer", }, { "be", function() require("neo-tree.command").execute({ source = "buffers", toggle = true }) end, - desc = "Buffer explorer", + desc = "Buffer Explorer", }, }, deactivate = function() vim.cmd([[Neotree close]]) end, init = function() - 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") - end - end + -- FIX: use `autocmd` for lazy-loading neo-tree instead of directly requiring it, + -- because `cwd` is not set up properly. + vim.api.nvim_create_autocmd("BufEnter", { + group = vim.api.nvim_create_augroup("Neotree_start_directory", { clear = true }), + desc = "Start Neo-tree with directory", + once = true, + callback = function() + if package.loaded["neo-tree"] then + return + else + local stats = vim.uv.fs_stat(vim.fn.argv(0)) + if stats and stats.type == "directory" then + require("neo-tree") + end + end + end, + }) end, opts = { sources = { "filesystem", "buffers", "git_status", "document_symbols" }, @@ -61,6 +73,20 @@ return { window = { mappings = { [""] = "none", + ["Y"] = { + function(state) + local node = state.tree:get_node() + local path = node:get_id() + vim.fn.setreg("+", path, "c") + end, + desc = "Copy Path to Clipboard", + }, + ["O"] = { + function(state) + require("lazy.util").open(state.tree:get_node().path, { system = true }) + end, + desc = "Open with System Application", + }, }, }, default_component_configs = { @@ -70,11 +96,17 @@ return { expander_expanded = "", expander_highlight = "NeoTreeExpander", }, + git_status = { + symbols = { + unstaged = "󰄱", + staged = "󰱒", + }, + }, }, }, config = function(_, opts) local function on_move(data) - Util.lsp.on_rename(data.source, data.destination) + LazyVim.lsp.on_rename(data.source, data.destination) end local events = require("neo-tree.events") @@ -98,11 +130,12 @@ return { -- search/replace in multiple files { "nvim-pack/nvim-spectre", + build = false, cmd = "Spectre", opts = { open_cmd = "noswapfile vnew" }, -- stylua: ignore keys = { - { "sr", function() require("spectre").open() end, desc = "Replace in files (Spectre)" }, + { "sr", function() require("spectre").open() end, desc = "Replace in Files (Spectre)" }, }, }, @@ -117,11 +150,23 @@ return { 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") + build = have_make and "make" + or "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build", + enabled = have_make or have_cmake, + config = function(plugin) + LazyVim.on_load("telescope.nvim", function() + local ok, err = pcall(require("telescope").load_extension, "fzf") + if not ok then + local lib = plugin.dir .. "/build/libfzf." .. (LazyVim.is_win() and "dll" or "so") + if not vim.uv.fs_stat(lib) then + LazyVim.warn("`telescope-fzf-native.nvim` not built. Rebuilding...") + require("lazy").build({ plugins = { plugin }, show = false }):wait(function() + LazyVim.info("Rebuilding `telescope-fzf-native.nvim` done.\nPlease restart Neovim.") + end) + else + LazyVim.error("Failed to load `telescope-fzf-native.nvim`:\n" .. err) + end + end end) end, }, @@ -132,41 +177,45 @@ return { "Telescope buffers sort_mru=true sort_lastused=true", desc = "Switch Buffer", }, - { "/", Util.telescope("live_grep"), desc = "Grep (root dir)" }, + { "/", LazyVim.telescope("live_grep"), desc = "Grep (Root Dir)" }, { ":", "Telescope command_history", desc = "Command History" }, - { "", Util.telescope("files"), desc = "Find Files (root dir)" }, + { "", LazyVim.telescope("files"), desc = "Find Files (Root Dir)" }, -- find { "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)" }, + { "fc", LazyVim.telescope.config_files(), desc = "Find Config File" }, + { "ff", LazyVim.telescope("files"), desc = "Find Files (Root Dir)" }, + { "fF", LazyVim.telescope("files", { cwd = false }), desc = "Find Files (cwd)" }, + { "fg", "Telescope git_files", desc = "Find Files (git-files)" }, { "fr", "Telescope oldfiles", desc = "Recent" }, - { "fR", Util.telescope("oldfiles", { cwd = vim.loop.cwd() }), desc = "Recent (cwd)" }, + { "fR", LazyVim.telescope("oldfiles", { cwd = vim.uv.cwd() }), desc = "Recent (cwd)" }, -- git - { "gc", "Telescope git_commits", desc = "commits" }, - { "gs", "Telescope git_status", desc = "status" }, + { "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" }, { "sC", "Telescope commands", desc = "Commands" }, - { "sd", "Telescope diagnostics bufnr=0", desc = "Document diagnostics" }, - { "sD", "Telescope diagnostics", desc = "Workspace diagnostics" }, - { "sg", Util.telescope("live_grep"), desc = "Grep (root dir)" }, - { "sG", Util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" }, + { "sd", "Telescope diagnostics bufnr=0", desc = "Document Diagnostics" }, + { "sD", "Telescope diagnostics", desc = "Workspace Diagnostics" }, + { "sg", LazyVim.telescope("live_grep"), desc = "Grep (Root Dir)" }, + { "sG", LazyVim.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" }, { "sh", "Telescope help_tags", desc = "Help Pages" }, { "sH", "Telescope highlights", desc = "Search Highlight Groups" }, + { "sj", "Telescope jumplist", desc = "Jumplist" }, { "sk", "Telescope keymaps", desc = "Key Maps" }, + { "sl", "Telescope loclist", desc = "Location List" }, { "sM", "Telescope man_pages", desc = "Man Pages" }, { "sm", "Telescope marks", desc = "Jump to Mark" }, { "so", "Telescope vim_options", desc = "Options" }, { "sR", "Telescope resume", desc = "Resume" }, - { "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" }, + { "sq", "Telescope quickfix", desc = "Quickfix List" }, + { "sw", LazyVim.telescope("grep_string", { word_match = "-w" }), desc = "Word (Root Dir)" }, + { "sW", LazyVim.telescope("grep_string", { cwd = false, word_match = "-w" }), desc = "Word (cwd)" }, + { "sw", LazyVim.telescope("grep_string"), mode = "v", desc = "Selection (Root Dir)" }, + { "sW", LazyVim.telescope("grep_string", { cwd = false }), mode = "v", desc = "Selection (cwd)" }, + { "uC", LazyVim.telescope("colorscheme", { enable_preview = true }), desc = "Colorscheme with Preview" }, { "ss", function() @@ -189,21 +238,16 @@ return { opts = function() local actions = require("telescope.actions") - local open_with_trouble = function(...) - return require("trouble.providers.telescope").open_with_trouble(...) - end - local open_selected_with_trouble = function(...) - return require("trouble.providers.telescope").open_selected_with_trouble(...) - end + local open_with_trouble = require("trouble.sources.telescope").open 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 })() + LazyVim.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 })() + LazyVim.telescope("find_files", { hidden = true, default_text = line })() end return { @@ -226,7 +270,7 @@ return { mappings = { i = { [""] = open_with_trouble, - [""] = open_selected_with_trouble, + [""] = open_with_trouble, [""] = find_files_no_ignore, [""] = find_files_with_hidden, [""] = actions.cycle_history_next, @@ -267,7 +311,7 @@ return { "nvim-telescope/telescope.nvim", optional = true, opts = function(_, opts) - if not Util.has("flash.nvim") then + if not LazyVim.has("flash.nvim") then return end local function flash(prompt_bufnr) @@ -305,6 +349,7 @@ return { mode = { "n", "v" }, ["g"] = { name = "+goto" }, ["gs"] = { name = "+surround" }, + ["z"] = { name = "+fold" }, ["]"] = { name = "+next" }, ["["] = { name = "+prev" }, [""] = { name = "+tabs" }, @@ -350,14 +395,16 @@ return { end -- stylua: ignore start - map("n", "]h", gs.next_hunk, "Next Hunk") - map("n", "[h", gs.prev_hunk, "Prev Hunk") + map("n", "]h", function() gs.nav_hunk("next") end, "Next Hunk") + map("n", "[h", function() gs.nav_hunk("prev") end, "Prev Hunk") + map("n", "]H", function() gs.nav_hunk("last") end, "Last Hunk") + map("n", "[H", function() gs.nav_hunk("first") end, "First Hunk") map({ "n", "v" }, "ghs", ":Gitsigns stage_hunk", "Stage Hunk") map({ "n", "v" }, "ghr", ":Gitsigns reset_hunk", "Reset Hunk") map("n", "ghS", gs.stage_buffer, "Stage Buffer") map("n", "ghu", gs.undo_stage_hunk, "Undo Stage Hunk") map("n", "ghR", gs.reset_buffer, "Reset Buffer") - map("n", "ghp", gs.preview_hunk, "Preview Hunk") + map("n", "ghp", gs.preview_hunk_inline, "Preview Hunk Inline") map("n", "ghb", function() gs.blame_line({ full = true }) end, "Blame Line") map("n", "ghd", gs.diffthis, "Diff This") map("n", "ghD", function() gs.diffthis("~") end, "Diff This ~") @@ -366,89 +413,27 @@ return { }, }, - -- 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 = "LazyFile", - opts = { - delay = 200, - large_file_cutoff = 2000, - large_file_overrides = { - providers = { "lsp" }, - }, - }, - config = function(_, opts) - require("illuminate").configure(opts) - - local function map(key, dir, buffer) - vim.keymap.set("n", key, function() - require("illuminate")["goto_" .. dir .. "_reference"](false) - end, { desc = dir:sub(1, 1):upper() .. dir:sub(2) .. " Reference", buffer = buffer }) - end - - map("]]", "next") - map("[[", "prev") - - -- also set it after loading ftplugins, since a lot overwrite [[ and ]] - vim.api.nvim_create_autocmd("FileType", { - callback = function() - local buffer = vim.api.nvim_get_current_buf() - map("]]", "next", buffer) - map("[[", "prev", buffer) - end, - }) - end, - keys = { - { "]]", desc = "Next Reference" }, - { "[[", desc = "Prev Reference" }, - }, - }, - - -- buffer remove - { - "echasnovski/mini.bufremove", - - keys = { - { - "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)" }, - }, - }, - -- better diagnostics list and others { "folke/trouble.nvim", cmd = { "TroubleToggle", "Trouble" }, opts = { use_diagnostic_signs = true }, keys = { - { "xx", "TroubleToggle document_diagnostics", desc = "Document Diagnostics (Trouble)" }, - { "xX", "TroubleToggle workspace_diagnostics", desc = "Workspace Diagnostics (Trouble)" }, - { "xL", "TroubleToggle loclist", desc = "Location List (Trouble)" }, - { "xQ", "TroubleToggle quickfix", desc = "Quickfix List (Trouble)" }, + { "xx", "Trouble diagnostics toggle", desc = "Diagnostics (Trouble)" }, + { "xX", "Trouble diagnostics toggle filter.buf=0", desc = "Buffer Diagnostics (Trouble)" }, + { "cs", "Trouble symbols toggle focus=false", desc = "Symbols (Trouble)" }, + { + "cS", + "Trouble lsp toggle focus=false win.position=right", + desc = "LSP references/definitions/... (Trouble)", + }, + { "xL", "Trouble loclist toggle", desc = "Location List (Trouble)" }, + { "xQ", "Trouble qflist toggle", desc = "Quickfix List (Trouble)" }, { "[q", function() if require("trouble").is_open() then - require("trouble").previous({ skip_groups = true, jump = true }) + require("trouble").prev({ skip_groups = true, jump = true }) else local ok, err = pcall(vim.cmd.cprev) if not ok then @@ -456,7 +441,7 @@ return { end end end, - desc = "Previous trouble/quickfix item", + desc = "Previous Trouble/Quickfix Item", }, { "]q", @@ -470,7 +455,7 @@ return { end end end, - desc = "Next trouble/quickfix item", + desc = "Next Trouble/Quickfix Item", }, }, }, @@ -484,10 +469,10 @@ return { config = true, -- stylua: ignore keys = { - { "]t", function() require("todo-comments").jump_next() end, desc = "Next todo comment" }, - { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous todo comment" }, - { "xt", "TodoTrouble", desc = "Todo (Trouble)" }, - { "xT", "TodoTrouble keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme (Trouble)" }, + { "]t", function() require("todo-comments").jump_next() end, desc = "Next Todo Comment" }, + { "[t", function() require("todo-comments").jump_prev() end, desc = "Previous Todo Comment" }, + { "xt", "Trouble todo toggle", desc = "Todo (Trouble)" }, + { "xT", "Trouble todo toggle filter = {tag = {TODO,FIX,FIXME}}", desc = "Todo/Fix/Fixme (Trouble)" }, { "st", "TodoTelescope", desc = "Todo" }, { "sT", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme" }, }, diff --git a/lua/lazyvim/plugins/extras/coding/codeium.lua b/lua/lazyvim/plugins/extras/coding/codeium.lua index a9f40624..b95ad433 100644 --- a/lua/lazyvim/plugins/extras/coding/codeium.lua +++ b/lua/lazyvim/plugins/extras/coding/codeium.lua @@ -27,7 +27,7 @@ return { optional = true, event = "VeryLazy", opts = function(_, opts) - table.insert(opts.sections.lualine_x, 2, require("lazyvim.util").lualine.cmp_source("codeium")) + table.insert(opts.sections.lualine_x, 2, LazyVim.lualine.cmp_source("codeium")) end, }, } diff --git a/lua/lazyvim/plugins/extras/coding/copilot-chat.lua b/lua/lazyvim/plugins/extras/coding/copilot-chat.lua new file mode 100644 index 00000000..7e636b65 --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/copilot-chat.lua @@ -0,0 +1,125 @@ +return { + { + "CopilotC-Nvim/CopilotChat.nvim", + branch = "canary", + cmd = "CopilotChat", + opts = function() + local user = vim.env.USER or "User" + user = user:sub(1, 1):upper() .. user:sub(2) + return { + model = "gpt-4", + auto_insert_mode = true, + show_help = true, + question_header = " " .. user .. " ", + answer_header = " Copilot ", + window = { + width = 0.4, + }, + selection = function(source) + local select = require("CopilotChat.select") + return select.visual(source) or select.buffer(source) + end, + } + end, + keys = { + { + "aa", + function() + return require("CopilotChat").toggle() + end, + desc = "Toggle (CopilotChat)", + mode = { "n", "v" }, + }, + { + "ax", + function() + return require("CopilotChat").reset() + end, + desc = "Clear (CopilotChat)", + mode = { "n", "v" }, + }, + { + "aq", + function() + local input = vim.fn.input("Quick Chat: ") + if input ~= "" then + require("CopilotChat").ask(input) + end + end, + desc = "Quick Chat (CopilotChat)", + mode = { "n", "v" }, + }, + }, + config = function(_, opts) + local chat = require("CopilotChat") + require("CopilotChat.integrations.cmp").setup() + + vim.api.nvim_create_autocmd("BufEnter", { + pattern = "copilot-chat", + callback = function() + vim.opt_local.relativenumber = false + vim.opt_local.number = false + end, + }) + + chat.setup(opts) + end, + }, + + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["a"] = { name = "+ai" }, + }, + }, + }, + + -- Telescope integration + { + "nvim-telescope/telescope.nvim", + optional = true, + keys = { + -- Show help actions with telescope + { + "ad", + function() + local actions = require("CopilotChat.actions") + local help = actions.help_actions() + if not help then + LazyVim.warn("No diagnostics found on the current line") + return + end + require("CopilotChat.integrations.telescope").pick(help) + end, + desc = "Diagnostic Help (CopilotChat)", + mode = { "n", "v" }, + }, + -- Show prompts actions with telescope + { + "ap", + function() + local actions = require("CopilotChat.actions") + require("CopilotChat.integrations.telescope").pick(actions.prompt_actions()) + end, + desc = "Prompt Actions (CopilotChat)", + mode = { "n", "v" }, + }, + }, + }, + + -- Edgy integration + { + "folke/edgy.nvim", + optional = true, + opts = function(_, opts) + opts.right = opts.right or {} + table.insert(opts.right, { + ft = "copilot-chat", + title = "Copilot Chat", + size = { width = 50 }, + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/coding/copilot.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index 279a974f..afe14f61 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/copilot.lua @@ -1,5 +1,5 @@ return { - + recommended = true, -- copilot { "zbirenbaum/copilot.lua", @@ -19,12 +19,11 @@ return { optional = true, event = "VeryLazy", opts = function(_, opts) - local Util = require("lazyvim.util") local colors = { - [""] = Util.ui.fg("Special"), - ["Normal"] = Util.ui.fg("Special"), - ["Warning"] = Util.ui.fg("DiagnosticError"), - ["InProgress"] = Util.ui.fg("DiagnosticWarn"), + [""] = LazyVim.ui.fg("Special"), + ["Normal"] = LazyVim.ui.fg("Special"), + ["Warning"] = LazyVim.ui.fg("DiagnosticError"), + ["InProgress"] = LazyVim.ui.fg("DiagnosticWarn"), } table.insert(opts.sections.lualine_x, 2, { function() @@ -36,7 +35,7 @@ return { if not package.loaded["copilot"] then return end - local ok, clients = pcall(require("lazyvim.util").lsp.get_clients, { name = "copilot", bufnr = 0 }) + local ok, clients = pcall(LazyVim.lsp.get_clients, { name = "copilot", bufnr = 0 }) if not ok then return false end @@ -66,7 +65,7 @@ return { copilot_cmp.setup(opts) -- attach cmp source whenever copilot attaches -- fixes lazy-loading issues with the copilot cmp source - require("lazyvim.util").lsp.on_attach(function(client) + LazyVim.lsp.on_attach(function(client) if client.name == "copilot" then copilot_cmp._on_insert_enter({}) end diff --git a/lua/lazyvim/plugins/extras/coding/luasnip.lua b/lua/lazyvim/plugins/extras/coding/luasnip.lua new file mode 100644 index 00000000..bf0b3ea0 --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/luasnip.lua @@ -0,0 +1,49 @@ +return { + { + "L3MON4D3/LuaSnip", + build = (not LazyVim.is_win()) + and "echo 'NOTE: jsregexp is optional, so not a big deal if it fails to build'; make install_jsregexp" + or nil, + dependencies = { + { + "rafamadriz/friendly-snippets", + config = function() + require("luasnip.loaders.from_vscode").lazy_load() + end, + }, + { + "nvim-cmp", + dependencies = { + "saadparwaiz1/cmp_luasnip", + }, + opts = function(_, opts) + opts.snippet = { + expand = function(args) + require("luasnip").lsp_expand(args.body) + end, + } + table.insert(opts.sources, { name = "luasnip" }) + end, + }, + }, + opts = { + history = true, + delete_check_events = "TextChanged", + }, + }, + { + "nvim-cmp", + -- stylua: ignore + keys = { + { + "", + function() + return require("luasnip").jumpable(1) and "luasnip-jump-next" or "" + end, + expr = true, silent = true, mode = "i", + }, + { "", function() require("luasnip").jump(1) end, mode = "s" }, + { "", function() require("luasnip").jump(-1) end, mode = { "i", "s" } }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/coding/mini-comment.lua b/lua/lazyvim/plugins/extras/coding/mini-comment.lua new file mode 100644 index 00000000..457787ef --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/mini-comment.lua @@ -0,0 +1,20 @@ +return { + { + "echasnovski/mini.comment", + event = "VeryLazy", + opts = { + options = { + custom_commentstring = function() + return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring + end, + }, + }, + }, + { + "JoosepAlviste/nvim-ts-context-commentstring", + lazy = true, + opts = { + enable_autocmd = false, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/coding/mini-surround.lua b/lua/lazyvim/plugins/extras/coding/mini-surround.lua new file mode 100644 index 00000000..56d16a60 --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/mini-surround.lua @@ -0,0 +1,36 @@ +-- 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. +return { + "echasnovski/mini.surround", + recommended = true, + keys = function(_, keys) + -- Populate the keys based on the user's options + local opts = LazyVim.opts("mini.surround") + local mappings = { + { opts.mappings.add, desc = "Add Surrounding", mode = { "n", "v" } }, + { opts.mappings.delete, desc = "Delete Surrounding" }, + { opts.mappings.find, desc = "Find Right Surrounding" }, + { opts.mappings.find_left, desc = "Find Left Surrounding" }, + { opts.mappings.highlight, desc = "Highlight Surrounding" }, + { opts.mappings.replace, desc = "Replace Surrounding" }, + { opts.mappings.update_n_lines, desc = "Update `MiniSurround.config.n_lines`" }, + } + mappings = vim.tbl_filter(function(m) + return m[1] and #m[1] > 0 + end, mappings) + return vim.list_extend(mappings, keys) + end, + opts = { + mappings = { + 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` + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/coding/tabnine.lua b/lua/lazyvim/plugins/extras/coding/tabnine.lua index aac8519e..a255120e 100644 --- a/lua/lazyvim/plugins/extras/coding/tabnine.lua +++ b/lua/lazyvim/plugins/extras/coding/tabnine.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { -- Tabnine cmp source { @@ -8,7 +6,7 @@ return { { "tzachar/cmp-tabnine", build = { - Util.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh", + LazyVim.is_win() and "pwsh -noni .\\install.ps1" or "./install.sh", ":CmpTabnineHub", }, dependencies = "hrsh7th/nvim-cmp", @@ -30,7 +28,7 @@ return { priority = 100, }) - opts.formatting.format = Util.inject.args(opts.formatting.format, function(entry, item) + opts.formatting.format = LazyVim.inject.args(opts.formatting.format, function(entry, item) -- Hide percentage in the menu if entry.source.name == "cmp_tabnine" then item.menu = "" @@ -45,7 +43,7 @@ return { 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)) + table.insert(opts.sections.lualine_x, 2, LazyVim.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 index 00b675e9..46dca784 100644 --- a/lua/lazyvim/plugins/extras/coding/yanky.lua +++ b/lua/lazyvim/plugins/extras/coding/yanky.lua @@ -1,32 +1,31 @@ +-- better yank/paste 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 = { + "gbprod/yanky.nvim", + recommended = true, + desc = "Better Yank/Paste", + event = "LazyFile", + opts = { + highlight = { timer = 150 }, + }, + 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" }, - }, + { "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 c9aa291a..06b8862d 100644 --- a/lua/lazyvim/plugins/extras/dap/core.lua +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -12,12 +12,15 @@ end return { "mfussenegger/nvim-dap", + recommended = true, + desc = "Debugging support. Requires language specific adapters to be configured. (see lang extras)", dependencies = { -- fancy UI for the debugger { "rcarriga/nvim-dap-ui", + dependencies = { "nvim-neotest/nvim-nio" }, -- stylua: ignore keys = { { "du", function() require("dapui").toggle({ }) end, desc = "Dap UI" }, @@ -25,8 +28,6 @@ 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) @@ -89,7 +90,7 @@ return { { "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)" }, + { "dg", function() require("dap").goto_() end, desc = "Go to Line (No Execute)" }, { "di", function() require("dap").step_into() end, desc = "Step Into" }, { "dj", function() require("dap").down() end, desc = "Down" }, { "dk", function() require("dap").up() end, desc = "Up" }, @@ -114,5 +115,18 @@ return { { text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] } ) end + + -- setup dap config by VsCode launch.json file + local vscode = require("dap.ext.vscode") + local _filetypes = require("mason-nvim-dap.mappings.filetypes") + local filetypes = vim.tbl_deep_extend("force", _filetypes, { + ["node"] = { "javascriptreact", "typescriptreact", "typescript", "javascript" }, + ["pwa-node"] = { "javascriptreact", "typescriptreact", "typescript", "javascript" }, + }) + local json = require("plenary.json") + vscode.json_decode = function(str) + return vim.json.decode(json.json_strip_comments(str)) + end + vscode.load_launchjs(nil, filetypes) end, } diff --git a/lua/lazyvim/plugins/extras/editor/aerial.lua b/lua/lazyvim/plugins/extras/editor/aerial.lua index 440c9fda..afa2a602 100644 --- a/lua/lazyvim/plugins/extras/editor/aerial.lua +++ b/lua/lazyvim/plugins/extras/editor/aerial.lua @@ -1,5 +1,4 @@ local Config = require("lazyvim.config") -local Util = require("lazyvim.util") return { desc = "Aerial Symbol Browser", @@ -50,12 +49,20 @@ return { }, }, + { + "folke/trouble.nvim", + optional = true, + keys = { + { "cs", false }, + }, + }, + -- Telescope integration { "nvim-telescope/telescope.nvim", optional = true, opts = function() - Util.on_load("telescope.nvim", function() + LazyVim.on_load("telescope.nvim", function() require("telescope").load_extension("aerial") end) end, @@ -73,11 +80,11 @@ return { "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") + local edgy_idx = LazyVim.plugin.extra_idx("ui.edgy") + local aerial_idx = LazyVim.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.", { + LazyVim.warn("The `edgy.nvim` extra must be **imported** before the `aerial.nvim` extra to work properly.", { title = "LazyVim", }) end diff --git a/lua/lazyvim/plugins/extras/editor/dial.lua b/lua/lazyvim/plugins/extras/editor/dial.lua new file mode 100644 index 00000000..cc262a33 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/dial.lua @@ -0,0 +1,175 @@ +local M = {} +---@type table> +M.dials_by_ft = {} + +---@param increment boolean +---@param g? boolean +function M.dial(increment, g) + local mode = vim.fn.mode(true) + -- Use visual commands for VISUAL 'v', VISUAL LINE 'V' and VISUAL BLOCK '\22' + local is_visual = mode == "v" or mode == "V" or mode == "\22" + local func = (increment and "inc" or "dec") .. (g and "_g" or "_") .. (is_visual and "visual" or "normal") + local group = M.dials_by_ft[vim.bo.filetype] or "default" + return require("dial.map")[func](group) +end + +return { + "monaqa/dial.nvim", + recommended = true, + desc = "Increment and decrement numbers, dates, and more", + -- stylua: ignore + keys = { + { "", function() return M.dial(true) end, expr = true, desc = "Increment", mode = {"n", "v"} }, + { "", function() return M.dial(false) end, expr = true, desc = "Decrement", mode = {"n", "v"} }, + { "g", function() return M.dial(true, true) end, expr = true, desc = "Increment", mode = {"n", "v"} }, + { "g", function() return M.dial(false, true) end, expr = true, desc = "Decrement", mode = {"n", "v"} }, + }, + opts = function() + local augend = require("dial.augend") + + local logical_alias = augend.constant.new({ + elements = { "&&", "||" }, + word = false, + cyclic = true, + }) + + local ordinal_numbers = augend.constant.new({ + -- elements through which we cycle. When we increment, we go down + -- On decrement we go up + elements = { + "first", + "second", + "third", + "fourth", + "fifth", + "sixth", + "seventh", + "eighth", + "ninth", + "tenth", + }, + -- if true, it only matches strings with word boundary. firstDate wouldn't work for example + word = false, + -- do we cycle back and forth (tenth to first on increment, first to tenth on decrement). + -- Otherwise nothing will happen when there are no further values + cyclic = true, + }) + + local weekdays = augend.constant.new({ + elements = { + "Monday", + "Tuesday", + "Wednesday", + "Thursday", + "Friday", + "Saturday", + "Sunday", + }, + word = true, + cyclic = true, + }) + + local months = augend.constant.new({ + elements = { + "January", + "February", + "March", + "April", + "May", + "June", + "July", + "August", + "September", + "October", + "November", + "December", + }, + word = true, + cyclic = true, + }) + + local capitalized_boolean = augend.constant.new({ + elements = { + "True", + "False", + }, + word = true, + cyclic = true, + }) + + return { + dials_by_ft = { + css = "css", + javascript = "typescript", + javascriptreact = "typescript", + json = "json", + lua = "lua", + markdown = "markdown", + python = "python", + sass = "css", + scss = "css", + typescript = "typescript", + typescriptreact = "typescript", + }, + groups = { + default = { + augend.integer.alias.decimal, -- nonnegative decimal number (0, 1, 2, 3, ...) + augend.integer.alias.hex, -- nonnegative hex number (0x01, 0x1a1f, etc.) + augend.date.alias["%Y/%m/%d"], -- date (2022/02/19, etc.) + }, + typescript = { + augend.integer.alias.decimal, -- nonnegative and negative decimal number + augend.constant.alias.bool, -- boolean value (true <-> false) + logical_alias, + augend.constant.new({ elements = { "let", "const" } }), + ordinal_numbers, + weekdays, + months, + }, + css = { + augend.integer.alias.decimal, -- nonnegative and negative decimal number + augend.hexcolor.new({ + case = "lower", + }), + augend.hexcolor.new({ + case = "upper", + }), + }, + markdown = { + augend.misc.alias.markdown_header, + ordinal_numbers, + weekdays, + months, + }, + json = { + augend.integer.alias.decimal, -- nonnegative and negative decimal number + augend.semver.alias.semver, -- versioning (v1.1.2) + }, + lua = { + augend.integer.alias.decimal, -- nonnegative and negative decimal number + augend.constant.alias.bool, -- boolean value (true <-> false) + augend.constant.new({ + elements = { "and", "or" }, + word = true, -- if false, "sand" is incremented into "sor", "doctor" into "doctand", etc. + cyclic = true, -- "or" is incremented into "and". + }), + ordinal_numbers, + weekdays, + months, + }, + python = { + augend.integer.alias.decimal, -- nonnegative and negative decimal number + capitalized_boolean, + logical_alias, + ordinal_numbers, + weekdays, + months, + }, + }, + } + end, + config = function(_, opts) + require("dial.config").augends:register_group(opts.groups) + M.dials_by_ft = opts.dials_by_ft + end, +} diff --git a/lua/lazyvim/plugins/extras/editor/harpoon2.lua b/lua/lazyvim/plugins/extras/editor/harpoon2.lua new file mode 100644 index 00000000..760d805a --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/harpoon2.lua @@ -0,0 +1,42 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + opts = { + menu = { + width = vim.api.nvim_win_get_width(0) - 4, + }, + settings = { + save_on_toggle = true, + }, + }, + keys = function() + local keys = { + { + "H", + function() + require("harpoon"):list():add() + end, + desc = "Harpoon File", + }, + { + "h", + function() + local harpoon = require("harpoon") + harpoon.ui:toggle_quick_menu(harpoon:list()) + end, + desc = "Harpoon Quick Menu", + }, + } + + for i = 1, 5 do + table.insert(keys, { + "" .. i, + function() + require("harpoon"):list():select(i) + end, + desc = "Harpoon to File " .. i, + }) + end + return keys + end, +} diff --git a/lua/lazyvim/plugins/extras/editor/illuminate.lua b/lua/lazyvim/plugins/extras/editor/illuminate.lua new file mode 100644 index 00000000..d4f4bf89 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/illuminate.lua @@ -0,0 +1,45 @@ +-- Automatically highlights other instances of the word under your cursor. +-- This works with LSP, Treesitter, and regexp matching to find the other +-- instances. +return { + { + "RRethy/vim-illuminate", + event = "LazyFile", + opts = { + delay = 200, + large_file_cutoff = 2000, + large_file_overrides = { + providers = { "lsp" }, + }, + }, + config = function(_, opts) + require("illuminate").configure(opts) + + local function map(key, dir, buffer) + vim.keymap.set("n", key, function() + require("illuminate")["goto_" .. dir .. "_reference"](false) + end, { desc = dir:sub(1, 1):upper() .. dir:sub(2) .. " Reference", buffer = buffer }) + end + + map("]]", "next") + map("[[", "prev") + + -- also set it after loading ftplugins, since a lot overwrite [[ and ]] + vim.api.nvim_create_autocmd("FileType", { + callback = function() + local buffer = vim.api.nvim_get_current_buf() + map("]]", "next", buffer) + map("[[", "prev", buffer) + end, + }) + end, + keys = { + { "]]", desc = "Next Reference" }, + { "[[", desc = "Prev Reference" }, + }, + }, + { + "neovim/nvim-lspconfig", + opts = { document_highlight = { enabled = false } }, + }, +} diff --git a/lua/lazyvim/plugins/extras/editor/inc-rename.lua b/lua/lazyvim/plugins/extras/editor/inc-rename.lua new file mode 100644 index 00000000..a7c65243 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/inc-rename.lua @@ -0,0 +1,38 @@ +return { + + -- Rename with cmdpreview + recommended = true, + desc = "Incremental LSP renaming based on Neovim's command-preview feature", + { + "smjonas/inc-rename.nvim", + cmd = "IncRename", + opts = {}, + }, + + -- LSP Keymaps + { + "neovim/nvim-lspconfig", + opts = function() + local keys = require("lazyvim.plugins.lsp.keymaps").get() + keys[#keys + 1] = { + "cr", + function() + local inc_rename = require("inc_rename") + return ":" .. inc_rename.config.cmd_name .. " " .. vim.fn.expand("") + end, + expr = true, + desc = "Rename (inc-rename.nvim)", + has = "rename", + } + end, + }, + + --- Noice integration + { + "folke/noice.nvim", + optional = true, + opts = { + presets = { inc_rename = true }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/editor/leap.lua b/lua/lazyvim/plugins/extras/editor/leap.lua index ab422abf..6145d641 100644 --- a/lua/lazyvim/plugins/extras/editor/leap.lua +++ b/lua/lazyvim/plugins/extras/editor/leap.lua @@ -20,9 +20,9 @@ return { "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" }, + { "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") @@ -38,6 +38,7 @@ return { -- rename surround mappings from gs to gz to prevent conflict with leap { "echasnovski/mini.surround", + optional = true, opts = { mappings = { add = "gza", -- Add surrounding in Normal and Visual modes @@ -50,6 +51,15 @@ return { }, }, }, + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["gz"] = { name = "+surround" }, + }, + }, + }, -- makes some plugins dot-repeatable like leap { "tpope/vim-repeat", event = "VeryLazy" }, diff --git a/lua/lazyvim/plugins/extras/editor/mini-diff.lua b/lua/lazyvim/plugins/extras/editor/mini-diff.lua new file mode 100644 index 00000000..6e5040ad --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/mini-diff.lua @@ -0,0 +1,54 @@ +return { + -- disable gitsigns.nvim + { + "lewis6991/gitsigns.nvim", + enabled = false, + }, + + -- setup mini.diff + { + "echasnovski/mini.diff", + event = "VeryLazy", + keys = { + { + "go", + function() + require("mini.diff").toggle_overlay(0) + end, + desc = "Toggle mini.diff overlay", + }, + }, + opts = { + view = { + style = "sign", + signs = { + add = "▎", + change = "▎", + delete = "", + }, + }, + }, + }, + + -- lualine integration + { + "nvim-lualine/lualine.nvim", + opts = function(_, opts) + local x = opts.sections.lualine_x + for _, comp in ipairs(x) do + if comp[1] == "diff" then + comp.source = function() + local summary = vim.b.minidiff_summary + return summary + and { + added = summary.add, + modified = summary.change, + removed = summary.delete, + } + end + break + end + end + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/editor/mini-files.lua b/lua/lazyvim/plugins/extras/editor/mini-files.lua index 55fc768c..344981c3 100644 --- a/lua/lazyvim/plugins/extras/editor/mini-files.lua +++ b/lua/lazyvim/plugins/extras/editor/mini-files.lua @@ -18,12 +18,12 @@ return { function() require("mini.files").open(vim.api.nvim_buf_get_name(0), true) end, - desc = "Open mini.files (directory of current file)", + desc = "Open mini.files (Directory of Current File)", }, { "fM", function() - require("mini.files").open(vim.loop.cwd(), true) + require("mini.files").open(vim.uv.cwd(), true) end, desc = "Open mini.files (cwd)", }, @@ -50,14 +50,14 @@ return { callback = function(args) local buf_id = args.data.buf_id -- Tweak left-hand side of mapping to your liking - vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id }) + vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id, desc = "Toggle Hidden Files" }) end, }) vim.api.nvim_create_autocmd("User", { pattern = "MiniFilesActionRename", callback = function(event) - require("lazyvim.util").lsp.on_rename(event.data.from, event.data.to) + LazyVim.lsp.on_rename(event.data.from, event.data.to) end, }) end, diff --git a/lua/lazyvim/plugins/extras/editor/mini-move.lua b/lua/lazyvim/plugins/extras/editor/mini-move.lua new file mode 100644 index 00000000..aa8823ef --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/mini-move.lua @@ -0,0 +1,7 @@ +return { + { + "echasnovski/mini.move", + event = "VeryLazy", + opts = {}, + }, +} diff --git a/lua/lazyvim/plugins/extras/editor/navic.lua b/lua/lazyvim/plugins/extras/editor/navic.lua index 359c42d4..ad31d575 100644 --- a/lua/lazyvim/plugins/extras/editor/navic.lua +++ b/lua/lazyvim/plugins/extras/editor/navic.lua @@ -7,7 +7,7 @@ return { lazy = true, init = function() vim.g.navic_silence = true - require("lazyvim.util").lsp.on_attach(function(client, buffer) + LazyVim.lsp.on_attach(function(client, buffer) if client.supports_method("textDocument/documentSymbol") then require("nvim-navic").attach(client, buffer) end diff --git a/lua/lazyvim/plugins/extras/editor/symbols-outline.lua b/lua/lazyvim/plugins/extras/editor/outline.lua similarity index 62% rename from lua/lazyvim/plugins/extras/editor/symbols-outline.lua rename to lua/lazyvim/plugins/extras/editor/outline.lua index 32cdd17f..07c46705 100644 --- a/lua/lazyvim/plugins/extras/editor/symbols-outline.lua +++ b/lua/lazyvim/plugins/extras/editor/outline.lua @@ -1,13 +1,19 @@ -local Util = require("lazyvim.util") - return { + -- Disable `cs` keymap so it doesn't conflict with `outline.nvim` { - "simrat39/symbols-outline.nvim", - keys = { { "cs", "SymbolsOutline", desc = "Symbols Outline" } }, - cmd = "SymbolsOutline", + "folke/trouble.nvim", + optional = true, + keys = { + { "cs", false }, + }, + }, + { + "hedyhli/outline.nvim", + keys = { { "cs", "Outline", desc = "Toggle Outline" } }, + cmd = "Outline", opts = function() local Config = require("lazyvim.config") - local defaults = require("symbols-outline.config").defaults + local defaults = require("outline.config").defaults local opts = { symbols = {}, symbol_blacklist = {}, @@ -37,24 +43,22 @@ return { "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") + local edgy_idx = LazyVim.plugin.extra_idx("ui.edgy") + local symbols_idx = LazyVim.plugin.extra_idx("editor.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", - } + LazyVim.warn( + "The `edgy.nvim` extra must be **imported** before the `outline.nvim` extra to work properly.", + { title = "LazyVim" } ) end opts.right = opts.right or {} table.insert(opts.right, { - title = "Symbols Outline", + title = "Outline", ft = "Outline", pinned = true, - open = "SymbolsOutline", + open = "Outline", }) end, }, diff --git a/lua/lazyvim/plugins/extras/editor/refactoring.lua b/lua/lazyvim/plugins/extras/editor/refactoring.lua new file mode 100644 index 00000000..ff6351c7 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/refactoring.lua @@ -0,0 +1,138 @@ +return { + { + "ThePrimeagen/refactoring.nvim", + event = { "BufReadPre", "BufNewFile" }, + dependencies = { + "nvim-lua/plenary.nvim", + "nvim-treesitter/nvim-treesitter", + }, + keys = { + { + "rs", + function() + require("telescope").extensions.refactoring.refactors() + end, + mode = "v", + desc = "Refactor", + }, + { + "ri", + function() + require("refactoring").refactor("Inline Variable") + end, + mode = { "n", "v" }, + desc = "Inline Variable", + }, + { + "rb", + function() + require("refactoring").refactor("Extract Block") + end, + desc = "Extract Block", + }, + { + "rf", + function() + require("refactoring").refactor("Extract Block To File") + end, + desc = "Extract Block To File", + }, + { + "rP", + function() + require("refactoring").debug.printf({ below = false }) + end, + desc = "Debug Print", + }, + { + "rp", + function() + require("refactoring").debug.print_var({ normal = true }) + end, + desc = "Debug Print Variable", + }, + { + "rc", + function() + require("refactoring").debug.cleanup({}) + end, + desc = "Debug Cleanup", + }, + { + "rf", + function() + require("refactoring").refactor("Extract Function") + end, + mode = "v", + desc = "Extract Function", + }, + { + "rF", + function() + require("refactoring").refactor("Extract Function To File") + end, + mode = "v", + desc = "Extract Function To File", + }, + { + "rx", + function() + require("refactoring").refactor("Extract Variable") + end, + mode = "v", + desc = "Extract Variable", + }, + { + "rp", + function() + require("refactoring").debug.print_var() + end, + mode = "v", + desc = "Debug Print Variable", + }, + }, + opts = { + prompt_func_return_type = { + go = false, + java = false, + cpp = false, + c = false, + h = false, + hpp = false, + cxx = false, + }, + prompt_func_param_type = { + go = false, + java = false, + cpp = false, + c = false, + h = false, + hpp = false, + cxx = false, + }, + printf_statements = {}, + print_var_statements = {}, + show_success_message = true, -- shows a message with information about the refactor on success + -- i.e. [Refactor] Inlined 3 variable occurrences + }, + config = function(_, opts) + require("refactoring").setup(opts) + if LazyVim.has("telescope.nvim") then + LazyVim.on_load("telescope.nvim", function() + require("telescope").load_extension("refactoring") + end) + end + end, + }, + + -- which key integration + { + "folke/which-key.nvim", + optional = true, + opts = { + defaults = { + ["r"] = { name = "+refactor" }, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/angular.lua b/lua/lazyvim/plugins/extras/lang/angular.lua new file mode 100644 index 00000000..ce8a62e4 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/angular.lua @@ -0,0 +1,56 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + root = { + "angular.json", + "nx.json", --support for nx workspace + }, + }) + end, + + { + "nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "angular", "scss" }) + end + end, + }, + + -- angularls depends on typescript + { import = "lazyvim.plugins.extras.lang.typescript" }, + + -- LSP Servers + { + "neovim/nvim-lspconfig", + opts = { + servers = { + angularls = {}, + }, + setup = { + angularls = function() + LazyVim.lsp.on_attach(function(client) + if client.name == "angularls" then + --HACK: disable angular renaming capability due to duplicate rename popping up + client.server_capabilities.renameProvider = false + end + end) + end, + }, + }, + }, + + -- Configure tsserver plugin + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { + { + name = "@angular/language-server", + location = LazyVim.get_pkg_path("angular-language-server", "/node_modules/@angular/language-server"), + enableForWorkspaceTypeScriptVersions = false, + }, + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/ansible.lua b/lua/lazyvim/plugins/extras/lang/ansible.lua new file mode 100644 index 00000000..5f080395 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/ansible.lua @@ -0,0 +1,46 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "yaml.ansible", + root = { "ansible.cfg", ".ansible-lint" }, + }) + end, + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "yaml" }) + end + end, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + -- for ansiblels validation + vim.list_extend(opts.ensure_installed, { "ansible-lint" }) + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + ansiblels = {}, + }, + }, + }, + { + "mfussenegger/nvim-ansible", + ft = {}, + keys = { + { + "ta", + function() + require("ansible").run() + end, + desc = "Ansible Run Playbook/Role", + silent = true, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/astro.lua b/lua/lazyvim/plugins/extras/lang/astro.lua new file mode 100644 index 00000000..c0e8cfc0 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/astro.lua @@ -0,0 +1,48 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "astro", + root = { + "astro.config.js", + "astro.config.mjs", + "astro.config.cjs", + }, + }) + end, + + -- depends on the typescript extra + { import = "lazyvim.plugins.extras.lang.typescript" }, + + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "astro" }) + end + end, + }, + + -- LSP Servers + { + "neovim/nvim-lspconfig", + opts = { + servers = { + astro = {}, + }, + }, + }, + + -- Configure tsserver plugin + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { + { + name = "@astrojs/ts-plugin", + location = LazyVim.get_pkg_path("astro-language-server", "/node_modules/@astrojs/ts-plugin"), + enableForWorkspaceTypeScriptVersions = true, + }, + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/clangd.lua b/lua/lazyvim/plugins/extras/lang/clangd.lua index 08017700..86a1afe7 100644 --- a/lua/lazyvim/plugins/extras/lang/clangd.lua +++ b/lua/lazyvim/plugins/extras/lang/clangd.lua @@ -1,4 +1,17 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "c", "cpp", "objc", "objcpp", "cuda", "proto" }, + root = { + ".clangd", + ".clang-tidy", + ".clang-format", + "compile_commands.json", + "compile_flags.txt", + "configure.ac", -- AutoTools + }, + }) + end, -- Add C/C++ to treesitter { @@ -49,7 +62,7 @@ return { -- Ensure mason installs the server clangd = { keys = { - { "cR", "ClangdSwitchSourceHeader", desc = "Switch Source/Header (C/C++)" }, + { "ch", "ClangdSwitchSourceHeader", desc = "Switch Source/Header (C/C++)" }, }, root_dir = function(fname) return require("lspconfig.util").root_pattern( @@ -85,7 +98,7 @@ return { }, setup = { clangd = function(_, opts) - local clangd_ext_opts = require("lazyvim.util").opts("clangd_extensions.nvim") + local clangd_ext_opts = LazyVim.opts("clangd_extensions.nvim") require("clangd_extensions").setup(vim.tbl_deep_extend("force", clangd_ext_opts or {}, { server = opts })) return false end, @@ -144,7 +157,7 @@ return { type = "codelldb", request = "attach", name = "Attach to process", - processId = require("dap.utils").pick_process, + pid = require("dap.utils").pick_process, cwd = "${workspaceFolder}", }, } diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua index e95dbfdd..a5bc804c 100644 --- a/lua/lazyvim/plugins/extras/lang/cmake.lua +++ b/lua/lazyvim/plugins/extras/lang/cmake.lua @@ -1,4 +1,10 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = "cmake", + root = { "CMakePresets.json", "CTestConfig.cmake", "cmake" }, + }) + end, { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) @@ -43,7 +49,25 @@ return { }, { "Civitasv/cmake-tools.nvim", + lazy = true, + init = function() + local loaded = false + local function check() + local cwd = vim.uv.cwd() + if vim.fn.filereadable(cwd .. "/CMakeLists.txt") == 1 then + require("lazy").load({ plugins = { "cmake-tools.nvim" } }) + loaded = true + end + end + check() + vim.api.nvim_create_autocmd("DirChanged", { + callback = function() + if not loaded then + check() + end + end, + }) + end, opts = {}, - event = "LazyFile", }, } diff --git a/lua/lazyvim/plugins/extras/lang/docker.lua b/lua/lazyvim/plugins/extras/lang/docker.lua index da9605ec..98a9be44 100644 --- a/lua/lazyvim/plugins/extras/lang/docker.lua +++ b/lua/lazyvim/plugins/extras/lang/docker.lua @@ -1,4 +1,10 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = "dockerfile", + root = { "Dockerfile", "docker-compose.yml", "compose.yml", "docker-compose.yaml", "compose.yaml" }, + }) + end, { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) diff --git a/lua/lazyvim/plugins/extras/lang/elixir.lua b/lua/lazyvim/plugins/extras/lang/elixir.lua index f60dc18e..a6b9c260 100644 --- a/lua/lazyvim/plugins/extras/lang/elixir.lua +++ b/lua/lazyvim/plugins/extras/lang/elixir.lua @@ -1,4 +1,10 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "elixir", "eelixir", "heex", "surface" }, + root = "mix.exs", + }) + end, { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) diff --git a/lua/lazyvim/plugins/extras/lang/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index aaad0128..2ec43e22 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -1,4 +1,10 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "go", "gomod", "gowork", "gotmpl" }, + root = { "go.work", "go.mod" }, + }) + end, { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) @@ -61,7 +67,7 @@ return { gopls = function(_, opts) -- workaround for gopls not supporting semanticTokensProvider -- https://github.com/golang/go/issues/54531#issuecomment-1464982242 - require("lazyvim.util").lsp.on_attach(function(client, _) + LazyVim.lsp.on_attach(function(client, _) if client.name == "gopls" then if not client.server_capabilities.semanticTokensProvider then local semantic = client.config.capabilities.textDocument.semanticTokens @@ -148,6 +154,7 @@ return { ["neotest-go"] = { -- Here we can set options for neotest-go, e.g. -- args = { "-tags=integration" } + recursive_run = true, }, }, }, diff --git a/lua/lazyvim/plugins/extras/lang/haskell.lua b/lua/lazyvim/plugins/extras/lang/haskell.lua new file mode 100644 index 00000000..be1636bf --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/haskell.lua @@ -0,0 +1,99 @@ +return { + + -- Add Haskell to treesitter + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "haskell" }) + end + end, + }, + + { + "mrcjkb/haskell-tools.nvim", + version = "^3", + ft = { "haskell", "lhaskell", "cabal", "cabalproject" }, + dependencies = { + { "nvim-telescope/telescope.nvim", optional = true }, + }, + config = function() + local ok, telescope = pcall(require, "telescope") + if ok then + telescope.load_extension("ht") + end + end, + }, + + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "haskell-language-server" }) + end, + }, + + { + "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, { "haskell-debug-adapter" }) + end, + }, + }, + }, + + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + { "mrcjkb/neotest-haskell" }, + }, + opts = { + adapters = { + ["neotest-haskell"] = {}, + }, + }, + }, + + { + "mrcjkb/haskell-snippets.nvim", + dependencies = { "L3MON4D3/LuaSnip" }, + ft = { "haskell", "lhaskell", "cabal", "cabalproject" }, + config = function() + local haskell_snippets = require("haskell-snippets").all + require("luasnip").add_snippets("haskell", haskell_snippets, { key = "haskell" }) + end, + }, + + { + "luc-tielen/telescope_hoogle", + ft = { "haskell", "lhaskell", "cabal", "cabalproject" }, + dependencies = { + { "nvim-telescope/telescope.nvim" }, + }, + config = function() + local ok, telescope = pcall(require, "telescope") + if ok then + telescope.load_extension("hoogle") + end + end, + }, + + -- Make sure lspconfig doesn't start hls, + -- as it conflicts with haskell-tools + { + "neovim/nvim-lspconfig", + opts = { + setup = { + hls = function() + return true + end, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/helm.lua b/lua/lazyvim/plugins/extras/lang/helm.lua new file mode 100644 index 00000000..3f1fe00d --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/helm.lua @@ -0,0 +1,30 @@ +LazyVim.lsp.on_attach(function(client, buffer) + if client.name == "yamlls" then + if vim.api.nvim_get_option_value("filetype", { buf = buffer }) == "helm" then + vim.schedule(function() + vim.cmd("LspStop ++force yamlls") + end) + end + end +end) + +return { + { "towolf/vim-helm", ft = "helm" }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + yamlls = {}, + helm_ls = {}, + }, + }, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed, { + "helm-ls", + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/java.lua b/lua/lazyvim/plugins/extras/lang/java.lua index f7e7ca5f..a1b49716 100644 --- a/lua/lazyvim/plugins/extras/lang/java.lua +++ b/lua/lazyvim/plugins/extras/lang/java.lua @@ -1,5 +1,3 @@ -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" } @@ -18,6 +16,20 @@ local function extend_or_override(config, custom, ...) end return { + recommended = function() + return LazyVim.extras.wants({ + ft = "java", + root = { + "build.gradle", + "build.gradle.kts", + "build.xml", -- Ant + "pom.xml", -- Maven + "settings.gradle", -- Gradle + "settings.gradle.kts", -- Gradle + }, + }) + end, + -- Add java to treesitter. { "nvim-treesitter/nvim-treesitter", @@ -104,17 +116,25 @@ return { -- These depend on nvim-dap, but can additionally be disabled by setting false here. dap = { hotcodereplace = "auto", config_overrides = {} }, + dap_main = {}, test = true, + settings = { + java = { + inlayHints = { + parameterNames = { + enabled = "all", + }, + }, + }, + }, } end, - config = function() - local opts = Util.opts("nvim-jdtls") or {} - + config = function(_, opts) -- 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 + if opts.dap and LazyVim.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 = { @@ -145,8 +165,9 @@ return { init_options = { bundles = bundles, }, + settings = opts.settings, -- enable CMP capabilities - capabilities = require("cmp_nvim_lsp").default_capabilities(), + capabilities = LazyVim.has("cmp-nvim-lsp") and require("cmp_nvim_lsp").default_capabilities() or nil, }, opts.jdtls) -- Existing server will be reused if the root_dir matches. @@ -195,10 +216,10 @@ return { }, }, { mode = "v", buffer = args.buf }) - if opts.dap and Util.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then + if opts.dap and LazyVim.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() + require("jdtls.dap").setup_dap_main_class_configs(opts.dap_main) -- Java Test require Java debugger to work if opts.test and mason_registry.is_installed("java-test") then diff --git a/lua/lazyvim/plugins/extras/lang/json.lua b/lua/lazyvim/plugins/extras/lang/json.lua index ff41ba4f..3f1de268 100644 --- a/lua/lazyvim/plugins/extras/lang/json.lua +++ b/lua/lazyvim/plugins/extras/lang/json.lua @@ -1,4 +1,10 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "json", "jsonc", "json5" }, + root = { "*.json" }, + }) + end, -- add json to treesitter { diff --git a/lua/lazyvim/plugins/extras/lang/kotlin.lua b/lua/lazyvim/plugins/extras/lang/kotlin.lua new file mode 100644 index 00000000..1db56545 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/kotlin.lua @@ -0,0 +1,117 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "kotlin", + root = { + "settings.gradle", -- Gradle (multi-project) + "settings.gradle.kts", -- Gradle (multi-project) + "build.xml", -- Ant + "pom.xml", -- Maven + "build.gradle", -- Gradle + "build.gradle.kts", -- Gradle + }, + }) + end, + -- Add packages(linting, debug adapter) + { + "williamboman/mason.nvim", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed or {}, { "ktlint", "kotlin-debug-adapter" }) + end, + }, + -- Add syntax highlighting + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed or {}, { "kotlin" }) + end, + }, + -- Add language server + { + "neovim/nvim-lspconfig", + opts = { + servers = { + kotlin_language_server = {}, + }, + }, + }, + -- Add linting as optional + { + "mfussenegger/nvim-lint", + optional = true, + dependencies = "williamboman/mason.nvim", + opts = { + linters_by_ft = { kotlin = { "ktlint" } }, + }, + }, + -- Add formatting as optional + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { kotlin = { "ktlint" } }, + }, + }, + -- Add formatting and linting as optional + { + "nvimtools/none-ls.nvim", + optional = true, + opts = function(_, opts) + local nls = require("null-ls") + opts.sources = vim.list_extend(opts.sources or {}, { + nls.builtins.formatting.ktlint, + nls.builtins.diagnostics.ktlint, + }) + end, + }, + -- Add debugger + { + "mfussenegger/nvim-dap", + optional = true, + dependencies = "williamboman/mason.nvim", + opts = function() + local dap = require("dap") + if not dap.adapters.kotlin then + require("dap").adapters.kotlin = { + type = "executable", + command = "kotlin-debug-adapter", + options = { auto_continue_if_many_stopped = false }, + } + end + + dap.configurations.kotlin = { + { + type = "kotlin", + request = "launch", + name = "This file", + -- may differ, when in doubt, whatever your project structure may be, + -- it has to correspond to the class file located at `build/classes/` + -- and of course you have to build before you debug + mainClass = function() + local root = vim.fs.find("src", { path = vim.uv.cwd(), upward = true, stop = vim.env.HOME })[1] or "" + local fname = vim.api.nvim_buf_get_name(0) + -- src/main/kotlin/websearch/Main.kt -> websearch.MainKt + return fname:gsub(root, ""):gsub("main/kotlin/", ""):gsub(".kt", "Kt"):gsub("/", "."):sub(2, -1) + end, + projectRoot = "${workspaceFolder}", + jsonLogFile = "", + enableJsonLogging = false, + }, + { + -- Use this for unit tests + -- First, run + -- ./gradlew --info cleanTest test --debug-jvm + -- then attach the debugger to it + type = "kotlin", + request = "attach", + name = "Attach to debugging session", + port = 5005, + args = {}, + projectRoot = vim.fn.getcwd, + hostName = "localhost", + timeout = 2000, + }, + } + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua index 5aa9dc33..81f4cc88 100644 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -1,4 +1,20 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = "markdown", + root = "README.md", + }) + end, + { + "stevearc/conform.nvim", + optional = true, + opts = { + formatters_by_ft = { + ["markdown"] = { { "prettierd", "prettier" }, "markdownlint", "markdown-toc" }, + ["markdown.mdx"] = { { "prettierd", "prettier" }, "markdownlint", "markdown-toc" }, + }, + }, + }, { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) @@ -69,6 +85,8 @@ return { for _, ft in ipairs({ "markdown", "norg", "rmd", "org" }) do opts[ft] = { headline_highlights = {}, + -- disable bullets for now. See https://github.com/lukas-reineke/headlines.nvim/issues/66 + bullets = {}, } for i = 1, 6 do local hl = "Headline" .. i diff --git a/lua/lazyvim/plugins/extras/lang/omnisharp.lua b/lua/lazyvim/plugins/extras/lang/omnisharp.lua index 31162e0c..74fd2bd2 100644 --- a/lua/lazyvim/plugins/extras/lang/omnisharp.lua +++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua @@ -1,4 +1,11 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "cs", "vb" }, + root = { "*.sln", "*.csproj", "omnisharp.json", "function.json" }, + }) + end, + { "Hoffs/omnisharp-extended-lsp.nvim", lazy = true }, { "nvim-treesitter/nvim-treesitter", @@ -35,8 +42,9 @@ return { { "williamboman/mason.nvim", opts = function(_, opts) - opts.ensure_installed = opts.ensure_installed or {} - table.insert(opts.ensure_installed, "csharpier") + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "netcoredbg", "csharpier" }) + end end, }, { @@ -65,4 +73,48 @@ return { }, }, }, + { + "mfussenegger/nvim-dap", + optional = true, + opts = function() + local dap = require("dap") + if not dap.adapters["netcoredbg"] then + require("dap").adapters["netcoredbg"] = { + type = "executable", + command = vim.fn.exepath("netcoredbg"), + args = { "--interpreter=vscode" }, + } + end + for _, lang in ipairs({ "cs", "fsharp", "vb" }) do + if not dap.configurations[lang] then + dap.configurations[lang] = { + { + type = "netcoredbg", + name = "Launch file", + request = "launch", + ---@diagnostic disable-next-line: redundant-parameter + program = function() + return vim.fn.input("Path to dll: ", vim.fn.getcwd() .. "/", "file") + end, + cwd = "${workspaceFolder}", + }, + } + end + end + end, + }, + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + "Issafalcon/neotest-dotnet", + }, + opts = { + adapters = { + ["neotest-dotnet"] = { + -- Here we can set options for neotest-dotnet + }, + }, + }, + }, } diff --git a/lua/lazyvim/plugins/extras/lang/python-semshi.lua b/lua/lazyvim/plugins/extras/lang/python-semshi.lua deleted file mode 100644 index e4e32c10..00000000 --- a/lua/lazyvim/plugins/extras/lang/python-semshi.lua +++ /dev/null @@ -1,32 +0,0 @@ -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 index cc9bc52e..7a716b3e 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -1,4 +1,27 @@ +if lazyvim_docs then + -- LSP Server to use for Python. + -- Set to "basedpyright" to use basedpyright instead of pyright. + vim.g.lazyvim_python_lsp = "pyright" + vim.g.lazyvim_python_ruff = "ruff_lsp" +end + +local lsp = vim.g.lazyvim_python_lsp or "pyright" +local ruff = vim.g.lazyvim_python_ruff or "ruff_lsp" + return { + recommended = function() + return LazyVim.extras.wants({ + ft = "python", + root = { + "pyproject.toml", + "setup.py", + "setup.cfg", + "requirements.txt", + "Pipfile", + "pyrightconfig.json", + }, + }) + end, { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) @@ -11,8 +34,22 @@ return { "neovim/nvim-lspconfig", opts = { servers = { - pyright = {}, + pyright = { + enabled = lsp == "pyright", + }, + basedpyright = { + enabled = lsp == "basedpyright", + }, + [lsp] = { + enabled = true, + }, ruff_lsp = { + enabled = ruff == "ruff_lsp", + }, + ruff = { + enabled = ruff == "ruff", + }, + [ruff] = { keys = { { "co", @@ -31,9 +68,9 @@ return { }, }, setup = { - ruff_lsp = function() - require("lazyvim.util").lsp.on_attach(function(client, _) - if client.name == "ruff_lsp" then + [ruff] = function() + LazyVim.lsp.on_attach(function(client, _) + if client.name == ruff then -- Disable hover in favor of Pyright client.server_capabilities.hoverProvider = false end @@ -69,8 +106,7 @@ return { { "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") + require("dap-python").setup(LazyVim.get_pkg_path("debugpy", "/venv/bin/python")) end, }, }, @@ -78,7 +114,7 @@ return { "linux-cultist/venv-selector.nvim", cmd = "VenvSelect", opts = function(_, opts) - if require("lazyvim.util").has("nvim-dap-python") then + if LazyVim.has("nvim-dap-python") then opts.dap_enabled = true end return vim.tbl_deep_extend("force", opts, { @@ -90,6 +126,13 @@ return { }, }) end, - keys = { { "cv", ":VenvSelect", desc = "Select VirtualEnv" } }, + keys = { { "cv", ":VenvSelect", desc = "Select VirtualEnv", ft = "python" } }, + }, + { + "hrsh7th/nvim-cmp", + opts = function(_, opts) + opts.auto_brackets = opts.auto_brackets or {} + table.insert(opts.auto_brackets, "python") + end, }, } diff --git a/lua/lazyvim/plugins/extras/lang/r.lua b/lua/lazyvim/plugins/extras/lang/r.lua new file mode 100644 index 00000000..eee57149 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/r.lua @@ -0,0 +1,94 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "r", + root = { "*.R", "*.Rmd", "*qmd" }, + }) + end, + { + "R-nvim/R.nvim", + lazy = false, + opts = { + -- Create a table with the options to be passed to setup() + R_args = { "--quiet", "--no-save" }, + hook = { + on_filetype = function() + -- This function will be called at the FileType event + -- of files supported by R.nvim. This is an + -- opportunity to create mappings local to buffers. + vim.keymap.set("n", "", "RDSendLine", { buffer = true }) + vim.keymap.set("v", "", "RSendSelection", { buffer = true }) + + -- Increase the width of which-key to handle the longer r-nvim descriptions + local wk = require("which-key") + -- Workaround from https://github.com/folke/which-key.nvim/issues/514#issuecomment-1987286901 + wk.register({ + [""] = { + a = { name = "+(a)ll", ["🚫"] = "which_key_ignore" }, + b = { name = "+(b)etween marks", ["🚫"] = "which_key_ignore" }, + c = { name = "+(c)hunks", ["🚫"] = "which_key_ignore" }, + f = { name = "+(f)unctions", ["🚫"] = "which_key_ignore" }, + g = { name = "+(g)oto", ["🚫"] = "which_key_ignore" }, + k = { name = "+(k)nit", ["🚫"] = "which_key_ignore" }, + p = { name = "+(p)aragraph", ["🚫"] = "which_key_ignore" }, + q = { name = "+(q)uarto", ["🚫"] = "which_key_ignore" }, + r = { name = "+(r) general", ["🚫"] = "which_key_ignore" }, + s = { name = "+(s)plit or (s)end", ["🚫"] = "which_key_ignore" }, + t = { name = "+(t)erminal", ["🚫"] = "which_key_ignore" }, + v = { name = "+(v)iew", ["🚫"] = "which_key_ignore" }, + }, + }) + end, + }, + pdfviewer = "", + }, + config = function(_, opts) + vim.g.rout_follow_colorscheme = true + require("r").setup(opts) + require("r.pdf.generic").open = vim.ui.open + end, + }, + { + "hrsh7th/nvim-cmp", + optional = true, + dependencies = { "R-nvim/cmp-r" }, + opts = function(_, opts) + opts.sources = opts.sources or {} + table.insert(opts.sources, { name = "cmp_r" }) + end, + }, + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "markdown", "markdown_inline", "r", "rnoweb" }) + end + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + r_language_server = { + root_dir = function(fname) + return require("lspconfig.util").root_pattern("DESCRIPTION", "NAMESPACE", ".Rbuildignore")(fname) + or require("lspconfig.util").find_git_ancestor(fname) + or vim.loop.os_homedir() + end, + }, + }, + }, + }, + { + "nvim-neotest/neotest", + optional = true, + dependencies = { + "shunsambongi/neotest-testthat", + }, + opts = { + adapters = { + ["neotest-testthat"] = {}, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/ruby.lua b/lua/lazyvim/plugins/extras/lang/ruby.lua index a7894692..40ff8005 100644 --- a/lua/lazyvim/plugins/extras/lang/ruby.lua +++ b/lua/lazyvim/plugins/extras/lang/ruby.lua @@ -1,4 +1,10 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = "ruby", + root = "Gemfile", + }) + end, { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) diff --git a/lua/lazyvim/plugins/extras/lang/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua index 1e6e0594..5a3c59d7 100644 --- a/lua/lazyvim/plugins/extras/lang/rust.lua +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -1,4 +1,10 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = "rust", + root = { "Cargo.toml", "rust-project.json" }, + }) + end, -- Extend auto completion { @@ -8,7 +14,7 @@ return { "Saecki/crates.nvim", event = { "BufRead Cargo.toml" }, opts = { - src = { + completion = { cmp = { enabled = true }, }, }, @@ -16,10 +22,8 @@ return { }, ---@param opts cmp.ConfigSchema opts = function(_, opts) - local cmp = require("cmp") - opts.sources = cmp.config.sources(vim.list_extend(opts.sources, { - { name = "crates" }, - })) + opts.sources = opts.sources or {} + table.insert(opts.sources, { name = "crates" }) end, }, @@ -27,9 +31,8 @@ return { { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) - if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "ron", "rust", "toml" }) - end + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "ron", "rust", "toml" }) end, }, @@ -38,51 +41,62 @@ return { "williamboman/mason.nvim", optional = true, opts = function(_, opts) - if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "codelldb" }) - end + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "codelldb" }) 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) + "mrcjkb/rustaceanvim", + version = "^4", -- Recommended + ft = { "rust" }, + opts = { + server = { + on_attach = function(_, bufnr) + vim.keymap.set("n", "cR", function() + vim.cmd.RustLsp("codeAction") + end, { desc = "Code Action", buffer = bufnr }) + vim.keymap.set("n", "dr", function() + vim.cmd.RustLsp("debuggables") + end, { desc = "Rust Debuggables", buffer = bufnr }) + end, + default_settings = { + -- rust-analyzer language server configuration + ["rust-analyzer"] = { + cargo = { + allFeatures = true, + loadOutDirsFromCheck = true, + buildScripts = { + enable = 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" }, + }, + }, + }, + }, + }, + }, + config = function(_, opts) + vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {}) + if vim.fn.executable("rust-analyzer") == 0 then + LazyVim.error( + "**rust-analyzer** not found in PATH, please install it.\nhttps://rust-analyzer.github.io/", + { title = "rustaceanvim" } + ) 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 🚀 @@ -90,37 +104,6 @@ return { "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 = { { @@ -137,26 +120,17 @@ return { }, }, }, - 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"] = {}, - }, - }, + opts = function(_, opts) + opts.adapters = opts.adapters or {} + vim.list_extend(opts.adapters, { + require("rustaceanvim.neotest"), + }) + end, }, } diff --git a/lua/lazyvim/plugins/extras/lang/scala.lua b/lua/lazyvim/plugins/extras/lang/scala.lua new file mode 100644 index 00000000..2092b15c --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/scala.lua @@ -0,0 +1,98 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "scala", + root = { "build.sbt", "build.sc", "build.gradle", "pom.xml" }, + }) + end, + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "scala" }) + end + end, + }, + { + "scalameta/nvim-metals", + ft = { "scala", "sbt" }, + config = function() end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + metals = { + keys = { + { + "me", + function() + require("telescope").extensions.metals.commands() + end, + desc = "Metals commands", + }, + { + "mc", + function() + require("metals").compile_cascade() + end, + desc = "Metals compile cascade", + }, + }, + init_options = { + statusBarProvider = "off", + }, + settings = { + showImplicitArguments = true, + excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" }, + }, + }, + }, + setup = { + metals = function(_, opts) + local metals = require("metals") + local metals_config = vim.tbl_deep_extend("force", metals.bare_config(), opts) + metals_config.on_attach = LazyVim.has("nvim-dap") and metals.setup_dap or nil + + local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) + vim.api.nvim_create_autocmd("FileType", { + pattern = { "scala", "sbt" }, + callback = function() + metals.initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + return true + end, + }, + }, + }, + + { + "mfussenegger/nvim-dap", + optional = true, + opts = function() + -- Debug settings + local dap = require("dap") + dap.configurations.scala = { + { + type = "scala", + request = "launch", + name = "RunOrTest", + metals = { + runType = "runOrTestFile", + --args = { "firstArg", "secondArg", "thirdArg" }, -- here just as an example + }, + }, + { + type = "scala", + request = "launch", + name = "Test Target", + metals = { + runType = "testTarget", + }, + }, + } + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/svelte.lua b/lua/lazyvim/plugins/extras/lang/svelte.lua new file mode 100644 index 00000000..4319b509 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/svelte.lua @@ -0,0 +1,48 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "svelte", + root = { + "svelte.config.js", + "svelte.config.mjs", + "svelte.config.cjs", + }, + }) + end, + + -- depends on the typescript extra + { import = "lazyvim.plugins.extras.lang.typescript" }, + + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "svelte" }) + end + end, + }, + + -- LSP Servers + { + "neovim/nvim-lspconfig", + opts = { + servers = { + svelte = {}, + }, + }, + }, + + -- Configure tsserver plugin + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { + { + name = "typescript-svelte-plugin", + location = LazyVim.get_pkg_path("svelte-language-server", "/node_modules/typescript-svelte-plugin"), + enableForWorkspaceTypeScriptVersions = true, + }, + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/tailwind.lua b/lua/lazyvim/plugins/extras/lang/tailwind.lua index 795449ee..17ed92ef 100644 --- a/lua/lazyvim/plugins/extras/lang/tailwind.lua +++ b/lua/lazyvim/plugins/extras/lang/tailwind.lua @@ -1,4 +1,18 @@ return { + recommended = function() + return LazyVim.extras.wants({ + root = { + "tailwind.config.js", + "tailwind.config.cjs", + "tailwind.config.mjs", + "tailwind.config.ts", + "postcss.config.js", + "postcss.config.cjs", + "postcss.config.mjs", + "postcss.config.ts", + }, + }) + end, { "neovim/nvim-lspconfig", opts = { diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua index ea7bd5de..e75a0eca 100644 --- a/lua/lazyvim/plugins/extras/lang/terraform.lua +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -1,10 +1,11 @@ -vim.api.nvim_create_autocmd("FileType", { - pattern = { "hcl", "terraform" }, - desc = "terraform/hcl commentstring configuration", - command = "setlocal commentstring=#\\ %s", -}) - return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "terraform", "hcl" }, + root = ".terraform", + }) + end, + { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) @@ -24,6 +25,14 @@ return { }, }, }, + -- ensure terraform tools are installed + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "tflint" }) + end, + }, { "nvimtools/none-ls.nvim", optional = true, @@ -56,4 +65,25 @@ return { }, }, }, + { + "nvim-telescope/telescope.nvim", + dependencies = { + { + "ANGkeith/telescope-terraform-doc.nvim", + config = function() + LazyVim.on_load("telescope.nvim", function() + require("telescope").load_extension("terraform_doc") + end) + end, + }, + { + "cappyzawa/telescope-terraform.nvim", + config = function() + LazyVim.on_load("telescope.nvim", function() + require("telescope").load_extension("terraform") + end) + end, + }, + }, + }, } diff --git a/lua/lazyvim/plugins/extras/lang/tex.lua b/lua/lazyvim/plugins/extras/lang/tex.lua index e8d4feff..5d667b40 100644 --- a/lua/lazyvim/plugins/extras/lang/tex.lua +++ b/lua/lazyvim/plugins/extras/lang/tex.lua @@ -1,4 +1,10 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = { "tex", "plaintex", "bib" }, + root = { ".latexmkrc", ".texlabroot", "texlabroot", "Tectonic.toml" }, + }) + end, { "folke/which-key.nvim", optional = true, @@ -14,7 +20,7 @@ return { "nvim-treesitter/nvim-treesitter", opts = function(_, opts) if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "bibtex", "latex" }) + vim.list_extend(opts.ensure_installed, { "bibtex" }) end if type(opts.highlight.disable) == "table" then vim.list_extend(opts.highlight.disable, { "latex" }) @@ -28,14 +34,6 @@ return { "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, diff --git a/lua/lazyvim/plugins/extras/lang/toml.lua b/lua/lazyvim/plugins/extras/lang/toml.lua new file mode 100644 index 00000000..9dcc029d --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/toml.lua @@ -0,0 +1,31 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "toml", + root = "*.toml", + }) + end, + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "toml" }) + end + end, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "taplo" }) + end, + }, + { + "neovim/nvim-lspconfig", + opts = { + servers = { + taplo = {}, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 4f53ae8c..482af408 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -1,12 +1,24 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, + root = { "tsconfig.json", "package.json", "jsconfig.json" }, + }) + end, - -- add typescript to treesitter { - "nvim-treesitter/nvim-treesitter", - opts = function(_, opts) - if type(opts.ensure_installed) == "table" then - vim.list_extend(opts.ensure_installed, { "typescript", "tsx" }) - end + "yioneko/nvim-vtsls", + lazy = true, + opts = {}, + config = function(_, opts) + require("vtsls").config(opts) end, }, @@ -16,59 +28,113 @@ return { opts = { -- make sure mason installs the server servers = { - ---@type lspconfig.options.tsserver tsserver = { + enabled = false, + }, + vtsls = { + -- explicitly add default filetypes, so that we can extend + -- them in related extras + filetypes = { + "javascript", + "javascriptreact", + "javascript.jsx", + "typescript", + "typescriptreact", + "typescript.tsx", + }, + settings = { + complete_function_calls = true, + vtsls = { + enableMoveToFileCodeAction = true, + autoUseWorkspaceTsdk = true, + experimental = { + completion = { + enableServerSideFuzzyMatch = true, + }, + }, + }, + typescript = { + updateImportsOnFileMove = { enabled = "always" }, + suggest = { + completeFunctionCalls = true, + }, + inlayHints = { + enumMemberValues = { enabled = true }, + functionLikeReturnTypes = { enabled = true }, + parameterNames = { enabled = "literals" }, + parameterTypes = { enabled = true }, + propertyDeclarationTypes = { enabled = true }, + variableTypes = { enabled = false }, + }, + }, + }, keys = { + { + "gD", + function() + require("vtsls").commands.goto_source_definition(0) + end, + desc = "Goto Source Definition", + }, + { + "gR", + function() + require("vtsls").commands.file_references(0) + end, + desc = "File References", + }, { "co", function() - vim.lsp.buf.code_action({ - apply = true, - context = { - only = { "source.organizeImports.ts" }, - diagnostics = {}, - }, - }) + require("vtsls").commands.organize_imports(0) end, desc = "Organize Imports", }, { - "cR", + "cM", function() - vim.lsp.buf.code_action({ - apply = true, - context = { - only = { "source.removeUnused.ts" }, - diagnostics = {}, - }, - }) + require("vtsls").commands.add_missing_imports(0) end, - desc = "Remove Unused Imports", + desc = "Add missing imports", }, - }, - settings = { - typescript = { - format = { - indentSize = vim.o.shiftwidth, - convertTabsToSpaces = vim.o.expandtab, - tabSize = vim.o.tabstop, - }, + { + "cu", + function() + require("vtsls").commands.remove_unused_imports(0) + end, + desc = "Remove unused imports", }, - javascript = { - format = { - indentSize = vim.o.shiftwidth, - convertTabsToSpaces = vim.o.expandtab, - tabSize = vim.o.tabstop, - }, + { + "cD", + function() + require("vtsls").commands.fix_all(0) + end, + desc = "Fix all diagnostics", }, - completions = { - completeFunctionCalls = true, + { + "cV", + function() + require("vtsls").commands.select_ts_version(0) + end, + desc = "Select TS workspace version", }, }, }, }, + setup = { + tsserver = function() + -- disable tsserver + return true + end, + vtsls = function(_, opts) + -- copy typescript settings to javascript + opts.settings.javascript = + vim.tbl_deep_extend("force", {}, opts.settings.typescript, opts.settings.javascript or {}) + end, + }, }, }, + { "mfussenegger/nvim-dap", optional = true, @@ -92,13 +158,26 @@ return { command = "node", -- 💀 Make sure to update this path to point to your installation args = { - require("mason-registry").get_package("js-debug-adapter"):get_install_path() - .. "/js-debug/src/dapDebugServer.js", + LazyVim.get_pkg_path("js-debug-adapter", "/js-debug/src/dapDebugServer.js"), "${port}", }, }, } end + if not dap.adapters["node"] then + dap.adapters["node"] = function(cb, config) + if config.type == "node" then + config.type = "pwa-node" + end + local nativeAdapter = dap.adapters["pwa-node"] + if type(nativeAdapter) == "function" then + nativeAdapter(cb, config) + else + cb(nativeAdapter) + end + end + end + 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/vue.lua b/lua/lazyvim/plugins/extras/lang/vue.lua new file mode 100644 index 00000000..6c47d56e --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/vue.lua @@ -0,0 +1,48 @@ +return { + recommended = function() + return LazyVim.extras.wants({ + ft = "vue", + root = { "vue.config.js" }, + }) + end, + + -- depends on the typescript extra + { import = "lazyvim.plugins.extras.lang.typescript" }, + + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + if type(opts.ensure_installed) == "table" then + vim.list_extend(opts.ensure_installed, { "vue" }) + end + end, + }, + + -- Add LSP servers + { + "neovim/nvim-lspconfig", + opts = { + servers = { + volar = {}, + vtsls = {}, + }, + }, + }, + + -- Configure tsserver plugin + { + "neovim/nvim-lspconfig", + opts = function(_, opts) + table.insert(opts.servers.vtsls.filetypes, "vue") + LazyVim.extend(opts.servers.vtsls, "settings.vtsls.tsserver.globalPlugins", { + { + name = "@vue/typescript-plugin", + location = LazyVim.get_pkg_path("vue-language-server", "/node_modules/@vue/language-server"), + languages = { "vue" }, + configNamespace = "typescript", + enableForWorkspaceTypeScriptVersions = true, + }, + }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua index 5afe1b83..0aa23a2b 100644 --- a/lua/lazyvim/plugins/extras/lang/yaml.lua +++ b/lua/lazyvim/plugins/extras/lang/yaml.lua @@ -1,4 +1,9 @@ return { + recommended = function() + return LazyVim.extras.wants({ + ft = "yaml", + }) + end, -- add yaml specific modules to treesitter { @@ -64,7 +69,7 @@ return { 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, _) + LazyVim.lsp.on_attach(function(client, _) if client.name == "yamlls" then client.server_capabilities.documentFormattingProvider = true end diff --git a/lua/lazyvim/plugins/extras/linting/eslint.lua b/lua/lazyvim/plugins/extras/linting/eslint.lua index 9537303d..df6e79dd 100644 --- a/lua/lazyvim/plugins/extras/linting/eslint.lua +++ b/lua/lazyvim/plugins/extras/linting/eslint.lua @@ -8,17 +8,17 @@ return { eslint = { settings = { -- helps eslint find the eslintrc when it's placed in a subfolder instead of the cwd root - workingDirectory = { mode = "auto" }, + workingDirectories = { mode = "auto" }, }, }, }, setup = { eslint = function() local function get_client(buf) - return require("lazyvim.util").lsp.get_clients({ name = "eslint", bufnr = buf })[1] + return LazyVim.lsp.get_clients({ name = "eslint", bufnr = buf })[1] end - local formatter = require("lazyvim.util").lsp.formatter({ + local formatter = LazyVim.lsp.formatter({ name = "eslint: lsp", primary = false, priority = 200, @@ -44,7 +44,7 @@ return { end -- register the formatter with LazyVim - require("lazyvim.util").format.register(formatter) + LazyVim.format.register(formatter) end, }, }, diff --git a/lua/lazyvim/plugins/extras/lsp/neoconf.lua b/lua/lazyvim/plugins/extras/lsp/neoconf.lua new file mode 100644 index 00000000..4016816d --- /dev/null +++ b/lua/lazyvim/plugins/extras/lsp/neoconf.lua @@ -0,0 +1,12 @@ +return { + { + "neovim/nvim-lspconfig", + dependencies = { + { + "folke/neoconf.nvim", + cmd = "Neoconf", + opts = {}, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lsp/none-ls.lua b/lua/lazyvim/plugins/extras/lsp/none-ls.lua index aa907b8e..40651e2d 100644 --- a/lua/lazyvim/plugins/extras/lsp/none-ls.lua +++ b/lua/lazyvim/plugins/extras/lsp/none-ls.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { -- none-ls { @@ -7,14 +5,14 @@ return { event = "LazyFile", dependencies = { "mason.nvim" }, init = function() - Util.on_very_lazy(function() + LazyVim.on_very_lazy(function() -- register the formatter with LazyVim - require("lazyvim.util").format.register({ + LazyVim.format.register({ name = "none-ls.nvim", priority = 200, -- set higher than conform, the builtin formatter primary = true, format = function(buf) - return Util.lsp.format({ + return LazyVim.lsp.format({ bufnr = buf, filter = function(client) return client.name == "null-ls" diff --git a/lua/lazyvim/plugins/extras/test/core.lua b/lua/lazyvim/plugins/extras/test/core.lua index 321955ab..9a91ccc3 100644 --- a/lua/lazyvim/plugins/extras/test/core.lua +++ b/lua/lazyvim/plugins/extras/test/core.lua @@ -1,4 +1,6 @@ return { + recommended = true, + desc = "Neotest support. Requires language specific adapters to be configured. (see lang extras)", { "folke/which-key.nvim", optional = true, @@ -10,6 +12,7 @@ return { }, { "nvim-neotest/neotest", + dependencies = { "nvim-neotest/nvim-nio" }, opts = { -- Can be a list of adapters like what neotest expects, -- or a list of adapter names, @@ -26,7 +29,7 @@ return { output = { open_on_run = true }, quickfix = { open = function() - if require("lazyvim.util").has("trouble.nvim") then + if LazyVim.has("trouble.nvim") then require("trouble").open({ mode = "quickfix", focus = false }) else vim.cmd("copen") @@ -46,7 +49,7 @@ return { }, }, neotest_ns) - if require("lazyvim.util").has("trouble.nvim") then + if LazyVim.has("trouble.nvim") then opts.consumers = opts.consumers or {} -- Refresh and auto close trouble after running tests ---@type neotest.Consumer @@ -108,8 +111,9 @@ return { -- stylua: ignore keys = { { "tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" }, - { "tT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" }, + { "tT", function() require("neotest").run.run(vim.uv.cwd()) end, desc = "Run All Test Files" }, { "tr", function() require("neotest").run.run() end, desc = "Run Nearest" }, + { "tl", function() require("neotest").run.run_last() end, desc = "Run Last" }, { "ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" }, { "to", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" }, { "tO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" }, diff --git a/lua/lazyvim/plugins/extras/ui/edgy.lua b/lua/lazyvim/plugins/extras/ui/edgy.lua index e2513828..4ccdc5f0 100644 --- a/lua/lazyvim/plugins/extras/ui/edgy.lua +++ b/lua/lazyvim/plugins/extras/ui/edgy.lua @@ -40,12 +40,6 @@ 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", @@ -67,7 +61,7 @@ return { end, pinned = true, open = function() - vim.api.nvim_input("e") + require("neo-tree.command").execute({ dir = LazyVim.root() }) end, size = { height = 0.5 }, }, @@ -111,6 +105,19 @@ return { end, }, } + for _, pos in ipairs({ "top", "bottom", "left", "right" }) do + opts[pos] = opts[pos] or {} + table.insert(opts[pos], { + ft = "trouble", + filter = function(_buf, win) + return vim.w[win].trouble + and vim.w[win].trouble.position == pos + and vim.w[win].trouble.type == "split" + and vim.w[win].trouble.relative == "editor" + and not vim.w[win].trouble_preview + end, + }) + end return opts end, }, diff --git a/lua/lazyvim/plugins/extras/ui/mini-animate.lua b/lua/lazyvim/plugins/extras/ui/mini-animate.lua index dd2f8cd7..c1f44d6d 100644 --- a/lua/lazyvim/plugins/extras/ui/mini-animate.lua +++ b/lua/lazyvim/plugins/extras/ui/mini-animate.lua @@ -1,37 +1,36 @@ +-- animations return { - -- animations - { - "echasnovski/mini.animate", - event = "VeryLazy", - opts = function() - -- don't use animate when scrolling with the mouse - local mouse_scrolled = false - for _, scroll in ipairs({ "Up", "Down" }) do - local key = "" - vim.keymap.set({ "", "i" }, key, function() - mouse_scrolled = true - return key - end, { expr = true }) - end + "echasnovski/mini.animate", + recommended = true, + event = "VeryLazy", + opts = function() + -- don't use animate when scrolling with the mouse + local mouse_scrolled = false + for _, scroll in ipairs({ "Up", "Down" }) do + local key = "" + vim.keymap.set({ "", "i" }, key, function() + mouse_scrolled = true + return key + end, { expr = true }) + end - local animate = require("mini.animate") - return { - resize = { - timing = animate.gen_timing.linear({ duration = 100, unit = "total" }), - }, - scroll = { - timing = animate.gen_timing.linear({ duration = 150, unit = "total" }), - subscroll = animate.gen_subscroll.equal({ - predicate = function(total_scroll) - if mouse_scrolled then - mouse_scrolled = false - return false - end - return total_scroll > 1 - end, - }), - }, - } - end, - }, + local animate = require("mini.animate") + return { + resize = { + timing = animate.gen_timing.linear({ duration = 50, unit = "total" }), + }, + scroll = { + timing = animate.gen_timing.linear({ duration = 150, unit = "total" }), + subscroll = animate.gen_subscroll.equal({ + predicate = function(total_scroll) + if mouse_scrolled then + mouse_scrolled = false + return false + end + return total_scroll > 1 + end, + }), + }, + } + end, } diff --git a/lua/lazyvim/plugins/extras/ui/mini-indentscope.lua b/lua/lazyvim/plugins/extras/ui/mini-indentscope.lua new file mode 100644 index 00000000..a7632145 --- /dev/null +++ b/lua/lazyvim/plugins/extras/ui/mini-indentscope.lua @@ -0,0 +1,42 @@ +return { + -- 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 = "LazyFile", + opts = { + -- symbol = "▏", + symbol = "│", + options = { try_as_border = true }, + }, + init = function() + vim.api.nvim_create_autocmd("FileType", { + pattern = { + "help", + "alpha", + "dashboard", + "neo-tree", + "Trouble", + "trouble", + "lazy", + "mason", + "notify", + "toggleterm", + "lazyterm", + }, + callback = function() + vim.b.miniindentscope_disable = true + end, + }) + end, + }, + { + "lukas-reineke/indent-blankline.nvim", + event = "LazyFile", + opts = { + scope = { enabled = false }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/ui/mini-starter.lua b/lua/lazyvim/plugins/extras/ui/mini-starter.lua index 5f5ec9c5..e6078d60 100644 --- a/lua/lazyvim/plugins/extras/ui/mini-starter.lua +++ b/lua/lazyvim/plugins/extras/ui/mini-starter.lua @@ -63,12 +63,15 @@ return { vim.api.nvim_create_autocmd("User", { pattern = "LazyVimStarted", - callback = function() + callback = function(ev) local stats = require("lazy").stats() local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100) local pad_footer = string.rep(" ", 8) starter.config.footer = pad_footer .. "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" - pcall(starter.refresh) + -- INFO: based on @echasnovski's recommendation (thanks a lot!!!) + if vim.bo[ev.buf].filetype == "starter" then + pcall(starter.refresh) + end end, }) end, diff --git a/lua/lazyvim/plugins/extras/ui/treesitter-context.lua b/lua/lazyvim/plugins/extras/ui/treesitter-context.lua new file mode 100644 index 00000000..a1f8d5f3 --- /dev/null +++ b/lua/lazyvim/plugins/extras/ui/treesitter-context.lua @@ -0,0 +1,21 @@ +-- Show context of the current function +return { + "nvim-treesitter/nvim-treesitter-context", + event = "LazyFile", + opts = { mode = "cursor", max_lines = 3 }, + keys = { + { + "ut", + function() + local tsc = require("treesitter-context") + tsc.toggle() + if LazyVim.inject.get_upvalue(tsc.toggle, "enabled") then + LazyVim.info("Enabled Treesitter Context", { title = "Option" }) + else + LazyVim.warn("Disabled Treesitter Context", { title = "Option" }) + end + end, + desc = "Toggle Treesitter Context", + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/util/dot.lua b/lua/lazyvim/plugins/extras/util/dot.lua index c25e0f6c..8066d363 100644 --- a/lua/lazyvim/plugins/extras/util/dot.lua +++ b/lua/lazyvim/plugins/extras/util/dot.lua @@ -3,35 +3,27 @@ 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 + return vim.uv.fs_stat(xdg_config .. "/" .. path) ~= nil end return { - - -- Add Hyprland Parser + recommended = true, + desc = "Language support for dotfiles", { - "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", - } + "neovim/nvim-lspconfig", + opts = { + servers = { + bashls = {}, + }, + }, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "shellcheck" }) end, }, - -- add some stuff to treesitter { "nvim-treesitter/nvim-treesitter", @@ -43,16 +35,25 @@ return { end vim.filetype.add({ - extension = { rasi = "rasi" }, + extension = { rasi = "rasi", rofi = "rasi", wofi = "rasi" }, + filename = { + ["vifmrc"] = "vim", + }, pattern = { [".*/waybar/config"] = "jsonc", [".*/mako/config"] = "dosini", - [".*/kitty/*.conf"] = "bash", + [".*/kitty/.+%.conf"] = "bash", + [".*/hypr/.+%.conf"] = "hyprlang", + ["%.env%.[%w_.-]+"] = "sh", }, }) add("git_config") + if have("hypr") then + add("hyprlang") + end + if have("fish") then add("fish") end diff --git a/lua/lazyvim/plugins/extras/util/gitui.lua b/lua/lazyvim/plugins/extras/util/gitui.lua new file mode 100644 index 00000000..2a7a4fa6 --- /dev/null +++ b/lua/lazyvim/plugins/extras/util/gitui.lua @@ -0,0 +1,38 @@ +return { + + -- Ensure GitUI tool is installed + { + "williamboman/mason.nvim", + keys = { + { + "gG", + function() + LazyVim.terminal.open({ "gitui" }, { esc_esc = false, ctrl_hjkl = false }) + end, + desc = "GitUi (cwd)", + }, + { + "gg", + function() + LazyVim.terminal.open({ "gitui" }, { cwd = LazyVim.root.get(), esc_esc = false, ctrl_hjkl = false }) + end, + desc = "GitUi (Root Dir)", + }, + }, + init = function() + -- delete lazygit keymap for file history + vim.api.nvim_create_autocmd("User", { + pattern = "LazyVimKeymaps", + once = true, + callback = function() + pcall(vim.keymap.del, "n", "gf") + pcall(vim.keymap.del, "n", "gl") + end, + }) + end, + opts = function(_, opts) + opts.ensure_installed = opts.ensure_installed or {} + vim.list_extend(opts.ensure_installed, { "gitui" }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua index 2add9c2f..287c0d77 100644 --- a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua +++ b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua @@ -5,6 +5,8 @@ M.hl = {} M.plugin = { "echasnovski/mini.hipatterns", + recommended = true, + desc = "Highlight colors in your code. Also includes Tailwind CSS support.", event = "LazyFile", opts = function() local hi = require("mini.hipatterns") @@ -12,25 +14,42 @@ M.plugin = { -- custom LazyVim option to enable the tailwind integration tailwind = { enabled = true, - ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" }, + ft = { + "astro", + "css", + "heex", + "html", + "html-eex", + "javascript", + "javascriptreact", + "rust", + "svelte", + "typescript", + "typescriptreact", + "vue", + }, -- full: the whole css class will be highlighted -- compact: only the color will be highlighted style = "full", }, highlighters = { hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }), + shorthand = { + pattern = "()#%x%x%x()%f[^%x%w]", + group = function(_, _, data) + ---@type string + local match = data.full_match + local r, g, b = match:sub(2, 2), match:sub(3, 3), match:sub(4, 4) + local hex_color = "#" .. r .. r .. g .. g .. b .. b + + return MiniHipatterns.compute_hex_color_group(hex_color, "bg") + end, + extmark_opts = { priority = 2000 }, + }, }, } end, config = function(_, opts) - -- backward compatibility - if opts.tailwind == true then - opts.tailwind = { - enabled = true, - ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" }, - style = "full", - } - end if type(opts.tailwind) == "table" and opts.tailwind.enabled then -- reset hl groups when colorscheme changes vim.api.nvim_create_autocmd("ColorScheme", { diff --git a/lua/lazyvim/plugins/extras/util/project.lua b/lua/lazyvim/plugins/extras/util/project.lua index 3936c96a..16e72077 100644 --- a/lua/lazyvim/plugins/extras/util/project.lua +++ b/lua/lazyvim/plugins/extras/util/project.lua @@ -11,7 +11,7 @@ return { event = "VeryLazy", config = function(_, opts) require("project_nvim").setup(opts) - require("lazyvim.util").on_load("telescope.nvim", function() + LazyVim.on_load("telescope.nvim", function() require("telescope").load_extension("projects") end) end, diff --git a/lua/lazyvim/plugins/extras/util/startuptime.lua b/lua/lazyvim/plugins/extras/util/startuptime.lua new file mode 100644 index 00000000..5775b564 --- /dev/null +++ b/lua/lazyvim/plugins/extras/util/startuptime.lua @@ -0,0 +1,8 @@ +-- measure startuptime +return { + "dstein64/vim-startuptime", + cmd = "StartupTime", + config = function() + vim.g.startuptime_tries = 10 + end, +} diff --git a/lua/lazyvim/plugins/extras/vscode.lua b/lua/lazyvim/plugins/extras/vscode.lua index 6f78fd9f..25930d1d 100644 --- a/lua/lazyvim/plugins/extras/vscode.lua +++ b/lua/lazyvim/plugins/extras/vscode.lua @@ -3,17 +3,21 @@ if not vim.g.vscode then end local enabled = { + "dial.nvim", "flit.nvim", "lazy.nvim", "leap.nvim", "mini.ai", "mini.comment", + "mini.move", "mini.pairs", "mini.surround", "nvim-treesitter", "nvim-treesitter-textobjects", "nvim-ts-context-commentstring", + "ts-comments.nvim", "vim-repeat", + "yanky.nvim", "LazyVim", } diff --git a/lua/lazyvim/plugins/formatting.lua b/lua/lazyvim/plugins/formatting.lua index eb2dd1a8..28dea8ed 100644 --- a/lua/lazyvim/plugins/formatting.lua +++ b/lua/lazyvim/plugins/formatting.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - local M = {} ---@param opts ConformOpts @@ -10,14 +8,17 @@ function M.setup(_, opts) 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)) + LazyVim.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( + LazyVim.warn( ("Don't set `opts.%s` for `conform.nvim`.\n**LazyVim** will use the conform formatter automatically"):format( key ) @@ -39,7 +40,7 @@ return { { "cF", function() - require("conform").format({ formatters = { "injected" } }) + require("conform").format({ formatters = { "injected" }, timeout_ms = 3000 }) end, mode = { "n", "v" }, desc = "Format Injected Langs", @@ -47,16 +48,14 @@ return { }, init = function() -- Install the conform formatter on VeryLazy - require("lazyvim.util").on_very_lazy(function() - require("lazyvim.util").format.register({ + LazyVim.on_very_lazy(function() + LazyVim.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 })) + local opts = LazyVim.opts("conform.nvim") + require("conform").format(LazyVim.merge({}, opts.format, { bufnr = buf })) end, sources = function(buf) local ret = require("conform").list_formatters(buf) @@ -71,7 +70,7 @@ return { opts = function() local plugin = require("lazy.core.config").plugins["conform.nvim"] if plugin.config ~= M.setup then - Util.error({ + LazyVim.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", @@ -84,6 +83,7 @@ return { timeout_ms = 3000, async = false, -- not recommended to change quiet = false, -- not recommended to change + lsp_fallback = true, -- not recommended to change }, ---@type table formatters_by_ft = { diff --git a/lua/lazyvim/plugins/linting.lua b/lua/lazyvim/plugins/linting.lua index 2d2527c1..c532e59b 100644 --- a/lua/lazyvim/plugins/linting.lua +++ b/lua/lazyvim/plugins/linting.lua @@ -11,6 +11,7 @@ return { -- ['*'] = { 'global linter' }, -- Use the "_" filetype to run linters on filetypes that don't have other linters configured. -- ['_'] = { 'fallback linter' }, + -- ["*"] = { "typos" }, }, -- LazyVim extension to easily override linter options -- or add custom linters. @@ -27,8 +28,6 @@ return { }, }, config = function(_, opts) - local Util = require("lazyvim.util") - local M = {} local lint = require("lint") @@ -42,7 +41,7 @@ return { lint.linters_by_ft = opts.linters_by_ft function M.debounce(ms, fn) - local timer = vim.loop.new_timer() + local timer = vim.uv.new_timer() return function(...) local argv = { ... } timer:start(ms, 0, function() @@ -59,6 +58,9 @@ return { -- * 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) + -- Create a copy of the names table to avoid modifying the original. + names = vim.list_extend({}, names) + -- Add fallback linters. if #names == 0 then vim.list_extend(names, lint.linters_by_ft["_"] or {}) @@ -73,7 +75,7 @@ return { names = vim.tbl_filter(function(name) local linter = lint.linters[name] if not linter then - Util.warn("Linter not found: " .. name, { title = "nvim-lint" }) + LazyVim.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) diff --git a/lua/lazyvim/plugins/lsp/init.lua b/lua/lazyvim/plugins/lsp/init.lua index f0823e46..5066d393 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -1,128 +1,170 @@ -local Util = require("lazyvim.util") - return { -- lspconfig { "neovim/nvim-lspconfig", event = "LazyFile", dependencies = { - { "folke/neoconf.nvim", cmd = "Neoconf", config = false, dependencies = { "nvim-lspconfig" } }, - { "folke/neodev.nvim", opts = {} }, "mason.nvim", "williamboman/mason-lspconfig.nvim", }, ---@class PluginLspOpts - opts = { - -- options for vim.diagnostic.config() - diagnostics = { - underline = true, - update_in_insert = false, - virtual_text = { - spacing = 4, - source = "if_many", - prefix = "●", - -- this will set set the prefix to a function that returns the diagnostics icon based on the severity - -- this only works on a recent 0.10.0 build. Will be set to "●" when not supported - -- prefix = "icons", + opts = function() + return { + -- options for vim.diagnostic.config() + ---@type vim.diagnostic.Opts + diagnostics = { + underline = true, + update_in_insert = false, + virtual_text = { + spacing = 4, + source = "if_many", + prefix = "●", + -- this will set set the prefix to a function that returns the diagnostics icon based on the severity + -- this only works on a recent 0.10.0 build. Will be set to "●" when not supported + -- prefix = "icons", + }, + severity_sort = true, + signs = { + text = { + [vim.diagnostic.severity.ERROR] = LazyVim.config.icons.diagnostics.Error, + [vim.diagnostic.severity.WARN] = LazyVim.config.icons.diagnostics.Warn, + [vim.diagnostic.severity.HINT] = LazyVim.config.icons.diagnostics.Hint, + [vim.diagnostic.severity.INFO] = LazyVim.config.icons.diagnostics.Info, + }, + }, }, - severity_sort = true, - }, - -- Enable this to enable the builtin LSP inlay hints on Neovim >= 0.10.0 - -- Be aware that you also will need to properly configure your LSP server to - -- provide the inlay hints. - inlay_hints = { - enabled = false, - }, - -- add any global capabilities here - capabilities = {}, - -- options for vim.lsp.buf.format - -- `bufnr` and `filter` is handled by the LazyVim formatter, - -- but can be also overridden when specified - format = { - formatting_options = nil, - timeout_ms = nil, - }, - -- LSP Server Settings - ---@type lspconfig.options - servers = { - 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 = { - checkThirdParty = false, - }, - completion = { - callSnippet = "Replace", + -- Enable this to enable the builtin LSP inlay hints on Neovim >= 0.10.0 + -- Be aware that you also will need to properly configure your LSP server to + -- provide the inlay hints. + inlay_hints = { + enabled = true, + exclude = {}, -- filetypes for which you don't want to enable inlay hints + }, + -- Enable this to enable the builtin LSP code lenses on Neovim >= 0.10.0 + -- Be aware that you also will need to properly configure your LSP server to + -- provide the code lenses. + codelens = { + enabled = false, + }, + -- Enable lsp cursor word highlighting + document_highlight = { + enabled = true, + }, + -- add any global capabilities here + capabilities = { + workspace = { + fileOperations = { + didRename = true, + willRename = true, + }, + }, + }, + -- options for vim.lsp.buf.format + -- `bufnr` and `filter` is handled by the LazyVim formatter, + -- but can be also overridden when specified + format = { + formatting_options = nil, + timeout_ms = nil, + }, + -- LSP Server Settings + ---@type lspconfig.options + servers = { + 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 = { + checkThirdParty = false, + }, + codeLens = { + enable = true, + }, + completion = { + callSnippet = "Replace", + }, + doc = { + privateName = { "^_" }, + }, + hint = { + enable = true, + setType = false, + paramType = true, + paramName = "Disable", + semicolon = "Disable", + arrayIndex = "Disable", + }, }, }, }, }, - }, - -- you can do any additional lsp server setup here - -- return true if you don't want this server to be setup with lspconfig - ---@type table - setup = { - -- example to setup with typescript.nvim - -- tsserver = function(_, opts) - -- require("typescript").setup({ server = opts }) - -- return true - -- end, - -- Specify * to use this function as a fallback for any server - -- ["*"] = function(server, opts) end, - }, - }, + -- you can do any additional lsp server setup here + -- return true if you don't want this server to be setup with lspconfig + ---@type table + setup = { + -- example to setup with typescript.nvim + -- tsserver = function(_, opts) + -- require("typescript").setup({ server = opts }) + -- return true + -- end, + -- Specify * to use this function as a fallback for any server + -- ["*"] = function(server, opts) end, + }, + } + end, ---@param opts PluginLspOpts config = function(_, opts) - 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 - 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 + LazyVim.format.register(LazyVim.lsp.formatter()) -- setup keymaps - Util.lsp.on_attach(function(client, buffer) + LazyVim.lsp.on_attach(function(client, buffer) require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) end) - local register_capability = vim.lsp.handlers["client/registerCapability"] + LazyVim.lsp.setup() + LazyVim.lsp.on_dynamic_capability(require("lazyvim.plugins.lsp.keymaps").on_attach) - 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 + LazyVim.lsp.words.setup(opts.document_highlight) - -- 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 - - local inlay_hint = vim.lsp.buf.inlay_hint or vim.lsp.inlay_hint - - if opts.inlay_hints.enabled and inlay_hint then - Util.lsp.on_attach(function(client, buffer) - if client.supports_method("textDocument/inlayHint") then - inlay_hint(buffer, true) + -- diagnostics signs + if vim.fn.has("nvim-0.10.0") == 0 then + if type(opts.diagnostics.signs) ~= "boolean" then + for severity, icon in pairs(opts.diagnostics.signs.text) do + local name = vim.diagnostic.severity[severity]:lower():gsub("^%l", string.upper) + name = "DiagnosticSign" .. name + vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) end - end) + end + end + + if vim.fn.has("nvim-0.10") == 1 then + -- inlay hints + if opts.inlay_hints.enabled then + LazyVim.lsp.on_supports_method("textDocument/inlayHint", function(client, buffer) + if + vim.api.nvim_buf_is_valid(buffer) + and vim.bo[buffer].buftype == "" + and not vim.tbl_contains(opts.inlay_hints.exclude, vim.bo[buffer].filetype) + then + LazyVim.toggle.inlay_hints(buffer, true) + end + end) + end + + -- code lens + if opts.codelens.enabled and vim.lsp.codelens then + LazyVim.lsp.on_supports_method("textDocument/codeLens", function(client, buffer) + vim.lsp.codelens.refresh() + vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, { + buffer = buffer, + callback = vim.lsp.codelens.refresh, + }) + end) + end end if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then @@ -177,24 +219,36 @@ return { for server, server_opts in pairs(servers) do if server_opts then server_opts = server_opts == true and {} or server_opts - -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig - if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then - setup(server) - else - ensure_installed[#ensure_installed + 1] = server + if server_opts.enabled ~= false then + -- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig + if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then + setup(server) + else + ensure_installed[#ensure_installed + 1] = server + end end end end if have_mason then - mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } }) + mlsp.setup({ + ensure_installed = vim.tbl_deep_extend( + "force", + ensure_installed, + LazyVim.opts("mason-lspconfig.nvim").ensure_installed or {} + ), + handlers = { setup }, + }) end - if Util.lsp.get_config("denols") and Util.lsp.get_config("tsserver") then + if LazyVim.lsp.is_enabled("denols") and LazyVim.lsp.is_enabled("vtsls") 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) - return not is_deno(root_dir) + LazyVim.lsp.disable("vtsls", is_deno) + LazyVim.lsp.disable("denols", function(root_dir, config) + if not is_deno(root_dir) then + config.settings.deno.enable = false + end + return false end) end end, @@ -227,19 +281,15 @@ return { }) end, 100) end) - local function ensure_installed() + + mr.refresh(function() for _, tool in ipairs(opts.ensure_installed) do local p = mr.get_package(tool) if not p:is_installed() then p:install() end end - end - if mr.refresh then - mr.refresh(ensure_installed) - else - ensure_installed() - end + end) end, }, } diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index 10e5d86f..3f2bd690 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -3,8 +3,8 @@ local M = {} ---@type LazyKeysLspSpec[]|nil M._keys = nil ----@alias LazyKeysLspSpec LazyKeysSpec|{has?:string} ----@alias LazyKeysLsp LazyKeys|{has?:string} +---@alias LazyKeysLspSpec LazyKeysSpec|{has?:string|string[], cond?:fun():boolean} +---@alias LazyKeysLsp LazyKeys|{has?:string|string[], cond?:fun():boolean} ---@return LazyKeysLspSpec[] function M.get() @@ -15,7 +15,7 @@ function M.get() M._keys = { { "cl", "LspInfo", desc = "Lsp Info" }, { "gd", function() require("telescope.builtin").lsp_definitions({ reuse_win = true }) end, desc = "Goto Definition", has = "definition" }, - { "gr", "Telescope lsp_references", desc = "References" }, + { "gr", "Telescope lsp_references", desc = "References", nowait = true }, { "gD", vim.lsp.buf.declaration, desc = "Goto Declaration" }, { "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" }, @@ -23,6 +23,10 @@ function M.get() { "gK", vim.lsp.buf.signature_help, desc = "Signature Help", has = "signatureHelp" }, { "", vim.lsp.buf.signature_help, mode = "i", desc = "Signature Help", has = "signatureHelp" }, { "ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" }, + { "cc", vim.lsp.codelens.run, desc = "Run Codelens", mode = { "n", "v" }, has = "codeLens" }, + { "cC", vim.lsp.codelens.refresh, desc = "Refresh & Display Codelens", mode = { "n" }, has = "codeLens" }, + { "cR", LazyVim.lsp.rename_file, desc = "Rename File", mode ={"n"}, has = { "workspace/didRenameFiles", "workspace/willRenameFiles" } }, + { "cr", vim.lsp.buf.rename, desc = "Rename", has = "rename" }, { "cA", function() @@ -37,29 +41,32 @@ function M.get() end, desc = "Source Action", has = "codeAction", - } + }, + { "]]", function() LazyVim.lsp.words.jump(vim.v.count1) end, has = "documentHighlight", + desc = "Next Reference", cond = function() return LazyVim.lsp.words.enabled end }, + { "[[", function() LazyVim.lsp.words.jump(-vim.v.count1) end, has = "documentHighlight", + desc = "Prev Reference", cond = function() return LazyVim.lsp.words.enabled end }, + { "", function() LazyVim.lsp.words.jump(vim.v.count1, true) end, has = "documentHighlight", + desc = "Next Reference", cond = function() return LazyVim.lsp.words.enabled end }, + { "", function() LazyVim.lsp.words.jump(-vim.v.count1, true) end, has = "documentHighlight", + desc = "Prev Reference", cond = function() return LazyVim.lsp.words.enabled 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 ----@param method string +---@param method string|string[] function M.has(buffer, method) + if type(method) == "table" then + for _, m in ipairs(method) do + if M.has(buffer, m) then + return true + end + end + return false + end method = method:find("/") and method or "textDocument/" .. method - local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer }) + local clients = LazyVim.lsp.get_clients({ bufnr = buffer }) for _, client in ipairs(clients) do if client.supports_method(method) then return true @@ -68,15 +75,15 @@ function M.has(buffer, method) return false end ----@return (LazyKeys|{has?:string})[] +---@return LazyKeysLsp[] 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 }) + local opts = LazyVim.opts("nvim-lspconfig") + local clients = LazyVim.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) @@ -89,8 +96,12 @@ function M.on_attach(_, buffer) local keymaps = M.resolve(buffer) for _, keys in pairs(keymaps) do - if not keys.has or M.has(buffer, keys.has) then + local has = not keys.has or M.has(buffer, keys.has) + local cond = not (keys.cond == false or ((type(keys.cond) == "function") and not keys.cond())) + + if has and cond then local opts = Keys.opts(keys) + opts.cond = nil opts.has = nil opts.silent = opts.silent ~= false opts.buffer = buffer diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index e66725c0..7d3b5e89 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -7,46 +7,20 @@ return { version = false, -- last release is way too old and doesn't work on Windows build = ":TSUpdate", event = { "LazyFile", "VeryLazy" }, + lazy = vim.fn.argc(-1) == 0, -- load treesitter early when opening a file from the cmdline 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 + -- no longer trigger the **nvim-treesitter** module to be loaded in time. + -- Luckily, the only things 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", - 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", "TSUpdate", "TSInstall" }, keys = { - { "", desc = "Increment selection" }, - { "", desc = "Decrement selection", mode = "x" }, + { "", desc = "Increment Selection" }, + { "", desc = "Decrement Selection", mode = "x" }, }, ---@type TSConfig ---@diagnostic disable-next-line: missing-fields @@ -75,6 +49,7 @@ return { "typescript", "vim", "vimdoc", + "xml", "yaml", }, incremental_selection = { @@ -99,42 +74,44 @@ return { ---@param opts TSConfig config = function(_, opts) if type(opts.ensure_installed) == "table" then - ---@type table - local added = {} - opts.ensure_installed = vim.tbl_filter(function(lang) - if added[lang] then - return false - end - added[lang] = true - return true - end, opts.ensure_installed) + opts.ensure_installed = LazyVim.dedup(opts.ensure_installed) end require("nvim-treesitter.configs").setup(opts) end, }, - -- Show context of the current function { - "nvim-treesitter/nvim-treesitter-context", - event = "LazyFile", + "nvim-treesitter/nvim-treesitter-textobjects", + event = "VeryLazy", 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" }) + config = function() + -- If treesitter is already loaded, we need to run config again for textobjects + if LazyVim.is_loaded("nvim-treesitter") then + local opts = LazyVim.opts("nvim-treesitter") + require("nvim-treesitter.configs").setup({ textobjects = opts.textobjects }) + end + + -- 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, - desc = "Toggle Treesitter Context", - }, - }, + end + end + end, }, -- Automatically add closing tags for HTML and JSX diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 524f3132..5ef3405e 100644 --- a/lua/lazyvim/plugins/ui.lua +++ b/lua/lazyvim/plugins/ui.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { -- Better `vim.notify()` { @@ -10,10 +8,11 @@ return { function() require("notify").dismiss({ silent = true, pending = true }) end, - desc = "Dismiss all Notifications", + desc = "Dismiss All Notifications", }, }, opts = { + stages = "static", timeout = 3000, max_height = function() return math.floor(vim.o.lines * 0.75) @@ -27,8 +26,8 @@ return { }, init = function() -- when noice is not enabled, install notify on VeryLazy - if not Util.has("noice.nvim") then - Util.on_very_lazy(function() + if not LazyVim.has("noice.nvim") then + LazyVim.on_very_lazy(function() vim.notify = require("notify") end) end @@ -59,24 +58,24 @@ return { "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" }, + { "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" }, { "[B", "BufferLineMovePrev", desc = "Move buffer prev" }, { "]B", "BufferLineMoveNext", desc = "Move buffer next" }, }, opts = { options = { -- stylua: ignore - close_command = function(n) require("mini.bufremove").delete(n, false) end, + close_command = function(n) LazyVim.ui.bufremove(n) end, -- stylua: ignore - right_mouse_command = function(n) require("mini.bufremove").delete(n, false) end, + right_mouse_command = function(n) LazyVim.ui.bufremove(n) end, diagnostics = "nvim_lsp", always_show_bufferline = false, diagnostics_indicator = function(_, _, diag) @@ -98,7 +97,7 @@ return { config = function(_, opts) require("bufferline").setup(opts) -- Fix bufferline when restoring a session - vim.api.nvim_create_autocmd("BufAdd", { + vim.api.nvim_create_autocmd({ "BufAdd", "BufDelete" }, { callback = function() vim.schedule(function() pcall(nvim_bufferline) @@ -131,7 +130,7 @@ return { vim.o.laststatus = vim.g.lualine_laststatus - return { + local opts = { options = { theme = "auto", globalstatus = true, @@ -142,7 +141,7 @@ return { lualine_b = { "branch" }, lualine_c = { - Util.lualine.root_dir(), + LazyVim.lualine.root_dir(), { "diagnostics", symbols = { @@ -153,31 +152,32 @@ return { }, }, { "filetype", icon_only = true, separator = "", padding = { left = 1, right = 0 } }, - { Util.lualine.pretty_path() }, + { LazyVim.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.ui.fg("Statement"), + color = function() return LazyVim.ui.fg("Statement") end, }, -- 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.ui.fg("Constant"), + color = function() return LazyVim.ui.fg("Constant") end, }, -- stylua: ignore { function() return " " .. require("dap").status() end, - cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, - color = Util.ui.fg("Debug"), + cond = function() return package.loaded["dap"] and require("dap").status() ~= "" end, + color = function() return LazyVim.ui.fg("Debug") end, }, + -- stylua: ignore { require("lazy.status").updates, cond = require("lazy.status").has_updates, - color = Util.ui.fg("Special"), + color = function() return LazyVim.ui.fg("Special") end, }, { "diff", @@ -210,6 +210,26 @@ return { }, extensions = { "neo-tree", "lazy" }, } + + -- do not add trouble symbols if aerial is enabled + if vim.g.trouble_lualine then + local trouble = require("trouble") + local symbols = trouble.statusline + and trouble.statusline({ + mode = "symbols", + groups = {}, + title = false, + filter = { range = true }, + format = "{kind_icon}{symbol.name:Normal}", + hl_group = "lualine_c_normal", + }) + table.insert(opts.sections.lualine_c, { + symbols and symbols.get, + cond = symbols and symbols.has, + }) + end + + return opts end, }, @@ -222,7 +242,7 @@ return { char = "│", tab_char = "│", }, - scope = { enabled = false }, + scope = { show_start = false, show_end = false }, exclude = { filetypes = { "help", @@ -242,45 +262,11 @@ return { main = "ibl", }, - -- 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 = "LazyFile", - opts = { - -- symbol = "▏", - symbol = "│", - options = { try_as_border = true }, - }, - init = function() - vim.api.nvim_create_autocmd("FileType", { - pattern = { - "help", - "alpha", - "dashboard", - "neo-tree", - "Trouble", - "trouble", - "lazy", - "mason", - "notify", - "toggleterm", - "lazyterm", - }, - callback = function() - vim.b.miniindentscope_disable = true - end, - }) - end, - }, - -- Displays a popup with possible key bindings of the command you started typing { "folke/which-key.nvim", opts = function(_, opts) - if require("lazyvim.util").has("noice.nvim") then + if LazyVim.has("noice.nvim") then opts.defaults["sn"] = { name = "+noice" } end end, @@ -315,7 +301,6 @@ return { bottom_search = true, command_palette = true, long_message_to_split = true, - inc_rename = true, }, }, -- stylua: ignore @@ -325,8 +310,9 @@ return { { "snh", function() require("noice").cmd("history") end, desc = "Noice History" }, { "sna", function() require("noice").cmd("all") end, desc = "Noice All" }, { "snd", function() require("noice").cmd("dismiss") end, desc = "Dismiss All" }, - { "", function() if not require("noice.lsp").scroll(4) then return "" end end, silent = true, expr = true, desc = "Scroll forward", mode = {"i", "n", "s"} }, - { "", function() if not require("noice.lsp").scroll(-4) then return "" end end, silent = true, expr = true, desc = "Scroll backward", mode = {"i", "n", "s"}}, + { "snt", function() require("noice").cmd("telescope") end, desc = "Noice Telescope" }, + { "", function() if not require("noice.lsp").scroll(4) then return "" end end, silent = true, expr = true, desc = "Scroll Forward", mode = {"i", "n", "s"} }, + { "", function() if not require("noice.lsp").scroll(-4) then return "" end end, silent = true, expr = true, desc = "Scroll Backward", mode = {"i", "n", "s"}}, }, }, @@ -336,22 +322,9 @@ return { -- 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", + lazy = false, -- As https://github.com/nvimdev/dashboard-nvim/pull/450, dashboard-nvim shouldn't be lazy-loaded to properly handle stdin. opts = function() local logo = [[ ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z @@ -375,15 +348,15 @@ return { 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" }, + { action = LazyVim.telescope("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 LazyVim.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 = function() vim.api.nvim_input("qa") end, desc = " Quit", icon = " ", key = "q" }, }, footer = function() local stats = require("lazy").stats() diff --git a/lua/lazyvim/plugins/util.lua b/lua/lazyvim/plugins/util.lua index c3870889..cf5d9e03 100644 --- a/lua/lazyvim/plugins/util.lua +++ b/lua/lazyvim/plugins/util.lua @@ -1,14 +1,5 @@ return { - -- measure startuptime - { - "dstein64/vim-startuptime", - cmd = "StartupTime", - config = function() - vim.g.startuptime_tries = 10 - end, - }, - -- 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. diff --git a/lua/lazyvim/plugins/xtras.lua b/lua/lazyvim/plugins/xtras.lua index 4eb73804..8b4b2ec9 100644 --- a/lua/lazyvim/plugins/xtras.lua +++ b/lua/lazyvim/plugins/xtras.lua @@ -3,12 +3,27 @@ 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.editor.outline"] = 100, + ["lazyvim.plugins.extras.editor.trouble-v3"] = 100, + ["lazyvim.plugins.extras.lang.typescript"] = 5, + ["lazyvim.plugins.extras.ui.edgy"] = 2, ["lazyvim.plugins.extras.test.core"] = 1, ["lazyvim.plugins.extras.dap.core"] = 1, } -table.sort(Config.json.data.extras, function(a, b) +---@type string[] +local extras = LazyVim.dedup(Config.json.data.extras) + +local version = vim.version() +local v = version.major .. "_" .. version.minor + +local compat = { "0_9" } + +if vim.tbl_contains(compat, v) then + extras[#extras + 1] = "lazyvim.plugins.compat.nvim-" .. v +end + +table.sort(extras, function(a, b) local pa = prios[a] or 10 local pb = prios[b] or 10 if pa == pb then @@ -20,4 +35,4 @@ end) ---@param extra string return vim.tbl_map(function(extra) return { import = extra } -end, Config.json.data.extras) +end, extras) diff --git a/lua/lazyvim/types.lua b/lua/lazyvim/types.lua new file mode 100644 index 00000000..52a340c9 --- /dev/null +++ b/lua/lazyvim/types.lua @@ -0,0 +1,7 @@ +---@meta + +---@class LazyVimGlobals +vim.g = {} + +_G.lazyvim_docs = true +_G.LazyVim = require("lazyvim.util") diff --git a/lua/lazyvim/util/cmp.lua b/lua/lazyvim/util/cmp.lua new file mode 100644 index 00000000..e4a7f700 --- /dev/null +++ b/lua/lazyvim/util/cmp.lua @@ -0,0 +1,126 @@ +---@class lazyvim.util.cmp +local M = {} + +---@alias Placeholder {n:number, text:string} + +---@param snippet string +---@param fn fun(placeholder:Placeholder):string +---@return string +function M.snippet_replace(snippet, fn) + return snippet:gsub("%$%b{}", function(m) + local n, name = m:match("^%${(%d+):(.+)}$") + return n and fn({ n = n, text = name }) or m + end) or snippet +end + +-- This function resolves nested placeholders in a snippet. +---@param snippet string +---@return string +function M.snippet_preview(snippet) + local ok, parsed = pcall(function() + return vim.lsp._snippet_grammar.parse(snippet) + end) + return ok and tostring(parsed) + or M.snippet_replace(snippet, function(placeholder) + return M.snippet_preview(placeholder.text) + end):gsub("%$0", "") +end + +-- This function replaces nested placeholders in a snippet with LSP placeholders. +function M.snippet_fix(snippet) + local texts = {} ---@type table + return M.snippet_replace(snippet, function(placeholder) + texts[placeholder.n] = texts[placeholder.n] or M.snippet_preview(placeholder.text) + return "${" .. placeholder.n .. ":" .. texts[placeholder.n] .. "}" + end) +end + +---@param entry cmp.Entry +function M.auto_brackets(entry) + local cmp = require("cmp") + local Kind = cmp.lsp.CompletionItemKind + local item = entry:get_completion_item() + if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) then + local cursor = vim.api.nvim_win_get_cursor(0) + local prev_char = vim.api.nvim_buf_get_text(0, cursor[1] - 1, cursor[2], cursor[1] - 1, cursor[2] + 1, {})[1] + if prev_char ~= "(" and prev_char ~= ")" then + local keys = vim.api.nvim_replace_termcodes("()", false, false, true) + vim.api.nvim_feedkeys(keys, "i", true) + end + end +end + +-- This function adds missing documentation to snippets. +-- The documentation is a preview of the snippet. +---@param window cmp.CustomEntriesView|cmp.NativeEntriesView +function M.add_missing_snippet_docs(window) + local cmp = require("cmp") + local Kind = cmp.lsp.CompletionItemKind + local entries = window:get_entries() + for _, entry in ipairs(entries) do + if entry:get_kind() == Kind.Snippet then + local item = entry:get_completion_item() + if not item.documentation and item.insertText then + item.documentation = { + kind = cmp.lsp.MarkupKind.Markdown, + value = string.format("```%s\n%s\n```", vim.bo.filetype, M.snippet_preview(item.insertText)), + } + end + end + end +end + +-- This is a better implementation of `cmp.confirm`: +-- * check if the completion menu is visible without waiting for running sources +-- * create an undo point before confirming +-- This function is both faster and more reliable. +---@param opts? {select: boolean, behavior: cmp.ConfirmBehavior} +function M.confirm(opts) + local cmp = require("cmp") + opts = vim.tbl_extend("force", { + select = true, + behavior = cmp.ConfirmBehavior.Insert, + }, opts or {}) + return function(fallback) + if cmp.core.view:visible() or vim.fn.pumvisible() == 1 then + LazyVim.create_undo() + if cmp.confirm(opts) then + return + end + end + return fallback() + end +end + +function M.expand(snippet) + -- Native sessions don't support nested snippet sessions. + -- Always use the top-level session. + -- Otherwise, when on the first placeholder and selecting a new completion, + -- the nested session will be used instead of the top-level session. + -- See: https://github.com/LazyVim/LazyVim/issues/3199 + local session = vim.snippet.active() and vim.snippet._session or nil + + local ok, err = pcall(vim.snippet.expand, snippet) + if not ok then + local fixed = M.snippet_fix(snippet) + ok = pcall(vim.snippet.expand, fixed) + + local msg = ok and "Failed to parse snippet,\nbut was able to fix it automatically." + or ("Failed to parse snippet.\n" .. err) + + LazyVim[ok and "warn" or "error"]( + ([[%s +```%s +%s +```]]):format(msg, vim.bo.filetype, snippet), + { title = "vim.snippet" } + ) + end + + -- Restore top-level session when needed + if session then + vim.snippet._session = session + end +end + +return M diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua index 4e2f0bc1..9cd16a3e 100644 --- a/lua/lazyvim/util/extras.lua +++ b/lua/lazyvim/util/extras.lua @@ -3,7 +3,6 @@ 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 @@ -17,12 +16,16 @@ local Util = require("lazyvim.util") ---@field desc? string ---@field enabled boolean ---@field managed boolean +---@field recommended? boolean +---@field imports string[] ---@field row? number +---@field section? string ---@field plugins string[] ---@field optional string[] ---@class lazyvim.util.extras local M = {} +M.buf = 0 ---@type LazyExtraSource[] M.sources = { @@ -34,15 +37,33 @@ M.ns = vim.api.nvim_create_namespace("lazyvim.extras") ---@type string[] M.state = nil +---@param opts {ft?: string|string[], root?: string|string[]} +---@return boolean +function M.wants(opts) + if opts.ft then + opts.ft = type(opts.ft) == "string" and { opts.ft } or opts.ft + for _, f in ipairs(opts.ft) do + if vim.bo[M.buf].filetype == f then + return true + end + end + end + if opts.root then + opts.root = type(opts.root) == "string" and { opts.root } or opts.root + return #LazyVim.root.detectors.pattern(M.buf, opts.root) > 0 + end + return false +end + ---@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) + local root = LazyVim.find_root(source.module) if root then - Util.walk(root, function(path, name, type) - if type == "file" and name:match("%.lua$") then + LazyVim.walk(root, function(path, name, type) + if (type == "file" or type == "link") 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 @@ -62,7 +83,16 @@ end ---@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 spec = Plugin.Spec.new(nil, { optional = true }) + spec:parse({ import = modname }) + local imports = vim.tbl_filter(function(x) + return x ~= modname + end, spec.modules) + if #imports > 0 then + spec = Plugin.Spec.new(nil, { optional = true }) + spec.modules = vim.deepcopy(imports) + spec:parse({ import = modname }) + end local plugins = {} ---@type string[] local optional = {} ---@type string[] for _, p in pairs(spec.plugins) do @@ -75,13 +105,21 @@ function M.get_extra(source, modname) table.sort(plugins) table.sort(optional) + ---@type boolean|(fun():boolean?)|nil + local recommended = require(modname).recommended or false + if type(recommended) == "function" then + recommended = recommended() or false + end + ---@type LazyExtra return { source = source, name = modname:sub(#source.module + 2), module = modname, enabled = enabled, + imports = imports, desc = require(modname).desc, + recommended = recommended, managed = vim.tbl_contains(Config.json.data.extras, modname) or not enabled, plugins = plugins, optional = optional, @@ -98,6 +136,7 @@ local X = {} ---@return LazyExtraView function X.new() local self = setmetatable({}, { __index = X }) + M.buf = vim.api.nvim_get_current_buf() self.float = Float.new({ title = "LazyVim Extras" }) self.float:on_key("x", function() self:toggle() @@ -119,7 +158,7 @@ function X:toggle() for _, extra in ipairs(self.extras) do if extra.row == pos[1] then if not extra.managed then - Util.error( + LazyVim.error( "Not managed by LazyExtras. Remove from your config to enable/disable here.", { title = "LazyExtras" } ) @@ -137,8 +176,8 @@ function X:toggle() M.state[#M.state + 1] = extra.module end table.sort(Config.json.data.extras) - Util.json.save() - Util.info( + LazyVim.json.save() + LazyVim.info( "`" .. extra.name .. "`" @@ -172,7 +211,7 @@ function X:update() diag.lnum = diag.row - 1 return diag end, self.diag), - { signs = false, virtual_text = true } + { signs = false, virtual_text = true, underline = false } ) end @@ -187,8 +226,21 @@ function X:render() :append("", "LazySpecial") :append(" key", "LazyComment") :nl() - self:section({ enabled = true, title = "Enabled" }) - self:section({ enabled = false, title = "Disabled" }) + for _, extra in ipairs(self.extras) do + extra.section = nil + end + self:section({ + recommended = true, + enabled = false, + include = "^lang%.", + title = "Recommended Languages", + empty = false, + }) + self:section({ enabled = true, exclude = "^lang%.", title = "Enabled Plugins" }) + self:section({ enabled = true, title = "Enabled Languages" }) + self:section({ recommended = true, title = "Recommended Plugins", empty = false }) + self:section({ title = "Plugins", exclude = "^lang%." }) + self:section({ title = "Languages" }) end ---@param extra LazyExtra @@ -207,9 +259,16 @@ function X:extra(extra) self.text:append(" " .. LazyConfig.options.ui.icons.not_loaded .. " ", hl) end self.text:append(extra.name) + if extra.recommended then + self.text:append(" "):append(LazyConfig.options.ui.icons.favorite or " ", "LazyCommit") + end if extra.source.name ~= "LazyVim" then self.text:append(" "):append(LazyConfig.options.ui.icons.event .. " " .. extra.source.name, "LazyReasonEvent") end + for _, import in ipairs(extra.imports) do + import = import:gsub("^lazyvim.plugins.extras.", "") + self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. import, "LazyReasonStart") + end for _, plugin in ipairs(extra.plugins) do self.text:append(" "):append(LazyConfig.options.ui.icons.plugin .. "" .. plugin, "LazyReasonPlugin") end @@ -222,16 +281,25 @@ function X:extra(extra) self.text:nl() end ----@param opts {enabled?:boolean, title?:string} +---@param opts {enabled?:boolean, title:string, recommended?:boolean, include?:string, exclude?:string, empty?:boolean} 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 + return extra.section == nil + and (opts.enabled == nil or extra.enabled == opts.enabled) + and (opts.recommended == nil or extra.recommended == opts.recommended) + and (opts.include == nil or extra.name:find(opts.include)) + and (opts.exclude == nil or not extra.name:find(opts.exclude)) end, self.extras) + if opts.empty == false and #extras == 0 then + return + end + self.text:nl():append(opts.title .. ":", "LazyH2"):append(" (" .. #extras .. ")", "LazyComment"):nl() for _, extra in ipairs(extras) do + extra.section = opts.title self:extra(extra) end end diff --git a/lua/lazyvim/util/format.lua b/lua/lazyvim/util/format.lua index fa972296..e6325538 100644 --- a/lua/lazyvim/util/format.lua +++ b/lua/lazyvim/util/format.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.format ---@overload fun(opts?: {force?:boolean}) local M = setmetatable({}, { @@ -26,7 +24,7 @@ function M.register(formatter) end function M.formatexpr() - if Util.has("conform.nvim") then + if LazyVim.has("conform.nvim") then return require("conform").formatexpr() end return vim.lsp.formatexpr({ timeout_ms = 3000 }) @@ -76,7 +74,7 @@ function M.info(buf) if not have then lines[#lines + 1] = "\n***No formatters available for this buffer.***" end - Util[enabled and "info" or "warn"]( + LazyVim[enabled and "info" or "warn"]( table.concat(lines, "\n"), { title = "LazyFormat (" .. (enabled and "enabled" or "disabled") .. ")" } ) @@ -120,14 +118,14 @@ function M.format(opts) for _, formatter in ipairs(M.resolve(buf)) do if formatter.active then done = true - Util.try(function() + LazyVim.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" }) + LazyVim.warn("No formatter available", { title = "LazyVim" }) end end @@ -136,7 +134,7 @@ function M.health() 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({ + LazyVim.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`,", diff --git a/lua/lazyvim/util/init.lua b/lua/lazyvim/util/init.lua index 24fd0a1b..e6927069 100644 --- a/lua/lazyvim/util/init.lua +++ b/lua/lazyvim/util/init.lua @@ -1,11 +1,13 @@ local LazyUtil = require("lazy.core.util") ---@class lazyvim.util: LazyUtilCore +---@field config LazyVimConfig ---@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 lazygit lazyvim.util.lazygit ---@field toggle lazyvim.util.toggle ---@field format lazyvim.util.format ---@field plugin lazyvim.util.plugin @@ -14,6 +16,8 @@ local LazyUtil = require("lazy.core.util") ---@field news lazyvim.util.news ---@field json lazyvim.util.json ---@field lualine lazyvim.util.lualine +---@field mini lazyvim.util.mini +---@field cmp lazyvim.util.cmp local M = {} ---@type table @@ -38,7 +42,7 @@ setmetatable(M, { 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) + M.deprecate([[LazyVim.]] .. k, [[LazyVim.]] .. mod .. "." .. key) ---@diagnostic disable-next-line: no-unknown t[mod] = require("lazyvim.util." .. mod) -- load here to prevent loops return t[mod][key] @@ -50,12 +54,25 @@ setmetatable(M, { }) function M.is_win() - return vim.loop.os_uname().sysname:find("Windows") ~= nil + return vim.uv.os_uname().sysname:find("Windows") ~= nil +end + +---@param name string +function M.get_plugin(name) + return require("lazy.core.config").spec.plugins[name] +end + +---@param name string +---@param path string? +function M.get_plugin_path(name, path) + local plugin = M.get_plugin(name) + path = path and "/" .. path or "" + return plugin and (plugin.dir .. path) end ---@param plugin string function M.has(plugin) - return require("lazy.core.config").spec.plugins[plugin] ~= nil + return M.get_plugin(plugin) ~= nil end ---@param fn fun() @@ -68,9 +85,30 @@ function M.on_very_lazy(fn) }) end +--- This extends a deeply nested list with a key in a table +--- that is a dot-separated string. +--- The nested list will be created if it does not exist. +---@generic T +---@param t T[] +---@param key string +---@param values T[] +---@return T[]? +function M.extend(t, key, values) + local keys = vim.split(key, ".", { plain = true }) + for i = 1, #keys do + local k = keys[i] + t[k] = t[k] or {} + if type(t) ~= "table" then + return + end + t = t[k] + end + return vim.list_extend(t, values) +end + ---@param name string function M.opts(name) - local plugin = require("lazy.core.config").plugins[name] + local plugin = require("lazy.core.config").spec.plugins[name] if not plugin then return {} end @@ -97,8 +135,8 @@ function M.lazy_notify() local orig = vim.notify vim.notify = temp - local timer = vim.loop.new_timer() - local check = assert(vim.loop.new_check()) + local timer = vim.uv.new_timer() + local check = assert(vim.uv.new_check()) local replay = function() timer:stop() @@ -124,11 +162,15 @@ function M.lazy_notify() timer:start(500, 0, replay) end +function M.is_loaded(name) + local Config = require("lazy.core.config") + return Config.plugins[name] and Config.plugins[name]._.loaded +end + ---@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 + if M.is_loaded(name) then fn(name) else vim.api.nvim_create_autocmd("User", { @@ -168,4 +210,56 @@ function M.safe_keymap_set(mode, lhs, rhs, opts) end end +---@generic T +---@param list T[] +---@return T[] +function M.dedup(list) + local ret = {} + local seen = {} + for _, v in ipairs(list) do + if not seen[v] then + table.insert(ret, v) + seen[v] = true + end + end + return ret +end + +M.CREATE_UNDO = vim.api.nvim_replace_termcodes("u", true, true, true) +function M.create_undo() + if vim.api.nvim_get_mode().mode == "i" then + vim.api.nvim_feedkeys(M.CREATE_UNDO, "n", false) + end +end + +--- Gets a path to a package in the Mason registry. +--- Prefer this to `get_package`, since the package might not always be +--- available yet and trigger errors. +---@param pkg string +---@param path? string +---@param opts? { warn?: boolean } +function M.get_pkg_path(pkg, path, opts) + pcall(require, "mason") -- make sure Mason is loaded. Will fail when generating docs + local root = vim.env.MASON or (vim.fn.stdpath("data") .. "/mason") + opts = opts or {} + opts.warn = opts.warn == nil and true or opts.warn + path = path or "" + local ret = root .. "/packages/" .. pkg .. "/" .. path + if opts.warn and not vim.loop.fs_stat(ret) then + M.warn( + ("Mason package path not found for **%s**:\n- `%s`\nYou may need to force update the package."):format(pkg, path) + ) + end + return ret +end + +--- Override the default title for notifications. +for _, level in ipairs({ "info", "warn", "error" }) do + M[level] = function(msg, opts) + opts = opts or {} + opts.title = opts.title or "LazyVim" + return LazyUtil[level](msg, opts) + end +end + return M diff --git a/lua/lazyvim/util/inject.lua b/lua/lazyvim/util/inject.lua index 81e0f57a..859afc81 100644 --- a/lua/lazyvim/util/inject.lua +++ b/lua/lazyvim/util/inject.lua @@ -31,4 +31,20 @@ function M.get_upvalue(func, name) end end +function M.set_upvalue(func, name, value) + local i = 1 + while true do + local n = debug.getupvalue(func, i) + if not n then + break + end + if n == name then + debug.setupvalue(func, i, value) + return + end + i = i + 1 + end + LazyVim.error("upvalue not found: " .. name) +end + return M diff --git a/lua/lazyvim/util/json.lua b/lua/lazyvim/util/json.lua index d98d0382..60466a45 100644 --- a/lua/lazyvim/util/json.lua +++ b/lua/lazyvim/util/json.lua @@ -1,5 +1,4 @@ local Config = require("lazyvim.config") -local Util = require("lazyvim.util") ---@class lazyvim.util.json local M = {} @@ -14,7 +13,7 @@ local function encode(value, indent) elseif t == "number" or t == "boolean" then return tostring(value) elseif t == "table" then - local is_list = Util.is_list(value) + local is_list = LazyVim.is_list(value) local parts = {} local next_indent = indent .. " " @@ -51,13 +50,13 @@ function M.save() 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:write(LazyVim.json.encode(Config.json.data)) f:close() end end function M.migrate() - Util.info("Migrating `lazyvim.json` to version `" .. Config.json.version .. "`") + LazyVim.info("Migrating `lazyvim.json` to version `" .. Config.json.version .. "`") local json = Config.json -- v0 @@ -74,6 +73,26 @@ function M.migrate() -- replace double extras module name return extra:gsub("^lazyvim%.plugins%.extras%.lazyvim%.plugins%.extras%.", "lazyvim.plugins.extras.") end, json.data.extras or {}) + elseif json.data.version == 2 then + json.data.extras = vim.tbl_map(function(extra) + return extra == "lazyvim.plugins.extras.editor.symbols-outline" and "lazyvim.plugins.extras.editor.outline" + or extra + end, json.data.extras or {}) + elseif json.data.version == 3 then + json.data.extras = vim.tbl_filter(function(extra) + return not ( + extra == "lazyvim.plugins.extras.coding.mini-ai" + or extra == "lazyvim.plugins.extras.ui.treesitter-rewrite" + ) + end, json.data.extras or {}) + elseif json.data.version == 4 then + json.data.extras = vim.tbl_filter(function(extra) + return not (extra == "lazyvim.plugins.extras.lazyrc") + end, json.data.extras or {}) + elseif json.data.version == 5 then + json.data.extras = vim.tbl_filter(function(extra) + return not (extra == "lazyvim.plugins.extras.editor.trouble-v3") + end, json.data.extras or {}) end M.save() diff --git a/lua/lazyvim/util/lazygit.lua b/lua/lazyvim/util/lazygit.lua new file mode 100644 index 00000000..e360ad82 --- /dev/null +++ b/lua/lazyvim/util/lazygit.lua @@ -0,0 +1,162 @@ +---@class lazyvim.util.lazygit +---@field config_dir? string +---@overload fun(cmd: string|string[], opts: LazyTermOpts): LazyFloat +local M = setmetatable({}, { + __call = function(m, ...) + return m.open(...) + end, +}) + +---@alias LazyGitColor {fg?:string, bg?:string, bold?:boolean} + +---@class LazyGitTheme: table +---@field activeBorderColor LazyGitColor +---@field cherryPickedCommitBgColor LazyGitColor +---@field cherryPickedCommitFgColor LazyGitColor +---@field defaultFgColor LazyGitColor +---@field inactiveBorderColor LazyGitColor +---@field optionsTextColor LazyGitColor +---@field searchingActiveBorderColor LazyGitColor +---@field selectedLineBgColor LazyGitColor +---@field unstagedChangesColor LazyGitColor +M.theme = { + [241] = { fg = "Special" }, + activeBorderColor = { fg = "MatchParen", bold = true }, + cherryPickedCommitBgColor = { fg = "Identifier" }, + cherryPickedCommitFgColor = { fg = "Function" }, + defaultFgColor = { fg = "Normal" }, + inactiveBorderColor = { fg = "FloatBorder" }, + optionsTextColor = { fg = "Function" }, + searchingActiveBorderColor = { fg = "MatchParen", bold = true }, + selectedLineBgColor = { bg = "Visual" }, -- set to `default` to have no background colour + unstagedChangesColor = { fg = "DiagnosticError" }, +} + +M.theme_path = LazyVim.norm(vim.fn.stdpath("cache") .. "/lazygit-theme.yml") + +-- re-create config file on startup +M.dirty = true + +-- re-create theme file on ColorScheme change +vim.api.nvim_create_autocmd("ColorScheme", { + callback = function() + M.dirty = true + end, +}) + +-- Opens lazygit +---@param opts? LazyTermOpts | {args?: string[]} +function M.open(opts) + if vim.g.lazygit_theme ~= nil then + LazyVim.deprecate("vim.g.lazygit_theme", "vim.g.lazygit_config") + end + + opts = vim.tbl_deep_extend("force", {}, { + esc_esc = false, + ctrl_hjkl = false, + }, opts or {}) + + local cmd = { "lazygit" } + vim.list_extend(cmd, opts.args or {}) + + if vim.g.lazygit_config then + if M.dirty then + M.update_config() + end + + if not M.config_dir then + local Process = require("lazy.manage.process") + local ok, lines = pcall(Process.exec, { "lazygit", "-cd" }) + if ok then + M.config_dir = lines[1] + vim.env.LG_CONFIG_FILE = LazyVim.norm(M.config_dir .. "/config.yml" .. "," .. M.theme_path) + else + ---@diagnostic disable-next-line: cast-type-mismatch + ---@cast lines string + LazyVim.error( + { "Failed to get **lazygit** config directory.", "Will not apply **lazygit** config.", "", "# Error:", lines }, + { title = "lazygit" } + ) + end + end + end + + return LazyVim.terminal(cmd, opts) +end + +function M.set_ansi_color(idx, color) + io.write(("\27]4;%d;%s\7"):format(idx, color)) +end + +---@param v LazyGitColor +---@return string[] +function M.get_color(v) + ---@type string[] + local color = {} + if v.fg then + color[1] = LazyVim.ui.color(v.fg) + elseif v.bg then + color[1] = LazyVim.ui.color(v.bg, true) + end + if v.bold then + table.insert(color, "bold") + end + return color +end + +function M.update_config() + ---@type table + local theme = {} + + for k, v in pairs(M.theme) do + if type(k) == "number" then + local color = M.get_color(v) + -- LazyGit uses color 241 a lot, so also set it to a nice color + -- pcall, since some terminals don't like this + pcall(M.set_ansi_color, k, color[1]) + else + theme[k] = M.get_color(v) + end + end + + local config = [[ +os: + editPreset: "nvim-remote" +gui: + nerdFontsVersion: 3 + theme: +]] + + ---@type string[] + local lines = {} + for k, v in pairs(theme) do + lines[#lines + 1] = (" %s:"):format(k) + for _, c in ipairs(v) do + lines[#lines + 1] = (" - %q"):format(c) + end + end + config = config .. table.concat(lines, "\n") + require("lazy.util").write_file(M.theme_path, config) + M.dirty = false +end + +---@param opts? {count?: number}|LazyCmdOptions +function M.blame_line(opts) + opts = vim.tbl_deep_extend("force", { + count = 3, + filetype = "git", + size = { + width = 0.6, + height = 0.6, + }, + border = "rounded", + }, opts or {}) + local cursor = vim.api.nvim_win_get_cursor(0) + local line = cursor[1] + local file = vim.api.nvim_buf_get_name(0) + local root = LazyVim.root.detectors.pattern(0, { ".git" })[1] + local cmd = { "git", "-C", root, "log", "-n", opts.count, "-u", "-L", line .. ",+1:" .. file } + return require("lazy.util").float_cmd(cmd, opts) +end + +return M diff --git a/lua/lazyvim/util/lsp.lua b/lua/lazyvim/util/lsp.lua index b34a2afe..b68f7349 100644 --- a/lua/lazyvim/util/lsp.lua +++ b/lua/lazyvim/util/lsp.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.lsp local M = {} @@ -7,14 +5,14 @@ local M = {} ---@param opts? lsp.Client.filter function M.get_clients(opts) - local ret = {} ---@type lsp.Client[] + local ret = {} ---@type vim.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 + ---@param client vim.lsp.Client ret = vim.tbl_filter(function(client) return client.supports_method(opts.method, { bufnr = opts.bufnr }) end, ret) @@ -23,37 +21,156 @@ function M.get_clients(opts) return opts and opts.filter and vim.tbl_filter(opts.filter, ret) or ret end ----@param on_attach fun(client, buffer) +---@param on_attach fun(client:vim.lsp.Client, buffer) function M.on_attach(on_attach) - vim.api.nvim_create_autocmd("LspAttach", { + return 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) + if client then + return on_attach(client, buffer) + end end, }) end +---@type table>> +M._supports_method = {} + +function M.setup() + local register_capability = vim.lsp.handlers["client/registerCapability"] + vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx) + ---@diagnostic disable-next-line: no-unknown + local ret = register_capability(err, res, ctx) + local client = vim.lsp.get_client_by_id(ctx.client_id) + if client then + for buffer in pairs(client.attached_buffers) do + vim.api.nvim_exec_autocmds("User", { + pattern = "LspDynamicCapability", + data = { client_id = client.id, buffer = buffer }, + }) + end + end + return ret + end + M.on_attach(M._check_methods) + M.on_dynamic_capability(M._check_methods) +end + +---@param client vim.lsp.Client +function M._check_methods(client, buffer) + -- don't trigger on invalid buffers + if not vim.api.nvim_buf_is_valid(buffer) then + return + end + -- don't trigger on non-listed buffers + if not vim.bo[buffer].buflisted then + return + end + -- don't trigger on nofile buffers + if vim.bo[buffer].buftype == "nofile" then + return + end + for method, clients in pairs(M._supports_method) do + clients[client] = clients[client] or {} + if not clients[client][buffer] then + if client.supports_method and client.supports_method(method, { bufnr = buffer }) then + clients[client][buffer] = true + vim.api.nvim_exec_autocmds("User", { + pattern = "LspSupportsMethod", + data = { client_id = client.id, buffer = buffer, method = method }, + }) + end + end + end +end + +---@param fn fun(client:vim.lsp.Client, buffer):boolean? +---@param opts? {group?: integer} +function M.on_dynamic_capability(fn, opts) + return vim.api.nvim_create_autocmd("User", { + pattern = "LspDynamicCapability", + group = opts and opts.group or nil, + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + local buffer = args.data.buffer ---@type number + if client then + return fn(client, buffer) + end + end, + }) +end + +---@param method string +---@param fn fun(client:vim.lsp.Client, buffer) +function M.on_supports_method(method, fn) + M._supports_method[method] = M._supports_method[method] or setmetatable({}, { __mode = "k" }) + return vim.api.nvim_create_autocmd("User", { + pattern = "LspSupportsMethod", + callback = function(args) + local client = vim.lsp.get_client_by_id(args.data.client_id) + local buffer = args.data.buffer ---@type number + if client and method == args.data.method then + return fn(client, buffer) + end + end, + }) +end + +function M.rename_file() + local buf = vim.api.nvim_get_current_buf() + local old = assert(LazyVim.root.realpath(vim.api.nvim_buf_get_name(buf))) + local root = assert(LazyVim.root.realpath(LazyVim.root.get({ normalize = true }))) + assert(old:find(root, 1, true) == 1, "File not in project root") + + local extra = old:sub(#root + 2) + + vim.ui.input({ + prompt = "New File Name: ", + default = extra, + }, function(new) + if not new or new == "" or new == extra then + return + end + new = LazyVim.norm(root .. "/" .. new) + vim.fn.mkdir(vim.fs.dirname(new), "p") + M.on_rename(old, new, function() + vim.fn.rename(old, new) + vim.cmd.edit(new) + vim.api.nvim_buf_delete(buf, { force = true }) + vim.fn.delete(old) + end) + end) +end + ---@param from string ---@param to string -function M.on_rename(from, to) +---@param rename? fun() +function M.on_rename(from, to, rename) + local changes = { files = { { + oldUri = vim.uri_from_fname(from), + newUri = vim.uri_from_fname(to), + } } } + local clients = M.get_clients() for _, client in ipairs(clients) do if client.supports_method("workspace/willRenameFiles") then - ---@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) + local resp = client.request_sync("workspace/willRenameFiles", changes, 1000, 0) if resp and resp.result ~= nil then vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding) end end end + + if rename then + rename() + end + + for _, client in ipairs(clients) do + if client.supports_method("workspace/didRenameFiles") then + client.notify("workspace/didRenameFiles", changes) + end + end end ---@return _.lspconfig.options @@ -62,6 +179,11 @@ function M.get_config(server) return rawget(configs, server) end +function M.is_enabled(server) + local c = M.get_config(server) + return c and c.enabled ~= false +end + ---@param server string ---@param cond fun( root_dir, config): boolean function M.disable(server, cond) @@ -87,39 +209,119 @@ function M.formatter(opts) primary = true, priority = 1, format = function(buf) - M.format(Util.merge(filter, { bufnr = buf })) + M.format(LazyVim.merge({}, filter, { bufnr = buf })) end, sources = function(buf) - local clients = M.get_clients(Util.merge(filter, { bufnr = buf })) - ---@param client lsp.Client + local clients = M.get_clients(LazyVim.merge({}, filter, { bufnr = buf })) + ---@param client vim.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 + ---@param client vim.lsp.Client return vim.tbl_map(function(client) return client.name end, ret) end, } - return Util.merge(ret, opts) --[[@as LazyFormatter]] + return LazyVim.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 {}) + opts = vim.tbl_deep_extend( + "force", + {}, + opts or {}, + LazyVim.opts("nvim-lspconfig").format or {}, + LazyVim.opts("conform.nvim").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 +---@alias LspWord {from:{[1]:number, [2]:number}, to:{[1]:number, [2]:number}} 1-0 indexed +M.words = {} +M.words.enabled = false +M.words.ns = vim.api.nvim_create_namespace("vim_lsp_references") + +---@param opts? {enabled?: boolean} +function M.words.setup(opts) + opts = opts or {} + if not opts.enabled then + return + end + M.words.enabled = true + local handler = vim.lsp.handlers["textDocument/documentHighlight"] + vim.lsp.handlers["textDocument/documentHighlight"] = function(err, result, ctx, config) + if not vim.api.nvim_buf_is_loaded(ctx.bufnr) then + return + end + vim.lsp.buf.clear_references() + return handler(err, result, ctx, config) + end + + M.on_supports_method("textDocument/documentHighlight", function(_, buf) + vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI", "CursorMoved", "CursorMovedI" }, { + group = vim.api.nvim_create_augroup("lsp_word_" .. buf, { clear = true }), + buffer = buf, + callback = function(ev) + if not require("lazyvim.plugins.lsp.keymaps").has(buf, "documentHighlight") then + return false + end + if not ({ M.words.get() })[2] then + if ev.event:find("CursorMoved") then + vim.lsp.buf.clear_references() + else + vim.lsp.buf.document_highlight() + end + end + end, + }) + end) +end + +---@return LspWord[] words, number? current +function M.words.get() + local cursor = vim.api.nvim_win_get_cursor(0) + local current, ret = nil, {} ---@type number?, LspWord[] + for _, extmark in ipairs(vim.api.nvim_buf_get_extmarks(0, M.words.ns, 0, -1, { details = true })) do + local w = { + from = { extmark[2] + 1, extmark[3] }, + to = { extmark[4].end_row + 1, extmark[4].end_col }, + } + ret[#ret + 1] = w + if cursor[1] >= w.from[1] and cursor[1] <= w.to[1] and cursor[2] >= w.from[2] and cursor[2] <= w.to[2] then + current = #ret + end + end + return ret, current +end + +---@param count number +---@param cycle? boolean +function M.words.jump(count, cycle) + local words, idx = M.words.get() + if not idx then + return + end + idx = idx + count + if cycle then + idx = (idx - 1) % #words + 1 + end + local target = words[idx] + if target then + vim.api.nvim_win_set_cursor(0, target.from) + end +end + return M diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index 3e3cdb9a..3e546873 100644 --- a/lua/lazyvim/util/lualine.lua +++ b/lua/lazyvim/util/lualine.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.lualine local M = {} @@ -25,9 +23,9 @@ function M.cmp_source(name, icon) end local colors = { - ok = Util.ui.fg("Special"), - error = Util.ui.fg("DiagnosticError"), - pending = Util.ui.fg("DiagnosticWarn"), + ok = LazyVim.ui.fg("Special"), + error = LazyVim.ui.fg("DiagnosticError"), + pending = LazyVim.ui.fg("DiagnosticWarn"), } return { @@ -48,7 +46,8 @@ end ---@param hl_group? string ---@return string function M.format(component, text, hl_group) - if not hl_group then + text = text:gsub("%%", "%%%%") + if not hl_group or hl_group == "" then return text end ---@type table @@ -56,17 +55,32 @@ function M.format(component, text, hl_group) 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) + ---@type string[] + local gui = vim.tbl_filter(function(x) + return x + end, { + utils.extract_highlight_colors(hl_group, "bold") and "bold", + utils.extract_highlight_colors(hl_group, "italic") and "italic", + }) + + lualine_hl_group = component:create_hl({ + fg = utils.extract_highlight_colors(hl_group, "fg"), + gui = #gui > 0 and table.concat(gui, ",") or nil, + }, "LV_" .. hl_group) --[[@as string]] 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?} +---@param opts? {relative: "cwd"|"root", modified_hl: string?, directory_hl: string?, filename_hl: string?} function M.pretty_path(opts) opts = vim.tbl_extend("force", { relative = "cwd", - modified_hl = "Constant", + modified_hl = "MatchParen", + directory_hl = "", + filename_hl = "Bold", + modified_sign = "", + length = 3, }, opts or {}) return function(self) @@ -75,8 +89,9 @@ function M.pretty_path(opts) if path == "" then return "" end - local root = Util.root.get({ normalize = true }) - local cwd = Util.root.cwd() + + local root = LazyVim.root.get({ normalize = true }) + local cwd = LazyVim.root.cwd() if opts.relative == "cwd" and path:find(cwd, 1, true) == 1 then path = path:sub(#cwd + 2) @@ -86,15 +101,26 @@ function M.pretty_path(opts) local sep = package.config:sub(1, 1) local parts = vim.split(path, "[\\/]") - if #parts > 3 then - parts = { parts[1], "…", parts[#parts - 1], parts[#parts] } + + if opts.length == 0 then + parts = parts + elseif #parts > opts.length then + parts = { parts[1], "…", table.concat({ unpack(parts, #parts - opts.length + 2, #parts) }, sep) } end if opts.modified_hl and vim.bo.modified then + parts[#parts] = parts[#parts] .. opts.modified_sign parts[#parts] = M.format(self, parts[#parts], opts.modified_hl) + else + parts[#parts] = M.format(self, parts[#parts], opts.filename_hl) end - return table.concat(parts, sep) + local dir = "" + if #parts > 1 then + dir = table.concat({ unpack(parts, 1, #parts - 1) }, sep) + dir = M.format(self, dir .. sep, opts.directory_hl) + end + return dir .. parts[#parts] end end @@ -106,12 +132,12 @@ function M.root_dir(opts) parent = true, other = true, icon = "󱉭 ", - color = Util.ui.fg("Special"), + color = LazyVim.ui.fg("Special"), }, opts or {}) local function get() - local cwd = Util.root.cwd() - local root = Util.root.get({ normalize = true }) + local cwd = LazyVim.root.cwd() + local root = LazyVim.root.get({ normalize = true }) local name = vim.fs.basename(root) if root == cwd then diff --git a/lua/lazyvim/util/mini.lua b/lua/lazyvim/util/mini.lua new file mode 100644 index 00000000..986a1887 --- /dev/null +++ b/lua/lazyvim/util/mini.lua @@ -0,0 +1,112 @@ +---@class lazyvim.util.mini +local M = {} + +---@alias Mini.ai.loc {line:number, col:number} +---@alias Mini.ai.region {from:Mini.ai.loc, to:Mini.ai.loc} + +-- Mini.ai indent text object +-- For "a", it will include the non-whitespace line surrounding the indent block. +-- "a" is line-wise, "i" is character-wise. +function M.ai_indent(ai_type) + local spaces = (" "):rep(vim.o.tabstop) + local lines = vim.api.nvim_buf_get_lines(0, 0, -1, false) + local indents = {} ---@type {line: number, indent: number, text: string}[] + + for l, line in ipairs(lines) do + if not line:find("^%s*$") then + indents[#indents + 1] = { line = l, indent = #line:gsub("\t", spaces):match("^%s*"), text = line } + end + end + + local ret = {} ---@type (Mini.ai.region | {indent: number})[] + + for i = 1, #indents do + if i == 1 or indents[i - 1].indent < indents[i].indent then + local from, to = i, i + for j = i + 1, #indents do + if indents[j].indent < indents[i].indent then + break + end + to = j + end + from = ai_type == "a" and from > 1 and from - 1 or from + to = ai_type == "a" and to < #indents and to + 1 or to + ret[#ret + 1] = { + indent = indents[i].indent, + from = { line = indents[from].line, col = ai_type == "a" and 1 or indents[from].indent + 1 }, + to = { line = indents[to].line, col = #indents[to].text }, + } + end + end + + return ret +end + +-- taken from MiniExtra.gen_ai_spec.buffer +function M.ai_buffer(ai_type) + local start_line, end_line = 1, vim.fn.line("$") + if ai_type == "i" then + -- Skip first and last blank lines for `i` textobject + local first_nonblank, last_nonblank = vim.fn.nextnonblank(start_line), vim.fn.prevnonblank(end_line) + -- Do nothing for buffer with all blanks + if first_nonblank == 0 or last_nonblank == 0 then + return { from = { line = start_line, col = 1 } } + end + start_line, end_line = first_nonblank, last_nonblank + end + + local to_col = math.max(vim.fn.getline(end_line):len(), 1) + return { from = { line = start_line, col = 1 }, to = { line = end_line, col = to_col } } +end + +-- register all text objects with which-key +function M.ai_whichkey() + ---@type table + local i = { + [" "] = "Whitespace", + ['"'] = 'Balanced "', + ["'"] = "Balanced '", + ["`"] = "Balanced `", + ["("] = "Balanced (", + [")"] = "Balanced ) including white-space", + [">"] = "Balanced > including white-space", + [""] = "Balanced <", + ["]"] = "Balanced ] including white-space", + ["["] = "Balanced [", + ["}"] = "Balanced } including white-space", + ["{"] = "Balanced {", + ["?"] = "User Prompt", + _ = "Underscore", + a = "Argument", + b = "Balanced ), ], }", + c = "Class", + d = "Digit(s)", + e = "Word in CamelCase & snake_case", + f = "Function", + g = "Entire file", + i = "Indent", + o = "Block, conditional, loop", + q = "Quote `, \", '", + t = "Tag", + u = "Use/call function & method", + U = "Use/call without dot in name", + } + local a = vim.deepcopy(i) + for k, v in pairs(a) do + a[k] = v:gsub(" including.*", "") + end + + local ic = vim.deepcopy(i) + local ac = vim.deepcopy(a) + for key, name in pairs({ n = "Next", l = "Last" }) do + i[key] = vim.tbl_extend("force", { name = "Inside " .. name .. " textobject" }, ic) + a[key] = vim.tbl_extend("force", { name = "Around " .. name .. " textobject" }, ac) + end + require("which-key").register({ + mode = { "o", "x" }, + i = i, + a = a, + }) +end + +return M diff --git a/lua/lazyvim/util/news.lua b/lua/lazyvim/util/news.lua index 4c212470..5434649a 100644 --- a/lua/lazyvim/util/news.lua +++ b/lua/lazyvim/util/news.lua @@ -1,11 +1,10 @@ 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) + local stat = vim.uv.fs_stat(file) if not stat then return end @@ -27,7 +26,7 @@ function M.setup() end function M.welcome() - Util.info("Welcome to LazyVim!") + LazyVim.info("Welcome to LazyVim!") end function M.changelog() @@ -50,7 +49,7 @@ function M.open(file, opts) 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) + return LazyVim.error("plugin not found: " .. opts.plugin) end file = plugin.dir .. "/" .. file elseif opts.rtp then @@ -58,7 +57,7 @@ function M.open(file, opts) end if not file then - return Util.error("File not found") + return LazyVim.error("File not found") end if opts.when_changed then @@ -68,7 +67,7 @@ function M.open(file, opts) return end Config.json.data.news[ref] = hash - Util.json.save() + LazyVim.json.save() -- don't open if file has never been opened if is_new then return diff --git a/lua/lazyvim/util/plugin.lua b/lua/lazyvim/util/plugin.lua index 7ab69134..f34527ac 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -1,10 +1,8 @@ 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 @@ -12,13 +10,18 @@ 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.", + ["lazyvim.plugins.extras.coding.native_snippets"] = "Native snippets are now the default for **Neovim >= 0.10**", + ["lazyvim.plugins.extras.ui.treesitter-rewrite"] = "Disabled `treesitter-rewrite` extra for now. Not ready yet.", + ["lazyvim.plugins.extras.coding.mini-ai"] = "`mini.ai` is now a core LazyVim plugin (again)", + ["lazyvim.plugins.extras.lazyrc"] = "local spec files are now a lazy.nvim feature", + ["lazyvim.plugins.extras.editor.trouble-v3"] = "Trouble v3 has been merged in main", + ["lazyvim.plugins.extras.lang.python-semshi"] = [[The python-semshi extra has been removed, + because it's causing too many issues. + Either use `basedpyright`, or copy the [old extra](https://github.com/LazyVim/LazyVim/blob/c1f5fcf9c7ed2659c9d5ac41b3bb8a93e0a3c6a0/lua/lazyvim/plugins/extras/lang/python-semshi.lua#L1) to your own config. + ]], } -M.deprecated_modules = { - ["null-ls"] = "lsp.none-ls", - ["nvim-navic.lib"] = "editor.navic", - ["nvim-navic"] = "editor.navic", -} +M.deprecated_modules = {} ---@type table M.renames = { @@ -35,7 +38,7 @@ function M.setup() M.lazy_file() table.insert(package.loaders, function(module) if M.deprecated_modules[module] then - Util.warn( + LazyVim.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] @@ -56,90 +59,55 @@ function M.extra_idx(name) 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 + -- This autocmd will only trigger when a file was loaded from the cmdline. + -- It will render the file as quickly as possible. + vim.api.nvim_create_autocmd("BufReadPost", { + once = true, + callback = function(event) + -- Skip if we already entered vim + if vim.v.vim_did_enter == 1 then + return + end + + -- Try to guess the filetype (may change later on during Neovim startup) + local ft = vim.filetype.match({ buf = event.buf }) + if ft then + -- Add treesitter highlights and fallback to syntax + local lang = vim.treesitter.language.get_lang(ft) + if not (lang and pcall(vim.treesitter.start, event.buf, lang)) then + vim.bo[event.buf].syntax = ft + end + + -- Trigger early redraw + vim.cmd([[redraw]]) + end + end, + }) -- Add support for the LazyFile event 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, - }) + Event.mappings.LazyFile = { id = "LazyFile", event = M.lazy_file_events } + Event.mappings["User LazyFile"] = Event.mappings.LazyFile end function M.fix_imports() - Plugin.Spec.import = Util.inject.args(Plugin.Spec.import, function(_, spec) + Plugin.Spec.import = LazyVim.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 }) + dep = dep .. "\n" .. "Please remove the extra from `lazyvim.json` to hide this warning." + LazyVim.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) + Plugin.Spec.add = LazyVim.inject.args(Plugin.Spec.add, function(self, plugin) if type(plugin) == "table" then if M.renames[plugin[1]] then - Util.warn( + LazyVim.warn( ("Plugin `%s` was renamed to `%s`.\nPlease update your config for `%s`"):format( plugin[1], M.renames[plugin[1]], diff --git a/lua/lazyvim/util/root.lua b/lua/lazyvim/util/root.lua index 29581975..4523f3cf 100644 --- a/lua/lazyvim/util/root.lua +++ b/lua/lazyvim/util/root.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.root ---@overload fun(): string local M = setmetatable({}, { @@ -22,7 +20,7 @@ M.spec = { "lsp", { ".git", "lua" }, "cwd" } M.detectors = {} function M.detectors.cwd() - return { vim.loop.cwd() } + return { vim.uv.cwd() } end function M.detectors.lsp(buf) @@ -31,7 +29,7 @@ function M.detectors.lsp(buf) return {} end local roots = {} ---@type string[] - for _, client in pairs(Util.lsp.get_clients({ bufnr = buf })) do + for _, client in pairs(LazyVim.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 @@ -40,7 +38,7 @@ function M.detectors.lsp(buf) end end return vim.tbl_filter(function(path) - path = Util.norm(path) + path = LazyVim.norm(path) return path and bufpath:find(path, 1, true) == 1 end, roots) end @@ -48,8 +46,18 @@ 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] + local path = M.bufpath(buf) or vim.uv.cwd() + local pattern = vim.fs.find(function(name) + for _, p in ipairs(patterns) do + if name == p then + return true + end + if p:sub(1, 1) == "*" and name:find(vim.pesc(p:sub(2)) .. "$") then + return true + end + end + return false + end, { path = path, upward = true })[1] return pattern and { vim.fs.dirname(pattern) } or {} end @@ -58,15 +66,15 @@ function M.bufpath(buf) end function M.cwd() - return M.realpath(vim.loop.cwd()) or "" + return M.realpath(vim.uv.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) + path = vim.uv.fs_realpath(path) or path + return LazyVim.norm(path) end ---@param spec LazyRootSpec @@ -132,8 +140,8 @@ function M.info() 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() + LazyVim.info(lines, { title = "LazyVim Roots" }) + return roots[1] and roots[1].paths[1] or vim.uv.cwd() end ---@type table @@ -141,10 +149,13 @@ M.cache = {} function M.setup() vim.api.nvim_create_user_command("LazyRoot", function() - Util.root.info() + LazyVim.root.info() end, { desc = "LazyVim roots for the current buffer" }) - vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost" }, { + -- FIX: doesn't properly clear cache in neo-tree `set_root` (which should happen presumably on `DirChanged`), + -- probably because the event is triggered in the neo-tree buffer, therefore add `BufEnter` + -- Maybe this is too frequent on `BufEnter` and something else should be done instead?? + vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged", "BufEnter" }, { group = vim.api.nvim_create_augroup("lazyvim_root_cache", { clear = true }), callback = function(event) M.cache[event.buf] = nil @@ -164,13 +175,20 @@ function M.get(opts) 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() + ret = roots[1] and roots[1].paths[1] or vim.uv.cwd() M.cache[buf] = ret end if opts and opts.normalize then return ret end - return Util.is_win() and ret:gsub("/", "\\") or ret + return LazyVim.is_win() and ret:gsub("/", "\\") or ret +end + +function M.git() + local root = M.get() + local git_root = vim.fs.find(".git", { path = root, upward = true })[1] + local ret = git_root and vim.fn.fnamemodify(git_root, ":h") or root + return ret end ---@param opts? {hl_last?: string} diff --git a/lua/lazyvim/util/telescope.lua b/lua/lazyvim/util/telescope.lua index 1d816b80..bb030627 100644 --- a/lua/lazyvim/util/telescope.lua +++ b/lua/lazyvim/util/telescope.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.telescope.opts ---@field cwd? string|boolean ---@field show_untracked? boolean @@ -22,26 +20,34 @@ function M.telescope(builtin, 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]] + opts = vim.tbl_deep_extend("force", { cwd = LazyVim.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 + if + vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.git") + and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.ignore") + and not vim.uv.fs_stat((opts.cwd or vim.uv.cwd()) .. "/.rgignore") + then + if opts.show_untracked == nil then + opts.show_untracked = true + end builtin = "git_files" else builtin = "find_files" end end - if opts.cwd and opts.cwd ~= vim.loop.cwd() then + if opts.cwd and opts.cwd ~= vim.uv.cwd() then + local function open_cwd_dir() + 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 ---@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) + -- opts.desc is overridden by telescope, until it's changed there is this fix + map("i", "", open_cwd_dir, { desc = "Open cwd Directory" }) return true end end @@ -51,7 +57,7 @@ function M.telescope(builtin, opts) end function M.config_files() - return Util.telescope("find_files", { cwd = vim.fn.stdpath("config") }) + return LazyVim.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 index 7787615b..6d40dc95 100644 --- a/lua/lazyvim/util/terminal.lua +++ b/lua/lazyvim/util/terminal.lua @@ -9,6 +9,37 @@ local M = setmetatable({}, { ---@type table local terminals = {} +---@param shell? string +function M.setup(shell) + vim.o.shell = shell or vim.o.shell + + -- Special handling for pwsh + if shell == "pwsh" or shell == "powershell" then + -- Check if 'pwsh' is executable and set the shell accordingly + if vim.fn.executable("pwsh") == 1 then + vim.o.shell = "pwsh" + elseif vim.fn.executable("powershell") == 1 then + vim.o.shell = "powershell" + else + return LazyVim.error("No powershell executable found") + end + + -- Setting shell command flags + vim.o.shellcmdflag = + "-NoLogo -ExecutionPolicy RemoteSigned -Command [Console]::InputEncoding=[Console]::OutputEncoding=[System.Text.UTF8Encoding]::new();$PSDefaultParameterValues['Out-File:Encoding']='utf8';" + + -- Setting shell redirection + vim.o.shellredir = '2>&1 | %{ "$_" } | Out-File %s; exit $LastExitCode' + + -- Setting shell pipe + vim.o.shellpipe = '2>&1 | %{ "$_" } | Tee-Object %s; exit $LastExitCode' + + -- Setting shell quote options + vim.o.shellquote = "" + vim.o.shellxquote = "" + end +end + ---@class LazyTermOpts: LazyCmdOptions ---@field interactive? boolean ---@field esc_esc? boolean @@ -21,6 +52,7 @@ function M.open(cmd, opts) opts = vim.tbl_deep_extend("force", { ft = "lazyterm", size = { width = 0.9, height = 0.9 }, + backdrop = LazyVim.has("edgy.nvim") and not cmd and 100 or nil, }, opts or {}, { persistent = true }) --[[@as LazyTermOpts]] local termkey = vim.inspect({ cmd = cmd or "shell", cwd = opts.cwd, env = opts.env, count = vim.v.count1 }) @@ -41,6 +73,14 @@ function M.open(cmd, opts) vim.keymap.set("t", "", "", { buffer = buf, nowait = true }) end + vim.keymap.set("n", "gf", function() + local f = vim.fn.findfile(vim.fn.expand("")) + if f ~= "" then + vim.cmd("close") + vim.cmd("e " .. f) + end + end, { buffer = buf }) + vim.api.nvim_create_autocmd("BufEnter", { buffer = buf, callback = function() diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua index b520070b..95bb3e76 100644 --- a/lua/lazyvim/util/toggle.lua +++ b/lua/lazyvim/util/toggle.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - ---@class lazyvim.util.toggle local M = {} @@ -14,15 +12,15 @@ function M.option(option, silent, values) ---@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" }) + return LazyVim.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" }) + LazyVim.info("Enabled " .. option, { title = "Option" }) else - Util.warn("Disabled " .. option, { title = "Option" }) + LazyVim.warn("Disabled " .. option, { title = "Option" }) end end end @@ -33,26 +31,85 @@ function M.number() 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" }) + LazyVim.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" }) + LazyVim.info("Enabled line numbers", { title = "Option" }) end end local enabled = true function M.diagnostics() + -- if this Neovim version supports checking if diagnostics are enabled + -- then use that for the current state + if vim.diagnostic.is_enabled then + enabled = vim.diagnostic.is_enabled() + elseif vim.diagnostic.is_disabled then + enabled = not vim.diagnostic.is_disabled() + end enabled = not enabled + if enabled then vim.diagnostic.enable() - Util.info("Enabled diagnostics", { title = "Diagnostics" }) + LazyVim.info("Enabled diagnostics", { title = "Diagnostics" }) else vim.diagnostic.disable() - Util.warn("Disabled diagnostics", { title = "Diagnostics" }) + LazyVim.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({ bufnr = buf or 0 }) + end + ih.enable(value, { bufnr = buf }) + end +end + +---@type {k:string, v:any}[] +M._maximized = nil +---@param state boolean? +function M.maximize(state) + if state == (M._maximized ~= nil) then + return + end + if M._maximized then + for _, opt in ipairs(M._maximized) do + vim.o[opt.k] = opt.v + end + M._maximized = nil + vim.cmd("wincmd =") + else + M._maximized = {} + local function set(k, v) + table.insert(M._maximized, 1, { k = k, v = vim.o[k] }) + vim.o[k] = v + end + set("winwidth", 999) + set("winheight", 999) + set("winminwidth", 10) + set("winminheight", 4) + vim.cmd("wincmd =") + end + -- `QuitPre` seems to be executed even if we quit a normal window, so we don't want that + -- `VimLeavePre` might be another consideration? Not sure about differences between the 2 + vim.api.nvim_create_autocmd("ExitPre", { + once = true, + group = vim.api.nvim_create_augroup("lazyvim_restore_max_exit_pre", { clear = true }), + desc = "Restore width/height when close Neovim while maximized", + callback = function() + M.maximize(false) + end, + }) +end + setmetatable(M, { __call = function(m, ...) return m.option(...) diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index 68999eda..5877fd7f 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -10,12 +10,19 @@ local M = {} function M.get_signs(buf, lnum) -- Get regular signs ---@type Sign[] - local signs = vim.tbl_map(function(sign) - ---@type Sign - local ret = vim.fn.sign_getdefined(sign.name)[1] - ret.priority = sign.priority - return ret - end, vim.fn.sign_getplaced(buf, { group = "*", lnum = lnum })[1].signs) + 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( @@ -92,12 +99,18 @@ function M.statuscolumn() local components = { "", "", "" } -- left, middle, right + local show_open_folds = vim.g.lazyvim_statuscolumn and vim.g.lazyvim_statuscolumn.folds_open + local use_githl = vim.g.lazyvim_statuscolumn and vim.g.lazyvim_statuscolumn.folds_githl + if show_signs then ---@type Sign?,Sign?,Sign? - local left, right, fold + local left, right, fold, githl for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do - if s.name and s.name:find("GitSign") then + if s.name and (s.name:find("GitSign") or s.name:find("MiniDiffSign")) then right = s + if use_githl then + githl = s["texthl"] + end else left = s end @@ -105,9 +118,16 @@ function M.statuscolumn() 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" } + fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = githl or "Folded" } + elseif + show_open_folds + and not LazyVim.ui.skip_foldexpr[buf] + and vim.treesitter.foldexpr(vim.v.lnum):sub(1, 1) == ">" + then -- fold start + fold = { text = vim.opt.fillchars:get().foldopen or "", texthl = githl } end end) -- Left: mark or non-git sign @@ -129,20 +149,42 @@ function M.statuscolumn() components[2] = "%=" .. components[2] .. " " -- right align end + if vim.v.virtnum ~= 0 then + components[2] = "%= " + end + return table.concat(components, "") end +---@return {fg?:string}? function M.fg(name) + local color = M.color(name) + return color and { fg = color } or nil +end + +---@param name string +---@param bg? boolean +---@return string? +function M.color(name, bg) ---@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) + local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name, link = false }) + 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 + ---@type string? + local color = nil + if hl then + if bg then + color = hl.bg or hl.background + else + color = hl.fg or hl.foreground + end + end + return color and string.format("#%06x", color) or nil end M.skip_foldexpr = {} ---@type table -local skip_check = assert(vim.loop.new_check()) +local skip_check = assert(vim.uv.new_check()) function M.foldexpr() local buf = vim.api.nvim_get_current_buf() @@ -179,4 +221,47 @@ function M.foldexpr() return "0" end +---@param buf number? +function M.bufremove(buf) + buf = buf or 0 + buf = buf == 0 and vim.api.nvim_get_current_buf() or buf + + 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 == 0 then -- Cancel + return + end + if choice == 1 then -- Yes + vim.cmd.write() + end + end + + for _, win in ipairs(vim.fn.win_findbuf(buf)) do + vim.api.nvim_win_call(win, function() + if not vim.api.nvim_win_is_valid(win) or vim.api.nvim_win_get_buf(win) ~= buf then + return + end + -- Try using alternate buffer + local alt = vim.fn.bufnr("#") + if alt ~= buf and vim.fn.buflisted(alt) == 1 then + vim.api.nvim_win_set_buf(win, alt) + return + end + + -- Try using previous buffer + local has_previous = pcall(vim.cmd, "bprevious") + if has_previous and buf ~= vim.api.nvim_win_get_buf(win) then + return + end + + -- Create new listed buffer + local new_buf = vim.api.nvim_create_buf(true, false) + vim.api.nvim_win_set_buf(win, new_buf) + end) + end + if vim.api.nvim_buf_is_valid(buf) then + pcall(vim.cmd, "bdelete! " .. buf) + end +end + return M diff --git a/queries/lua/highlights.scm b/queries/lua/highlights.scm index 829b2b08..eb048490 100644 --- a/queries/lua/highlights.scm +++ b/queries/lua/highlights.scm @@ -2,3 +2,6 @@ ((identifier) @namespace.builtin (#eq? @namespace.builtin "vim")) + +((identifier) @namespace.builtin + (#eq? @namespace.builtin "LazyVim")) diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 00000000..1d1b8b1d --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,5 @@ +{ + "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json", + "release-type": "simple", + "extra-files": ["lua/lazyvim/config/init.lua"] +}