Compare commits
271 Commits
Author | SHA1 | Date | |
---|---|---|---|
821672a0db | |||
8ce862e12e | |||
952a0cfb96 | |||
d69d55afd4 | |||
7a36e2989c | |||
049fe77c3c | |||
5a47492535 | |||
15f5a229d9 | |||
bb4a7fe410 | |||
419086e8a3 | |||
49ae2344a1 | |||
1efe3a96b2 | |||
5ed3250f24 | |||
9c1a5620ed | |||
08422bf559 | |||
fc236b3a2a | |||
01fbeb139b | |||
99ce1002d7 | |||
3b4c27e6a6 | |||
a94ef5953a | |||
0c05f8a185 | |||
6b68378c2c | |||
0e671ad7fa | |||
b68311eb6d | |||
a866c6801d | |||
5c97e0c1d0 | |||
72b81553f3 | |||
88238e2109 | |||
c272bba013 | |||
b16012b106 | |||
efc72b0649 | |||
2a3bac7690 | |||
98e2ffcf14 | |||
2c89770504 | |||
30824369c2 | |||
1288f0d5a5 | |||
a3ec4c21f7 | |||
f7a63042f9 | |||
b7a925904e | |||
5eccaeb992 | |||
962fc6bab4 | |||
e990d23cfe | |||
b027bebeab | |||
19f4250888 | |||
33f61b58de | |||
5373af76f8 | |||
c526ea338b | |||
ba0cfbccf3 | |||
47ee48faba | |||
7bc979a7c1 | |||
9c7821e681 | |||
95e2a07f16 | |||
d35d982984 | |||
877e63ca8e | |||
bc24b68260 | |||
b75ed594a9 | |||
4f2bb725be | |||
2f0bfbbad8 | |||
01a6085b2b | |||
2b5ae7b63c | |||
dc40f02f35 | |||
4b367952f6 | |||
7c9abd7463 | |||
868ccedff2 | |||
29632c6b29 | |||
5b7ae96c5d | |||
e9fb81e94d | |||
b172f47f27 | |||
9cfe88c7ba | |||
163a4f9275 | |||
076b2e432e | |||
5bf45e3139 | |||
eba510ec69 | |||
39fa63646d | |||
e975f021ea | |||
bf66e71adc | |||
cd96e3d9e5 | |||
5559228300 | |||
3dcc074693 | |||
58c3842faa | |||
89db0157b1 | |||
7443effe26 | |||
78298cb134 | |||
55bf4d104c | |||
c12835ab86 | |||
183fd89d76 | |||
99785ce36b | |||
bb0d4d4e7d | |||
f8982332be | |||
0c517d1f5c | |||
df6a0d3b10 | |||
7a7c024bf6 | |||
29554455aa | |||
b227d9727a | |||
b4099a6477 | |||
5a27e1def0 | |||
06e4ba2fdb | |||
23410a4594 | |||
c737f2b6c2 | |||
78354a1e5e | |||
080ea29354 | |||
3d7238f753 | |||
a43d1b79f2 | |||
bd1ba54d13 | |||
9f2010a8b9 | |||
e09423b28c | |||
2525b91313 | |||
a213da4430 | |||
b57582bc91 | |||
d41ef05cc0 | |||
dfde622847 | |||
44df7434d4 | |||
049e323714 | |||
7d96b07c6f | |||
ad229bbf42 | |||
cbf1d335ed | |||
6ebf3ab084 | |||
25d37a2cdd | |||
7409fef291 | |||
3f5c2c283e | |||
f51719a12d | |||
ea4858874b | |||
c42ebc216a | |||
bdddb215cc | |||
eb143ebe11 | |||
86ac9989ea | |||
dc1d48f436 | |||
5202a0f006 | |||
7b9145c12d | |||
3e46dd61cd | |||
43763a6226 | |||
6c334fed6a | |||
d18331ca89 | |||
59f3b3e096 | |||
4fbb7a2803 | |||
b760ec63c4 | |||
d565684ade | |||
c7aeda9db1 | |||
3a718c5c85 | |||
6c86952a0e | |||
ad214af54d | |||
40983a3269 | |||
2f93f69171 | |||
4379ae8ab9 | |||
eb92903342 | |||
03282126e3 | |||
1274310e6d | |||
14e708a246 | |||
437156a3ae | |||
063f8d6dff | |||
d63c471008 | |||
4042614005 | |||
81ab5bed7a | |||
5264909b54 | |||
68c21ec452 | |||
7fe0d5c7c7 | |||
342fa02370 | |||
ac1051686b | |||
55cc8b67fc | |||
1d2c97cbda | |||
0b8c799a7a | |||
1caa27ba4a | |||
3518c1d73b | |||
ae8c371ff4 | |||
17fe32e428 | |||
ef21bea975 | |||
38ad79d548 | |||
95b86c8d1d | |||
01a1b8e80d | |||
06c38c52a9 | |||
77efbe8bcf | |||
cfaf3b054e | |||
5f6913c0db | |||
a94f7afdeb | |||
b391c37e53 | |||
338680d80a | |||
df9547f432 | |||
0155de00ab | |||
0cb8974221 | |||
700cdaf30d | |||
feaeab9fca | |||
54846ff763 | |||
f562d1d197 | |||
bc14e02a1f | |||
df94a044ec | |||
29ec138f8e | |||
98775f5631 | |||
36aa64bc0b | |||
02c5e8d953 | |||
a9e9204dae | |||
2d8116ef67 | |||
bef36bb2fd | |||
a099b2d3ab | |||
1defd5f670 | |||
6e01e8560e | |||
7691daa036 | |||
7476da7811 | |||
1c06aa35ee | |||
078250a114 | |||
7ce1b1519a | |||
79fe0455a0 | |||
a6062758d2 | |||
ed48b85dbe | |||
f67f20184f | |||
7048619cc1 | |||
59eb19835f | |||
c4572fcec8 | |||
c272cb2940 | |||
381ee0a9fc | |||
b48a1969d3 | |||
b0cef1f506 | |||
049c84509c | |||
ade4342c42 | |||
18328d10c9 | |||
df5cbfdbec | |||
11d414c358 | |||
7a8ca6222a | |||
db66353db9 | |||
a7b25e13fa | |||
a0b1256554 | |||
501474e421 | |||
b984c0cff5 | |||
9f5a0f1bd8 | |||
d0b378f427 | |||
aa4f7ec651 | |||
c10e550639 | |||
f0b548af2f | |||
cec000dfd8 | |||
6b740fd300 | |||
564e25a277 | |||
df6ac591ba | |||
bcdcfab020 | |||
8bb0c9ddd8 | |||
0bed79f844 | |||
a28885be3f | |||
f5e010d887 | |||
9f30a2e03a | |||
9d9e6b1188 | |||
3ffd5408a1 | |||
f1dbd097e4 | |||
aa8bae07ae | |||
75299da24c | |||
5aad5749a7 | |||
5bb2314787 | |||
b1b5b461bf | |||
23ba877bb0 | |||
8f3834bc13 | |||
c407ddfe8a | |||
3c6357815c | |||
079d3967d0 | |||
ae9c74d88e | |||
e7a515e548 | |||
2002265461 | |||
f441faad03 | |||
6fec14e508 | |||
b10c9ade77 | |||
2e951e4f44 | |||
0d32e62567 | |||
9dd2487529 | |||
1f7be0bbad | |||
57c2dcb3a3 | |||
099fd48844 | |||
04a60e251b | |||
d285548ae0 | |||
368c65e14b | |||
3a52307505 | |||
3c0f28331b | |||
c32943f2aa | |||
d00aade8db | |||
f6f3ce4a9b | |||
16e4a3f8fd |
3
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
3
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -16,7 +16,7 @@ body:
|
||||
required: true
|
||||
- label: I have searched the existing issues of LazyVim
|
||||
required: true
|
||||
- label: I have searched the exsiting issues of plugins related to this issue
|
||||
- label: I have searched the existing issues of plugins related to this issue
|
||||
required: true
|
||||
- type: input
|
||||
attributes:
|
||||
@ -59,6 +59,7 @@ body:
|
||||
value: |
|
||||
-- DO NOT change the paths and don't remove the colorscheme
|
||||
local root = vim.fn.fnamemodify("./.repro", ":p")
|
||||
|
||||
-- set stdpaths to use .repro
|
||||
for _, name in ipairs({ "config", "data", "state", "cache" }) do
|
||||
vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
|
||||
|
10
.github/workflows/ci.yml
vendored
10
.github/workflows/ci.yml
vendored
@ -15,8 +15,12 @@ jobs:
|
||||
- name: Install Neovim
|
||||
shell: bash
|
||||
run: |
|
||||
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim-linux64.deb -O /tmp/nvim.deb
|
||||
sudo dpkg -i /tmp/nvim.deb
|
||||
mkdir -p /tmp/nvim
|
||||
wget -q https://github.com/neovim/neovim/releases/download/nightly/nvim.appimage -O /tmp/nvim/nvim.appimage
|
||||
cd /tmp/nvim
|
||||
chmod a+x ./nvim.appimage
|
||||
./nvim.appimage --appimage-extract
|
||||
echo "/tmp/nvim/squashfs-root/usr/bin/" >> $GITHUB_PATH
|
||||
- name: Run Tests
|
||||
run: |
|
||||
nvim --version
|
||||
@ -55,7 +59,7 @@ jobs:
|
||||
with:
|
||||
release-type: simple
|
||||
package-name: LazyVim
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v3
|
||||
- name: tag stable versions
|
||||
if: ${{ steps.release.outputs.release_created }}
|
||||
run: |
|
||||
|
@ -7,7 +7,7 @@
|
||||
},
|
||||
"neoconf": {
|
||||
"plugins": {
|
||||
"sumneko_lua": {
|
||||
"lua_ls": {
|
||||
"enabled": true
|
||||
}
|
||||
}
|
||||
|
624
CHANGELOG.md
624
CHANGELOG.md
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 March 01
|
||||
*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 June 05
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *LazyVim-table-of-contents*
|
||||
@ -43,7 +43,6 @@ pre-configured setup.
|
||||
|
||||
FEATURES *LazyVim-features*
|
||||
|
||||
|
||||
- Transform your Neovim into a full-fledged IDE
|
||||
- Easily customize and extend your config with lazy.nvim <https://github.com/folke/lazy.nvim>
|
||||
- Blazingly fast
|
||||
@ -53,7 +52,6 @@ FEATURES *LazyVim-features*
|
||||
|
||||
REQUIREMENTS *LazyVim-requirements*
|
||||
|
||||
|
||||
- Neovim >= **0.8.0** (needs to be built with **LuaJIT**)
|
||||
- Git >= **2.19.0** (for partial clones support)
|
||||
- a Nerd Font <https://www.nerdfonts.com/> **(optional)**
|
||||
@ -77,7 +75,6 @@ Try it with Docker ~
|
||||
|
||||
Install the LazyVim Starter ~
|
||||
|
||||
|
||||
- Make a backup of your current Neovim files:
|
||||
>sh
|
||||
mv ~/.config/nvim ~/.config/nvim.bak
|
||||
|
@ -1,4 +1,4 @@
|
||||
-- This file is automatically loaded by plugins.init
|
||||
-- This file is automatically loaded by lazyvim.config.init
|
||||
|
||||
local function augroup(name)
|
||||
return vim.api.nvim_create_augroup("lazyvim_" .. name, { clear = true })
|
||||
@ -42,15 +42,19 @@ vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
group = augroup("close_with_q"),
|
||||
pattern = {
|
||||
"qf",
|
||||
"PlenaryTestPopup",
|
||||
"help",
|
||||
"lspinfo",
|
||||
"man",
|
||||
"notify",
|
||||
"lspinfo",
|
||||
"qf",
|
||||
"spectre_panel",
|
||||
"startuptime",
|
||||
"tsplayground",
|
||||
"PlenaryTestPopup",
|
||||
"neotest-output",
|
||||
"checkhealth",
|
||||
"neotest-summary",
|
||||
"neotest-output-panel",
|
||||
},
|
||||
callback = function(event)
|
||||
vim.bo[event.buf].buflisted = false
|
||||
@ -67,3 +71,15 @@ vim.api.nvim_create_autocmd("FileType", {
|
||||
vim.opt_local.spell = true
|
||||
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
|
||||
return
|
||||
end
|
||||
local file = vim.loop.fs_realpath(event.match) or event.match
|
||||
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
|
||||
end,
|
||||
})
|
||||
|
@ -14,14 +14,22 @@ local defaults = {
|
||||
defaults = {
|
||||
autocmds = true, -- lazyvim.config.autocmds
|
||||
keymaps = true, -- lazyvim.config.keymaps
|
||||
options = true, -- lazyvim.config.options
|
||||
-- lazyvim.config.options can't be configured here since that's loaded before lazyvim setup
|
||||
-- if you want to disable loading options, add `package.loaded["lazyvim.config.options"] = true` to the top of your init.lua
|
||||
},
|
||||
-- icons used by other plugins
|
||||
icons = {
|
||||
dap = {
|
||||
Stopped = { " ", "DiagnosticWarn", "DapStoppedLine" },
|
||||
Breakpoint = " ",
|
||||
BreakpointCondition = " ",
|
||||
BreakpointRejected = { " ", "DiagnosticError" },
|
||||
LogPoint = ".>",
|
||||
},
|
||||
diagnostics = {
|
||||
Error = " ",
|
||||
Warn = " ",
|
||||
Hint = " ",
|
||||
Hint = " ",
|
||||
Info = " ",
|
||||
},
|
||||
git = {
|
||||
@ -42,7 +50,7 @@ local defaults = {
|
||||
Event = " ",
|
||||
Field = " ",
|
||||
File = " ",
|
||||
Folder = " ",
|
||||
Folder = " ",
|
||||
Function = " ",
|
||||
Interface = " ",
|
||||
Key = " ",
|
||||
@ -50,7 +58,7 @@ local defaults = {
|
||||
Method = " ",
|
||||
Module = " ",
|
||||
Namespace = " ",
|
||||
Null = "ﳠ ",
|
||||
Null = " ",
|
||||
Number = " ",
|
||||
Object = " ",
|
||||
Operator = " ",
|
||||
@ -69,6 +77,10 @@ local defaults = {
|
||||
},
|
||||
}
|
||||
|
||||
M.renames = {
|
||||
["windwp/nvim-spectre"] = "nvim-pack/nvim-spectre",
|
||||
}
|
||||
|
||||
---@type LazyVimConfig
|
||||
local options
|
||||
|
||||
@ -132,15 +144,16 @@ function M.load(name)
|
||||
end, {
|
||||
msg = "Failed loading " .. mod,
|
||||
on_error = function(msg)
|
||||
local modpath = require("lazy.core.cache").find(mod)
|
||||
if modpath then
|
||||
Util.error(msg)
|
||||
local info = require("lazy.core.cache").find(mod)
|
||||
if info == nil or (type(info) == "table" and #info == 0) then
|
||||
return
|
||||
end
|
||||
Util.error(msg)
|
||||
end,
|
||||
})
|
||||
end
|
||||
-- always load lazyvim, then user file
|
||||
if M.defaults[name] then
|
||||
if M.defaults[name] or name == "options" then
|
||||
_load("lazyvim.config." .. name)
|
||||
end
|
||||
_load("config." .. name)
|
||||
@ -148,6 +161,8 @@ function M.load(name)
|
||||
-- HACK: LazyVim may have overwritten options of the Lazy ui, so reset this here
|
||||
vim.cmd([[do VimResized]])
|
||||
end
|
||||
local pattern = "LazyVim" .. name:sub(1, 1):upper() .. name:sub(2)
|
||||
vim.api.nvim_exec_autocmds("User", { pattern = pattern, modeline = false })
|
||||
end
|
||||
|
||||
M.did_init = false
|
||||
@ -161,6 +176,14 @@ function M.init()
|
||||
-- this is needed to make sure options will be correctly applied
|
||||
-- after installing missing plugins
|
||||
require("lazyvim.config").load("options")
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
local add = Plugin.Spec.add
|
||||
Plugin.Spec.add = function(self, plugin, ...)
|
||||
if type(plugin) == "table" and M.renames[plugin[1]] then
|
||||
plugin[1] = M.renames[plugin[1]]
|
||||
end
|
||||
return add(self, plugin, ...)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -1,5 +1,4 @@
|
||||
-- This file is automatically loaded by lazyvim.plugins.config
|
||||
|
||||
-- This file is automatically loaded by lazyvim.config.init
|
||||
local Util = require("lazyvim.util")
|
||||
|
||||
local function map(mode, lhs, rhs, opts)
|
||||
@ -9,6 +8,9 @@ local function map(mode, lhs, rhs, opts)
|
||||
if not keys.active[keys.parse({ lhs, mode = mode }).id] then
|
||||
opts = opts or {}
|
||||
opts.silent = opts.silent ~= false
|
||||
if opts.remap and not vim.g.vscode then
|
||||
opts.remap = nil
|
||||
end
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
@ -18,10 +20,10 @@ map("n", "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||
map("n", "k", "v:count == 0 ? 'gk' : 'k'", { expr = true, silent = true })
|
||||
|
||||
-- Move to window using the <ctrl> hjkl keys
|
||||
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window" })
|
||||
map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window" })
|
||||
map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window" })
|
||||
map("n", "<C-l>", "<C-w>l", { desc = "Go to right window" })
|
||||
map("n", "<C-h>", "<C-w>h", { desc = "Go to left window", remap = true })
|
||||
map("n", "<C-j>", "<C-w>j", { desc = "Go to lower window", remap = true })
|
||||
map("n", "<C-k>", "<C-w>k", { desc = "Go to upper window", remap = true })
|
||||
map("n", "<C-l>", "<C-w>l", { desc = "Go to right window", remap = true })
|
||||
|
||||
-- Resize window using <ctrl> arrow keys
|
||||
map("n", "<C-Up>", "<cmd>resize +2<cr>", { desc = "Increase window height" })
|
||||
@ -112,8 +114,8 @@ local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3
|
||||
map("n", "<leader>uc", function() Util.toggle("conceallevel", false, {0, conceallevel}) end, { desc = "Toggle Conceal" })
|
||||
|
||||
-- lazygit
|
||||
map("n", "<leader>gg", function() Util.float_term({ "lazygit" }, { cwd = Util.get_root() }) end, { desc = "Lazygit (root dir)" })
|
||||
map("n", "<leader>gG", function() Util.float_term({ "lazygit" }) end, { desc = "Lazygit (cwd)" })
|
||||
map("n", "<leader>gg", function() Util.float_term({ "lazygit" }, { cwd = Util.get_root(), esc_esc = false }) end, { desc = "Lazygit (root dir)" })
|
||||
map("n", "<leader>gG", function() Util.float_term({ "lazygit" }, {esc_esc = false}) end, { desc = "Lazygit (cwd)" })
|
||||
|
||||
-- quit
|
||||
map("n", "<leader>qq", "<cmd>qa<cr>", { desc = "Quit all" })
|
||||
@ -124,17 +126,26 @@ if vim.fn.has("nvim-0.9.0") == 1 then
|
||||
end
|
||||
|
||||
-- floating terminal
|
||||
map("n", "<leader>ft", function() Util.float_term(nil, { cwd = Util.get_root() }) end, { desc = "Terminal (root dir)" })
|
||||
local lazyterm = function() Util.float_term(nil, { cwd = Util.get_root() }) end
|
||||
map("n", "<leader>ft", lazyterm, { desc = "Terminal (root dir)" })
|
||||
map("n", "<leader>fT", function() Util.float_term() end, { desc = "Terminal (cwd)" })
|
||||
map("t", "<esc><esc>", "<c-\\><c-n>", {desc = "Enter Normal Mode"})
|
||||
map("n", "<c-/>", lazyterm, { desc = "Terminal (root dir)" })
|
||||
|
||||
-- Terminal Mappings
|
||||
map("t", "<esc><esc>", "<c-\\><c-n>", { desc = "Enter Normal Mode" })
|
||||
map("t", "<C-h>", "<cmd>wincmd h<cr>", { desc = "Go to left window"})
|
||||
map("t", "<C-j>", "<cmd>wincmd j<cr>", { desc = "Go to lower window"})
|
||||
map("t", "<C-k>", "<cmd>wincmd k<cr>", { desc = "Go to upper window"})
|
||||
map("t", "<C-l>", "<cmd>wincmd l<cr>", { desc = "Go to right window"})
|
||||
map("t", '<C-/>', "<cmd>close<cr>", {desc = "Hide Terminal"})
|
||||
|
||||
-- windows
|
||||
map("n", "<leader>ww", "<C-W>p", { desc = "Other window" })
|
||||
map("n", "<leader>wd", "<C-W>c", { desc = "Delete window" })
|
||||
map("n", "<leader>w-", "<C-W>s", { desc = "Split window below" })
|
||||
map("n", "<leader>w|", "<C-W>v", { desc = "Split window right" })
|
||||
map("n", "<leader>-", "<C-W>s", { desc = "Split window below" })
|
||||
map("n", "<leader>|", "<C-W>v", { desc = "Split window right" })
|
||||
map("n", "<leader>ww", "<C-W>p", { desc = "Other window", remap = true })
|
||||
map("n", "<leader>wd", "<C-W>c", { desc = "Delete window", remap = true })
|
||||
map("n", "<leader>w-", "<C-W>s", { desc = "Split window below", remap = true })
|
||||
map("n", "<leader>w|", "<C-W>v", { desc = "Split window right", remap = true })
|
||||
map("n", "<leader>-", "<C-W>s", { desc = "Split window below", remap = true })
|
||||
map("n", "<leader>|", "<C-W>v", { desc = "Split window right", remap = true })
|
||||
|
||||
-- tabs
|
||||
map("n", "<leader><tab>l", "<cmd>tablast<cr>", { desc = "Last Tab" })
|
||||
|
@ -1,5 +1,4 @@
|
||||
-- This file is automatically loaded by plugins.config
|
||||
|
||||
vim.g.mapleader = " "
|
||||
vim.g.maplocalleader = " "
|
||||
|
||||
@ -28,7 +27,7 @@ opt.scrolloff = 4 -- Lines of context
|
||||
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
|
||||
opt.shiftround = true -- Round indent
|
||||
opt.shiftwidth = 2 -- Size of an indent
|
||||
opt.shortmess:append { W = true, I = true, c = true }
|
||||
opt.shortmess:append({ W = true, I = true, c = true })
|
||||
opt.showmode = false -- Dont show mode since we have a statusline
|
||||
opt.sidescrolloff = 8 -- Columns of context
|
||||
opt.signcolumn = "yes" -- Always show the signcolumn, otherwise it would shift the text each time
|
||||
@ -49,7 +48,7 @@ opt.wrap = false -- Disable line wrap
|
||||
|
||||
if vim.fn.has("nvim-0.9.0") == 1 then
|
||||
opt.splitkeep = "screen"
|
||||
opt.shortmess:append { C = true }
|
||||
opt.shortmess:append({ C = true })
|
||||
end
|
||||
|
||||
-- Fix markdown indentation settings
|
||||
|
@ -1,12 +1,17 @@
|
||||
local M = {}
|
||||
|
||||
local start = vim.health.start or vim.health.report_start
|
||||
local ok = vim.health.ok or vim.health.report_ok
|
||||
local warn = vim.health.warn or vim.health.report_warn
|
||||
local error = vim.health.error or vim.health.report_error
|
||||
|
||||
function M.check()
|
||||
vim.health.report_start("LazyVim")
|
||||
start("LazyVim")
|
||||
|
||||
if vim.fn.has("nvim-0.8.0") == 1 then
|
||||
vim.health.report_ok("Using Neovim >= 0.8.0")
|
||||
ok("Using Neovim >= 0.8.0")
|
||||
else
|
||||
vim.health.report_error("Neovim >= 0.8.0 is required")
|
||||
error("Neovim >= 0.8.0 is required")
|
||||
end
|
||||
|
||||
for _, cmd in ipairs({ "git", "rg", { "fd", "fdfind" }, "lazygit" }) do
|
||||
@ -23,9 +28,9 @@ function M.check()
|
||||
end
|
||||
|
||||
if found then
|
||||
vim.health.report_ok(("`%s` is installed"):format(name))
|
||||
ok(("`%s` is installed"):format(name))
|
||||
else
|
||||
vim.health.report_warn(("`%s` is not installed"):format(name))
|
||||
warn(("`%s` is not installed"):format(name))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -3,7 +3,9 @@ return {
|
||||
-- snippets
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
build = "make install_jsregexp",
|
||||
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()
|
||||
@ -58,6 +60,10 @@ return {
|
||||
["<C-Space>"] = cmp.mapping.complete(),
|
||||
["<C-e>"] = cmp.mapping.abort(),
|
||||
["<CR>"] = cmp.mapping.confirm({ select = true }), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
["<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.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
@ -87,9 +93,7 @@ return {
|
||||
{
|
||||
"echasnovski/mini.pairs",
|
||||
event = "VeryLazy",
|
||||
config = function(_, opts)
|
||||
require("mini.pairs").setup(opts)
|
||||
end,
|
||||
opts = {},
|
||||
},
|
||||
|
||||
-- surround
|
||||
@ -124,10 +128,6 @@ return {
|
||||
update_n_lines = "gzn", -- Update `n_lines`
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
-- use gz mappings instead of s to prevent conflict with leap
|
||||
require("mini.surround").setup(opts)
|
||||
end,
|
||||
},
|
||||
|
||||
-- comments
|
||||
@ -136,15 +136,12 @@ return {
|
||||
"echasnovski/mini.comment",
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
hooks = {
|
||||
pre = function()
|
||||
require("ts_context_commentstring.internal").update_commentstring({})
|
||||
options = {
|
||||
custom_commentstring = function()
|
||||
return require("ts_context_commentstring.internal").calculate_commentstring() or vim.bo.commentstring
|
||||
end,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("mini.comment").setup(opts)
|
||||
end,
|
||||
},
|
||||
|
||||
-- better text-objects
|
||||
|
@ -12,5 +12,34 @@ return {
|
||||
"catppuccin/nvim",
|
||||
lazy = true,
|
||||
name = "catppuccin",
|
||||
opts = {
|
||||
integrations = {
|
||||
alpha = true,
|
||||
cmp = true,
|
||||
gitsigns = true,
|
||||
illuminate = true,
|
||||
indent_blankline = { enabled = true },
|
||||
lsp_trouble = true,
|
||||
mini = true,
|
||||
native_lsp = {
|
||||
enabled = true,
|
||||
underlines = {
|
||||
errors = { "undercurl" },
|
||||
hints = { "undercurl" },
|
||||
warnings = { "undercurl" },
|
||||
information = { "undercurl" },
|
||||
},
|
||||
},
|
||||
navic = { enabled = true },
|
||||
neotest = true,
|
||||
noice = true,
|
||||
notify = true,
|
||||
nvimtree = true,
|
||||
semantic_tokens = true,
|
||||
telescope = true,
|
||||
treesitter = true,
|
||||
which_key = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -2,5 +2,5 @@ require("lazyvim.config").init()
|
||||
|
||||
return {
|
||||
{ "folke/lazy.nvim", version = "*" },
|
||||
{ "LazyVim/LazyVim", priority = 10000, lazy = false, config = true, version = "*" },
|
||||
{ "LazyVim/LazyVim", priority = 10000, lazy = false, config = true, cond = true, version = "*" },
|
||||
}
|
||||
|
@ -37,21 +37,44 @@ return {
|
||||
end
|
||||
end,
|
||||
opts = {
|
||||
sources = { "filesystem", "buffers", "git_status", "document_symbols" },
|
||||
filesystem = {
|
||||
bind_to_cwd = false,
|
||||
follow_current_file = true,
|
||||
use_libuv_file_watcher = true,
|
||||
},
|
||||
window = {
|
||||
mappings = {
|
||||
["<space>"] = "none",
|
||||
},
|
||||
},
|
||||
default_component_configs = {
|
||||
indent = {
|
||||
with_expanders = true, -- if nil and file nesting is enabled, will enable expanders
|
||||
expander_collapsed = "",
|
||||
expander_expanded = "",
|
||||
expander_highlight = "NeoTreeExpander",
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("neo-tree").setup(opts)
|
||||
vim.api.nvim_create_autocmd("TermClose", {
|
||||
pattern = "*lazygit",
|
||||
callback = function()
|
||||
if package.loaded["neo-tree.sources.git_status"] then
|
||||
require("neo-tree.sources.git_status").refresh()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- search/replace in multiple files
|
||||
{
|
||||
"windwp/nvim-spectre",
|
||||
"nvim-pack/nvim-spectre",
|
||||
cmd = "Spectre",
|
||||
opts = { open_cmd = "noswapfile vnew" },
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>sr", function() require("spectre").open() end, desc = "Replace in files (Spectre)" },
|
||||
@ -61,11 +84,12 @@ return {
|
||||
-- fuzzy finder
|
||||
{
|
||||
"nvim-telescope/telescope.nvim",
|
||||
commit = vim.fn.has("nvim-0.9.0") == 0 and "057ee0f8783" or nil,
|
||||
cmd = "Telescope",
|
||||
version = false, -- telescope did only one release, so use HEAD for now
|
||||
keys = {
|
||||
{ "<leader>,", "<cmd>Telescope buffers show_all_buffers=true<cr>", desc = "Switch Buffer" },
|
||||
{ "<leader>/", Util.telescope("live_grep"), desc = "Find in Files (Grep)" },
|
||||
{ "<leader>/", Util.telescope("live_grep"), desc = "Grep (root dir)" },
|
||||
{ "<leader>:", "<cmd>Telescope command_history<cr>", desc = "Command History" },
|
||||
{ "<leader><space>", Util.telescope("files"), desc = "Find Files (root dir)" },
|
||||
-- find
|
||||
@ -73,6 +97,7 @@ return {
|
||||
{ "<leader>ff", Util.telescope("files"), desc = "Find Files (root dir)" },
|
||||
{ "<leader>fF", Util.telescope("files", { cwd = false }), desc = "Find Files (cwd)" },
|
||||
{ "<leader>fr", "<cmd>Telescope oldfiles<cr>", desc = "Recent" },
|
||||
{ "<leader>fR", Util.telescope("oldfiles", { cwd = vim.loop.cwd() }), desc = "Recent (cwd)" },
|
||||
-- git
|
||||
{ "<leader>gc", "<cmd>Telescope git_commits<CR>", desc = "commits" },
|
||||
{ "<leader>gs", "<cmd>Telescope git_status<CR>", desc = "status" },
|
||||
@ -81,7 +106,8 @@ return {
|
||||
{ "<leader>sb", "<cmd>Telescope current_buffer_fuzzy_find<cr>", desc = "Buffer" },
|
||||
{ "<leader>sc", "<cmd>Telescope command_history<cr>", desc = "Command History" },
|
||||
{ "<leader>sC", "<cmd>Telescope commands<cr>", desc = "Commands" },
|
||||
{ "<leader>sd", "<cmd>Telescope diagnostics<cr>", desc = "Diagnostics" },
|
||||
{ "<leader>sd", "<cmd>Telescope diagnostics bufnr=0<cr>", desc = "Document diagnostics" },
|
||||
{ "<leader>sD", "<cmd>Telescope diagnostics<cr>", desc = "Workspace diagnostics" },
|
||||
{ "<leader>sg", Util.telescope("live_grep"), desc = "Grep (root dir)" },
|
||||
{ "<leader>sG", Util.telescope("live_grep", { cwd = false }), desc = "Grep (cwd)" },
|
||||
{ "<leader>sh", "<cmd>Telescope help_tags<cr>", desc = "Help Pages" },
|
||||
@ -114,7 +140,7 @@ return {
|
||||
},
|
||||
{
|
||||
"<leader>sS",
|
||||
Util.telescope("lsp_workspace_symbols", {
|
||||
Util.telescope("lsp_dynamic_workspace_symbols", {
|
||||
symbols = {
|
||||
"Class",
|
||||
"Function",
|
||||
@ -144,10 +170,14 @@ return {
|
||||
return require("trouble.providers.telescope").open_selected_with_trouble(...)
|
||||
end,
|
||||
["<a-i>"] = function()
|
||||
Util.telescope("find_files", { no_ignore = true })()
|
||||
local action_state = require("telescope.actions.state")
|
||||
local line = action_state.get_current_line()
|
||||
Util.telescope("find_files", { no_ignore = true, default_text = line })()
|
||||
end,
|
||||
["<a-h>"] = function()
|
||||
Util.telescope("find_files", { hidden = true })()
|
||||
local action_state = require("telescope.actions.state")
|
||||
local line = action_state.get_current_line()
|
||||
Util.telescope("find_files", { hidden = true, default_text = line })()
|
||||
end,
|
||||
["<C-Down>"] = function(...)
|
||||
return require("telescope.actions").cycle_history_next(...)
|
||||
@ -187,7 +217,6 @@ return {
|
||||
},
|
||||
{
|
||||
"ggandor/leap.nvim",
|
||||
commit = "9a69feb",
|
||||
keys = {
|
||||
{ "s", mode = { "n", "x", "o" }, desc = "Leap forward to" },
|
||||
{ "S", mode = { "n", "x", "o" }, desc = "Leap backward to" },
|
||||
@ -210,11 +239,7 @@ return {
|
||||
event = "VeryLazy",
|
||||
opts = {
|
||||
plugins = { spelling = true },
|
||||
},
|
||||
config = function(_, opts)
|
||||
local wk = require("which-key")
|
||||
wk.setup(opts)
|
||||
local keymaps = {
|
||||
defaults = {
|
||||
mode = { "n", "v" },
|
||||
["g"] = { name = "+goto" },
|
||||
["gz"] = { name = "+surround" },
|
||||
@ -231,11 +256,12 @@ return {
|
||||
["<leader>u"] = { name = "+ui" },
|
||||
["<leader>w"] = { name = "+windows" },
|
||||
["<leader>x"] = { name = "+diagnostics/quickfix" },
|
||||
}
|
||||
if Util.has("noice.nvim") then
|
||||
keymaps["<leader>sn"] = { name = "+noice" }
|
||||
end
|
||||
wk.register(keymaps)
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
local wk = require("which-key")
|
||||
wk.setup(opts)
|
||||
wk.register(opts.defaults)
|
||||
end,
|
||||
},
|
||||
|
||||
@ -280,7 +306,13 @@ return {
|
||||
{
|
||||
"RRethy/vim-illuminate",
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
opts = { delay = 200 },
|
||||
opts = {
|
||||
delay = 200,
|
||||
large_file_cutoff = 2000,
|
||||
large_file_overrides = {
|
||||
providers = { "lsp" },
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("illuminate").configure(opts)
|
||||
|
||||
@ -366,6 +398,7 @@ return {
|
||||
{ "<leader>xt", "<cmd>TodoTrouble<cr>", desc = "Todo (Trouble)" },
|
||||
{ "<leader>xT", "<cmd>TodoTrouble keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme (Trouble)" },
|
||||
{ "<leader>st", "<cmd>TodoTelescope<cr>", desc = "Todo" },
|
||||
{ "<leader>sT", "<cmd>TodoTelescope keywords=TODO,FIX,FIXME<cr>", desc = "Todo/Fix/Fixme" },
|
||||
},
|
||||
},
|
||||
}
|
||||
|
93
lua/lazyvim/plugins/extras/coding/copilot.lua
Normal file
93
lua/lazyvim/plugins/extras/coding/copilot.lua
Normal file
@ -0,0 +1,93 @@
|
||||
return {
|
||||
|
||||
-- copilot
|
||||
{
|
||||
"zbirenbaum/copilot.lua",
|
||||
cmd = "Copilot",
|
||||
build = ":Copilot auth",
|
||||
opts = {
|
||||
suggestion = { enabled = false },
|
||||
panel = { enabled = false },
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvim-lualine/lualine.nvim",
|
||||
optional = true,
|
||||
event = "VeryLazy",
|
||||
opts = function(_, opts)
|
||||
local Util = require("lazyvim.util")
|
||||
local colors = {
|
||||
[""] = Util.fg("Special"),
|
||||
["Normal"] = Util.fg("Special"),
|
||||
["Warning"] = Util.fg("DiagnosticError"),
|
||||
["InProgress"] = Util.fg("DiagnosticWarn"),
|
||||
}
|
||||
table.insert(opts.sections.lualine_x, 2, {
|
||||
function()
|
||||
local icon = require("lazyvim.config").icons.kinds.Copilot
|
||||
local status = require("copilot.api").status.data
|
||||
return icon .. (status.message or "")
|
||||
end,
|
||||
cond = function()
|
||||
local ok, clients = pcall(vim.lsp.get_active_clients, { name = "copilot", bufnr = 0 })
|
||||
return ok and #clients > 0
|
||||
end,
|
||||
color = function()
|
||||
if not package.loaded["copilot"] then
|
||||
return
|
||||
end
|
||||
local status = require("copilot.api").status.data
|
||||
return colors[status.status] or colors[""]
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- copilot cmp source
|
||||
{
|
||||
"nvim-cmp",
|
||||
dependencies = {
|
||||
{
|
||||
"zbirenbaum/copilot-cmp",
|
||||
dependencies = "copilot.lua",
|
||||
opts = {},
|
||||
config = function(_, opts)
|
||||
local copilot_cmp = require("copilot_cmp")
|
||||
copilot_cmp.setup(opts)
|
||||
-- attach cmp source whenever copilot attaches
|
||||
-- fixes lazy-loading issues with the copilot cmp source
|
||||
require("lazyvim.util").on_attach(function(client)
|
||||
if client.name == "copilot" then
|
||||
copilot_cmp._on_insert_enter({})
|
||||
end
|
||||
end)
|
||||
end,
|
||||
},
|
||||
},
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
local cmp = require("cmp")
|
||||
|
||||
table.insert(opts.sources, 1, { name = "copilot", group_index = 2 })
|
||||
|
||||
opts.sorting = {
|
||||
priority_weight = 2,
|
||||
comparators = {
|
||||
require("copilot_cmp.comparators").prioritize,
|
||||
|
||||
-- Below is the default comparitor list and order for nvim-cmp
|
||||
cmp.config.compare.offset,
|
||||
-- cmp.config.compare.scopes, --this is commented in nvim-cmp too
|
||||
cmp.config.compare.exact,
|
||||
cmp.config.compare.score,
|
||||
cmp.config.compare.recently_used,
|
||||
cmp.config.compare.locality,
|
||||
cmp.config.compare.kind,
|
||||
cmp.config.compare.sort_text,
|
||||
cmp.config.compare.length,
|
||||
cmp.config.compare.order,
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
}
|
104
lua/lazyvim/plugins/extras/dap/core.lua
Normal file
104
lua/lazyvim/plugins/extras/dap/core.lua
Normal file
@ -0,0 +1,104 @@
|
||||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
|
||||
dependencies = {
|
||||
|
||||
-- fancy UI for the debugger
|
||||
{
|
||||
"rcarriga/nvim-dap-ui",
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>du", function() require("dapui").toggle({ }) end, desc = "Dap UI" },
|
||||
{ "<leader>de", function() require("dapui").eval() end, desc = "Eval", mode = {"n", "v"} },
|
||||
},
|
||||
opts = {},
|
||||
config = function(_, opts)
|
||||
local dap = require("dap")
|
||||
local dapui = require("dapui")
|
||||
dapui.setup(opts)
|
||||
dap.listeners.after.event_initialized["dapui_config"] = function()
|
||||
dapui.open({})
|
||||
end
|
||||
dap.listeners.before.event_terminated["dapui_config"] = function()
|
||||
dapui.close({})
|
||||
end
|
||||
dap.listeners.before.event_exited["dapui_config"] = function()
|
||||
dapui.close({})
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
-- virtual text for the debugger
|
||||
{
|
||||
"theHamsta/nvim-dap-virtual-text",
|
||||
opts = {},
|
||||
},
|
||||
|
||||
-- which key integration
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
defaults = {
|
||||
["<leader>d"] = { name = "+debug" },
|
||||
["<leader>da"] = { name = "+adapters" },
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- mason.nvim integration
|
||||
{
|
||||
"jay-babu/mason-nvim-dap.nvim",
|
||||
dependencies = "mason.nvim",
|
||||
cmd = { "DapInstall", "DapUninstall" },
|
||||
opts = {
|
||||
-- Makes a best effort to setup the various debuggers with
|
||||
-- reasonable debug configurations
|
||||
automatic_installation = true,
|
||||
|
||||
-- You can provide additional configuration to the handlers,
|
||||
-- see mason-nvim-dap README for more information
|
||||
handlers = {},
|
||||
|
||||
-- You'll need to check that you have the required things installed
|
||||
-- online, please don't ask me how to install them :)
|
||||
ensure_installed = {
|
||||
-- Update this to ensure that you have the debuggers for the langs you want
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>dB", function() require("dap").set_breakpoint(vim.fn.input('Breakpoint condition: ')) end, desc = "Breakpoint Condition" },
|
||||
{ "<leader>db", function() require("dap").toggle_breakpoint() end, desc = "Toggle Breakpoint" },
|
||||
{ "<leader>dc", function() require("dap").continue() end, desc = "Continue" },
|
||||
{ "<leader>dC", function() require("dap").run_to_cursor() end, desc = "Run to Cursor" },
|
||||
{ "<leader>dg", function() require("dap").goto_() end, desc = "Go to line (no execute)" },
|
||||
{ "<leader>di", function() require("dap").step_into() end, desc = "Step Into" },
|
||||
{ "<leader>dj", function() require("dap").down() end, desc = "Down" },
|
||||
{ "<leader>dk", function() require("dap").up() end, desc = "Up" },
|
||||
{ "<leader>dl", function() require("dap").run_last() end, desc = "Run Last" },
|
||||
{ "<leader>do", function() require("dap").step_out() end, desc = "Step Out" },
|
||||
{ "<leader>dO", function() require("dap").step_over() end, desc = "Step Over" },
|
||||
{ "<leader>dp", function() require("dap").pause() end, desc = "Pause" },
|
||||
{ "<leader>dr", function() require("dap").repl.toggle() end, desc = "Toggle REPL" },
|
||||
{ "<leader>ds", function() require("dap").session() end, desc = "Session" },
|
||||
{ "<leader>dt", function() require("dap").terminate() end, desc = "Terminate" },
|
||||
{ "<leader>dw", function() require("dap.ui.widgets").hover() end, desc = "Widgets" },
|
||||
},
|
||||
|
||||
config = function()
|
||||
local Config = require("lazyvim.config")
|
||||
vim.api.nvim_set_hl(0, "DapStoppedLine", { default = true, link = "Visual" })
|
||||
|
||||
for name, sign in pairs(Config.icons.dap) do
|
||||
sign = type(sign) == "table" and sign or { sign }
|
||||
vim.fn.sign_define(
|
||||
"Dap" .. name,
|
||||
{ text = sign[1], texthl = sign[2] or "DiagnosticInfo", linehl = sign[3], numhl = sign[3] }
|
||||
)
|
||||
end
|
||||
end,
|
||||
}
|
27
lua/lazyvim/plugins/extras/dap/nlua.lua
Normal file
27
lua/lazyvim/plugins/extras/dap/nlua.lua
Normal file
@ -0,0 +1,27 @@
|
||||
return {
|
||||
"mfussenegger/nvim-dap",
|
||||
|
||||
dependencies = {
|
||||
{
|
||||
"jbyuki/one-small-step-for-vimkind",
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>daL", function() require("osv").launch({ port = 8086 }) end, desc = "Adapter Lua Server" },
|
||||
{ "<leader>dal", function() require("osv").run_this() end, desc = "Adapter Lua" },
|
||||
},
|
||||
config = function()
|
||||
local dap = require("dap")
|
||||
dap.adapters.nlua = function(callback, config)
|
||||
callback({ type = "server", host = config.host or "127.0.0.1", port = config.port or 8086 })
|
||||
end
|
||||
dap.configurations.lua = {
|
||||
{
|
||||
type = "nlua",
|
||||
request = "attach",
|
||||
name = "Attach to running Neovim instance",
|
||||
},
|
||||
}
|
||||
end,
|
||||
},
|
||||
},
|
||||
}
|
15
lua/lazyvim/plugins/extras/formatting/prettier.lua
Normal file
15
lua/lazyvim/plugins/extras/formatting/prettier.lua
Normal file
@ -0,0 +1,15 @@
|
||||
return {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.ensure_installed, "prettierd")
|
||||
end,
|
||||
},
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
opts = function(_, opts)
|
||||
local nls = require("null-ls")
|
||||
table.insert(opts.sources, nls.builtins.formatting.prettierd)
|
||||
end,
|
||||
},
|
||||
}
|
77
lua/lazyvim/plugins/extras/lang/go.lua
Normal file
77
lua/lazyvim/plugins/extras/lang/go.lua
Normal file
@ -0,0 +1,77 @@
|
||||
return {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
vim.list_extend(opts.ensure_installed, {
|
||||
"go",
|
||||
"gomod",
|
||||
"gowork",
|
||||
"gosum",
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
gopls = {
|
||||
settings = {
|
||||
gopls = {
|
||||
semanticTokens = true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
setup = {
|
||||
gopls = function()
|
||||
-- workaround for gopls not supporting semantictokensprovider
|
||||
-- https://github.com/golang/go/issues/54531#issuecomment-1464982242
|
||||
require("lazyvim.util").on_attach(function(client, _)
|
||||
if client.name == "gopls" then
|
||||
if not client.server_capabilities.semanticTokensProvider then
|
||||
local semantic = client.config.capabilities.textDocument.semanticTokens
|
||||
client.server_capabilities.semanticTokensProvider = {
|
||||
full = true,
|
||||
legend = {
|
||||
tokenTypes = semantic.tokenTypes,
|
||||
tokenModifiers = semantic.tokenModifiers,
|
||||
},
|
||||
range = true,
|
||||
}
|
||||
end
|
||||
end
|
||||
end)
|
||||
-- end workaround
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"mason.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
table.insert(opts.ensure_installed, "delve")
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
"nvim-neotest/neotest-go",
|
||||
},
|
||||
opts = {
|
||||
adapters = {
|
||||
["neotest-go"] = {
|
||||
-- Here we can set options for neotest-go, e.g.
|
||||
-- args = { "-tags=integration" }
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
35
lua/lazyvim/plugins/extras/lang/tailwind.lua
Normal file
35
lua/lazyvim/plugins/extras/lang/tailwind.lua
Normal file
@ -0,0 +1,35 @@
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
opts = {
|
||||
servers = {
|
||||
tailwindcss = {
|
||||
filetypes_exclude = { "markdown" },
|
||||
},
|
||||
},
|
||||
setup = {
|
||||
tailwindcss = function(_, opts)
|
||||
local tw = require("lspconfig.server_configurations.tailwindcss")
|
||||
--- @param ft string
|
||||
opts.filetypes = vim.tbl_filter(function(ft)
|
||||
return not vim.tbl_contains(opts.filetypes_exclude or {}, ft)
|
||||
end, tw.default_config.filetypes)
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"hrsh7th/nvim-cmp",
|
||||
dependencies = {
|
||||
{ "roobert/tailwindcss-colorizer-cmp.nvim", config = true },
|
||||
},
|
||||
opts = function(_, opts)
|
||||
-- original LazyVim kind icon formatter
|
||||
local format_kinds = opts.formatting.format
|
||||
opts.formatting.format = function(entry, item)
|
||||
format_kinds(entry, item) -- add icons
|
||||
return require("tailwindcss-colorizer-cmp").formatter(entry, item)
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
@ -17,7 +17,28 @@ return {
|
||||
opts = {
|
||||
-- make sure mason installs the server
|
||||
servers = {
|
||||
tsserver = {},
|
||||
---@type lspconfig.options.tsserver
|
||||
tsserver = {
|
||||
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,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
setup = {
|
||||
tsserver = function(_, opts)
|
||||
@ -25,6 +46,7 @@ return {
|
||||
if client.name == "tsserver" then
|
||||
-- stylua: ignore
|
||||
vim.keymap.set("n", "<leader>co", "<cmd>TypescriptOrganizeImports<CR>", { buffer = buffer, desc = "Organize Imports" })
|
||||
-- stylua: ignore
|
||||
vim.keymap.set("n", "<leader>cR", "<cmd>TypescriptRenameFile<CR>", { desc = "Rename File", buffer = buffer })
|
||||
end
|
||||
end)
|
||||
@ -34,4 +56,62 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"jose-elias-alvarez/null-ls.nvim",
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, require("typescript.extensions.null-ls.code-actions"))
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
optional = true,
|
||||
dependencies = {
|
||||
{
|
||||
"williamboman/mason.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
table.insert(opts.ensure_installed, "js-debug-adapter")
|
||||
end,
|
||||
},
|
||||
},
|
||||
opts = function()
|
||||
local dap = require("dap")
|
||||
if not dap.adapters["pwa-node"] then
|
||||
require("dap").adapters["pwa-node"] = {
|
||||
type = "server",
|
||||
host = "localhost",
|
||||
port = "${port}",
|
||||
executable = {
|
||||
command = "node",
|
||||
-- 💀 Make sure to update this path to point to your installation
|
||||
args = {
|
||||
require("mason-registry").get_package("js-debug-adapter"):get_install_path()
|
||||
.. "/js-debug/src/dapDebugServer.js",
|
||||
"${port}",
|
||||
},
|
||||
},
|
||||
}
|
||||
end
|
||||
for _, language in ipairs({ "typescript", "javascript" }) do
|
||||
if not dap.configurations[language] then
|
||||
dap.configurations[language] = {
|
||||
{
|
||||
type = "pwa-node",
|
||||
request = "launch",
|
||||
name = "Launch file",
|
||||
program = "${file}",
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
{
|
||||
type = "pwa-node",
|
||||
request = "attach",
|
||||
name = "Attach",
|
||||
processId = require("dap.utils").pick_process,
|
||||
cwd = "${workspaceFolder}",
|
||||
},
|
||||
}
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
32
lua/lazyvim/plugins/extras/linting/eslint.lua
Normal file
32
lua/lazyvim/plugins/extras/linting/eslint.lua
Normal file
@ -0,0 +1,32 @@
|
||||
return {
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
-- other settings removed for brevity
|
||||
opts = {
|
||||
---@type lspconfig.options
|
||||
servers = {
|
||||
eslint = {
|
||||
settings = {
|
||||
-- helps eslint find the eslintrc when it's placed in a subfolder instead of the cwd root
|
||||
workingDirectory = { mode = "auto" },
|
||||
},
|
||||
},
|
||||
},
|
||||
setup = {
|
||||
eslint = function()
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
callback = function(event)
|
||||
local client = vim.lsp.get_active_clients({ bufnr = event.buf, name = "eslint" })[1]
|
||||
if client then
|
||||
local diag = vim.diagnostic.get(event.buf, { namespace = vim.lsp.diagnostic.get_namespace(client.id) })
|
||||
if #diag > 0 then
|
||||
vim.cmd("EslintFixAll")
|
||||
end
|
||||
end
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
96
lua/lazyvim/plugins/extras/test/core.lua
Normal file
96
lua/lazyvim/plugins/extras/test/core.lua
Normal file
@ -0,0 +1,96 @@
|
||||
return {
|
||||
{
|
||||
"folke/which-key.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
defaults = {
|
||||
["<leader>t"] = { name = "+test" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvim-neotest/neotest",
|
||||
opts = {
|
||||
-- Can be a list of adapters like what neotest expects,
|
||||
-- or a list of adapter names,
|
||||
-- or a table of adapter names, mapped to adapter configs.
|
||||
-- The adapter will then be automatically loaded with the config.
|
||||
adapters = {},
|
||||
-- Example for loading neotest-go with a custom config
|
||||
-- adapters = {
|
||||
-- ["neotest-go"] = {
|
||||
-- args = { "-tags=integration" },
|
||||
-- },
|
||||
-- },
|
||||
status = { virtual_text = true },
|
||||
output = { open_on_run = true },
|
||||
quickfix = {
|
||||
open = function()
|
||||
if require("lazyvim.util").has("trouble.nvim") then
|
||||
vim.cmd("Trouble quickfix")
|
||||
else
|
||||
vim.cmd("copen")
|
||||
end
|
||||
end,
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
local neotest_ns = vim.api.nvim_create_namespace("neotest")
|
||||
vim.diagnostic.config({
|
||||
virtual_text = {
|
||||
format = function(diagnostic)
|
||||
-- Replace newline and tab characters with space for more compact diagnostics
|
||||
local message = diagnostic.message:gsub("\n", " "):gsub("\t", " "):gsub("%s+", " "):gsub("^%s+", "")
|
||||
return message
|
||||
end,
|
||||
},
|
||||
}, neotest_ns)
|
||||
|
||||
if opts.adapters then
|
||||
local adapters = {}
|
||||
for name, config in pairs(opts.adapters or {}) do
|
||||
if type(name) == "number" then
|
||||
if type(config) == "string" then
|
||||
config = require(config)
|
||||
end
|
||||
adapters[#adapters + 1] = config
|
||||
elseif config ~= false then
|
||||
local adapter = require(name)
|
||||
if type(config) == "table" and not vim.tbl_isempty(config) then
|
||||
local meta = getmetatable(adapter)
|
||||
if adapter.setup then
|
||||
adapter.setup(config)
|
||||
elseif meta and meta.__call then
|
||||
adapter(config)
|
||||
else
|
||||
error("Adapter " .. name .. " does not support setup")
|
||||
end
|
||||
end
|
||||
adapters[#adapters + 1] = adapter
|
||||
end
|
||||
end
|
||||
opts.adapters = adapters
|
||||
end
|
||||
|
||||
require("neotest").setup(opts)
|
||||
end,
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>tt", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
|
||||
{ "<leader>tT", function() require("neotest").run.run(vim.loop.cwd()) end, desc = "Run All Test Files" },
|
||||
{ "<leader>tr", function() require("neotest").run.run() end, desc = "Run Nearest" },
|
||||
{ "<leader>ts", function() require("neotest").summary.toggle() end, desc = "Toggle Summary" },
|
||||
{ "<leader>to", function() require("neotest").output.open({ enter = true, auto_close = true }) end, desc = "Show Output" },
|
||||
{ "<leader>tO", function() require("neotest").output_panel.toggle() end, desc = "Toggle Output Panel" },
|
||||
{ "<leader>tS", function() require("neotest").run.stop() end, desc = "Stop" },
|
||||
},
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
optional = true,
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
{ "<leader>td", function() require("neotest").run.run({strategy = "dap"}) end, desc = "Debug Nearest" },
|
||||
},
|
||||
},
|
||||
}
|
@ -33,8 +33,5 @@ return {
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
require("mini.animate").setup(opts)
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
@ -10,12 +10,12 @@ return {
|
||||
event = "VimEnter",
|
||||
opts = function()
|
||||
local logo = table.concat({
|
||||
"██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z",
|
||||
"██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z",
|
||||
"██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z",
|
||||
"██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z",
|
||||
"███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║",
|
||||
"╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝",
|
||||
" ██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z",
|
||||
" ██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z ",
|
||||
" ██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z ",
|
||||
" ██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z ",
|
||||
" ███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║ ",
|
||||
" ╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝ ",
|
||||
}, "\n")
|
||||
local pad = string.rep(" ", 22)
|
||||
local new_section = function(name, action, section)
|
||||
@ -35,6 +35,7 @@ return {
|
||||
new_section("Lazy", "Lazy", "Config"),
|
||||
new_section("New file", "ene | startinsert", "Built-in"),
|
||||
new_section("Quit", "qa", "Built-in"),
|
||||
new_section("Session restore", [[lua require("persistence").load()]], "Session"),
|
||||
},
|
||||
content_hooks = {
|
||||
starter.gen_hook.adding_bullet(pad .. "░ ", false),
|
||||
|
387
lua/lazyvim/plugins/extras/util/mini-hipatterns.lua
Normal file
387
lua/lazyvim/plugins/extras/util/mini-hipatterns.lua
Normal file
File diff suppressed because it is too large
Load Diff
45
lua/lazyvim/plugins/extras/util/project.lua
Normal file
45
lua/lazyvim/plugins/extras/util/project.lua
Normal file
@ -0,0 +1,45 @@
|
||||
return {
|
||||
{
|
||||
"telescope.nvim",
|
||||
dependencies = {
|
||||
-- project management
|
||||
{
|
||||
"ahmedkhalf/project.nvim",
|
||||
opts = {},
|
||||
event = "VeryLazy",
|
||||
config = function(_, opts)
|
||||
require("project_nvim").setup(opts)
|
||||
require("telescope").load_extension("projects")
|
||||
end,
|
||||
keys = {
|
||||
{ "<leader>fp", "<Cmd>Telescope projects<CR>", desc = "Projects" },
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"goolord/alpha-nvim",
|
||||
optional = true,
|
||||
opts = function(_, dashboard)
|
||||
local button = dashboard.button("p", " " .. " Projects", ":Telescope projects <CR>")
|
||||
button.opts.hl = "AlphaButtons"
|
||||
button.opts.hl_shortcut = "AlphaShortcut"
|
||||
table.insert(dashboard.section.buttons.val, 4, button)
|
||||
end,
|
||||
},
|
||||
{
|
||||
"echasnovski/mini.starter",
|
||||
optional = true,
|
||||
opts = function(_, opts)
|
||||
local items = {
|
||||
{
|
||||
name = "Projects",
|
||||
action = "Telescope projects",
|
||||
section = string.rep(" ", 22) .. "Telescope",
|
||||
},
|
||||
}
|
||||
vim.list_extend(opts.items, items)
|
||||
end,
|
||||
},
|
||||
}
|
67
lua/lazyvim/plugins/extras/vscode.lua
Normal file
67
lua/lazyvim/plugins/extras/vscode.lua
Normal file
@ -0,0 +1,67 @@
|
||||
if not vim.g.vscode then
|
||||
return {}
|
||||
end
|
||||
|
||||
local enabled = {
|
||||
"flit.nvim",
|
||||
"lazy.nvim",
|
||||
"leap.nvim",
|
||||
"mini.ai",
|
||||
"mini.comment",
|
||||
"mini.pairs",
|
||||
"mini.surround",
|
||||
"nvim-treesitter",
|
||||
"nvim-treesitter-textobjects",
|
||||
"nvim-ts-context-commentstring",
|
||||
"vim-repeat",
|
||||
"LazyVim",
|
||||
}
|
||||
|
||||
local Config = require("lazy.core.config")
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
Config.options.checker.enabled = false
|
||||
Config.options.change_detection.enabled = false
|
||||
|
||||
-- HACK: disable all plugins except the ones we want
|
||||
local fix_disabled = Plugin.Spec.fix_disabled
|
||||
function Plugin.Spec.fix_disabled(self)
|
||||
for _, plugin in pairs(self.plugins) do
|
||||
if not (vim.tbl_contains(enabled, plugin.name) or plugin.vscode) then
|
||||
plugin.enabled = false
|
||||
end
|
||||
end
|
||||
fix_disabled(self)
|
||||
end
|
||||
|
||||
-- HACK: don't clean plugins in vscode
|
||||
local update_state = Plugin.update_state
|
||||
function Plugin.update_state()
|
||||
update_state()
|
||||
Config.to_clean = {}
|
||||
end
|
||||
|
||||
-- Add some vscode specific keymaps
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "LazyVimKeymaps",
|
||||
callback = function()
|
||||
vim.keymap.set("n", "<leader><space>", "<cmd>Find<cr>")
|
||||
vim.keymap.set("n", "<leader>/", [[<cmd>call VSCodeNotify('workbench.action.findInFiles')<cr>]])
|
||||
vim.keymap.set("n", "<leader>ss", [[<cmd>call VSCodeNotify('workbench.action.gotoSymbol')<cr>]])
|
||||
end,
|
||||
})
|
||||
|
||||
return {
|
||||
{
|
||||
"LazyVim/LazyVim",
|
||||
config = function(_, opts)
|
||||
opts = opts or {}
|
||||
-- disable the colorscheme
|
||||
opts.colorscheme = function() end
|
||||
require("lazyvim").setup(opts)
|
||||
end,
|
||||
},
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = { highlight = { enable = false } },
|
||||
},
|
||||
}
|
@ -2,62 +2,147 @@ local Util = require("lazy.core.util")
|
||||
|
||||
local M = {}
|
||||
|
||||
M.autoformat = true
|
||||
---@type PluginLspOpts
|
||||
M.opts = nil
|
||||
|
||||
function M.toggle()
|
||||
if vim.b.autoformat == false then
|
||||
vim.b.autoformat = nil
|
||||
M.autoformat = true
|
||||
M.opts.autoformat = true
|
||||
else
|
||||
M.autoformat = not M.autoformat
|
||||
M.opts.autoformat = not M.opts.autoformat
|
||||
end
|
||||
if M.autoformat then
|
||||
if M.opts.autoformat then
|
||||
Util.info("Enabled format on save", { title = "Format" })
|
||||
else
|
||||
Util.warn("Disabled format on save", { title = "Format" })
|
||||
end
|
||||
end
|
||||
|
||||
function M.format()
|
||||
---@param opts? {force?:boolean}
|
||||
function M.format(opts)
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
if vim.b.autoformat == false then
|
||||
if vim.b.autoformat == false and not (opts and opts.force) then
|
||||
return
|
||||
end
|
||||
local ft = vim.bo[buf].filetype
|
||||
local have_nls = #require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") > 0
|
||||
|
||||
local formatters = M.get_formatters(buf)
|
||||
local client_ids = vim.tbl_map(function(client)
|
||||
return client.id
|
||||
end, formatters.active)
|
||||
|
||||
if #client_ids == 0 then
|
||||
return
|
||||
end
|
||||
|
||||
if M.opts.format_notify then
|
||||
M.notify(formatters)
|
||||
end
|
||||
|
||||
vim.lsp.buf.format(vim.tbl_deep_extend("force", {
|
||||
bufnr = buf,
|
||||
filter = function(client)
|
||||
if have_nls then
|
||||
return client.name == "null-ls"
|
||||
end
|
||||
return client.name ~= "null-ls"
|
||||
return vim.tbl_contains(client_ids, client.id)
|
||||
end,
|
||||
}, require("lazyvim.util").opts("nvim-lspconfig").format or {}))
|
||||
end
|
||||
|
||||
function M.on_attach(client, buf)
|
||||
-- dont format if client disabled it
|
||||
---@param formatters LazyVimFormatters
|
||||
function M.notify(formatters)
|
||||
local lines = { "# Active:" }
|
||||
|
||||
for _, client in ipairs(formatters.active) do
|
||||
local line = "- **" .. client.name .. "**"
|
||||
if client.name == "null-ls" then
|
||||
line = line
|
||||
.. " ("
|
||||
.. table.concat(
|
||||
vim.tbl_map(function(f)
|
||||
return "`" .. f.name .. "`"
|
||||
end, formatters.null_ls),
|
||||
", "
|
||||
)
|
||||
.. ")"
|
||||
end
|
||||
table.insert(lines, line)
|
||||
end
|
||||
|
||||
if #formatters.available > 0 then
|
||||
table.insert(lines, "")
|
||||
table.insert(lines, "# Disabled:")
|
||||
for _, client in ipairs(formatters.available) do
|
||||
table.insert(lines, "- **" .. client.name .. "**")
|
||||
end
|
||||
end
|
||||
|
||||
vim.notify(table.concat(lines, "\n"), vim.log.levels.INFO, {
|
||||
title = "Formatting",
|
||||
on_open = function(win)
|
||||
vim.api.nvim_win_set_option(win, "conceallevel", 3)
|
||||
vim.api.nvim_win_set_option(win, "spell", false)
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
vim.treesitter.start(buf, "markdown")
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
-- Gets all lsp clients that support formatting.
|
||||
-- When a null-ls formatter is available for the current filetype,
|
||||
-- only null-ls formatters are returned.
|
||||
function M.get_formatters(bufnr)
|
||||
local ft = vim.bo[bufnr].filetype
|
||||
-- check if we have any null-ls formatters for the current filetype
|
||||
local null_ls = package.loaded["null-ls"] and require("null-ls.sources").get_available(ft, "NULL_LS_FORMATTING") or {}
|
||||
|
||||
---@class LazyVimFormatters
|
||||
local ret = {
|
||||
---@type lsp.Client[]
|
||||
active = {},
|
||||
---@type lsp.Client[]
|
||||
available = {},
|
||||
null_ls = null_ls,
|
||||
}
|
||||
|
||||
---@type lsp.Client[]
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = bufnr })
|
||||
for _, client in ipairs(clients) do
|
||||
if M.supports_format(client) then
|
||||
if (#null_ls > 0 and client.name == "null-ls") or #null_ls == 0 then
|
||||
table.insert(ret.active, client)
|
||||
else
|
||||
table.insert(ret.available, client)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return ret
|
||||
end
|
||||
|
||||
-- Gets all lsp clients that support formatting
|
||||
-- and have not disabled it in their client config
|
||||
---@param client lsp.Client
|
||||
function M.supports_format(client)
|
||||
if
|
||||
client.config
|
||||
and client.config.capabilities
|
||||
and client.config.capabilities.documentFormattingProvider == false
|
||||
then
|
||||
return
|
||||
return false
|
||||
end
|
||||
return client.supports_method("textDocument/formatting") or client.supports_method("textDocument/rangeFormatting")
|
||||
end
|
||||
|
||||
if client.supports_method("textDocument/formatting") then
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("LspFormat." .. buf, {}),
|
||||
buffer = buf,
|
||||
callback = function()
|
||||
if M.autoformat then
|
||||
M.format()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
---@param opts PluginLspOpts
|
||||
function M.setup(opts)
|
||||
M.opts = opts
|
||||
vim.api.nvim_create_autocmd("BufWritePre", {
|
||||
group = vim.api.nvim_create_augroup("LazyVimFormat", {}),
|
||||
callback = function()
|
||||
if M.opts.autoformat then
|
||||
M.format()
|
||||
end
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return M
|
||||
|
@ -5,7 +5,7 @@ return {
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
dependencies = {
|
||||
{ "folke/neoconf.nvim", cmd = "Neoconf", config = true },
|
||||
{ "folke/neodev.nvim", opts = { experimental = { pathStrict = true } } },
|
||||
{ "folke/neodev.nvim", opts = {} },
|
||||
"mason.nvim",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
{
|
||||
@ -21,11 +21,23 @@ return {
|
||||
diagnostics = {
|
||||
underline = true,
|
||||
update_in_insert = false,
|
||||
virtual_text = { spacing = 4, prefix = "●" },
|
||||
virtual_text = {
|
||||
spacing = 4,
|
||||
source = "if_many",
|
||||
prefix = "●",
|
||||
-- this will set set the prefix to a function that returns the diagnostics icon based on the severity
|
||||
-- this only works on a recent 0.10.0 build. Will be set to "●" when not supported
|
||||
-- prefix = "icons",
|
||||
},
|
||||
severity_sort = true,
|
||||
},
|
||||
-- add any global capabilities here
|
||||
capabilities = {},
|
||||
-- Automatically format on save
|
||||
autoformat = true,
|
||||
-- Enable this to show formatters used in a notification
|
||||
-- Useful for debugging formatter issues
|
||||
format_notify = false,
|
||||
-- options for vim.lsp.buf.format
|
||||
-- `bufnr` and `filter` is handled by the LazyVim formatter,
|
||||
-- but can be also overridden when specified
|
||||
@ -65,12 +77,12 @@ return {
|
||||
},
|
||||
},
|
||||
---@param opts PluginLspOpts
|
||||
config = function(plugin, opts)
|
||||
config = function(_, opts)
|
||||
local Util = require("lazyvim.util")
|
||||
-- setup autoformat
|
||||
require("lazyvim.plugins.lsp.format").autoformat = opts.autoformat
|
||||
require("lazyvim.plugins.lsp.format").setup(opts)
|
||||
-- setup formatting and keymaps
|
||||
require("lazyvim.util").on_attach(function(client, buffer)
|
||||
require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
|
||||
Util.on_attach(function(client, buffer)
|
||||
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
||||
end)
|
||||
|
||||
@ -79,10 +91,29 @@ return {
|
||||
name = "DiagnosticSign" .. name
|
||||
vim.fn.sign_define(name, { text = icon, texthl = name, numhl = "" })
|
||||
end
|
||||
vim.diagnostic.config(opts.diagnostics)
|
||||
|
||||
if type(opts.diagnostics.virtual_text) == "table" and opts.diagnostics.virtual_text.prefix == "icons" then
|
||||
opts.diagnostics.virtual_text.prefix = vim.fn.has("nvim-0.10.0") == 0 and "●"
|
||||
or function(diagnostic)
|
||||
local icons = require("lazyvim.config").icons.diagnostics
|
||||
for d, icon in pairs(icons) do
|
||||
if diagnostic.severity == vim.diagnostic.severity[d:upper()] then
|
||||
return icon
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
vim.diagnostic.config(vim.deepcopy(opts.diagnostics))
|
||||
|
||||
local servers = opts.servers
|
||||
local capabilities = require("cmp_nvim_lsp").default_capabilities(vim.lsp.protocol.make_client_capabilities())
|
||||
local capabilities = vim.tbl_deep_extend(
|
||||
"force",
|
||||
{},
|
||||
vim.lsp.protocol.make_client_capabilities(),
|
||||
require("cmp_nvim_lsp").default_capabilities(),
|
||||
opts.capabilities or {}
|
||||
)
|
||||
|
||||
local function setup(server)
|
||||
local server_opts = vim.tbl_deep_extend("force", {
|
||||
@ -101,23 +132,19 @@ return {
|
||||
require("lspconfig")[server].setup(server_opts)
|
||||
end
|
||||
|
||||
-- temp fix for lspconfig rename
|
||||
-- https://github.com/neovim/nvim-lspconfig/pull/2439
|
||||
local mappings = require("mason-lspconfig.mappings.server")
|
||||
if not mappings.lspconfig_to_package.lua_ls then
|
||||
mappings.lspconfig_to_package.lua_ls = "lua-language-server"
|
||||
mappings.package_to_lspconfig["lua-language-server"] = "lua_ls"
|
||||
-- get all the servers that are available thourgh mason-lspconfig
|
||||
local have_mason, mlsp = pcall(require, "mason-lspconfig")
|
||||
local all_mslp_servers = {}
|
||||
if have_mason then
|
||||
all_mslp_servers = vim.tbl_keys(require("mason-lspconfig.mappings.server").lspconfig_to_package)
|
||||
end
|
||||
|
||||
local mlsp = require("mason-lspconfig")
|
||||
local available = mlsp.get_available_servers()
|
||||
|
||||
local ensure_installed = {} ---@type string[]
|
||||
for server, server_opts in pairs(servers) do
|
||||
if server_opts then
|
||||
server_opts = server_opts == true and {} or server_opts
|
||||
-- run manual setup if mason=false or if this is a server that cannot be installed with mason-lspconfig
|
||||
if server_opts.mason == false or not vim.tbl_contains(available, server) then
|
||||
if server_opts.mason == false or not vim.tbl_contains(all_mslp_servers, server) then
|
||||
setup(server)
|
||||
else
|
||||
ensure_installed[#ensure_installed + 1] = server
|
||||
@ -125,8 +152,17 @@ return {
|
||||
end
|
||||
end
|
||||
|
||||
require("mason-lspconfig").setup({ ensure_installed = ensure_installed })
|
||||
require("mason-lspconfig").setup_handlers({ setup })
|
||||
if have_mason then
|
||||
mlsp.setup({ ensure_installed = ensure_installed, handlers = { setup } })
|
||||
end
|
||||
|
||||
if Util.lsp_get_config("denols") and Util.lsp_get_config("tsserver") then
|
||||
local is_deno = require("lspconfig.util").root_pattern("deno.json", "deno.jsonc")
|
||||
Util.lsp_disable("tsserver", is_deno)
|
||||
Util.lsp_disable("denols", function(root_dir)
|
||||
return not is_deno(root_dir)
|
||||
end)
|
||||
end
|
||||
end,
|
||||
},
|
||||
|
||||
@ -138,10 +174,13 @@ return {
|
||||
opts = function()
|
||||
local nls = require("null-ls")
|
||||
return {
|
||||
root_dir = require("null-ls.utils").root_pattern(".null-ls-root", ".neoconf.json", "Makefile", ".git"),
|
||||
sources = {
|
||||
-- nls.builtins.formatting.prettierd,
|
||||
nls.builtins.formatting.fish_indent,
|
||||
nls.builtins.diagnostics.fish,
|
||||
nls.builtins.formatting.stylua,
|
||||
nls.builtins.diagnostics.flake8,
|
||||
nls.builtins.formatting.shfmt,
|
||||
-- nls.builtins.diagnostics.flake8,
|
||||
},
|
||||
}
|
||||
end,
|
||||
@ -156,21 +195,27 @@ return {
|
||||
opts = {
|
||||
ensure_installed = {
|
||||
"stylua",
|
||||
"shellcheck",
|
||||
"shfmt",
|
||||
"flake8",
|
||||
-- "flake8",
|
||||
},
|
||||
},
|
||||
---@param opts MasonSettings | {ensure_installed: string[]}
|
||||
config = function(plugin, opts)
|
||||
config = function(_, opts)
|
||||
require("mason").setup(opts)
|
||||
local mr = require("mason-registry")
|
||||
for _, tool in ipairs(opts.ensure_installed) do
|
||||
local p = mr.get_package(tool)
|
||||
if not p:is_installed() then
|
||||
p:install()
|
||||
local function ensure_installed()
|
||||
for _, tool in ipairs(opts.ensure_installed) do
|
||||
local p = mr.get_package(tool)
|
||||
if not p:is_installed() then
|
||||
p:install()
|
||||
end
|
||||
end
|
||||
end
|
||||
if mr.refresh then
|
||||
mr.refresh(ensure_installed)
|
||||
else
|
||||
ensure_installed()
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user