Compare commits
47 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 |
97
CHANGELOG.md
97
CHANGELOG.md
@ -1,5 +1,102 @@
|
||||
# Changelog
|
||||
|
||||
## [4.5.1](https://github.com/LazyVim/LazyVim/compare/v4.5.0...v4.5.1) (2023-06-05)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **keymaps:** remove `c-w` mapping ([952a0cf](https://github.com/LazyVim/LazyVim/commit/952a0cfb96e7258dcbe8c9f4d8bdfd978888f17c))
|
||||
|
||||
## [4.5.0](https://github.com/LazyVim/LazyVim/compare/v4.4.0...v4.5.0) (2023-06-03)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **keymaps:** added `<c-/>` in normal/terminal mode to toggle main terminal ([7a36e29](https://github.com/LazyVim/LazyVim/commit/7a36e2989c3d62e8dbaf4036f5c4551929c565a5))
|
||||
* **keymaps:** added some useful keymaps for terminals ([49ae234](https://github.com/LazyVim/LazyVim/commit/49ae2344a18f93c5b4209357e265a2732365ab19))
|
||||
* **neo-tree:** enabled document_symbols for neo-tree ([419086e](https://github.com/LazyVim/LazyVim/commit/419086e8a393df05ae1311e7580e034051df85eb))
|
||||
* **noice:** route some undo messages to the mini view ([fc236b3](https://github.com/LazyVim/LazyVim/commit/fc236b3a2a90001df11ed4a6bad7bce87f459cf9))
|
||||
* **util:** LazyVim terminals are now persistent by default (toggleterm) ([5a47492](https://github.com/LazyVim/LazyVim/commit/5a4749253501569ec0ae2c644ed778e45ad637c0))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **indentscope:** dont use indentscope/blankline for lazyterm/toggleterm/notify ([15f5a22](https://github.com/LazyVim/LazyVim/commit/15f5a229d9b9fcdfd980050e7fe8dff74313d9fd))
|
||||
* **lualine:** dont load copilot when not available. Fixes [#872](https://github.com/LazyVim/LazyVim/issues/872) ([5ed3250](https://github.com/LazyVim/LazyVim/commit/5ed3250f2475f498cd14643f4788ee95108f2ada))
|
||||
* **spectre:** make spectre behave with regards to swap files ([bb4a7fe](https://github.com/LazyVim/LazyVim/commit/bb4a7fe410d8aaf9507cd2a8ed7c7680852cf297))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **illuminate:** on large files >2000 lines, enable lsp references only ([08422bf](https://github.com/LazyVim/LazyVim/commit/08422bf559cb74a2e673e60d551269cbcb2e18df))
|
||||
|
||||
## [4.4.0](https://github.com/LazyVim/LazyVim/compare/v4.3.1...v4.4.0) (2023-05-29)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **catppuccin:** enabled integration for plugins included with LazyVim ([0c05f8a](https://github.com/LazyVim/LazyVim/commit/0c05f8a185e61cc67199bf4b0b3b61933d292b0f))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **indent-blankline:** don't load indent-blankline for nvim-notify ([a94ef59](https://github.com/LazyVim/LazyVim/commit/a94ef5953a6f14731d9aea447e769c280db140ab))
|
||||
|
||||
## [4.3.1](https://github.com/LazyVim/LazyVim/compare/v4.3.0...v4.3.1) (2023-05-28)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **dashboard:** center the LazyVim logo ([#845](https://github.com/LazyVim/LazyVim/issues/845)) ([72b8155](https://github.com/LazyVim/LazyVim/commit/72b81553f378669b2cbad16662faed2a6b524df6))
|
||||
* **luasnip:** use `echo` instead of `echo -e` for build warning ([88238e2](https://github.com/LazyVim/LazyVim/commit/88238e2109e8340fae1424f693149ff2c334ae1c))
|
||||
* **neotest:** properly detect __call. Fixes [#847](https://github.com/LazyVim/LazyVim/issues/847) ([0e671ad](https://github.com/LazyVim/LazyVim/commit/0e671ad7fabdb3af181feda18951596a83167bc9))
|
||||
* **neotest:** removed `<leader>tR` in favor of `<leader>tt` ([a866c68](https://github.com/LazyVim/LazyVim/commit/a866c6801df058c6bef613acfb2eeea9cedb41b1))
|
||||
|
||||
## [4.3.0](https://github.com/LazyVim/LazyVim/compare/v4.2.0...v4.3.0) (2023-05-27)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **neotest:** added `<leader>tt` and `<leader>tT` to run tests in file or all test files ([efc72b0](https://github.com/LazyVim/LazyVim/commit/efc72b06496f7540085928094808e9a0f45222b9))
|
||||
* **neotest:** allow adapter names as a list ([98e2ffc](https://github.com/LazyVim/LazyVim/commit/98e2ffcf14bb5f336ee2e4679d2b7d5699486bcc))
|
||||
* **noetest:** open trouble instead of quickfix on errors when available ([2c89770](https://github.com/LazyVim/LazyVim/commit/2c897705049cb89d6cd28b59be4bd7db872ffe6b))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **hipatterns:** default options ([3082436](https://github.com/LazyVim/LazyVim/commit/30824369c2c58647df170566766ea1dbda2730cc))
|
||||
* **neotest:** added some additional filetypes to close with q ([1288f0d](https://github.com/LazyVim/LazyVim/commit/1288f0d5a5cc5f5279678cc3c3d99abe20a1e052))
|
||||
* **neotest:** support neotest adapaters that use `setup()` for custom setup ([2a3bac7](https://github.com/LazyVim/LazyVim/commit/2a3bac769045abac76395fcabb36b17b68bc42fc))
|
||||
|
||||
## [4.2.0](https://github.com/LazyVim/LazyVim/compare/v4.1.1...v4.2.0) (2023-05-26)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **hipatterns:** made tailwind ft and style configurable ([f7a6304](https://github.com/LazyVim/LazyVim/commit/f7a63042f9b6f2353d861ba4cec23789d0254b5b))
|
||||
* **lsp:** added `nvim-lspconfig.opts.format_notify`. Enable this to debug formatter issues. ([5eccaeb](https://github.com/LazyVim/LazyVim/commit/5eccaeb992217d47f111c78a3d519aae3d9a5edc))
|
||||
* **lsp:** added support for upcoming dynamic registration of formatters ([962fc6b](https://github.com/LazyVim/LazyVim/commit/962fc6bab43cdf68e5602fe06a54c7a5fac053b6))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **hipatterns:** reset hl groups when colorscheme changes ([b7a9259](https://github.com/LazyVim/LazyVim/commit/b7a925904ea30d85a96683df9980960ef349eacf))
|
||||
|
||||
## [4.1.1](https://github.com/LazyVim/LazyVim/compare/v4.1.0...v4.1.1) (2023-05-26)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **hipatterns:** make it work on stable ([33f61b5](https://github.com/LazyVim/LazyVim/commit/33f61b58de3519ef568bc9591fb877a71a203a6d))
|
||||
* **hipatterns:** make sure priority is higher than the one for references ([b027beb](https://github.com/LazyVim/LazyVim/commit/b027bebeab30308f26f5cafe1642f3aa0e541ca3))
|
||||
|
||||
## [4.1.0](https://github.com/LazyVim/LazyVim/compare/v4.0.0...v4.1.0) (2023-05-25)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **hipatterns:** better tailwind fg colors ([c526ea3](https://github.com/LazyVim/LazyVim/commit/c526ea338b415a51fa78936b7044ec67d78528b2))
|
||||
|
||||
## [4.0.0](https://github.com/LazyVim/LazyVim/compare/v3.7.2...v4.0.0) (2023-05-25)
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 May 25
|
||||
*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 June 05
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *LazyVim-table-of-contents*
|
||||
|
@ -51,8 +51,10 @@ vim.api.nvim_create_autocmd("FileType", {
|
||||
"spectre_panel",
|
||||
"startuptime",
|
||||
"tsplayground",
|
||||
"checkhealth",
|
||||
"neotest-output",
|
||||
"checkhealth",
|
||||
"neotest-summary",
|
||||
"neotest-output-panel",
|
||||
},
|
||||
callback = function(event)
|
||||
vim.bo[event.buf].buflisted = false
|
||||
|
@ -126,9 +126,18 @@ 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("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", remap = true })
|
||||
|
@ -4,7 +4,7 @@ return {
|
||||
{
|
||||
"L3MON4D3/LuaSnip",
|
||||
build = (not jit.os:find("Windows"))
|
||||
and "echo -e 'NOTE: jsregexp is optional, so not a big deal if it fails to build\n'; make install_jsregexp"
|
||||
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",
|
||||
|
@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ return {
|
||||
end
|
||||
end,
|
||||
opts = {
|
||||
sources = { "filesystem", "buffers", "git_status", "document_symbols" },
|
||||
filesystem = {
|
||||
bind_to_cwd = false,
|
||||
follow_current_file = true,
|
||||
@ -72,6 +73,8 @@ return {
|
||||
-- search/replace in multiple files
|
||||
{
|
||||
"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)" },
|
||||
@ -303,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)
|
||||
|
||||
|
@ -33,6 +33,9 @@ return {
|
||||
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,
|
||||
|
@ -12,6 +12,7 @@ return {
|
||||
"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 = {},
|
||||
@ -21,6 +22,17 @@ return {
|
||||
-- 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")
|
||||
@ -38,11 +50,21 @@ return {
|
||||
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
|
||||
adapter = adapter(config)
|
||||
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
|
||||
@ -54,8 +76,9 @@ return {
|
||||
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>tR", function() require("neotest").run.run(vim.fn.expand("%")) end, desc = "Run File" },
|
||||
{ "<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" },
|
||||
|
@ -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)
|
||||
|
@ -1,5 +1,8 @@
|
||||
local M = {}
|
||||
|
||||
---@type table<string,true>
|
||||
M.hl = {}
|
||||
|
||||
M.plugin = {
|
||||
"echasnovski/mini.hipatterns",
|
||||
event = "BufReadPre",
|
||||
@ -7,31 +10,64 @@ M.plugin = {
|
||||
local hi = require("mini.hipatterns")
|
||||
return {
|
||||
-- custom LazyVim option to enable the tailwind integration
|
||||
tailwind = true,
|
||||
tailwind = {
|
||||
enabled = true,
|
||||
ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" },
|
||||
-- full: the whole css class will be highlighted
|
||||
-- compact: only the color will be highlighted
|
||||
style = "full",
|
||||
},
|
||||
highlighters = {
|
||||
hex_color = hi.gen_highlighter.hex_color({ priority = 5000 }),
|
||||
hex_color = hi.gen_highlighter.hex_color({ priority = 2000 }),
|
||||
},
|
||||
}
|
||||
end,
|
||||
config = function(_, opts)
|
||||
local hi = require("mini.hipatterns")
|
||||
if opts.tailwind then
|
||||
local hex_color = opts.highlighters.hex_color or hi.gen_highlighter.hex_color({ priority = 5000 })
|
||||
local tailwind_ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" }
|
||||
-- backward compatibility
|
||||
if opts.tailwind == true then
|
||||
opts.tailwind = {
|
||||
enabled = true,
|
||||
ft = { "typescriptreact", "javascriptreact", "css", "javascript", "typescript", "html" },
|
||||
style = "full",
|
||||
}
|
||||
end
|
||||
if type(opts.tailwind) == "table" and opts.tailwind.enabled then
|
||||
-- reset hl groups when colorscheme changes
|
||||
vim.api.nvim_create_autocmd("ColorScheme", {
|
||||
callback = function()
|
||||
M.hl = {}
|
||||
end,
|
||||
})
|
||||
opts.highlighters.tailwind = {
|
||||
pattern = function()
|
||||
if not vim.list_contains(tailwind_ft, vim.bo.filetype) then
|
||||
if not vim.tbl_contains(opts.tailwind.ft, vim.bo.filetype) then
|
||||
return
|
||||
end
|
||||
return "%f[%w:-]()[%w:-]+%-[a-z%-]+%-%d+()%f[^%w:-]"
|
||||
end,
|
||||
group = function(_, match)
|
||||
local color, shade = match:match("[%w-]+%-([a-z%-]+)%-(%d+)")
|
||||
local hex = vim.tbl_get(M.colors, color, tonumber(shade))
|
||||
if hex then
|
||||
return hex_color.group(nil, nil, { full_match = "#" .. hex })
|
||||
if opts.tailwind.style == "full" then
|
||||
return "%f[%w:-]()[%w:-]+%-[a-z%-]+%-%d+()%f[^%w:-]"
|
||||
elseif opts.tailwind.style == "compact" then
|
||||
return "%f[%w:-][%w:-]+%-()[a-z%-]+%-%d+()%f[^%w:-]"
|
||||
end
|
||||
end,
|
||||
group = function(_, _, m)
|
||||
---@type string
|
||||
local match = m.full_match
|
||||
---@type string, number
|
||||
local color, shade = match:match("[%w-]+%-([a-z%-]+)%-(%d+)")
|
||||
shade = assert(tonumber(shade))
|
||||
local bg = vim.tbl_get(M.colors, color, shade)
|
||||
if bg then
|
||||
local hl = "MiniHipatternsTailwind" .. color .. shade
|
||||
if not M.hl[hl] then
|
||||
M.hl[hl] = true
|
||||
local bg_shade = shade == 500 and 950 or shade < 500 and 900 or 100
|
||||
local fg = vim.tbl_get(M.colors, color, bg_shade)
|
||||
vim.api.nvim_set_hl(0, hl, { bg = "#" .. bg, fg = "#" .. fg })
|
||||
end
|
||||
return hl
|
||||
end
|
||||
end,
|
||||
priority = 2000,
|
||||
}
|
||||
end
|
||||
require("mini.hipatterns").setup(opts)
|
||||
|
@ -2,16 +2,17 @@ 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" })
|
||||
@ -24,42 +25,124 @@ function M.format(opts)
|
||||
if vim.b.autoformat == false and not (opts and opts.force) then
|
||||
return
|
||||
end
|
||||
local ft = vim.bo[buf].filetype
|
||||
local have_nls = package.loaded["null-ls"]
|
||||
and (#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
|
||||
|
@ -35,6 +35,9 @@ return {
|
||||
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
|
||||
@ -77,10 +80,9 @@ return {
|
||||
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
|
||||
Util.on_attach(function(client, buffer)
|
||||
require("lazyvim.plugins.lsp.format").on_attach(client, buffer)
|
||||
require("lazyvim.plugins.lsp.keymaps").on_attach(client, buffer)
|
||||
end)
|
||||
|
||||
|
@ -169,7 +169,18 @@ return {
|
||||
opts = {
|
||||
-- char = "▏",
|
||||
char = "│",
|
||||
filetype_exclude = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" },
|
||||
filetype_exclude = {
|
||||
"help",
|
||||
"alpha",
|
||||
"dashboard",
|
||||
"neo-tree",
|
||||
"Trouble",
|
||||
"lazy",
|
||||
"mason",
|
||||
"notify",
|
||||
"toggleterm",
|
||||
"lazyterm",
|
||||
},
|
||||
show_trailing_blankline_indent = false,
|
||||
show_current_context = false,
|
||||
},
|
||||
@ -187,7 +198,18 @@ return {
|
||||
},
|
||||
init = function()
|
||||
vim.api.nvim_create_autocmd("FileType", {
|
||||
pattern = { "help", "alpha", "dashboard", "neo-tree", "Trouble", "lazy", "mason" },
|
||||
pattern = {
|
||||
"help",
|
||||
"alpha",
|
||||
"dashboard",
|
||||
"neo-tree",
|
||||
"Trouble",
|
||||
"lazy",
|
||||
"mason",
|
||||
"notify",
|
||||
"toggleterm",
|
||||
"lazyterm",
|
||||
},
|
||||
callback = function()
|
||||
vim.b.miniindentscope_disable = true
|
||||
end,
|
||||
@ -222,7 +244,11 @@ return {
|
||||
{
|
||||
filter = {
|
||||
event = "msg_show",
|
||||
find = "%d+L, %d+B",
|
||||
any = {
|
||||
{ find = "%d+L, %d+B" },
|
||||
{ find = "; after #%d+" },
|
||||
{ find = "; before #%d+" },
|
||||
},
|
||||
},
|
||||
view = "mini",
|
||||
},
|
||||
@ -253,12 +279,12 @@ return {
|
||||
opts = function()
|
||||
local dashboard = require("alpha.themes.dashboard")
|
||||
local logo = [[
|
||||
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z
|
||||
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z
|
||||
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z
|
||||
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z
|
||||
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z
|
||||
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z
|
||||
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z
|
||||
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z
|
||||
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||
]]
|
||||
|
||||
dashboard.section.header.val = vim.split(logo, "\n")
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -123,17 +123,39 @@ function M.telescope(builtin, opts)
|
||||
end
|
||||
end
|
||||
|
||||
---@type table<string,LazyFloat>
|
||||
local terminals = {}
|
||||
|
||||
-- Opens a floating terminal (interactive by default)
|
||||
---@param cmd? string[]|string
|
||||
---@param opts? LazyCmdOptions|{interactive?:boolean, esc_esc?:false}
|
||||
function M.float_term(cmd, opts)
|
||||
opts = vim.tbl_deep_extend("force", {
|
||||
ft = "lazyterm",
|
||||
size = { width = 0.9, height = 0.9 },
|
||||
}, opts or {})
|
||||
local float = require("lazy.util").float_term(cmd, opts)
|
||||
if opts.esc_esc == false then
|
||||
vim.keymap.set("t", "<esc>", "<esc>", { buffer = float.buf, nowait = true })
|
||||
}, opts or {}, { persistent = true })
|
||||
---@cast opts LazyCmdOptions|{interactive?:boolean, esc_esc?:false}
|
||||
|
||||
local termkey = vim.inspect({ cmd = cmd or "shell", cwd = opts.cwd, env = opts.env })
|
||||
|
||||
if terminals[termkey] and terminals[termkey]:buf_valid() then
|
||||
terminals[termkey]:toggle()
|
||||
else
|
||||
terminals[termkey] = require("lazy.util").float_term(cmd, opts)
|
||||
local buf = terminals[termkey].buf
|
||||
vim.b[buf].lazyterm_cmd = cmd
|
||||
if opts.esc_esc == false then
|
||||
vim.keymap.set("t", "<esc>", "<esc>", { buffer = buf, nowait = true })
|
||||
end
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
buffer = buf,
|
||||
callback = function()
|
||||
vim.cmd.startinsert()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
return terminals[termkey]
|
||||
end
|
||||
|
||||
---@param silent boolean?
|
||||
|
Reference in New Issue
Block a user