From ddbcc31c6249a7c3b796c48e85014b61218f5a40 Mon Sep 17 00:00:00 2001 From: Anjo Tadena Date: Tue, 9 Apr 2024 08:10:35 +0800 Subject: [PATCH] Sync from upstream to main (#2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(dot): treesitter for hypr was renamed to hyprlang * feat(autocmds): dont use conceal for json files * chore(build): auto-generate vimdoc * feat(lsp): add diagnostic signs to lsp options (#2192) Co-authored-by: Gary Murray * feat(test): Add tl to neotest.run_last() (#1968) * feat(gitsigns): update gitsigns.nvim preview command (#2178) * chores(format.lua): Fix typo * Change gitsigns.nvim hunk preview shortcut Change `preview_hunk` to recently added `preview_hunk_inline` command * feat(keymaps): add function to toggle between light/dark backgrounds (#2088) * fix(eslint): correct working directories name (#2071) * feat(neo-tree): Adds copy file name command to Neo-Tree with 'Y' binding (#2137) Co-authored-by: Ricardo Rebelo * chore(main): release 10.9.0 (#2391) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix: fixup for #2137 * chore(main): release 10.9.1 (#2399) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * docs: typo in init.lua (#2365) * docs(README-DE): remove .txt extension (#2321) Probably some windows editor that added this automatically + known extensions hidden. * fix(autocmds): avoid checktime when buftype=nofile (#2270) It triggered an 'E11: Invalid in command-line window; executes, CTRL-C quits' error when Neovim was in Command Line window and FocusGained. * fix(typescript): don't hardcode values in lua table (#2254) * fix(typescript): don't hardcode values in lua table When a user changes `vim.opt.shiftwidth` with some auto-command, it's not taken into account. Make `opts` a function, so that values get evaluated when `lspconfig` loads instead. * fix(typescript): remove format settings entirely * fix(typescript): add back comment and Lua annotations * fix(typescript): bring back function call completion snippets * fix(options): change default conceal level to 2 (#2053) 3 hides all concealed text, even if there are replacement chars defined e.g. : for Markdown, 3 hides list item markers, dots for asterisk lists and em-dashes for dash lists If replacements are defined as defaults in a plugin, the "Laziest™" config would seem to be displaying them. Level 1 only seems useful when alignment really matters. * feat(toggle): use `vim.diagnostic.is_disabled` when available (#2217) * feat(toggle-diagnostics): change logic based on `vim.diagnostic.is_disabled` After discussion in #2215, I thought maybe it would be beneficial if we could change the logic of the `toggle-diagnostics` function based on if the user has disabled diagnostics in his own configuration. * feat(toggle-diagnostics): revert to `enable` instead of `status` * fix(toggle): use vim.diagnostics enabled state when possible --------- Co-authored-by: Folke Lemaitre * fix(neo-tree): better copy file name with `Y` * fix(hyprlang): use lazyvim way to install (#2404) * chore(build): auto-generate vimdoc * fix(rust): avoid resetting cmp group_index to 1 (#2332) For example, 'buffer' source by default has group_index = 2 [1], however if we take all the sources plus crates and run them through cmp.config.sources() again, since it's a one-dimensional list, all group_indexes will be reset to 1. [1] https://github.com/LazyVim/LazyVim/blob/879e29504d43e9f178d967ecc34d482f902e5a91/lua/lazyvim/plugins/coding.lua#L74-L80 * feat: added `LazyHealth` that loads all plugins and runs `:checkhealth` * feat(snippets): added extra to use native snippets instead of LuaSnip. * feat(telescope): add fg for finding files using git-files (#2353) I found this to be more useful than the current ff and fF * fix(autocmds): apply conceal level change to local buffer options (#2409) * chore(build): auto-generate vimdoc * chore(main): release 10.10.0 (#2400) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * chore(build): auto-generate vimdoc * fix(dot): remove hyprlang plugin (#2623) * chore(build): auto-generate vimdoc * fix(neo-tree): Add description to "Y" in Neo-Tree (#2642) It copies the path of the file/directory * fix(autocmds): nvim already binds q to close for man-files (#2594) * fix(options): don't lower timeoutlen when in VS Code (#2568) Avoid lowering timeoutlen when running in VS Code, to avoid unwanted timeouts from key mappings. The lower value of 300ms (down from Neovim's default of 1000ms) works great outside of VS Code, where it helps trigger the which-key UI quickly, and where which-key prevents timeouts from occuring. But in VS Code (where which-key isn't applicable), the lower value makes it difficult to perform some key mappings in time, such as `]p`, which requires shifting hand position. * fix(yanky): properly disable sqlite.lua on Windows (#2543) When directly modifying its `enabled` property, the plugin will remain disabled even if required by another plugin. * feat(hipatterns): add shorthand hex color support (#2562) * feat(lang) replace rust-tools.nvim with rustacean.nvim - fixes #2113 (#2198) * feat(lang) - move to rustacean.nvim, fixes #2113 * update rustacean plugin * PR comment for lsp settings * fix(telescope): dont use git_files when .ignore or .rgignore file is present * feat(lang): add ansible support (#1218) * feat(treesitter): add xml to `ensure_installed` (#1962) * chore(treesitter.lua): fix typo (#2026) * fix typo * fix typo * fix(telescope): anonymous keymap (#1879) * fix(telescope): anonymous keymap * fix(telescope): add desc * fix(telescope): function name * fix(telescope): update description * fix(telescope): diagnostic disable * feat(lang): add Haskell config (#2052) * feat(util) create gitui extension (#2238) * feat(symbols-outline): use outline.nvim instead of symbols-outline.nvim (#2535) * feat(extras): Add scala support using nvim-metals (#1347) * Add scala support using nvim-metals nvim-metals: https://github.com/scalameta/nvim-metals minimal example configuration from their documentation: https://github.com/scalameta/nvim-metals/discussions/39 * add treesitter syntax highlighting * feat(lang): add support for helm chart templates (#2273) * feat(lang): add support for helm chart templates * fix(helm): stop yamlls and disable autostart * fix(helm): stop yaml & docker compose lsp on helm file types Revert disabling `autostart` since that kills the LSP globally even when opening a standard yaml file, like GitHub Workflow file. * fix(helm): remove docker compose lsp overrides Since docker compose LSP does not seem to be triggered or started by opening *.yaml helm files, the config overrides were removed to simplify Helm config. * fix(helm): ensure mason installs helm lsp * feat(omnisharp): add `nvim-dap` configuration (#2532) * feat(omnisharp): add `nvim-dap` configuration * chore(omnisharp): add `netcoredbg` to `ensure_installed` * chore: simplify get `netcoredbg` path * fix(util.ui.fg): Add `link=false` to show effective definition (#2542) Fixes #2540 by showing the effective definition instead of the linked group name. * feat(extras): Enable project-specific plugin specs using local .lazy.lua (#2115) * feat(extras): Enable project-specific plugin specs using .lazy.lua * added a warning when extra lazyrc is not the last plugin spec * feat(lang): add telescope terraform integrations (#2235) * feat(lang): add telescope terraform integrations Closes #2234 Add telescope integrations for: - https://github.com/ANGkeith/telescope-terraform-doc.nvim - https://github.com/cappyzawa/telescope-terraform.nvim * fix(lang): remove event from terraform telescope extensions * style: formatting * feat(autocmds): added support for copy/paste through ssh. Needs Neovim >= 0.10.0 * feat(extras): add harpoon2 (#2455) * feat(extras): add harpoon2 * Update lua/lazyvim/plugins/extras/editor/harpoon2.lua Co-authored-by: Iordanis Petkakis * chore: formatting --------- Co-authored-by: Iordanis Petkakis * feat(ui): dashboard files searches git files if in git repo (#2240) just like `ff` keymap for telescope * fix(lang): Change `rustacean` keymaps to `vim.keymap.set` instead of `which-key` (#2660) Based on this [comment](https://github.com/LazyVim/LazyVim/pull/2198#pullrequestreview-1873658780). * fix(ansible): incorrect key spec * feat(lsp): added native codelens support. Enable in lsp settings. (disabled by default). Fixes #2656 * feat(java): allow opts for setup_dap_main_class_configs() (#2581) [1] https://github.com/mfussenegger/nvim-jdtls/blob/382b9f625861f47d95876bcfb4c261f3b96077cb/doc/jdtls.txt#L206-L210 * fix(go): adding opts recursive_run (#2520) Adding opts recursive_run to fix the error 'no Go files in /path/project.' This issue is caused by a recent change in the 'nvim-neotest/neotest-go' project, which now [defaults to non-recursive behavior](https://github.com/nvim-neotest/neotest-go/pull/72) * fix(util): clear buffer root cache when cwd change (#2502) * chore(main): release 10.11.0 (#2659) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(extras): show rename of symbols-outline => outline * chore(main): release 10.11.1 (#2664) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(lang): replace rust-tools.nvim with rustacean.nvim #2198 dummy commit to trigger changelog. original commit message was not correct and didnt get picked up by the changelog * fix(extras): set correct priority for outline extra. Fixes #2666 * chore(main): release 10.12.0 (#2667) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(haskell): Make Haskell-snippets lazy load for performance (#2676) * fix(haskell): add filetype to haskell-snippets for lazy load * format haskell.lua --------- Co-authored-by: Uthman Mohamed <83053931+1239uth@users.noreply.github.com> * chore(build): auto-generate vimdoc * fix(hi-patterns): correct regex for shorthand hex colors. See ##2562 * fix(extras): automatically rename extra symbols-outline => outline. Fixes #2675 * fix(extras): prevent duplicate extra imports * chore(main): release 10.12.1 (#2677) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(terraform-extra): Drop unnecessary commentstring config for terraform (#2680) * fix(terraform-extra): Drop unnecessary commentstring config for terraform The commentstring for terraform and hcl files is now handled by nvim-ts-context-commentstring: JoosepAlviste/nvim-ts-context-commentstring#94 * Fixed terraform.lua issues. I'm bad. * chore(build): auto-generate vimdoc * feat(lualine): add more hl options to pretty_path (#2687) * feat(lualine): add more hl options to pretty_path Adds two additional options to pretty_path: filename_hl and dirpath_hl. This allows users to customize the highlight group of both the directory component of the path name and the filenname independently. modified_hl is still used when the buffer has been modified. Thanks to dpetka2001 (Iordanis Petkakis) for the changes to the format function. * feat: cleanup --------- Co-authored-by: Folke Lemaitre * chore(build): auto-generate vimdoc * fix(options): dont set clipboard in an SSH session, so that OSC52 can be enabled (when supported) * chore(build): auto-generate vimdoc * feat(git): add gf for lazygit commit history on current file (#2728) * Add gf for lazygit commit history on current file * Change root dir to git root using git command * refactor: cleanup --------- Co-authored-by: Uthman Mohamed <83053931+1239uth@users.noreply.github.com> Co-authored-by: Folke Lemaitre * chore(build): auto-generate vimdoc * fix(rust): don't overwrite `vim.g.rustaceanvim` if it is defined (#2720) * fix(conform): make `lsp_fallback` option user configurable (#2616) * chore(build): auto-generate vimdoc * fix(markdown): disable headlines.nvim in insert mode. Fixes #2717 * fix(markdown): disable headlines.nvim bullets for now * fix(mini.files): description for `g.` keybinding in mini.files (#2693) If you press `g` in a mini.files menu, the `.` key shows up but doesn't have a description. This adds a desc attribute to the binding so the menu shows a correct description. * fix(which-key): add group description for folds (#2496) Signed-off-by: Jeff Davis * chore(main): release 10.13.0 (#2684) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(git): use compatible function for windows and linux (#2740) * chore(build): auto-generate vimdoc * fix(lazygit): make sure we start lazygit in a valid git root * chore(build): auto-generate vimdoc * fix(neotest): add required nvim-nio to test and dap extra (neotest and nvim-dap-ui respectively) (#2763) * Adding required nvim-nio to neotest in test-core neotest now requires nvim-neotest/nvim-nio to be installed as per BREAKING CHANGE: https://github.com/nvim-neotest/neotest/pull/337 * Adding nvim-nio as dependency nvim-dap-ui now requires nvim-neotest/nvim-nio as a dependency as of recent changes * chore(build): auto-generate vimdoc * fix(extras): accept symlinks in User `extras` directory (#2745) * feat(lualine): add `modified_sign` to `pretty_path` (#2754) Closes #2752 I left the initial text blank on purpose, so that it doesn't change anything stylistically and let the user decide what he wants to add in his personal configuration for `lualine` spec. * fix(format): format injected langs does not wait 300ms (#2737) * feat(mini.ai): add more objects d,e,g,u,U (#2769) * chore(main): release 10.14.0 (#2741) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(lsp): dont auto install disabled lsp servers * feat(python): added option to configure basedpyright as lsp. Check the python extra docs. Fixes #2787 * chore(build): auto-generate vimdoc * chore(main): release 10.15.0 (#2790) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(util.telescope): make `show_untracked` configurable (#2789) * feat: added LazyVim global. Will refactor specs later to use that * fix(python): basedpyright is now supported by mason-lspconfig * chore(build): auto-generate vimdoc * fix(format): Don't leak bufnr into opts tables (#2794) * chore(build): auto-generate vimdoc * feat: use `vim.uv` everywhere instead of `vim.loop` * feat: use LazyVim everywhere instead of `require("lazyvim.util")` * feat(lazyterm): optional shell setup, mainly for pwsh. Fixes #2151 * fix(java): dont error when not using cmp. Fixes #2038 * feat(telescope-fzf-native): added support for building with cmake. Fixes #2132 * fix(cmake): lazy load cmake-tools. Fixes #2767 * fix: add shim for vim.uv just in case someone upgrades lazyvim before lazy * chore(main): release 10.16.0 (#2791) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(options): Disable foldtext for nightly (#2447) * chores(format.lua): Fix typo * Change gitsigns.nvim hunk preview shortcut Change `preview_hunk` to recently added `preview_hunk_inline` command * feat(options): remove redundant commented line * feat(options): use native folding see https://github.com/neovim/neovim/pull/20750 * feat(neo-tree): add mapping "O" to open with system default (#2758) * feat(neo-tree): add mapping "O" to open with system default * feat(neo-tree): add OS checks for system default open commands * Use `vim.ui.open` if exists * update OS checks * Just use vim.ui.open or throw error if doesn't exist * Make "O" undefined mapping if vim.ui.open isn't available * fix: use lazy's util.open instead --------- Co-authored-by: Uthman Mohamed <83053931+1239uth@users.noreply.github.com> Co-authored-by: saeedahsan Co-authored-by: Folke Lemaitre * chore(build): auto-generate vimdoc * feat(python): allow configuring other python lsp servers than pyright, basedpyright * chore(build): auto-generate vimdoc * feat(util): added util function to get a fg/bg color from the active colorscheme * feat(lazygit): lazygit now automatically uses colors from your Neovim colorscheme Disable by setting `vim.g.lazygit_theme = false` in your `options.lua` * chore(main): release 10.17.0 (#2805) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(lazygit): allow overriding default terminal options * chore(main): release 10.17.1 (#2827) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(lazygit): dont error when setting ansi color fails. Fixes #2829 * chore(main): release 10.17.2 (#2831) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * perf(notify): disable animation notifications. too big impact on performance for too little benefit To keep using animations, you can set stages = fade_in_slide_out for the nvim-notify plugin * chore(main): release 10.17.3 (#2833) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * feat(lazygit): configure lazygit nvim-remote as editor and enable nerdfont icons can be disabled with `vim.g.lazygit_config = false` * fix(terminal): dont use backdrop for edgy terminal windows * feat(extras): add dial extra (#2798) * feat: add dial extra * refactor: removed print statements * fix(extras): early return for dial extra * refactor: dials_by_ft like conform, nvim-lint. Simplified buffer specific groups --------- Co-authored-by: Folke Lemaitre * chore(main): release 10.18.0 (#2834) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * refactor: use `LazyVim.is_win()` * fix(autocmds): auto create directory on windows for uris. Fixes #2442 * fix(keymaps): update all keymap descriptions to be Title Case (#2844) * chore(build): auto-generate vimdoc * fix(lazygit): error handling for getting lazygit's config path * fix(lazygit): use `Visual` instead of `CursorLine` for selected line. Fixes #2846 * feat(lazygit): allow customizing the lazygit theme. Check the code to change the hl group mapping. Fixes #2846 * fix(python-semshi): better highlights (#2839) * chore(main): release 10.19.0 (#2835) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(config): type filter was broken for telescope symbols * fix(nvim-lint): don't duplicate linters. Fixes #2852 * feat(cmp): added option `auto_brackets` that adds brackets to functions/methods in configured filetypes * feat(python): enable auto_brackets for python, since pyright and basedpyright dont support this natively * chore(build): auto-generate vimdoc * feat(extras): added extra for the `trouble.nvim` v3 beta * fix(trouble): show message if use hasnt updated with Lazy yet after enabling the extra * fix(statuscolumn): right align signs when virtnum > 0 * feat(extras): added extra for mini.diff * feat(extras): use mini.move instead of native move (#2865) * chore(main): release 10.20.0 (#2849) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(trouble-v3): use the filtered symbols list for lualine * chore(main): release 10.20.1 (#2869) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(mini.move): default mini.move setup already maps the correct keys * feat(trouble): added `cS` to open a trouble list of all references / definitions / ... of the item under the cursor * feat(trouble): enabled edgy * chore(build): auto-generate vimdoc * fix(tex): don't override conceallevel for tex. Not sure why that was added * chore(main): release 10.21.0 (#2870) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(native_snippets): don't try to enable native snippets on Neovim < 0.10.0 and show warning * fix: merge conflict * fix(lsp): dont define diagnostics signs on >= 0.10.0 * fix(lsp): better support for diagnostics icons on Neovim nightly/stable * chore(main): release 10.21.1 (#2873) Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> * fix(harpoon): optimizes harpoon keys (#2877) * feat(dot): add bashls and shellcheck (#2879) --------- Signed-off-by: Jeff Davis Co-authored-by: Folke Lemaitre Co-authored-by: github-actions[bot] Co-authored-by: Gary Murray Co-authored-by: Gary Murray Co-authored-by: Samuel Abreu Co-authored-by: Sergey Kochetkov Co-authored-by: NickSager <121263610+NickSager@users.noreply.github.com> Co-authored-by: Nick Hester Co-authored-by: pr3c0g Co-authored-by: Ricardo Rebelo Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Pablo <52180403+pablos123@users.noreply.github.com> Co-authored-by: tippfehlr Co-authored-by: Frederick Zhang Co-authored-by: Iordanis Petkakis Co-authored-by: Adrian Wilkins Co-authored-by: Binh Duc Tran Co-authored-by: Yi Co-authored-by: Michael Olson <48652773+m0lson84@users.noreply.github.com> Co-authored-by: Luckas Co-authored-by: Aman9das <39594914+Aman9das@users.noreply.github.com> Co-authored-by: Dennis Eriksen <796800+dennisse@users.noreply.github.com> Co-authored-by: mbhutton Co-authored-by: MoetaYuko Co-authored-by: Daniel Mata <100956688+matadaniel@users.noreply.github.com> Co-authored-by: Andreas Gerlach Co-authored-by: Jakub Kozłowicz Co-authored-by: Amaan Qureshi Co-authored-by: Frederik Buchlák <30214087+fbuchlak@users.noreply.github.com> Co-authored-by: André Freitas Co-authored-by: Marc Jakobi Co-authored-by: Alafate Co-authored-by: Christian Kleinbölting Co-authored-by: Peter Benjamin Co-authored-by: Võ Quang Chiến <87252943+2giosangmitom@users.noreply.github.com> Co-authored-by: abeldekat <58370433+abeldekat@users.noreply.github.com> Co-authored-by: Nybkox Co-authored-by: Pedro Cattori Co-authored-by: Wellington Lopes Souza Co-authored-by: Tang-Tang Zhou Co-authored-by: Uthman Mohamed <83053931+uthmanmoh@users.noreply.github.com> Co-authored-by: Uthman Mohamed <83053931+1239uth@users.noreply.github.com> Co-authored-by: Adam Stracener <6558867+NeckBeardPrince@users.noreply.github.com> Co-authored-by: Pete Kazmier Co-authored-by: Marc Jakobi Co-authored-by: Dusty Phillips <86920+dusty-phillips@users.noreply.github.com> Co-authored-by: Jeff Davis Co-authored-by: craempler <74294267+msMatix@users.noreply.github.com> Co-authored-by: Stefan Krüger Co-authored-by: Phúc H. Lê Khắc Co-authored-by: Alexander Arvidsson Co-authored-by: saeedahsan Co-authored-by: Feliche-Demian Netliukh <51330172+Demianeen@users.noreply.github.com> Co-authored-by: Kevin Traver Co-authored-by: ammon134 <113684938+ammon134@users.noreply.github.com> Co-authored-by: Rubin Bhandari --- CHANGELOG.md | 293 ++++++++++++++++++ NEWS.md | 33 ++ README-DE.md.txt => README-DE.md | 0 doc/LazyVim.txt | 3 +- lua/lazyvim/config/autocmds.lua | 29 +- lua/lazyvim/config/init.lua | 43 ++- lua/lazyvim/config/keymaps.lua | 123 ++++---- lua/lazyvim/config/options.lua | 32 +- lua/lazyvim/init.lua | 2 + lua/lazyvim/plugins/coding.lua | 157 +++++++--- lua/lazyvim/plugins/editor.lua | 136 ++++---- lua/lazyvim/plugins/extras/coding/codeium.lua | 2 +- lua/lazyvim/plugins/extras/coding/copilot.lua | 13 +- .../plugins/extras/coding/native_snippets.lua | 64 ++++ lua/lazyvim/plugins/extras/coding/tabnine.lua | 8 +- lua/lazyvim/plugins/extras/coding/yanky.lua | 38 +-- lua/lazyvim/plugins/extras/dap/core.lua | 3 +- lua/lazyvim/plugins/extras/editor/aerial.lua | 9 +- lua/lazyvim/plugins/extras/editor/dial.lua | 171 ++++++++++ .../plugins/extras/editor/harpoon2.lua | 39 +++ lua/lazyvim/plugins/extras/editor/leap.lua | 6 +- .../plugins/extras/editor/mini-diff.lua | 54 ++++ .../plugins/extras/editor/mini-files.lua | 8 +- .../plugins/extras/editor/mini-move.lua | 7 + lua/lazyvim/plugins/extras/editor/navic.lua | 2 +- .../{symbols-outline.lua => outline.lua} | 26 +- .../plugins/extras/editor/trouble-v3.lua | 77 +++++ lua/lazyvim/plugins/extras/lang/ansible.lua | 38 +++ lua/lazyvim/plugins/extras/lang/clangd.lua | 2 +- lua/lazyvim/plugins/extras/lang/cmake.lua | 20 +- lua/lazyvim/plugins/extras/lang/go.lua | 3 +- lua/lazyvim/plugins/extras/lang/haskell.lua | 99 ++++++ lua/lazyvim/plugins/extras/lang/helm.lua | 30 ++ lua/lazyvim/plugins/extras/lang/java.lua | 13 +- lua/lazyvim/plugins/extras/lang/markdown.lua | 2 + lua/lazyvim/plugins/extras/lang/omnisharp.lua | 35 ++- .../plugins/extras/lang/python-semshi.lua | 7 +- lua/lazyvim/plugins/extras/lang/python.lua | 29 +- lua/lazyvim/plugins/extras/lang/rust.lua | 142 ++++----- lua/lazyvim/plugins/extras/lang/scala.lua | 74 +++++ lua/lazyvim/plugins/extras/lang/terraform.lua | 27 +- lua/lazyvim/plugins/extras/lang/tex.lua | 8 - .../plugins/extras/lang/typescript.lua | 16 +- lua/lazyvim/plugins/extras/lang/yaml.lua | 2 +- lua/lazyvim/plugins/extras/lazyrc.lua | 38 +++ lua/lazyvim/plugins/extras/linting/eslint.lua | 8 +- lua/lazyvim/plugins/extras/lsp/none-ls.lua | 8 +- lua/lazyvim/plugins/extras/test/core.lua | 8 +- lua/lazyvim/plugins/extras/ui/edgy.lua | 6 - lua/lazyvim/plugins/extras/util/dot.lua | 41 ++- lua/lazyvim/plugins/extras/util/gitui.lua | 23 ++ .../plugins/extras/util/mini-hipatterns.lua | 12 + lua/lazyvim/plugins/extras/util/project.lua | 2 +- lua/lazyvim/plugins/formatting.lua | 20 +- lua/lazyvim/plugins/linting.lua | 10 +- lua/lazyvim/plugins/lsp/init.lua | 75 +++-- lua/lazyvim/plugins/lsp/keymaps.lua | 10 +- lua/lazyvim/plugins/treesitter.lua | 16 +- lua/lazyvim/plugins/ui.lua | 57 ++-- lua/lazyvim/plugins/xtras.lua | 14 +- lua/lazyvim/types.lua | 4 + lua/lazyvim/util/extras.lua | 13 +- lua/lazyvim/util/format.lua | 12 +- lua/lazyvim/util/init.lua | 10 +- lua/lazyvim/util/json.lua | 12 +- lua/lazyvim/util/lazygit.lua | 143 +++++++++ lua/lazyvim/util/lsp.lua | 17 +- lua/lazyvim/util/lualine.lua | 52 +++- lua/lazyvim/util/news.lua | 11 +- lua/lazyvim/util/plugin.lua | 14 +- lua/lazyvim/util/root.lua | 35 ++- lua/lazyvim/util/telescope.lua | 36 ++- lua/lazyvim/util/terminal.lua | 32 ++ lua/lazyvim/util/toggle.lua | 22 +- lua/lazyvim/util/ui.lua | 32 +- 75 files changed, 2105 insertions(+), 613 deletions(-) rename README-DE.md.txt => README-DE.md (100%) create mode 100644 lua/lazyvim/plugins/extras/coding/native_snippets.lua create mode 100644 lua/lazyvim/plugins/extras/editor/dial.lua create mode 100644 lua/lazyvim/plugins/extras/editor/harpoon2.lua create mode 100644 lua/lazyvim/plugins/extras/editor/mini-diff.lua create mode 100644 lua/lazyvim/plugins/extras/editor/mini-move.lua rename lua/lazyvim/plugins/extras/editor/{symbols-outline.lua => outline.lua} (65%) create mode 100644 lua/lazyvim/plugins/extras/editor/trouble-v3.lua create mode 100644 lua/lazyvim/plugins/extras/lang/ansible.lua create mode 100644 lua/lazyvim/plugins/extras/lang/haskell.lua create mode 100644 lua/lazyvim/plugins/extras/lang/helm.lua create mode 100644 lua/lazyvim/plugins/extras/lang/scala.lua create mode 100644 lua/lazyvim/plugins/extras/lazyrc.lua create mode 100644 lua/lazyvim/plugins/extras/util/gitui.lua create mode 100644 lua/lazyvim/types.lua create mode 100644 lua/lazyvim/util/lazygit.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index 318c543d..4e3109d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,298 @@ # Changelog +## [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) diff --git a/NEWS.md b/NEWS.md index 50b72da3..1ca0ea62 100644 --- a/NEWS.md +++ b/NEWS.md @@ -2,6 +2,39 @@ ## 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 100% rename from README-DE.md.txt rename to README-DE.md diff --git a/doc/LazyVim.txt b/doc/LazyVim.txt index 2d805f3b..a88f4539 100644 --- a/doc/LazyVim.txt +++ b/doc/LazyVim.txt @@ -1,4 +1,4 @@ -*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2023 November 30 +*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2024 March 29 ============================================================================== 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..48faab3d 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,7 +57,6 @@ vim.api.nvim_create_autocmd("FileType", { "PlenaryTestPopup", "help", "lspinfo", - "man", "notify", "qf", "query", @@ -71,6 +74,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 +93,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 a296ef56..cea25f8b 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.8.2" -- 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 = 3, 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,23 @@ 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" }) end, }) - Util.track("colorscheme") - Util.try(function() + LazyVim.track("colorscheme") + LazyVim.try(function() if type(M.colorscheme) == "function" then M.colorscheme() else @@ -198,11 +204,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 +222,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 +233,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 +263,19 @@ 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() + LazyVim.plugin.setup() M.json.load() end diff --git a/lua/lazyvim/config/keymaps.lua b/lua/lazyvim/config/keymaps.lua index f7fe57d6..49f693c9 100644 --- a/lua/lazyvim/config/keymaps.lua +++ b/lua/lazyvim/config/keymaps.lua @@ -1,9 +1,8 @@ -- This file is automatically loaded by lazyvim.config.init -local Util = require("lazyvim.util") -- DO NOT USE THIS IN YOU 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 }) @@ -12,35 +11,35 @@ map({ "n", "x" }, "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true map({ "n", "x" }, "", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true }) -- Move to window using the hjkl keys -map("n", "", "h", { desc = "Go to left window", remap = true }) -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" }) -- 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 +47,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 +64,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" }) @@ -83,12 +82,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,56 +109,62 @@ 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" }) +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() Util.toggle.inlay_hints() end, { desc = "Toggle Inlay Hints" }) + 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", "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" }) -- 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" }) -- 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 }) -- tabs map("n", "l", "tablast", { desc = "Last Tab" }) diff --git a/lua/lazyvim/config/options.lua b/lua/lazyvim/config/options.lua index 3c9686b1..c20adcec 100644 --- a/lua/lazyvim/config/options.lua +++ b/lua/lazyvim/config/options.lua @@ -12,12 +12,31 @@ 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 + +-- Optionally setup the terminal to use +-- This sets `vim.o.shell` and does some additional configuration for: +-- * pwsh +-- * powershell +-- LazyVim.terminal.setup("pwsh") + local opt = vim.opt opt.autowrite = true -- Enable auto write -opt.clipboard = "unnamedplus" -- Sync with system clipboard + +if not vim.env.SSH_TTY then + -- only set clipboard if not in ssh, to make sure the OSC 52 + -- integration works automatically. Requires Neovim >= 0.10.0 + opt.clipboard = "unnamedplus" -- Sync with system clipboard +end + 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 @@ -49,7 +68,9 @@ opt.splitkeep = "screen" opt.splitright = true -- Put new windows right of current opt.tabstop = 2 -- Number of spaces tabs count for opt.termguicolors = true -- True color support -opt.timeoutlen = 300 +if not vim.g.vscode then + opt.timeoutlen = 300 -- Lower than default (1000) to quickly trigger which-key +end opt.undofile = true opt.undolevels = 10000 opt.updatetime = 200 -- Save swap file and trigger CursorHold @@ -60,7 +81,6 @@ opt.wrap = false -- Disable line wrap opt.fillchars = { foldopen = "", foldclose = "", - -- fold = "⸱", fold = " ", foldsep = " ", diff = "╱", @@ -73,16 +93,18 @@ 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()]] + vim.opt.foldtext = "v:lua.require'lazyvim.util'.ui.foldtext()" 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()" + vim.opt.foldtext = "" + vim.opt.fillchars = "fold: " else vim.opt.foldmethod = "indent" 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..0823c12e 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 }), @@ -73,7 +48,6 @@ return { }), sources = cmp.config.sources({ { name = "nvim_lsp" }, - { name = "luasnip" }, { name = "path" }, }, { { name = "buffer" }, @@ -95,15 +69,74 @@ 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 cmp = require("cmp") + local Kind = cmp.lsp.CompletionItemKind + cmp.setup(opts) + cmp.event:on("confirm_done", function(event) + if not vim.tbl_contains(opts.auto_brackets or {}, vim.bo.filetype) then + return + end + local entry = event.entry + local item = entry:get_completion_item() + if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) then + local keys = vim.api.nvim_replace_termcodes("()", false, false, true) + vim.api.nvim_feedkeys(keys, "i", true) + end + end) end, }, + -- snippets + { + "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", + }, + -- 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 pairs { "echasnovski/mini.pairs", @@ -113,15 +146,14 @@ return { { "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", + desc = "Toggle Auto Pairs", }, }, }, @@ -137,12 +169,12 @@ return { 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.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) @@ -203,13 +235,33 @@ return { f = ai.gen_spec.treesitter({ a = "@function.outer", i = "@function.inner" }, {}), c = ai.gen_spec.treesitter({ a = "@class.outer", i = "@class.inner" }, {}), t = { "<([%p%w]-)%f[^<%w][^<>]->.-", "^<.->().*()$" }, + 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]", + }, + "^().*()$", + }, + g = function() -- Whole buffer, similar to `gg` and 'G' motion + local from = { line = 1, col = 1 } + local to = { + line = vim.fn.line("$"), + col = math.max(vim.fn.getline("$"):len(), 1), + } + return { from = from, to = to } + end, + 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() + LazyVim.on_load("which-key.nvim", function() ---@type table local i = { [" "] = "Whitespace", @@ -229,10 +281,15 @@ return { a = "Argument", b = "Balanced ), ], }", c = "Class", + d = "Digit(s)", + e = "Word in CamelCase & snake_case", f = "Function", + g = "Entire file", 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 diff --git a/lua/lazyvim/plugins/editor.lua b/lua/lazyvim/plugins/editor.lua index b97826e7..d45367f4 100644 --- a/lua/lazyvim/plugins/editor.lua +++ b/lua/lazyvim/plugins/editor.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { -- file explorer @@ -11,32 +9,32 @@ 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 (cwd)", 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() @@ -44,7 +42,7 @@ return { end, init = function() if vim.fn.argc(-1) == 1 then - local stat = vim.loop.fs_stat(vim.fn.argv(0)) + local stat = vim.uv.fs_stat(vim.fn.argv(0)) if stat and stat.type == "directory" then require("neo-tree") end @@ -61,6 +59,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 = { @@ -74,7 +86,7 @@ return { }, 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") @@ -103,7 +115,7 @@ return { 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)" }, }, }, @@ -118,10 +130,11 @@ return { dependencies = { { "nvim-telescope/telescope-fzf-native.nvim", - build = "make", - enabled = vim.fn.executable("make") == 1, + build = vim.fn.executable("make") == 1 and "make" + or "cmake -S. -Bbuild -DCMAKE_BUILD_TYPE=Release && cmake --build build --config Release && cmake --install build --prefix build", + enabled = vim.fn.executable("make") == 1 or vim.fn.executable("cmake") == 1, config = function() - Util.on_load("telescope.nvim", function() + LazyVim.on_load("telescope.nvim", function() require("telescope").load_extension("fzf") end) end, @@ -133,41 +146,45 @@ return { "Telescope buffers sort_mru=true sort_lastused=true", desc = "Switch Buffer", }, - { "/", Util.telescope("live_grep"), desc = "Grep (root dir)" }, - { ":", "Telescope command_history", desc = "Command History" }, - { "", Util.telescope("files"), desc = "Find Files (root dir)" }, + { "/", LazyVim.telescope("live_grep"), desc = "Grep (root dir)" }, + { ":", "Telescope command_history", desc = "Command History" }, + { "", LazyVim.telescope("files"), desc = "Find Files (root dir)" }, + { "/", LazyVim.telescope("live_grep"), desc = "Grep (Root Dir)" }, + { ":", "Telescope command_history", desc = "Command History" }, + { "", 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)" }, - { "fr", "Telescope oldfiles", desc = "Recent" }, - { "fR", Util.telescope("oldfiles", { cwd = vim.loop.cwd() }), desc = "Recent (cwd)" }, + { "fb", "Telescope buffers sort_mru=true sort_lastused=true", desc = "Buffers" }, + { "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", 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)" }, - { "sh", "Telescope help_tags", desc = "Help Pages" }, - { "sH", "Telescope highlights", desc = "Search Highlight Groups" }, - { "sk", "Telescope keymaps", desc = "Key Maps" }, - { "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" }, + { '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", 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" }, + { "sk", "Telescope keymaps", desc = "Key Maps" }, + { "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", 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() @@ -199,12 +216,12 @@ return { 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 { @@ -268,7 +285,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) @@ -306,6 +323,7 @@ return { mode = { "n", "v" }, ["g"] = { name = "+goto" }, ["gs"] = { name = "+surround" }, + ["z"] = { name = "+fold" }, ["]"] = { name = "+next" }, ["["] = { name = "+prev" }, [""] = { name = "+tabs" }, @@ -358,7 +376,7 @@ return { 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 ~") @@ -457,7 +475,7 @@ return { end end end, - desc = "Previous trouble/quickfix item", + desc = "Previous Trouble/Quickfix Item", }, { "]q", @@ -471,7 +489,7 @@ return { end end end, - desc = "Next trouble/quickfix item", + desc = "Next Trouble/Quickfix Item", }, }, }, @@ -485,12 +503,12 @@ 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)" }, - { "st", "TodoTelescope", desc = "Todo" }, - { "sT", "TodoTelescope keywords=TODO,FIX,FIXME", desc = "Todo/Fix/Fixme" }, + { "]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)" }, + { "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.lua b/lua/lazyvim/plugins/extras/coding/copilot.lua index 279a974f..86c54a6e 100644 --- a/lua/lazyvim/plugins/extras/coding/copilot.lua +++ b/lua/lazyvim/plugins/extras/coding/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/native_snippets.lua b/lua/lazyvim/plugins/extras/coding/native_snippets.lua new file mode 100644 index 00000000..74b70784 --- /dev/null +++ b/lua/lazyvim/plugins/extras/coding/native_snippets.lua @@ -0,0 +1,64 @@ +if not vim.snippet then + LazyVim.warn("Native snippets are only supported on Neovim >= 0.10.0") + return {} +end + +return { + desc = "Use native snippets instead of LuaSnip. Only works on Neovim >= 0.10!", + { + "L3MON4D3/LuaSnip", + enabled = false, + }, + { + "nvim-cmp", + opts = { + snippet = { + expand = function(args) + vim.snippet.expand(args.body) + end, + }, + }, + keys = { + { + "", + function() + if vim.snippet.jumpable(1) then + vim.schedule(function() + vim.snippet.jump(1) + end) + return + end + return "" + end, + expr = true, + silent = true, + mode = "i", + }, + { + "", + function() + vim.schedule(function() + vim.snippet.jump(1) + end) + end, + silent = true, + mode = "s", + }, + { + "", + function() + if vim.snippet.jumpable(-1) then + vim.schedule(function() + vim.snippet.jump(-1) + end) + return + end + return "" + end, + expr = true, + silent = true, + mode = { "i", "s" }, + }, + }, + }, +} 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..e3549643 100644 --- a/lua/lazyvim/plugins/extras/coding/yanky.lua +++ b/lua/lazyvim/plugins/extras/coding/yanky.lua @@ -2,31 +2,31 @@ return { -- better yank/paste { "gbprod/yanky.nvim", - dependencies = { { "kkharji/sqlite.lua", enabled = not jit.os:find("Windows") } }, + dependencies = not LazyVim.is_win() and { "kkharji/sqlite.lua" } or {}, opts = { highlight = { timer = 250 }, - ring = { storage = jit.os:find("Windows") and "shada" or "sqlite" }, + ring = { storage = LazyVim.is_win() and "shada" or "sqlite" }, }, keys = { -- stylua: ignore { "p", function() require("telescope").extensions.yank_history.yank_history({ }) end, desc = "Open Yank History" }, - { "y", "(YankyYank)", mode = { "n", "x" }, desc = "Yank text" }, - { "p", "(YankyPutAfter)", mode = { "n", "x" }, desc = "Put yanked text after cursor" }, - { "P", "(YankyPutBefore)", mode = { "n", "x" }, desc = "Put yanked text before cursor" }, - { "gp", "(YankyGPutAfter)", mode = { "n", "x" }, desc = "Put yanked text after selection" }, - { "gP", "(YankyGPutBefore)", mode = { "n", "x" }, desc = "Put yanked text before selection" }, - { "[y", "(YankyCycleForward)", desc = "Cycle forward through yank history" }, - { "]y", "(YankyCycleBackward)", desc = "Cycle backward through yank history" }, - { "]p", "(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" }, - { "[p", "(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" }, - { "]P", "(YankyPutIndentAfterLinewise)", desc = "Put indented after cursor (linewise)" }, - { "[P", "(YankyPutIndentBeforeLinewise)", desc = "Put indented before cursor (linewise)" }, - { ">p", "(YankyPutIndentAfterShiftRight)", desc = "Put and indent right" }, - { "(YankyPutIndentAfterShiftLeft)", desc = "Put and indent left" }, - { ">P", "(YankyPutIndentBeforeShiftRight)", desc = "Put before and indent right" }, - { "(YankyPutIndentBeforeShiftLeft)", desc = "Put before and indent left" }, - { "=p", "(YankyPutAfterFilter)", desc = "Put after applying a filter" }, - { "=P", "(YankyPutBeforeFilter)", desc = "Put before applying a filter" }, + { "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..7e370629 100644 --- a/lua/lazyvim/plugins/extras/dap/core.lua +++ b/lua/lazyvim/plugins/extras/dap/core.lua @@ -18,6 +18,7 @@ return { -- 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" }, @@ -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" }, diff --git a/lua/lazyvim/plugins/extras/editor/aerial.lua b/lua/lazyvim/plugins/extras/editor/aerial.lua index 440c9fda..15a209ba 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", @@ -55,7 +54,7 @@ return { "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 +72,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..20ebd7ff --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/dial.lua @@ -0,0 +1,171 @@ +local M = {} +---@type table> +M.dials_by_ft = {} + +---@param increment boolean +---@param g? boolean +function M.dial(increment, g) + local is_visual = vim.fn.mode(true):sub(1, 1) == "v" + 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", + -- 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..666f7d58 --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/harpoon2.lua @@ -0,0 +1,39 @@ +return { + "ThePrimeagen/harpoon", + branch = "harpoon2", + opts = { + menu = { + width = vim.api.nvim_win_get_width(0) - 4, + }, + }, + keys = function() + local keys = { + { + "H", + function() + require("harpoon"):list():append() + 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/leap.lua b/lua/lazyvim/plugins/extras/editor/leap.lua index ab422abf..19bfd4a8 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") 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 65% rename from lua/lazyvim/plugins/extras/editor/symbols-outline.lua rename to lua/lazyvim/plugins/extras/editor/outline.lua index 32cdd17f..c571d789 100644 --- a/lua/lazyvim/plugins/extras/editor/symbols-outline.lua +++ b/lua/lazyvim/plugins/extras/editor/outline.lua @@ -1,13 +1,11 @@ -local Util = require("lazyvim.util") - return { { - "simrat39/symbols-outline.nvim", - keys = { { "cs", "SymbolsOutline", desc = "Symbols Outline" } }, - cmd = "SymbolsOutline", + "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 +35,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/trouble-v3.lua b/lua/lazyvim/plugins/extras/editor/trouble-v3.lua new file mode 100644 index 00000000..98e2db4b --- /dev/null +++ b/lua/lazyvim/plugins/extras/editor/trouble-v3.lua @@ -0,0 +1,77 @@ +local Config = require("lazyvim.config") + +for _, other in ipairs({ "aerial", "outline" }) do + local extra = "lazyvim.plugins.extras.editor." .. other + if vim.tbl_contains(Config.json.data.extras, extra) then + other = other:gsub("^%l", string.upper) + LazyVim.error({ + "**Trouble v3** includes support for document symbols.", + ("You currently have the **%s** extra enabled."):format(other), + "Please disable it in your config.", + }) + end +end + +return { + { + "folke/trouble.nvim", + branch = "dev", + keys = { + { "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)" }, + }, + }, + + -- lualine integration + { + "nvim-lualine/lualine.nvim", + optional = true, + opts = function(_, opts) + local trouble = require("trouble") + if not trouble.statusline then + LazyVim.error("You have enabled the **trouble-v3** extra,\nbut still need to update it with `:Lazy`") + return + end + + local symbols = trouble.statusline({ + mode = "symbols", + groups = {}, + title = false, + filter = { range = true }, + format = "{kind_icon}{symbol.name:Normal}", + }) + table.insert(opts.sections.lualine_c, { + symbols.get, + cond = symbols.has, + }) + end, + }, + + { + "folke/edgy.nvim", + optional = true, + opts = function(_, opts) + 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 + 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..301fa494 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/ansible.lua @@ -0,0 +1,38 @@ +return { + { + "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", + keys = { + { + "tr", + function() + require("ansible").run() + end, + silent = true, + }, + }, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/clangd.lua b/lua/lazyvim/plugins/extras/lang/clangd.lua index 08017700..7705360d 100644 --- a/lua/lazyvim/plugins/extras/lang/clangd.lua +++ b/lua/lazyvim/plugins/extras/lang/clangd.lua @@ -85,7 +85,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, diff --git a/lua/lazyvim/plugins/extras/lang/cmake.lua b/lua/lazyvim/plugins/extras/lang/cmake.lua index e95dbfdd..401669a3 100644 --- a/lua/lazyvim/plugins/extras/lang/cmake.lua +++ b/lua/lazyvim/plugins/extras/lang/cmake.lua @@ -43,7 +43,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/go.lua b/lua/lazyvim/plugins/extras/lang/go.lua index aaad0128..036eab6f 100644 --- a/lua/lazyvim/plugins/extras/lang/go.lua +++ b/lua/lazyvim/plugins/extras/lang/go.lua @@ -61,7 +61,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 +148,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..75b0805b 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" } @@ -104,17 +102,18 @@ return { -- These depend on nvim-dap, but can additionally be disabled by setting false here. dap = { hotcodereplace = "auto", config_overrides = {} }, + dap_main = {}, test = true, } end, config = function() - local opts = Util.opts("nvim-jdtls") or {} + local opts = LazyVim.opts("nvim-jdtls") or {} -- Find the extra bundles that should be passed on the jdtls command-line -- if nvim-dap is enabled with java debug/test. local mason_registry = require("mason-registry") local bundles = {} ---@type string[] - if opts.dap and Util.has("nvim-dap") and mason_registry.is_installed("java-debug-adapter") then + 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 = { @@ -146,7 +145,7 @@ return { bundles = bundles, }, -- 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 +194,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/markdown.lua b/lua/lazyvim/plugins/extras/lang/markdown.lua index 5aa9dc33..e56e6de2 100644 --- a/lua/lazyvim/plugins/extras/lang/markdown.lua +++ b/lua/lazyvim/plugins/extras/lang/markdown.lua @@ -69,6 +69,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..d4bd698b 100644 --- a/lua/lazyvim/plugins/extras/lang/omnisharp.lua +++ b/lua/lazyvim/plugins/extras/lang/omnisharp.lua @@ -35,8 +35,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 +66,34 @@ 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, + }, } diff --git a/lua/lazyvim/plugins/extras/lang/python-semshi.lua b/lua/lazyvim/plugins/extras/lang/python-semshi.lua index e4e32c10..2e6df6f9 100644 --- a/lua/lazyvim/plugins/extras/lang/python-semshi.lua +++ b/lua/lazyvim/plugins/extras/lang/python-semshi.lua @@ -16,15 +16,16 @@ return { callback = function() -- Only add style, inherit or link to the LSP's colors vim.cmd([[ - highlight! semshiGlobal gui=italic + highlight! link semshiGlobal @none 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 semshiUnresolved @none highlight! link semshiFree @none + highlight! link semshiAttribute @none + highlight! link semshiParameterUnused @none ]]) end, }) diff --git a/lua/lazyvim/plugins/extras/lang/python.lua b/lua/lazyvim/plugins/extras/lang/python.lua index cc9bc52e..bc1e28cf 100644 --- a/lua/lazyvim/plugins/extras/lang/python.lua +++ b/lua/lazyvim/plugins/extras/lang/python.lua @@ -1,3 +1,11 @@ +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" +end + +local lsp = vim.g.lazyvim_python_lsp or "pyright" + return { { "nvim-treesitter/nvim-treesitter", @@ -11,7 +19,15 @@ return { "neovim/nvim-lspconfig", opts = { servers = { - pyright = {}, + pyright = { + enabled = lsp == "pyright", + }, + basedpyright = { + enabled = lsp == "basedpyright", + }, + [lsp] = { + enabled = true, + }, ruff_lsp = { keys = { { @@ -32,7 +48,7 @@ return { }, setup = { ruff_lsp = function() - require("lazyvim.util").lsp.on_attach(function(client, _) + LazyVim.lsp.on_attach(function(client, _) if client.name == "ruff_lsp" then -- Disable hover in favor of Pyright client.server_capabilities.hoverProvider = false @@ -78,7 +94,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, { @@ -92,4 +108,11 @@ return { end, keys = { { "cv", ":VenvSelect", desc = "Select VirtualEnv" } }, }, + { + "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/rust.lua b/lua/lazyvim/plugins/extras/lang/rust.lua index 1e6e0594..613bc0f7 100644 --- a/lua/lazyvim/plugins/extras/lang/rust.lua +++ b/lua/lazyvim/plugins/extras/lang/rust.lua @@ -16,10 +16,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 +25,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 +35,54 @@ 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) - end - return { - dap = { - adapter = adapter, + "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, + 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" }, + }, + }, + }, }, - 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, - }, - } + }, + }, + config = function(_, opts) + vim.g.rustaceanvim = vim.tbl_deep_extend("keep", vim.g.rustaceanvim or {}, opts or {}) end, - config = function() end, }, -- Correctly setup lspconfig for Rust 🚀 @@ -90,37 +90,7 @@ 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" }, - }, - }, - }, - }, - }, + rust_analyzer = {}, taplo = { keys = { { @@ -138,9 +108,7 @@ 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 })) + rust_analyzer = function() return true end, }, @@ -150,13 +118,11 @@ return { { "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..eca2db45 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lang/scala.lua @@ -0,0 +1,74 @@ +-- NOTE: This setup does not define any lsp or dap specific key bindings +-- It is recommended that the LazyVim extras dap-core is imported "lazyvim.plugins.extras.dap.core" +-- If you like you can setup your own key bindings. +-- For minimalistic setup have a look at https://github.com/scalameta/nvim-metals/discussions/39 +return { + { + "hrsh7th/nvim-cmp", + requires = { + { "hrsh7th/cmp-nvim-lsp" }, + { "hrsh7th/cmp-vsnip" }, + { "hrsh7th/vim-vsnip" }, + }, + }, + { + "scalameta/nvim-metals", + dependencies = { + "nvim-lua/plenary.nvim", + "mfussenegger/nvim-dap", + }, + ft = { "scala", "sbt", "java" }, + init = function() + local metals_config = require("metals").bare_config() + metals_config.init_options.statusBarProvider = "on" + metals_config.settings = { + showImplicitArguments = true, + excludedPackages = { "akka.actor.typed.javadsl", "com.github.swagger.akka.javadsl" }, + } + metals_config.capabilities = require("cmp_nvim_lsp").default_capabilities() + metals_config.on_attach = function(client, bufnr) + require("metals").setup_dap() + end + + local nvim_metals_group = vim.api.nvim_create_augroup("nvim-metals", { clear = true }) + vim.api.nvim_create_autocmd("FileType", { + -- NOTE: You may or may not want java included here. You will need it if you + -- want basic Java support but it may also conflict if you are using + -- something like nvim-jdtls which also works on a java filetype autocmd. + pattern = { "scala", "sbt", "java" }, + callback = function() + require("metals").initialize_or_attach(metals_config) + end, + group = nvim_metals_group, + }) + + -- 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, + }, + { + "nvim-treesitter/nvim-treesitter", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed, { "scala" }) + end, + }, +} diff --git a/lua/lazyvim/plugins/extras/lang/terraform.lua b/lua/lazyvim/plugins/extras/lang/terraform.lua index ea7bd5de..b199b4f1 100644 --- a/lua/lazyvim/plugins/extras/lang/terraform.lua +++ b/lua/lazyvim/plugins/extras/lang/terraform.lua @@ -1,9 +1,3 @@ -vim.api.nvim_create_autocmd("FileType", { - pattern = { "hcl", "terraform" }, - desc = "terraform/hcl commentstring configuration", - command = "setlocal commentstring=#\\ %s", -}) - return { { "nvim-treesitter/nvim-treesitter", @@ -56,4 +50,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..f8dacfb4 100644 --- a/lua/lazyvim/plugins/extras/lang/tex.lua +++ b/lua/lazyvim/plugins/extras/lang/tex.lua @@ -28,14 +28,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/typescript.lua b/lua/lazyvim/plugins/extras/lang/typescript.lua index 4f53ae8c..4bb280d6 100644 --- a/lua/lazyvim/plugins/extras/lang/typescript.lua +++ b/lua/lazyvim/plugins/extras/lang/typescript.lua @@ -46,21 +46,8 @@ return { desc = "Remove Unused Imports", }, }, + ---@diagnostic disable-next-line: missing-fields settings = { - typescript = { - format = { - indentSize = vim.o.shiftwidth, - convertTabsToSpaces = vim.o.expandtab, - tabSize = vim.o.tabstop, - }, - }, - javascript = { - format = { - indentSize = vim.o.shiftwidth, - convertTabsToSpaces = vim.o.expandtab, - tabSize = vim.o.tabstop, - }, - }, completions = { completeFunctionCalls = true, }, @@ -69,6 +56,7 @@ return { }, }, }, + { "mfussenegger/nvim-dap", optional = true, diff --git a/lua/lazyvim/plugins/extras/lang/yaml.lua b/lua/lazyvim/plugins/extras/lang/yaml.lua index 5afe1b83..9fd88a3b 100644 --- a/lua/lazyvim/plugins/extras/lang/yaml.lua +++ b/lua/lazyvim/plugins/extras/lang/yaml.lua @@ -64,7 +64,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/lazyrc.lua b/lua/lazyvim/plugins/extras/lazyrc.lua new file mode 100644 index 00000000..24d06b51 --- /dev/null +++ b/lua/lazyvim/plugins/extras/lazyrc.lua @@ -0,0 +1,38 @@ +--[[ +Enable project-specific plugin specs. + +File .lazy.lua: + is read when present in the current working directory + should return a plugin spec + has to be manually trusted for each instance of the file + +This extra should be the last plugin spec added to lazy.nvim + +See: + :h 'exrc' + :h :trust +--]] +local filepath = vim.fn.fnamemodify(".lazy.lua", ":p") +local file = vim.secure.read(filepath) +if not file then + return {} +end + +vim.api.nvim_create_autocmd("User", { + pattern = "VeryLazy", + once = true, + callback = function() + local Config = require("lazy.core.config") + local lazyrc_idx = LazyVim.plugin.extra_idx("lazyrc") + + if lazyrc_idx and lazyrc_idx ~= #Config.spec.modules then + LazyVim.warn({ + "The `lazyrc` extra must be the last plugin spec added to **lazy.nvim**. ", + "", + "Add `{ import = 'lazyvim.plugins.extras.lazyrc' }` to file `config.lazy`. ", + "Do not use the `LazyExtras` command. ", + }, { title = "LazyVim", once = true }) + end + end, +}) +return loadstring(file)() 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/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..e7dbd792 100644 --- a/lua/lazyvim/plugins/extras/test/core.lua +++ b/lua/lazyvim/plugins/extras/test/core.lua @@ -10,6 +10,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 +27,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 +47,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 +109,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..1a9c5e12 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", diff --git a/lua/lazyvim/plugins/extras/util/dot.lua b/lua/lazyvim/plugins/extras/util/dot.lua index c25e0f6c..cf5c048f 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 { - "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" }, + "neovim/nvim-lspconfig", + opts = { + servers = { + bashls = {}, + }, + }, + }, + { + "williamboman/mason.nvim", + opts = function(_, opts) + vim.list_extend(opts.ensure_installed or {}, { + "shfmt", + "shellcheck", }) - require("nvim-treesitter.parsers").get_parser_configs().hypr = { - install_info = { - url = "https://github.com/luckasRanarison/tree-sitter-hypr", - files = { "src/parser.c" }, - branch = "master", - }, - filetype = "hypr", - } end, }, - -- add some stuff to treesitter { "nvim-treesitter/nvim-treesitter", @@ -48,11 +40,16 @@ return { [".*/waybar/config"] = "jsonc", [".*/mako/config"] = "dosini", [".*/kitty/*.conf"] = "bash", + [".*/hypr/.*%.conf"] = "hyprlang", }, }) 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..588cdbfd --- /dev/null +++ b/lua/lazyvim/plugins/extras/util/gitui.lua @@ -0,0 +1,23 @@ +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)" } + }, + 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..66e34c30 100644 --- a/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua +++ b/lua/lazyvim/plugins/extras/util/mini-hipatterns.lua @@ -19,6 +19,18 @@ M.plugin = { }, 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, 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/formatting.lua b/lua/lazyvim/plugins/formatting.lua index eb2dd1a8..718cb0f9 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,8 +48,8 @@ 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, @@ -56,7 +57,7 @@ return { 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 })) + require("conform").format(LazyVim.merge({}, opts.format, { bufnr = buf })) end, sources = function(buf) local ret = require("conform").list_formatters(buf) @@ -71,7 +72,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 +85,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 3b60d14b..c2a74ef5 100644 --- a/lua/lazyvim/plugins/lsp/init.lua +++ b/lua/lazyvim/plugins/lsp/init.lua @@ -1,5 +1,3 @@ -local Util = require("lazyvim.util") - return { -- lspconfig { @@ -14,6 +12,7 @@ return { ---@class PluginLspOpts opts = { -- options for vim.diagnostic.config() + ---@type vim.diagnostic.Opts diagnostics = { underline = true, update_in_insert = false, @@ -26,6 +25,14 @@ return { -- 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, + }, + }, }, -- 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 @@ -33,6 +40,12 @@ return { inlay_hints = { enabled = false, }, + -- 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, + }, -- add any global capabilities here capabilities = {}, -- options for vim.lsp.buf.format @@ -56,6 +69,9 @@ return { workspace = { checkThirdParty = false, }, + codeLens = { + enable = true, + }, completion = { callSnippet = "Replace", }, @@ -78,47 +94,58 @@ return { }, ---@param opts PluginLspOpts config = function(_, opts) - if Util.has("neoconf.nvim") then + if LazyVim.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"] vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx) + ---@diagnostic disable-next-line: no-unknown 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 client = vim.lsp.get_client_by_id(ctx.client_id) local buffer = vim.api.nvim_get_current_buf() require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) return ret end - -- diagnostics - for name, icon in pairs(require("lazyvim.config").icons.diagnostics) do - name = "DiagnosticSign" .. name - vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" }) + -- diagnostics signs + if vim.fn.has("nvim-0.10.0") == 0 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 + -- inlay hints if opts.inlay_hints.enabled then - Util.lsp.on_attach(function(client, buffer) + LazyVim.lsp.on_attach(function(client, buffer) if client.supports_method("textDocument/inlayHint") then - Util.toggle.inlay_hints(buffer, true) + LazyVim.toggle.inlay_hints(buffer, true) + end + end) + end + + -- code lens + if opts.codelens.enabled and vim.lsp.codelens then + LazyVim.lsp.on_attach(function(client, buffer) + if client.supports_method("textDocument/codeLens") then + vim.lsp.codelens.refresh() + --- autocmd BufEnter,CursorHold,InsertLeave lua vim.lsp.codelens.refresh() + vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, { + buffer = buffer, + callback = vim.lsp.codelens.refresh, + }) end end) end @@ -178,7 +205,7 @@ return { -- 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 + elseif server_opts.enabled ~= false then ensure_installed[#ensure_installed + 1] = server end end @@ -188,10 +215,10 @@ return { mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } }) end - if Util.lsp.get_config("denols") and Util.lsp.get_config("tsserver") then + if LazyVim.lsp.get_config("denols") and LazyVim.lsp.get_config("tsserver") then local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc") - Util.lsp.disable("tsserver", is_deno) - Util.lsp.disable("denols", function(root_dir) + LazyVim.lsp.disable("tsserver", is_deno) + LazyVim.lsp.disable("denols", function(root_dir) return not is_deno(root_dir) end) end diff --git a/lua/lazyvim/plugins/lsp/keymaps.lua b/lua/lazyvim/plugins/lsp/keymaps.lua index 10e5d86f..0f5aecb7 100644 --- a/lua/lazyvim/plugins/lsp/keymaps.lua +++ b/lua/lazyvim/plugins/lsp/keymaps.lua @@ -23,6 +23,8 @@ 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" }, { "cA", function() @@ -39,7 +41,7 @@ function M.get() has = "codeAction", } } - if require("lazyvim.util").has("inc-rename.nvim") then + if LazyVim.has("inc-rename.nvim") then M._keys[#M._keys + 1] = { "cr", function() @@ -59,7 +61,7 @@ end ---@param method string function M.has(buffer, method) method = method:find("/") and method or "textDocument/" .. method - local clients = require("lazyvim.util").lsp.get_clients({ bufnr = buffer }) + local clients = LazyVim.lsp.get_clients({ bufnr = buffer }) for _, client in ipairs(clients) do if client.supports_method(method) then return true @@ -75,8 +77,8 @@ function M.resolve(buffer) 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) diff --git a/lua/lazyvim/plugins/treesitter.lua b/lua/lazyvim/plugins/treesitter.lua index e66725c0..108582ff 100644 --- a/lua/lazyvim/plugins/treesitter.lua +++ b/lua/lazyvim/plugins/treesitter.lua @@ -10,8 +10,8 @@ return { 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") @@ -45,8 +45,8 @@ return { }, 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 +75,7 @@ return { "typescript", "vim", "vimdoc", + "xml", "yaml", }, incremental_selection = { @@ -123,13 +124,12 @@ return { { "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" }) + if LazyVim.inject.get_upvalue(tsc.toggle, "enabled") then + LazyVim.info("Enabled Treesitter Context", { title = "Option" }) else - Util.warn("Disabled Treesitter Context", { title = "Option" }) + LazyVim.warn("Disabled Treesitter Context", { title = "Option" }) end end, desc = "Toggle Treesitter Context", diff --git a/lua/lazyvim/plugins/ui.lua b/lua/lazyvim/plugins/ui.lua index 50efb153..47fb4280 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,15 +58,15 @@ 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" }, }, opts = { options = { @@ -140,7 +139,7 @@ return { lualine_b = { "branch" }, lualine_c = { - Util.lualine.root_dir(), + LazyVim.lualine.root_dir(), { "diagnostics", symbols = { @@ -151,31 +150,31 @@ 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 = LazyVim.ui.fg("Statement"), }, -- stylua: ignore { function() return require("noice").api.status.mode.get() end, cond = function() return package.loaded["noice"] and require("noice").api.status.mode.has() end, - color = Util.ui.fg("Constant"), + color = LazyVim.ui.fg("Constant"), }, -- stylua: ignore { function() return " " .. require("dap").status() end, cond = function () return package.loaded["dap"] and require("dap").status() ~= "" end, - color = Util.ui.fg("Debug"), + color = LazyVim.ui.fg("Debug"), }, { require("lazy.status").updates, cond = require("lazy.status").has_updates, - color = Util.ui.fg("Special"), + color = LazyVim.ui.fg("Special"), }, { "diff", @@ -278,7 +277,7 @@ return { { "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, @@ -323,8 +322,8 @@ 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"}}, + { "", 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"}}, }, }, @@ -338,7 +337,7 @@ return { "goolord/alpha-nvim", optional = true, enabled = function() - require("lazyvim.util").warn({ + LazyVim.warn({ "`dashboard.nvim` is now the default LazyVim starter plugin.", "", "To keep using `alpha.nvim`, please enable the `lazyvim.plugins.extras.ui.alpha` extra.", @@ -373,11 +372,11 @@ 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 = 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" }, diff --git a/lua/lazyvim/plugins/xtras.lua b/lua/lazyvim/plugins/xtras.lua index 4eb73804..39a561a1 100644 --- a/lua/lazyvim/plugins/xtras.lua +++ b/lua/lazyvim/plugins/xtras.lua @@ -3,11 +3,23 @@ local Config = require("lazyvim.config") -- Some extras need to be loaded before others local prios = { ["lazyvim.plugins.extras.editor.aerial"] = 100, - ["lazyvim.plugins.extras.editor.symbols-outline"] = 100, + ["lazyvim.plugins.extras.editor.outline"] = 100, + ["lazyvim.plugins.extras.editor.trouble-v3"] = 100, ["lazyvim.plugins.extras.test.core"] = 1, ["lazyvim.plugins.extras.dap.core"] = 1, } +local used = {} ---@type table + +---@type string[] +Config.json.data.extras = vim.tbl_filter(function(extra) + if used[extra] then + return false + end + used[extra] = true + return true +end, Config.json.data.extras) + table.sort(Config.json.data.extras, function(a, b) local pa = prios[a] or 10 local pb = prios[b] or 10 diff --git a/lua/lazyvim/types.lua b/lua/lazyvim/types.lua new file mode 100644 index 00000000..73a5fe7b --- /dev/null +++ b/lua/lazyvim/types.lua @@ -0,0 +1,4 @@ +---@class LazyVimGlobals +vim.g = {} + +_G.lazyvim_docs = true diff --git a/lua/lazyvim/util/extras.lua b/lua/lazyvim/util/extras.lua index 4e2f0bc1..74ab4b4c 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 @@ -39,10 +38,10 @@ 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 @@ -119,7 +118,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 +136,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 .. "`" 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..f343c338 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 @@ -38,7 +40,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,7 +52,7 @@ 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 plugin string @@ -97,8 +99,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() diff --git a/lua/lazyvim/util/json.lua b/lua/lazyvim/util/json.lua index d98d0382..3df7aecd 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,11 @@ 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 {}) end M.save() diff --git a/lua/lazyvim/util/lazygit.lua b/lua/lazyvim/util/lazygit.lua new file mode 100644 index 00000000..7a7af81e --- /dev/null +++ b/lua/lazyvim/util/lazygit.lua @@ -0,0 +1,143 @@ +---@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 = 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 = 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 + +return M diff --git a/lua/lazyvim/util/lsp.lua b/lua/lazyvim/util/lsp.lua index b34a2afe..e712120a 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 = {} @@ -87,10 +85,10 @@ 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 })) + local clients = M.get_clients(LazyVim.merge({}, filter, { bufnr = buf })) ---@param client lsp.Client local ret = vim.tbl_filter(function(client) return client.supports_method("textDocument/formatting") @@ -102,20 +100,25 @@ function M.formatter(opts) 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) diff --git a/lua/lazyvim/util/lualine.lua b/lua/lazyvim/util/lualine.lua index 3e3cdb9a..db4600f4 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,7 @@ end ---@param hl_group? string ---@return string function M.format(component, text, hl_group) - if not hl_group then + if not hl_group or hl_group == "" then return text end ---@type table @@ -56,17 +54,31 @@ 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 = "", }, opts or {}) return function(self) @@ -75,8 +87,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 +99,24 @@ 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] } 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 +128,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/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 054a7cc3..a8e784b6 100644 --- a/lua/lazyvim/util/plugin.lua +++ b/lua/lazyvim/util/plugin.lua @@ -1,5 +1,4 @@ local Plugin = require("lazy.core.plugin") -local Util = require("lazyvim.util") ---@class lazyvim.util.plugin local M = {} @@ -35,9 +34,8 @@ function M.setup() M.lazy_file() table.insert(package.loaders, function(module) if M.deprecated_modules[module] then - Util.warn( - ("`%s` is no longer included by default in **LazyVim**.\nPlease install the `%s` extra if you still want to use it.") - :format( + 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] ), @@ -126,21 +124,21 @@ function M.lazy_file() 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 }) + 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..4143206c 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,7 +46,7 @@ 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 path = M.bufpath(buf) or vim.uv.cwd() local pattern = vim.fs.find(patterns, { path = path, upward = true })[1] return pattern and { vim.fs.dirname(pattern) } or {} end @@ -58,15 +56,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 +130,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 +139,10 @@ 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" }, { + vim.api.nvim_create_autocmd({ "LspAttach", "BufWritePost", "DirChanged" }, { group = vim.api.nvim_create_augroup("lazyvim_root_cache", { clear = true }), callback = function(event) M.cache[event.buf] = nil @@ -164,13 +162,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..1a85d4f0 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 }) diff --git a/lua/lazyvim/util/toggle.lua b/lua/lazyvim/util/toggle.lua index db41c825..cb380d0d 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,23 +31,29 @@ 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_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 diff --git a/lua/lazyvim/util/ui.lua b/lua/lazyvim/util/ui.lua index ce8b4780..91339ca7 100644 --- a/lua/lazyvim/util/ui.lua +++ b/lua/lazyvim/util/ui.lua @@ -103,7 +103,7 @@ function M.statuscolumn() ---@type Sign?,Sign?,Sign? local left, right, fold for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do - if s.name and s.name:find("GitSign") then + if s.name and (s.name:find("GitSign") or s.name:find("MiniDiffSign")) then right = s else left = s @@ -136,20 +136,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()