Merge branch 'LazyVim:main' into main

This commit is contained in:
Rubin Bhandari 2024-05-21 15:24:06 +05:45 committed by GitHub
commit d15c7d692b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 566 additions and 215 deletions

View file

@ -1,5 +1,42 @@
# Changelog # Changelog
## [11.4.0](https://github.com/LazyVim/LazyVim/compare/v11.3.2...v11.4.0) (2024-05-20)
### Features
* **cmp:** add missing documentation to snippets when needed ([24a2a9f](https://github.com/LazyVim/LazyVim/commit/24a2a9fb0ba60e0e7c6c8c4ee95a5db7ea0e123e))
* **cmp:** better error handling and automatic fixing of snippets that fail to parse with native Neovim snippets ([97862f4](https://github.com/LazyVim/LazyVim/commit/97862f425997bf89f581e6aeceed9aac85d90432))
* **cmp:** move cmp autobracket support to util class ([39f3ebc](https://github.com/LazyVim/LazyVim/commit/39f3ebcadf49b285d8ae06270ed0c2098e7f03bd))
* **cmp:** resolve placeholders in generated missing snippet documentation ([7d72436](https://github.com/LazyVim/LazyVim/commit/7d72436193b3624a9198a5e57ec1bd7e90260c00))
* **extras.lang:** Add kotlin ([#2890](https://github.com/LazyVim/LazyVim/issues/2890)) ([94c9f4c](https://github.com/LazyVim/LazyVim/commit/94c9f4cf379e472fbd1a342ef28687dfa418dec0))
* **java:** enable inlay hints. Fixes [#3244](https://github.com/LazyVim/LazyVim/issues/3244) ([e5ea8ab](https://github.com/LazyVim/LazyVim/commit/e5ea8abd38c4b93edccd69c9ef4462377103a9c3))
* **kotlin:** added recommended checks ([dd417c3](https://github.com/LazyVim/LazyVim/commit/dd417c36cd14b5b347b4f82e9e7683b085c768fb))
* **lang:** add toml ([#3022](https://github.com/LazyVim/LazyVim/issues/3022)) ([e0c67f6](https://github.com/LazyVim/LazyVim/commit/e0c67f6776a5e6f1b72852567ce4fec16598b2da))
* **lsp:** properly update certain Neovim functionlity based on dynamic capabilities. See [#3244](https://github.com/LazyVim/LazyVim/issues/3244). Fixes [#3246](https://github.com/LazyVim/LazyVim/issues/3246) ([20e002f](https://github.com/LazyVim/LazyVim/commit/20e002f9f0e9bfdff1ffc638987fbd46b31e5f9b))
* **toml:** also recommend toml when theres toml files in the cwd ([c264253](https://github.com/LazyVim/LazyVim/commit/c264253d8fd4f068c7c2ddb5ea3c63596ab5d23f))
* **vscode:** enable more compatible plugins ([#3250](https://github.com/LazyVim/LazyVim/issues/3250)) ([5726f39](https://github.com/LazyVim/LazyVim/commit/5726f3966df7c1e9b350d24aa94f621d0ea484da))
### Bug Fixes
* **bufferline:** unpin bufferline with 0.9.x compatibility ([#3252](https://github.com/LazyVim/LazyVim/issues/3252)) ([ea1c3ad](https://github.com/LazyVim/LazyVim/commit/ea1c3ad6b46dfaeca9ff4564499b4cdc8f839610))
* **cmp:** no need to setup native snippets with latest cmp ([57a31c3](https://github.com/LazyVim/LazyVim/commit/57a31c3920bcb9baec9a6d3915506a638b0801b8))
* **cmp:** use better cmp.confirm ([2961162](https://github.com/LazyVim/LazyVim/commit/2961162ebaef96e4ffbc1e6c97dba0dc32efbbb0))
* **config:** add some extra LazyVim keys to lazy health ([76033c6](https://github.com/LazyVim/LazyVim/commit/76033c6aa92e633de968b515d3fd5f9e0447a74f))
## [11.3.2](https://github.com/LazyVim/LazyVim/compare/v11.3.1...v11.3.2) (2024-05-19)
### Bug Fixes
* **bufferline:** pin bufferline to older version on 0.9.x for now ([573aa22](https://github.com/LazyVim/LazyVim/commit/573aa226f9f9b9fb9c9886381d3fd06746b7ae6a))
* **cmp:** only complete on `<cr>` when cmp is really visible. Dont wait till it might be visible. Faster and more correct imho ([ad22ada](https://github.com/LazyVim/LazyVim/commit/ad22adab7d446018875de2dc96168295cad9298e))
* **git:** off-by-one issue in lazygit blame line ([#3230](https://github.com/LazyVim/LazyVim/issues/3230)) ([4208a09](https://github.com/LazyVim/LazyVim/commit/4208a09df8cd20fe491a5fdcc722c12fb07588dc))
* **gitui:** properly delete lazygit keymap at the correct time. Fixes [#3227](https://github.com/LazyVim/LazyVim/issues/3227) ([e346d17](https://github.com/LazyVim/LazyVim/commit/e346d17812de516ad0789ede49b49a8b7ba213fe))
* show refactored success msg ([#3233](https://github.com/LazyVim/LazyVim/issues/3233)) ([4a41012](https://github.com/LazyVim/LazyVim/commit/4a41012483e67ffe5ff65f31934ed668325ea131))
* **yanky:** load yanky earlier to avoid losing deleted lines ([#3234](https://github.com/LazyVim/LazyVim/issues/3234)) ([93c156a](https://github.com/LazyVim/LazyVim/commit/93c156a0a54e5400436a950263dd140ca591d3e5))
## [11.3.1](https://github.com/LazyVim/LazyVim/compare/v11.3.0...v11.3.1) (2024-05-18) ## [11.3.1](https://github.com/LazyVim/LazyVim/compare/v11.3.0...v11.3.1) (2024-05-18)

View file

@ -1,138 +1,138 @@
<div align="center"> <div align="center">
<img src="https://user-images.githubusercontent.com/292349/213446185-2db63fd5-8c84-459c-9f04-e286382d6e80.png"> <img src="https://user-images.githubusercontent.com/292349/213446185-2db63fd5-8c84-459c-9f04-e286382d6e80.png">
</div> </div>
<hr> <hr>
<h4 align="center"> <h4 align="center">
<a href="https://lazyvim.github.io/installation">Installieren</a> <a href="https://lazyvim.github.io/installation">Installieren</a>
· ·
<a href="https://lazyvim.github.io/configuration">Konfigurieren</a> <a href="https://lazyvim.github.io/configuration">Konfigurieren</a>
· ·
<a href="https://lazyvim.github.io">Dokumentation</a> <a href="https://lazyvim.github.io">Dokumentation</a>
</h4> </h4>
<div align="center"><p> <div align="center"><p>
<a href="https://github.com/LazyVim/LazyVim/releases/latest"> <a href="https://github.com/LazyVim/LazyVim/releases/latest">
<img alt="Latest release" src="https://img.shields.io/github/v/release/LazyVim/LazyVim?style=for-the-badge&logo=starship&color=C9CBFF&logoColor=D9E0EE&labelColor=302D41&include_prerelease&sort=semver" /> <img alt="Latest release" src="https://img.shields.io/github/v/release/LazyVim/LazyVim?style=for-the-badge&logo=starship&color=C9CBFF&logoColor=D9E0EE&labelColor=302D41&include_prerelease&sort=semver" />
</a> </a>
<a href="https://github.com/LazyVim/LazyVim/pulse"> <a href="https://github.com/LazyVim/LazyVim/pulse">
<img alt="Last commit" src="https://img.shields.io/github/last-commit/LazyVim/LazyVim?style=for-the-badge&logo=starship&color=8bd5ca&logoColor=D9E0EE&labelColor=302D41"/> <img alt="Last commit" src="https://img.shields.io/github/last-commit/LazyVim/LazyVim?style=for-the-badge&logo=starship&color=8bd5ca&logoColor=D9E0EE&labelColor=302D41"/>
</a> </a>
<a href="https://github.com/LazyVim/LazyVim/blob/main/LICENSE"> <a href="https://github.com/LazyVim/LazyVim/blob/main/LICENSE">
<img alt="License" src="https://img.shields.io/github/license/LazyVim/LazyVim?style=for-the-badge&logo=starship&color=ee999f&logoColor=D9E0EE&labelColor=302D41" /> <img alt="License" src="https://img.shields.io/github/license/LazyVim/LazyVim?style=for-the-badge&logo=starship&color=ee999f&logoColor=D9E0EE&labelColor=302D41" />
</a> </a>
<a href="https://github.com/LazyVim/LazyVim/stargazers"> <a href="https://github.com/LazyVim/LazyVim/stargazers">
<img alt="Stars" src="https://img.shields.io/github/stars/LazyVim/LazyVim?style=for-the-badge&logo=starship&color=c69ff5&logoColor=D9E0EE&labelColor=302D41" /> <img alt="Stars" src="https://img.shields.io/github/stars/LazyVim/LazyVim?style=for-the-badge&logo=starship&color=c69ff5&logoColor=D9E0EE&labelColor=302D41" />
</a> </a>
<a href="https://github.com/LazyVim/LazyVim/issues"> <a href="https://github.com/LazyVim/LazyVim/issues">
<img alt="Issues" src="https://img.shields.io/github/issues/LazyVim/LazyVim?style=for-the-badge&logo=bilibili&color=F5E0DC&logoColor=D9E0EE&labelColor=302D41" /> <img alt="Issues" src="https://img.shields.io/github/issues/LazyVim/LazyVim?style=for-the-badge&logo=bilibili&color=F5E0DC&logoColor=D9E0EE&labelColor=302D41" />
</a> </a>
<a href="https://github.com/LazyVim/LazyVim"> <a href="https://github.com/LazyVim/LazyVim">
<img alt="Repo Size" src="https://img.shields.io/github/repo-size/LazyVim/LazyVim?color=%23DDB6F2&label=SIZE&logo=codesandbox&style=for-the-badge&logoColor=D9E0EE&labelColor=302D41" /> <img alt="Repo Size" src="https://img.shields.io/github/repo-size/LazyVim/LazyVim?color=%23DDB6F2&label=SIZE&logo=codesandbox&style=for-the-badge&logoColor=D9E0EE&labelColor=302D41" />
</a> </a>
<a href="https://twitter.com/intent/follow?screen_name=folke"> <a href="https://twitter.com/intent/follow?screen_name=folke">
<img alt="follow on Twitter" src="https://img.shields.io/twitter/follow/folke?style=for-the-badge&logo=twitter&color=8aadf3&logoColor=D9E0EE&labelColor=302D41" /> <img alt="follow on Twitter" src="https://img.shields.io/twitter/follow/folke?style=for-the-badge&logo=twitter&color=8aadf3&logoColor=D9E0EE&labelColor=302D41" />
</a> </a>
</div> </div>
LazyVim ist ein Neovim-Setup aufgebaut auf [💤 lazy.nvim](https://github.com/folke/lazy.nvim). LazyVim ist ein Neovim-Setup aufgebaut auf [💤 lazy.nvim](https://github.com/folke/lazy.nvim).
Es erleichtert das Anpassen und Erweitern von Ihrer Konfiguration. Es erleichtert das Anpassen und Erweitern von Ihrer Konfiguration.
Anstatt von vorne anzufangen oder eine vorgefertigte Distro zu verwenden, gibt LazyVim das beste aus Anstatt von vorne anzufangen oder eine vorgefertigte Distro zu verwenden, gibt LazyVim das beste aus
beiden Welten - die Flexibilität Ihre Konfiguration zu verändern und einzustellen wie Sie es wollen beiden Welten - die Flexibilität Ihre Konfiguration zu verändern und einzustellen wie Sie es wollen
und die Einfachheit von einem vorgefertigten Setup. und die Einfachheit von einem vorgefertigten Setup.
![image](https://user-images.githubusercontent.com/292349/213447056-92290767-ea16-430c-8727-ce994c93e9cc.png) ![image](https://user-images.githubusercontent.com/292349/213447056-92290767-ea16-430c-8727-ce994c93e9cc.png)
![image](https://user-images.githubusercontent.com/292349/211285846-0b7bb3bf-0462-4029-b64c-4ee1d037fc1c.png) ![image](https://user-images.githubusercontent.com/292349/211285846-0b7bb3bf-0462-4029-b64c-4ee1d037fc1c.png)
## ✨ Features ## ✨ Features
- 🔥 Transformiere dein Neovim in eine komplette IDE - 🔥 Transformiere dein Neovim in eine komplette IDE
- 💤 Passe deine Konfiguration einfach an und erweitere diese mit [lazy.nvim](https://github.com/folke/lazy.nvim) - 💤 Passe deine Konfiguration einfach an und erweitere diese mit [lazy.nvim](https://github.com/folke/lazy.nvim)
- 🚀 Extrem schnell - 🚀 Extrem schnell
- 🧹 Logische Voreinstellungen für optionen, autocmds und keymaps - 🧹 Logische Voreinstellungen für optionen, autocmds und keymaps
- 📦 Kommt mit einem Haufen vorkonfigurierter, ready-to-use Plugins - 📦 Kommt mit einem Haufen vorkonfigurierter, ready-to-use Plugins
## ⚡️ Vorraussetzungen ## ⚡️ Vorraussetzungen
- Neovim >= **0.8.0** (gebraucht um mit **LuaJIT** zu bauen) - Neovim >= **0.8.0** (gebraucht um mit **LuaJIT** zu bauen)
- Git >= **2.19.0** (um Teil-Klone zu unterstützen) - Git >= **2.19.0** (um Teil-Klone zu unterstützen)
- eine [Nerd Font](https://www.nerdfonts.com/) **_(optional)_** - eine [Nerd Font](https://www.nerdfonts.com/) **_(optional)_**
## 🚀 Einstieg ## 🚀 Einstieg
Sie können eine Startvorlage für **LazyVim** [hier](https://github.com/LazyVim/starter) finden Sie können eine Startvorlage für **LazyVim** [hier](https://github.com/LazyVim/starter) finden
<details><summary>Versuchen Sie's mit Docker</summary> <details><summary>Versuchen Sie's mit Docker</summary>
```sh ```sh
docker run -w /root -it --rm alpine:edge sh -uelic ' docker run -w /root -it --rm alpine:edge sh -uelic '
apk add git lazygit neovim ripgrep alpine-sdk --update apk add git lazygit neovim ripgrep alpine-sdk --update
git clone https://github.com/LazyVim/starter ~/.config/nvim git clone https://github.com/LazyVim/starter ~/.config/nvim
cd ~/.config/nvim cd ~/.config/nvim
nvim nvim
' '
``` ```
</details> </details>
<details><summary>Installieren von <a href="https://github.com/LazyVim/starter">LazyVim Starter</a></summary> <details><summary>Installieren von <a href="https://github.com/LazyVim/starter">LazyVim Starter</a></summary>
- Neovim Files sichern: - Neovim Files sichern:
```sh ```sh
mv ~/.config/nvim ~/.config/nvim.bak mv ~/.config/nvim ~/.config/nvim.bak
mv ~/.local/share/nvim ~/.local/share/nvim.bak mv ~/.local/share/nvim ~/.local/share/nvim.bak
``` ```
- Den Starter Klonen: - Den Starter Klonen:
```sh ```sh
git clone https://github.com/LazyVim/starter ~/.config/nvim git clone https://github.com/LazyVim/starter ~/.config/nvim
``` ```
- Den `.git` Folder löschen, um die Konfiguration zu einer eigenen distro hinzuzufügen: - Den `.git` Folder löschen, um die Konfiguration zu einer eigenen distro hinzuzufügen:
```sh ```sh
rm -rf ~/.config/nvim/.git rm -rf ~/.config/nvim/.git
``` ```
- Neovim starten! - Neovim starten!
```sh ```sh
nvim nvim
``` ```
Refer to the comments in the files on how to customize **LazyVim**. Refer to the comments in the files on how to customize **LazyVim**.
</details> </details>
## 📂 Dateistruktur ## 📂 Dateistruktur
Die Dateien unter `config` werden automatisch und zur richtigen Zeit geladen, Die Dateien unter `config` werden automatisch und zur richtigen Zeit geladen,
sodass ein manuelles `require` nicht nötig ist. sodass ein manuelles `require` nicht nötig ist.
**LazyVim** bringt Konfigurationsdatein mit, die **_vor_** Ihren eigenen geladen werden - **LazyVim** bringt Konfigurationsdatein mit, die **_vor_** Ihren eigenen geladen werden -
siehe [hier](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/config) siehe [hier](https://github.com/LazyVim/LazyVim/tree/main/lua/lazyvim/config)
Sie können eigene Plugins unter `lua/plugins/` hinzufügen. Alle Dateien innerhalb Sie können eigene Plugins unter `lua/plugins/` hinzufügen. Alle Dateien innerhalb
dieses Ordners werden automatisch mit [lazy.nvim](https://github.com/folke/lazy.nvim) dieses Ordners werden automatisch mit [lazy.nvim](https://github.com/folke/lazy.nvim)
geladen. geladen.
<pre> <pre>
~/.config/nvim ~/.config/nvim
├── lua ├── lua
│ ├── config │ ├── config
│ │ ├── autocmds.lua │ │ ├── autocmds.lua
│ │ ├── keymaps.lua │ │ ├── keymaps.lua
│ │ ├── lazy.lua │ │ ├── lazy.lua
│ │ └── options.lua │ │ └── options.lua
│ └── plugins │ └── plugins
│ ├── spec1.lua │ ├── spec1.lua
│ ├── ** │ ├── **
│ └── spec2.lua │ └── spec2.lua
└── init.toml └── init.toml
</pre> </pre>
## ⚙️ Konfiguration ## ⚙️ Konfiguration
Siehe [Dokumentation](https://lazyvim.github.io). Siehe [Dokumentation](https://lazyvim.github.io).

View file

@ -1,4 +1,4 @@
*LazyVim.txt* For Neovim >= 0.9.0 Last change: 2024 May 19 *LazyVim.txt* For Neovim >= 0.9.0 Last change: 2024 May 20
============================================================================== ==============================================================================
Table of Contents *LazyVim-table-of-contents* Table of Contents *LazyVim-table-of-contents*

View file

@ -191,6 +191,13 @@ function M.setup(opts)
vim.cmd([[Lazy! load all]]) vim.cmd([[Lazy! load all]])
vim.cmd([[checkhealth]]) vim.cmd([[checkhealth]])
end, { desc = "Load all plugins and run :checkhealth" }) end, { desc = "Load all plugins and run :checkhealth" })
local health = require("lazy.health")
vim.list_extend(health.valid, {
"recommended",
"desc",
"vscode",
})
end, end,
}) })

View file

@ -36,19 +36,8 @@ return {
["<C-f>"] = cmp.mapping.scroll_docs(4), ["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(), ["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(), ["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = function(fallback) ["<CR>"] = LazyVim.cmp.confirm(),
if cmp.core.view:visible() or vim.fn.pumvisible() == 1 then ["<S-CR>"] = LazyVim.cmp.confirm({ behavior = cmp.ConfirmBehavior.Replace }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
LazyVim.create_undo()
if cmp.confirm({ select = true }) then
return
end
end
return fallback()
end,
["<S-CR>"] = cmp.mapping.confirm({
behavior = cmp.ConfirmBehavior.Replace,
select = true,
}), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
["<C-CR>"] = function(fallback) ["<C-CR>"] = function(fallback)
cmp.abort() cmp.abort()
fallback() fallback()
@ -83,23 +72,15 @@ return {
source.group_index = source.group_index or 1 source.group_index = source.group_index or 1
end end
local cmp = require("cmp") local cmp = require("cmp")
local Kind = cmp.lsp.CompletionItemKind
cmp.setup(opts) cmp.setup(opts)
cmp.event:on("confirm_done", function(event) cmp.event:on("confirm_done", function(event)
if not vim.tbl_contains(opts.auto_brackets or {}, vim.bo.filetype) then if vim.tbl_contains(opts.auto_brackets or {}, vim.bo.filetype) then
return LazyVim.cmp.auto_brackets(event.entry)
end
local entry = event.entry
local item = entry:get_completion_item()
if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) and item.insertTextFormat ~= 2 then
local cursor = vim.api.nvim_win_get_cursor(0)
local prev_char = vim.api.nvim_buf_get_text(0, cursor[1] - 1, cursor[2], cursor[1] - 1, cursor[2] + 1, {})[1]
if prev_char ~= "(" and prev_char ~= ")" then
local keys = vim.api.nvim_replace_termcodes("()<left>", false, false, true)
vim.api.nvim_feedkeys(keys, "i", true)
end
end end
end) end)
cmp.event:on("menu_opened", function(event)
LazyVim.cmp.add_missing_snippet_docs(event.window)
end)
end, end,
}, },
@ -113,8 +94,8 @@ return {
}, },
opts = function(_, opts) opts = function(_, opts)
opts.snippet = { opts.snippet = {
expand = function(args) expand = function(item)
vim.snippet.expand(args.body) return LazyVim.cmp.expand(item.body)
end, end,
} }
table.insert(opts.sources, { name = "snippets" }) table.insert(opts.sources, { name = "snippets" })

View file

@ -3,6 +3,7 @@ return {
"gbprod/yanky.nvim", "gbprod/yanky.nvim",
recommended = true, recommended = true,
desc = "Better Yank/Paste", desc = "Better Yank/Paste",
event = "LazyFile",
opts = { opts = {
highlight = { timer = 150 }, highlight = { timer = 150 },
}, },

View file

@ -112,6 +112,8 @@ return {
}, },
printf_statements = {}, printf_statements = {},
print_var_statements = {}, print_var_statements = {},
show_success_message = true, -- shows a message with information about the refactor on success
-- i.e. [Refactor] Inlined 3 variable occurrences
}, },
config = function(_, opts) config = function(_, opts)
require("refactoring").setup(opts) require("refactoring").setup(opts)

View file

@ -118,11 +118,18 @@ return {
dap = { hotcodereplace = "auto", config_overrides = {} }, dap = { hotcodereplace = "auto", config_overrides = {} },
dap_main = {}, dap_main = {},
test = true, test = true,
settings = {
java = {
inlayHints = {
parameterNames = {
enabled = "all",
},
},
},
},
} }
end, end,
config = function() config = function(_, opts)
local opts = LazyVim.opts("nvim-jdtls") or {}
-- Find the extra bundles that should be passed on the jdtls command-line -- Find the extra bundles that should be passed on the jdtls command-line
-- if nvim-dap is enabled with java debug/test. -- if nvim-dap is enabled with java debug/test.
local mason_registry = require("mason-registry") local mason_registry = require("mason-registry")
@ -158,6 +165,7 @@ return {
init_options = { init_options = {
bundles = bundles, bundles = bundles,
}, },
settings = opts.settings,
-- enable CMP capabilities -- enable CMP capabilities
capabilities = LazyVim.has("cmp-nvim-lsp") and require("cmp_nvim_lsp").default_capabilities() or nil, capabilities = LazyVim.has("cmp-nvim-lsp") and require("cmp_nvim_lsp").default_capabilities() or nil,
}, opts.jdtls) }, opts.jdtls)

View file

@ -0,0 +1,117 @@
return {
recommended = function()
return LazyVim.extras.wants({
ft = "kotlin",
root = {
"settings.gradle", -- Gradle (multi-project)
"settings.gradle.kts", -- Gradle (multi-project)
"build.xml", -- Ant
"pom.xml", -- Maven
"build.gradle", -- Gradle
"build.gradle.kts", -- Gradle
},
})
end,
-- Add packages(linting, debug adapter)
{
"williamboman/mason.nvim",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed or {}, { "ktlint", "kotlin-debug-adapter" })
end,
},
-- Add syntax highlighting
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
vim.list_extend(opts.ensure_installed or {}, { "kotlin" })
end,
},
-- Add language server
{
"neovim/nvim-lspconfig",
opts = {
servers = {
kotlin_language_server = {},
},
},
},
-- Add linting as optional
{
"mfussenegger/nvim-lint",
optional = true,
dependencies = "williamboman/mason.nvim",
opts = {
linters_by_ft = { kotlin = { "ktlint" } },
},
},
-- Add formatting as optional
{
"stevearc/conform.nvim",
optional = true,
opts = {
formatters_by_ft = { kotlin = { "ktlint" } },
},
},
-- Add formatting and linting as optional
{
"nvimtools/none-ls.nvim",
optional = true,
opts = function(_, opts)
local nls = require("null-ls")
opts.sources = vim.list_extend(opts.sources or {}, {
nls.builtins.formatting.ktlint,
nls.builtins.diagnostics.ktlint,
})
end,
},
-- Add debugger
{
"mfussenegger/nvim-dap",
optional = true,
dependencies = "williamboman/mason.nvim",
opts = function()
local dap = require("dap")
if not dap.adapters.kotlin then
require("dap").adapters.kotlin = {
type = "executable",
command = "kotlin-debug-adapter",
options = { auto_continue_if_many_stopped = false },
}
end
dap.configurations.kotlin = {
{
type = "kotlin",
request = "launch",
name = "This file",
-- may differ, when in doubt, whatever your project structure may be,
-- it has to correspond to the class file located at `build/classes/`
-- and of course you have to build before you debug
mainClass = function()
local root = vim.fs.find("src", { path = vim.uv.cwd(), upward = true, stop = vim.env.HOME })[1] or ""
local fname = vim.api.nvim_buf_get_name(0)
-- src/main/kotlin/websearch/Main.kt -> websearch.MainKt
return fname:gsub(root, ""):gsub("main/kotlin/", ""):gsub(".kt", "Kt"):gsub("/", "."):sub(2, -1)
end,
projectRoot = "${workspaceFolder}",
jsonLogFile = "",
enableJsonLogging = false,
},
{
-- Use this for unit tests
-- First, run
-- ./gradlew --info cleanTest test --debug-jvm
-- then attach the debugger to it
type = "kotlin",
request = "attach",
name = "Attach to debugging session",
port = 5005,
args = {},
projectRoot = vim.fn.getcwd,
hostName = "localhost",
timeout = 2000,
},
}
end,
},
}

View file

@ -0,0 +1,31 @@
return {
recommended = function()
return LazyVim.extras.wants({
ft = "toml",
root = "*.toml",
})
end,
{
"nvim-treesitter/nvim-treesitter",
opts = function(_, opts)
if type(opts.ensure_installed) == "table" then
vim.list_extend(opts.ensure_installed, { "toml" })
end
end,
},
{
"williamboman/mason.nvim",
opts = function(_, opts)
opts.ensure_installed = opts.ensure_installed or {}
vim.list_extend(opts.ensure_installed, { "taplo" })
end,
},
{
"neovim/nvim-lspconfig",
opts = {
servers = {
taplo = {},
},
},
},
}

View file

@ -3,17 +3,20 @@ if not vim.g.vscode then
end end
local enabled = { local enabled = {
"dial.nvim",
"flit.nvim", "flit.nvim",
"lazy.nvim", "lazy.nvim",
"leap.nvim", "leap.nvim",
"mini.ai", "mini.ai",
"mini.comment", "mini.comment",
"mini.move",
"mini.pairs", "mini.pairs",
"mini.surround", "mini.surround",
"nvim-treesitter", "nvim-treesitter",
"nvim-treesitter-textobjects", "nvim-treesitter-textobjects",
"nvim-ts-context-commentstring", "nvim-ts-context-commentstring",
"vim-repeat", "vim-repeat",
"yanky.nvim",
"LazyVim", "LazyVim",
} }

View file

@ -121,16 +121,8 @@ return {
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer) require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
end) end)
local register_capability = vim.lsp.handlers["client/registerCapability"] LazyVim.lsp.setup()
LazyVim.lsp.on_dynamic_capability(require("lazyvim.plugins.lsp.keymaps").on_attach)
vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx)
---@diagnostic disable-next-line: no-unknown
local ret = register_capability(err, res, ctx)
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
LazyVim.lsp.words.setup(opts.document_highlight) LazyVim.lsp.words.setup(opts.document_highlight)
@ -148,24 +140,19 @@ return {
if vim.fn.has("nvim-0.10") == 1 then if vim.fn.has("nvim-0.10") == 1 then
-- inlay hints -- inlay hints
if opts.inlay_hints.enabled then if opts.inlay_hints.enabled then
LazyVim.lsp.on_attach(function(client, buffer) LazyVim.lsp.on_supports_method("textDocument/inlayHint", function(client, buffer)
if client.supports_method("textDocument/inlayHint") then LazyVim.toggle.inlay_hints(buffer, true)
LazyVim.toggle.inlay_hints(buffer, true)
end
end) end)
end end
-- code lens -- code lens
if opts.codelens.enabled and vim.lsp.codelens then if opts.codelens.enabled and vim.lsp.codelens then
LazyVim.lsp.on_attach(function(client, buffer) LazyVim.lsp.on_supports_method("textDocument/codeLens", function(client, buffer)
if client.supports_method("textDocument/codeLens") then vim.lsp.codelens.refresh()
vim.lsp.codelens.refresh() vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, {
--- autocmd BufEnter,CursorHold,InsertLeave <buffer> lua vim.lsp.codelens.refresh() buffer = buffer,
vim.api.nvim_create_autocmd({ "BufEnter", "CursorHold", "InsertLeave" }, { callback = vim.lsp.codelens.refresh,
buffer = buffer, })
callback = vim.lsp.codelens.refresh,
})
end
end) end)
end end
end end

106
lua/lazyvim/util/cmp.lua Normal file
View file

@ -0,0 +1,106 @@
---@class lazyvim.util.cmp
local M = {}
---@param snippet string
---@param fn fun(placeholder:Placeholder):string
---@return string
function M.snippet_replace(snippet, fn)
return snippet:gsub("%$%b{}", function(m)
local n, name = m:match("^%${(%d+):(.+)}$")
return n and fn({ n = n, text = name }) or m
end) or snippet
end
-- This function resolves nested placeholders in a snippet.
---@param snippet string
---@return string
function M.snippet_preview(snippet)
local ret = M.snippet_replace(snippet, function(placeholder)
return M.snippet_preview(placeholder.text)
end):gsub("%$0", "")
return ret
end
-- This function replaces nested placeholders in a snippet with LSP placeholders.
function M.snippet_fix(snippet)
return M.snippet_replace(snippet, function(placeholder)
return "${" .. placeholder.n .. ":" .. M.snippet_preview(placeholder.text) .. "}"
end)
end
---@param entry cmp.Entry
function M.auto_brackets(entry)
local cmp = require("cmp")
local Kind = cmp.lsp.CompletionItemKind
local item = entry:get_completion_item()
if vim.tbl_contains({ Kind.Function, Kind.Method }, item.kind) then
local cursor = vim.api.nvim_win_get_cursor(0)
local prev_char = vim.api.nvim_buf_get_text(0, cursor[1] - 1, cursor[2], cursor[1] - 1, cursor[2] + 1, {})[1]
if prev_char ~= "(" and prev_char ~= ")" then
local keys = vim.api.nvim_replace_termcodes("()<left>", false, false, true)
vim.api.nvim_feedkeys(keys, "i", true)
end
end
end
-- This function adds missing documentation to snippets.
-- The documentation is a preview of the snippet.
---@param window cmp.CustomEntriesView|cmp.NativeEntriesView
function M.add_missing_snippet_docs(window)
local cmp = require("cmp")
local Kind = cmp.lsp.CompletionItemKind
local entries = window:get_entries()
for _, entry in ipairs(entries) do
if entry:get_kind() == Kind.Snippet then
local item = entry:get_completion_item()
if not item.documentation and item.insertText then
item.documentation = {
kind = cmp.lsp.MarkupKind.Markdown,
value = string.format("```%s\n%s\n```", vim.bo.filetype, M.snippet_preview(item.insertText)),
}
end
end
end
end
-- This is a better implementation of `cmp.confirm`:
-- * check if the completion menu is visible without waiting for running sources
-- * create an undo point before confirming
-- This function is both faster and more reliable.
---@param opts? {select: boolean, behavior: cmp.ConfirmBehavior}
function M.confirm(opts)
local cmp = require("cmp")
opts = vim.tbl_extend("force", {
select = true,
behavior = cmp.ConfirmBehavior.Insert,
}, opts or {})
return function(fallback)
if cmp.core.view:visible() or vim.fn.pumvisible() == 1 then
LazyVim.create_undo()
if cmp.confirm(opts) then
return
end
end
return fallback()
end
end
function M.expand(snippet)
local ok = pcall(vim.snippet.expand, snippet)
if not ok then
local fixed = M.snippet_fix(snippet)
ok = pcall(vim.snippet.expand, fixed)
local msg = ok and "Failed to parse snippet,\nbut was able to fix it automatically." or "Failed to parse snippet."
LazyVim[ok and "warn" or "error"](
([[%s
```%s
%s
```]]):format(msg, vim.bo.filetype, snippet),
{ title = "vim.snippet" }
)
end
end
return M

View file

@ -17,6 +17,7 @@ local LazyUtil = require("lazy.core.util")
---@field json lazyvim.util.json ---@field json lazyvim.util.json
---@field lualine lazyvim.util.lualine ---@field lualine lazyvim.util.lualine
---@field mini lazyvim.util.mini ---@field mini lazyvim.util.mini
---@field cmp lazyvim.util.cmp
local M = {} local M = {}
---@type table<string, string|string[]> ---@type table<string, string|string[]>

View file

@ -5,14 +5,14 @@ local M = {}
---@param opts? lsp.Client.filter ---@param opts? lsp.Client.filter
function M.get_clients(opts) function M.get_clients(opts)
local ret = {} ---@type lsp.Client[] local ret = {} ---@type vim.lsp.Client[]
if vim.lsp.get_clients then if vim.lsp.get_clients then
ret = vim.lsp.get_clients(opts) ret = vim.lsp.get_clients(opts)
else else
---@diagnostic disable-next-line: deprecated ---@diagnostic disable-next-line: deprecated
ret = vim.lsp.get_active_clients(opts) ret = vim.lsp.get_active_clients(opts)
if opts and opts.method then if opts and opts.method then
---@param client lsp.Client ---@param client vim.lsp.Client
ret = vim.tbl_filter(function(client) ret = vim.tbl_filter(function(client)
return client.supports_method(opts.method, { bufnr = opts.bufnr }) return client.supports_method(opts.method, { bufnr = opts.bufnr })
end, ret) end, ret)
@ -21,13 +21,85 @@ function M.get_clients(opts)
return opts and opts.filter and vim.tbl_filter(opts.filter, ret) or ret return opts and opts.filter and vim.tbl_filter(opts.filter, ret) or ret
end end
---@param on_attach fun(client:lsp.Client, buffer) ---@param on_attach fun(client:vim.lsp.Client, buffer)
function M.on_attach(on_attach) function M.on_attach(on_attach)
vim.api.nvim_create_autocmd("LspAttach", { return vim.api.nvim_create_autocmd("LspAttach", {
callback = function(args) callback = function(args)
local buffer = args.buf ---@type number local buffer = args.buf ---@type number
local client = vim.lsp.get_client_by_id(args.data.client_id) local client = vim.lsp.get_client_by_id(args.data.client_id)
on_attach(client, buffer) if client then
return on_attach(client, buffer)
end
end,
})
end
---@type table<string, table<vim.lsp.Client, table<number, boolean>>>
M._supports_method = {}
function M.setup()
local register_capability = vim.lsp.handlers["client/registerCapability"]
vim.lsp.handlers["client/registerCapability"] = function(err, res, ctx)
---@diagnostic disable-next-line: no-unknown
local ret = register_capability(err, res, ctx)
local client = vim.lsp.get_client_by_id(ctx.client_id)
local buffer = vim.api.nvim_get_current_buf()
if client then
vim.api.nvim_exec_autocmds("User", {
pattern = "LspDynamicCapability",
data = { client_id = client.id, buffer = buffer },
})
end
return ret
end
M.on_attach(M._check_methods)
M.on_dynamic_capability(M._check_methods)
end
---@param client vim.lsp.Client
function M._check_methods(client, buffer)
for method, clients in pairs(M._supports_method) do
clients[client] = clients[client] or {}
if not clients[client][buffer] then
if client.supports_method(method, { bufnr = buffer }) then
clients[client][buffer] = true
vim.api.nvim_exec_autocmds("User", {
pattern = "LspSupportsMethod",
data = { client_id = client.id, buffer = buffer, method = method },
})
end
end
end
end
---@param fn fun(client:vim.lsp.Client, buffer):boolean?
---@param opts? {group?: integer}
function M.on_dynamic_capability(fn, opts)
return vim.api.nvim_create_autocmd("User", {
pattern = "LspDynamicCapability",
group = opts and opts.group or nil,
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
local buffer = args.data.buffer ---@type number
if client then
return fn(client, buffer)
end
end,
})
end
---@param method string
---@param fn fun(client:vim.lsp.Client, buffer)
function M.on_supports_method(method, fn)
M._supports_method[method] = M._supports_method[method] or setmetatable({}, { __mode = "k" })
return vim.api.nvim_create_autocmd("User", {
pattern = "LspSupportsMethod",
callback = function(args)
local client = vim.lsp.get_client_by_id(args.data.client_id)
local buffer = args.data.buffer ---@type number
if client and method == args.data.method then
return fn(client, buffer)
end
end, end,
}) })
end end
@ -89,12 +161,12 @@ function M.formatter(opts)
end, end,
sources = function(buf) sources = function(buf)
local clients = M.get_clients(LazyVim.merge({}, filter, { bufnr = buf })) local clients = M.get_clients(LazyVim.merge({}, filter, { bufnr = buf }))
---@param client lsp.Client ---@param client vim.lsp.Client
local ret = vim.tbl_filter(function(client) local ret = vim.tbl_filter(function(client)
return client.supports_method("textDocument/formatting") return client.supports_method("textDocument/formatting")
or client.supports_method("textDocument/rangeFormatting") or client.supports_method("textDocument/rangeFormatting")
end, clients) end, clients)
---@param client lsp.Client ---@param client vim.lsp.Client
return vim.tbl_map(function(client) return vim.tbl_map(function(client)
return client.name return client.name
end, ret) end, ret)
@ -143,22 +215,20 @@ function M.words.setup(opts)
return handler(err, result, ctx, config) return handler(err, result, ctx, config)
end end
M.on_attach(function(client, buf) M.on_supports_method("textDocument/documentHighlight", function(_, buf)
if client.supports_method("textDocument/documentHighlight") then vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI", "CursorMoved", "CursorMovedI" }, {
vim.api.nvim_create_autocmd({ "CursorHold", "CursorHoldI", "CursorMoved", "CursorMovedI" }, { group = vim.api.nvim_create_augroup("lsp_word_" .. buf, { clear = true }),
group = vim.api.nvim_create_augroup("lsp_word_" .. buf, { clear = true }), buffer = buf,
buffer = buf, callback = function(ev)
callback = function(ev) if not M.words.at() then
if not M.words.at() then if ev.event:find("CursorMoved") then
if ev.event:find("CursorMoved") then vim.lsp.buf.clear_references()
vim.lsp.buf.clear_references() else
else vim.lsp.buf.document_highlight()
vim.lsp.buf.document_highlight()
end
end end
end, end
}) end,
end })
end) end)
end end