Compare commits
50 Commits
Author | SHA1 | Date | |
---|---|---|---|
c490c61d07 | |||
79010ae671 | |||
f4750859f2 | |||
9f034ab106 | |||
2f16a7b2d9 | |||
3833a7d1ce | |||
bd2ac542a0 | |||
35053290bf | |||
417de0193d | |||
a12d4bd4e4 | |||
afc8e7f8ca | |||
936d74bb61 | |||
f15dd301e5 | |||
d28c69e49e | |||
0e66ef8393 | |||
626ae1338a | |||
5f0713d2b6 | |||
758520dcbb | |||
ccff8683ba | |||
0e16033e9c | |||
6cf6b0a624 | |||
e08813fa11 | |||
e105c9daf6 | |||
1b74d67a0d | |||
b1ad48067e | |||
63467c1f21 | |||
13e9f6e6b5 | |||
6428fc167c | |||
762017dc35 | |||
afbe2043a7 | |||
f1ce07510d | |||
364bcf325d | |||
3f868aa825 | |||
fecc5faca2 | |||
19926d2848 | |||
450e0c6beb | |||
4e277fcb8f | |||
86d3694672 | |||
7c5a458761 | |||
ecac59c982 | |||
4ff51cd678 | |||
fe341e6b97 | |||
0ca732e0ef | |||
766d5e5bf7 | |||
9b16770573 | |||
e36f7d811c | |||
0b04e3908c | |||
e8ab2ff5b6 | |||
3acdac917b | |||
2ffd629cc7 |
116
CHANGELOG.md
116
CHANGELOG.md
@ -1,5 +1,121 @@
|
||||
# Changelog
|
||||
|
||||
## [9.0.0](https://github.com/LazyVim/LazyVim/compare/v8.4.4...v9.0.0) (2023-10-04)
|
||||
|
||||
|
||||
### ⚠ BREAKING CHANGES
|
||||
|
||||
* **mini.surround:** default surround mappings are now gs instead of gz (unless you enabled the leap extra)
|
||||
|
||||
### Features
|
||||
|
||||
* **extras:** added extra for dashboard.nvim ([417de01](https://github.com/LazyVim/LazyVim/commit/417de0193dd0663100a8b1eaedc2bc4976712c61))
|
||||
* **mini.surround:** default surround mappings are now gs instead of gz (unless you enabled the leap extra) ([d28c69e](https://github.com/LazyVim/LazyVim/commit/d28c69e49eab62b45f7d1562b3bc00afee5fbb65))
|
||||
* **treesitter:** added ]f, [f, ]F, [F, ]c, ]C, [c, [C for treesitter-textobjects ([0e66ef8](https://github.com/LazyVim/LazyVim/commit/0e66ef83934eb62ee2237e331dcbc0a22b809aae))
|
||||
* **treesitter:** map `vim` to `[@namespace](https://github.com/namespace).builtin` ([5f0713d](https://github.com/LazyVim/LazyVim/commit/5f0713d2b612a814586bffec39700ab6a30dc0ea))
|
||||
* **typescript:** add typescriptreact/javascriptreact to types ([#1574](https://github.com/LazyVim/LazyVim/issues/1574)) ([626ae13](https://github.com/LazyVim/LazyVim/commit/626ae1338a88f6cd8962d6c20bd79953a67f0b72))
|
||||
* **ui:** show alpha marks in statuscolumn ([bd2ac54](https://github.com/LazyVim/LazyVim/commit/bd2ac542a0bb4c58237cd6ca8848063bd20a5282))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **autocmds:** retore last location for correct buffer ([afc8e7f](https://github.com/LazyVim/LazyVim/commit/afc8e7f8cac06335efd12ec5f71cabb1f38a09b0))
|
||||
* **conform:** dont try merging function formatters. Fixes [#1582](https://github.com/LazyVim/LazyVim/issues/1582) ([f475085](https://github.com/LazyVim/LazyVim/commit/f4750859f2c2c9a41b3974ac05962ce9648d6c16))
|
||||
* **conform:** dont try to merge formatter functions ([9f034ab](https://github.com/LazyVim/LazyVim/commit/9f034ab10650e306e178d5189ee9214a52f2e8e5))
|
||||
* **nvim-lint:** dont try merging function linters ([79010ae](https://github.com/LazyVim/LazyVim/commit/79010ae671035d8ed0040ce51df4fb59ec3962f8))
|
||||
* **ui:** use custom fold when treesitter foldtext returns a string ([3505329](https://github.com/LazyVim/LazyVim/commit/35053290bf957a230c8758d31ba3997c0699f5f9))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* added support for `LazyFile` event that properly loads file based plugins without blocking the ui ([936d74b](https://github.com/LazyVim/LazyVim/commit/936d74bb6127721eeefa62e5f697d9693ab04fdd))
|
||||
* **config:** add LazyVim to the rtp early for faster spec loading ([2f16a7b](https://github.com/LazyVim/LazyVim/commit/2f16a7b2d96e912c9ab50ce99d9994413ff3678d))
|
||||
|
||||
## [8.4.4](https://github.com/LazyVim/LazyVim/compare/v8.4.3...v8.4.4) (2023-10-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ui:** work-around for telescope issue with treesitter folds ([ccff868](https://github.com/LazyVim/LazyVim/commit/ccff8683ba957250d71ef66429fc877f0ee5cedb))
|
||||
|
||||
## [8.4.3](https://github.com/LazyVim/LazyVim/compare/v8.4.2...v8.4.3) (2023-10-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ui:** always pad to 2 cells for status column icons. Fixes [#1571](https://github.com/LazyVim/LazyVim/issues/1571) ([6cf6b0a](https://github.com/LazyVim/LazyVim/commit/6cf6b0a6241c659113f5646ff64fba7dbf5161b9))
|
||||
|
||||
## [8.4.2](https://github.com/LazyVim/LazyVim/compare/v8.4.1...v8.4.2) (2023-10-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **nvim-lint:** dont evaluate conditions for linter functions. Fixes [#1569](https://github.com/LazyVim/LazyVim/issues/1569) ([b1ad480](https://github.com/LazyVim/LazyVim/commit/b1ad48067e2c18747bedd7b7054c3ce97ef32890))
|
||||
* **ui:** fixed foldtext on Neovim < 0.10 ([1b74d67](https://github.com/LazyVim/LazyVim/commit/1b74d67a0d5783e587dedc73a715cb0c9db6cd16))
|
||||
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* **options:** better detection for foldtext,statuscolumn,folexpr support ([e105c9d](https://github.com/LazyVim/LazyVim/commit/e105c9daf6e973b4a294a17b4d2d1882f2188ac6))
|
||||
|
||||
## [8.4.1](https://github.com/LazyVim/LazyVim/compare/v8.4.0...v8.4.1) (2023-10-03)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ui:** check folds of the statuscolumn win instead of current win ([13e9f6e](https://github.com/LazyVim/LazyVim/commit/13e9f6e6b5b085191b0ecf194ddf4c9e2d3ae6d7))
|
||||
|
||||
## [8.4.0](https://github.com/LazyVim/LazyVim/compare/v8.3.0...v8.4.0) (2023-10-03)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **keymaps:** added toggle for relative line numbers ([3f868aa](https://github.com/LazyVim/LazyVim/commit/3f868aa8254efbd494f6bf100c86a59c5a002c1c))
|
||||
* **options:** enable smoothscroll on nightly ([450e0c6](https://github.com/LazyVim/LazyVim/commit/450e0c6bebc5bb9a0c513cdffaf9c46d5f62d5fa))
|
||||
* **options:** enabled treesitter folding and foldtext when available ([19926d2](https://github.com/LazyVim/LazyVim/commit/19926d284862b5e58f29e73b71ec532ac29c54ba))
|
||||
* **ui:** fancy fold text ([f1ce075](https://github.com/LazyVim/LazyVim/commit/f1ce07510d2048e33fec2b609814d68a7175d591))
|
||||
* **ui:** fancy status column ([364bcf3](https://github.com/LazyVim/LazyVim/commit/364bcf325d91a06e6bd6516bdfed84399566cdb6))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **ui:** better fallback for foldtext when buffer does not have TreeSitter ([762017d](https://github.com/LazyVim/LazyVim/commit/762017dc35fc961bdcc7879a5527dbccced27792))
|
||||
* **ui:** Neovim < 0.10 ([afbe204](https://github.com/LazyVim/LazyVim/commit/afbe2043a73b6c90476812f9cc0ca4759814e5ac))
|
||||
|
||||
## [8.3.0](https://github.com/LazyVim/LazyVim/compare/v8.2.0...v8.3.0) (2023-10-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **conform:** added new keymap (leader-cF) to format injected languages ([86d3694](https://github.com/LazyVim/LazyVim/commit/86d36946727bade57918c6a358c6b6bae52d441b))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **indent-blankline:** set `config.indent.tab_char` ([#1552](https://github.com/LazyVim/LazyVim/issues/1552)) ([7c5a458](https://github.com/LazyVim/LazyVim/commit/7c5a458761fe7002c6603d602e8d130b9a62dd68))
|
||||
|
||||
## [8.2.0](https://github.com/LazyVim/LazyVim/compare/v8.1.0...v8.2.0) (2023-10-02)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **mini.files:** added lsp rename support to mini.files ([4ff51cd](https://github.com/LazyVim/LazyVim/commit/4ff51cd678343ea32668eaf0c1103caacb4334a2))
|
||||
|
||||
## [8.1.0](https://github.com/LazyVim/LazyVim/compare/v8.0.0...v8.1.0) (2023-10-01)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **conform:** set vim.opt.formatexpr ([766d5e5](https://github.com/LazyVim/LazyVim/commit/766d5e5bf7a8e40910a00aef4dc30f36376e5652))
|
||||
* **elixir:** Add credo if none-ls is used ([#1546](https://github.com/LazyVim/LazyVim/issues/1546)) ([2ffd629](https://github.com/LazyVim/LazyVim/commit/2ffd629cc7a68e6e4a721ac8babe6b7cf612868e))
|
||||
* **format:** show warning when no formatter ran when using the format keymap ([e36f7d8](https://github.com/LazyVim/LazyVim/commit/e36f7d811c396b60bcbf65f962b3f52d2f75b0b3))
|
||||
* **go:** add goimports ([#1549](https://github.com/LazyVim/LazyVim/issues/1549)) ([e8ab2ff](https://github.com/LazyVim/LazyVim/commit/e8ab2ff5b6a75952943d3ba44586c7de5588be33))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **format:** moved formatting keymap to lua/lazyvim/config/keymaps.lua ([9b16770](https://github.com/LazyVim/LazyVim/commit/9b1677057377400ab292c51bbc085c82637a39d4))
|
||||
|
||||
## [8.0.0](https://github.com/LazyVim/LazyVim/compare/v7.0.3...v8.0.0) (2023-10-01)
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ LazyVim 提供了两全其美的方式 - 根据需要调整配置的灵活性,
|
||||
|
||||
## ⚡️ 要求
|
||||
|
||||
- Neovim >= **0.8.0** (需要用 **LuaJIT** 构建)
|
||||
- Neovim >= **0.9.0** (需要用 **LuaJIT** 构建)
|
||||
- Git >= **2.19.0** (用于部分克隆支持)
|
||||
- 一个 [Nerd Font](https://www.nerdfonts.com/) 字体 **_(可选)_**
|
||||
- 一个用于 `nvim-treesitter` 的 **C** 编译器。看 [这里](https://github.com/nvim-treesitter/nvim-treesitter#requirements)
|
||||
|
@ -1,4 +1,4 @@
|
||||
*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 01
|
||||
*LazyVim.txt* For Neovim >= 0.8.0 Last change: 2023 October 04
|
||||
|
||||
==============================================================================
|
||||
Table of Contents *LazyVim-table-of-contents*
|
||||
|
@ -31,9 +31,9 @@ vim.api.nvim_create_autocmd({ "VimResized" }, {
|
||||
-- go to last loc when opening a buffer
|
||||
vim.api.nvim_create_autocmd("BufReadPost", {
|
||||
group = augroup("last_loc"),
|
||||
callback = function()
|
||||
callback = function(event)
|
||||
local exclude = { "gitcommit" }
|
||||
local buf = vim.api.nvim_get_current_buf()
|
||||
local buf = event.buf
|
||||
if vim.tbl_contains(exclude, vim.bo[buf].filetype) then
|
||||
return
|
||||
end
|
||||
@ -91,3 +91,16 @@ vim.api.nvim_create_autocmd({ "BufWritePre" }, {
|
||||
vim.fn.mkdir(vim.fn.fnamemodify(file, ":p:h"), "p")
|
||||
end,
|
||||
})
|
||||
|
||||
-- HACK: re-caclulate folds when entering a buffer through Telescope
|
||||
-- @see https://github.com/nvim-telescope/telescope.nvim/issues/699
|
||||
vim.api.nvim_create_autocmd("BufEnter", {
|
||||
group = augroup("fix_folds"),
|
||||
callback = function()
|
||||
if vim.opt.foldmethod:get() == "expr" then
|
||||
vim.schedule(function()
|
||||
vim.opt.foldmethod = "expr"
|
||||
end)
|
||||
end
|
||||
end,
|
||||
})
|
||||
|
@ -1,9 +1,9 @@
|
||||
---@type LazyVimConfig
|
||||
---@class LazyVimConfig: LazyVimOptions
|
||||
local M = {}
|
||||
|
||||
M.lazy_version = ">=9.1.0"
|
||||
|
||||
---@class LazyVimConfig
|
||||
---@class LazyVimOptions
|
||||
local defaults = {
|
||||
-- colorscheme can be a string like `catppuccin` or a function that will load the colorscheme
|
||||
---@type string|fun()
|
||||
@ -19,6 +19,9 @@ local defaults = {
|
||||
},
|
||||
-- icons used by other plugins
|
||||
icons = {
|
||||
misc = {
|
||||
dots = "",
|
||||
},
|
||||
dap = {
|
||||
Stopped = { " ", "DiagnosticWarn", "DapStoppedLine" },
|
||||
Breakpoint = " ",
|
||||
@ -83,12 +86,12 @@ M.renames = {
|
||||
["null-ls.nvim"] = "none-ls.nvim",
|
||||
}
|
||||
|
||||
---@type LazyVimConfig
|
||||
---@type LazyVimOptions
|
||||
local options
|
||||
|
||||
---@param opts? LazyVimConfig
|
||||
---@param opts? LazyVimOptions
|
||||
function M.setup(opts)
|
||||
options = vim.tbl_deep_extend("force", defaults, opts or {})
|
||||
options = vim.tbl_deep_extend("force", defaults, opts or {}) or {}
|
||||
|
||||
if vim.fn.has("nvim-0.9.0") == 0 then
|
||||
vim.api.nvim_echo({
|
||||
@ -121,8 +124,9 @@ function M.setup(opts)
|
||||
M.load("autocmds")
|
||||
end
|
||||
|
||||
local group = vim.api.nvim_create_augroup("LazyVim", { clear = true })
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
group = vim.api.nvim_create_augroup("LazyVim", { clear = true }),
|
||||
group = group,
|
||||
pattern = "VeryLazy",
|
||||
callback = function()
|
||||
if lazy_autocmds then
|
||||
@ -132,6 +136,8 @@ function M.setup(opts)
|
||||
end,
|
||||
})
|
||||
|
||||
M.lazy_file()
|
||||
|
||||
require("lazy.core.util").try(function()
|
||||
if type(M.colorscheme) == "function" then
|
||||
M.colorscheme()
|
||||
@ -147,6 +153,40 @@ function M.setup(opts)
|
||||
})
|
||||
end
|
||||
|
||||
-- Properly load file based plugins without blocking the UI
|
||||
function M.lazy_file()
|
||||
local events = {} ---@type {event: string, pattern?: string, buf: number, data?: any}[]
|
||||
|
||||
local function load()
|
||||
if #events == 0 then
|
||||
return
|
||||
end
|
||||
vim.api.nvim_del_augroup_by_name("lazy_file")
|
||||
vim.api.nvim_exec_autocmds("User", { pattern = "LazyFile", modeline = false })
|
||||
for _, event in ipairs(events) do
|
||||
vim.api.nvim_exec_autocmds(event.event, {
|
||||
pattern = event.pattern,
|
||||
modeline = false,
|
||||
buffer = event.buf,
|
||||
data = event.data,
|
||||
})
|
||||
end
|
||||
events = {}
|
||||
end
|
||||
|
||||
-- schedule wrap so that nested autocmds are executed
|
||||
-- and the UI can continue rendering without blocking
|
||||
load = vim.schedule_wrap(load)
|
||||
|
||||
vim.api.nvim_create_autocmd({ "BufReadPost", "BufWritePost", "BufNewFile" }, {
|
||||
group = vim.api.nvim_create_augroup("lazy_file", { clear = true }),
|
||||
callback = function(event)
|
||||
table.insert(events, event)
|
||||
load()
|
||||
end,
|
||||
})
|
||||
end
|
||||
|
||||
---@param range? string
|
||||
function M.has(range)
|
||||
local Semver = require("lazy.manage.semver")
|
||||
@ -187,6 +227,7 @@ M.did_init = false
|
||||
function M.init()
|
||||
if not M.did_init then
|
||||
M.did_init = true
|
||||
vim.opt.rtp:append(require("lazy.core.config").spec.plugins.LazyVim.dir)
|
||||
-- delay notifications till vim.notify was replaced or after 500ms
|
||||
require("lazyvim.util").lazy_notify()
|
||||
|
||||
@ -196,6 +237,7 @@ function M.init()
|
||||
require("lazyvim.config").load("options")
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
local add = Plugin.Spec.add
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
Plugin.Spec.add = function(self, plugin, ...)
|
||||
if type(plugin) == "table" and M.renames[plugin[1]] then
|
||||
require("lazy.core.util").warn(
|
||||
@ -210,6 +252,14 @@ function M.init()
|
||||
end
|
||||
return add(self, plugin, ...)
|
||||
end
|
||||
|
||||
-- Add support for the LazyFile event
|
||||
local Event = require("lazy.core.handler.event")
|
||||
local _event = Event._event
|
||||
---@diagnostic disable-next-line: duplicate-set-field
|
||||
Event._event = function(self, value)
|
||||
return value == "LazyFile" and "User LazyFile" or _event(self, value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -103,12 +103,18 @@ if not Util.has("trouble.nvim") then
|
||||
map("n", "]q", vim.cmd.cnext, { desc = "Next quickfix" })
|
||||
end
|
||||
|
||||
-- formatting
|
||||
map({ "n", "v" }, "<leader>cf", function()
|
||||
require("lazyvim.plugins.lsp.format").format({ force = true })
|
||||
end, { desc = "Format" })
|
||||
|
||||
-- stylua: ignore start
|
||||
|
||||
-- toggle options
|
||||
map("n", "<leader>uf", require("lazyvim.plugins.lsp.format").toggle, { desc = "Toggle format on Save" })
|
||||
map("n", "<leader>us", function() Util.toggle("spell") end, { desc = "Toggle Spelling" })
|
||||
map("n", "<leader>uw", function() Util.toggle("wrap") end, { desc = "Toggle Word Wrap" })
|
||||
map("n", "<leader>uL", function() Util.toggle("relativenumber") end, { desc = "Toggle Relative Line Numbers" })
|
||||
map("n", "<leader>ul", function() Util.toggle_number() end, { desc = "Toggle Line Numbers" })
|
||||
map("n", "<leader>ud", Util.toggle_diagnostics, { desc = "Toggle Diagnostics" })
|
||||
local conceallevel = vim.o.conceallevel > 0 and vim.o.conceallevel or 3
|
||||
|
@ -46,6 +46,31 @@ opt.updatetime = 200 -- Save swap file and trigger CursorHold
|
||||
opt.wildmode = "longest:full,full" -- Command-line completion mode
|
||||
opt.winminwidth = 5 -- Minimum window width
|
||||
opt.wrap = false -- Disable line wrap
|
||||
opt.fillchars = {
|
||||
foldopen = "",
|
||||
foldclose = "",
|
||||
-- fold = "⸱",
|
||||
fold = " ",
|
||||
foldsep = " ",
|
||||
diff = "╱",
|
||||
eob = " ",
|
||||
}
|
||||
|
||||
if vim.fn.has("nvim-0.10") == 1 then
|
||||
opt.smoothscroll = true
|
||||
end
|
||||
|
||||
-- Folding
|
||||
vim.opt.foldlevel = 99
|
||||
vim.opt.foldtext = "v:lua.require'lazyvim.util.ui'.foldtext()"
|
||||
|
||||
if vim.fn.has("nvim-0.9.0") == 1 then
|
||||
vim.opt.foldmethod = "expr"
|
||||
vim.opt.foldexpr = "v:lua.vim.treesitter.foldexpr()"
|
||||
vim.opt.statuscolumn = [[%!v:lua.require'lazyvim.util.ui'.statuscolumn()]]
|
||||
else
|
||||
vim.opt.foldmethod = "indent"
|
||||
end
|
||||
|
||||
-- Fix markdown indentation settings
|
||||
vim.g.markdown_recommended_style = 0
|
||||
|
@ -140,13 +140,13 @@ return {
|
||||
end,
|
||||
opts = {
|
||||
mappings = {
|
||||
add = "gza", -- Add surrounding in Normal and Visual modes
|
||||
delete = "gzd", -- Delete surrounding
|
||||
find = "gzf", -- Find surrounding (to the right)
|
||||
find_left = "gzF", -- Find surrounding (to the left)
|
||||
highlight = "gzh", -- Highlight surrounding
|
||||
replace = "gzr", -- Replace surrounding
|
||||
update_n_lines = "gzn", -- Update `n_lines`
|
||||
add = "gsa", -- Add surrounding in Normal and Visual modes
|
||||
delete = "gsd", -- Delete surrounding
|
||||
find = "gsf", -- Find surrounding (to the right)
|
||||
find_left = "gsF", -- Find surrounding (to the left)
|
||||
highlight = "gsh", -- Highlight surrounding
|
||||
replace = "gsr", -- Replace surrounding
|
||||
update_n_lines = "gsn", -- Update `n_lines`
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -179,7 +179,6 @@ return {
|
||||
-- { "i", mode = { "x", "o" } },
|
||||
-- },
|
||||
event = "VeryLazy",
|
||||
dependencies = { "nvim-treesitter-textobjects" },
|
||||
opts = function()
|
||||
local ai = require("mini.ai")
|
||||
return {
|
||||
|
@ -59,23 +59,12 @@ return {
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
opts.event_handlers = opts.event_handlers or {}
|
||||
|
||||
local function on_move(data)
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
for _, client in ipairs(clients) do
|
||||
if client:supports_method("workspace/willRenameFiles") then
|
||||
local resp = client.request_sync("workspace/willRenameFiles", {
|
||||
files = { { oldUri = vim.uri_from_fname(data.source), newUri = vim.uri_from_fname(data.destination) } },
|
||||
}, 1000)
|
||||
if resp and resp.result ~= nil then
|
||||
vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding)
|
||||
end
|
||||
end
|
||||
end
|
||||
Util.on_rename(data.source, data.destination)
|
||||
end
|
||||
|
||||
local events = require("neo-tree.events")
|
||||
opts.event_handlers = opts.event_handlers or {}
|
||||
vim.list_extend(opts.event_handlers, {
|
||||
{ event = events.FILE_MOVED, handler = on_move },
|
||||
{ event = events.FILE_RENAMED, handler = on_move },
|
||||
@ -321,7 +310,7 @@ return {
|
||||
-- hunks in a commit.
|
||||
{
|
||||
"lewis6991/gitsigns.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
event = "LazyFile",
|
||||
opts = {
|
||||
signs = {
|
||||
add = { text = "▎" },
|
||||
@ -360,7 +349,7 @@ return {
|
||||
-- instances.
|
||||
{
|
||||
"RRethy/vim-illuminate",
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
event = "LazyFile",
|
||||
opts = {
|
||||
delay = 200,
|
||||
large_file_cutoff = 2000,
|
||||
@ -451,7 +440,7 @@ return {
|
||||
{
|
||||
"folke/todo-comments.nvim",
|
||||
cmd = { "TodoTrouble", "TodoTelescope" },
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
event = "LazyFile",
|
||||
config = true,
|
||||
-- stylua: ignore
|
||||
keys = {
|
||||
|
@ -35,6 +35,22 @@ return {
|
||||
end,
|
||||
},
|
||||
|
||||
-- rename surround mappings from gs to gz to prevent conflict with leap
|
||||
{
|
||||
"echasnovski/mini.surround",
|
||||
opts = {
|
||||
mappings = {
|
||||
add = "gza", -- Add surrounding in Normal and Visual modes
|
||||
delete = "gzd", -- Delete surrounding
|
||||
find = "gzf", -- Find surrounding (to the right)
|
||||
find_left = "gzF", -- Find surrounding (to the left)
|
||||
highlight = "gzh", -- Highlight surrounding
|
||||
replace = "gzr", -- Replace surrounding
|
||||
update_n_lines = "gzn", -- Update `n_lines`
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
-- makes some plugins dot-repeatable like leap
|
||||
{ "tpope/vim-repeat", event = "VeryLazy" },
|
||||
}
|
||||
|
@ -53,5 +53,12 @@ return {
|
||||
vim.keymap.set("n", "g.", toggle_dotfiles, { buffer = buf_id })
|
||||
end,
|
||||
})
|
||||
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "MiniFilesActionRename",
|
||||
callback = function(event)
|
||||
require("lazyvim.util").on_rename(event.data.from, event.data.to)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
}
|
||||
|
@ -4,7 +4,18 @@ return {
|
||||
dependencies = { "mason.nvim" },
|
||||
lazy = true,
|
||||
cmd = "ConformInfo",
|
||||
keys = {
|
||||
{
|
||||
"<leader>cF",
|
||||
function()
|
||||
require("conform").format({ formatters = { "injected" } })
|
||||
end,
|
||||
mode = { "n", "v" },
|
||||
desc = "Format Injected Langs",
|
||||
},
|
||||
},
|
||||
init = function()
|
||||
vim.o.formatexpr = "v:lua.require'conform'.formatexpr()"
|
||||
-- Install the conform formatter on VeryLazy
|
||||
require("lazyvim.util").on_very_lazy(function()
|
||||
require("lazyvim.plugins.lsp.format").custom_format = function(buf)
|
||||
@ -32,9 +43,13 @@ return {
|
||||
},
|
||||
config = function(_, opts)
|
||||
opts.formatters = opts.formatters or {}
|
||||
for f, o in pairs(opts.formatters) do
|
||||
local ok, formatter = pcall(require, "conform.formatters." .. f)
|
||||
opts.formatters[f] = vim.tbl_deep_extend("force", {}, ok and formatter or {}, o)
|
||||
for name, formatter in pairs(opts.formatters) do
|
||||
if type(formatter) == "table" then
|
||||
local ok, defaults = pcall(require, "conform.formatters." .. name)
|
||||
if ok and type(defaults) == "table" then
|
||||
opts.formatters[name] = vim.tbl_deep_extend("force", {}, defaults, formatter)
|
||||
end
|
||||
end
|
||||
end
|
||||
require("conform").setup(opts)
|
||||
end,
|
||||
|
@ -45,6 +45,6 @@ return {
|
||||
{
|
||||
"Civitasv/cmake-tools.nvim",
|
||||
opts = {},
|
||||
event = "BufRead",
|
||||
event = "LazyFile",
|
||||
},
|
||||
}
|
||||
|
@ -29,4 +29,24 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"nvimtools/none-ls.nvim",
|
||||
optional = true,
|
||||
opts = function(_, opts)
|
||||
local nls = require("null-ls")
|
||||
opts.sources = opts.sources or {}
|
||||
vim.list_extend(opts.sources, {
|
||||
nls.builtins.diagnostics.credo,
|
||||
})
|
||||
end,
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
optional = true,
|
||||
opts = {
|
||||
linters_by_ft = {
|
||||
elixir = { "credo" },
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
@ -91,10 +91,20 @@ return {
|
||||
vim.list_extend(opts.sources, {
|
||||
nls.builtins.code_actions.gomodifytags,
|
||||
nls.builtins.code_actions.impl,
|
||||
nls.builtins.formatting.goimports,
|
||||
})
|
||||
end
|
||||
end,
|
||||
},
|
||||
{
|
||||
"stevearc/conform.nvim",
|
||||
optional = true,
|
||||
opts = {
|
||||
formatters_by_ft = {
|
||||
go = { "goimports" },
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
"mfussenegger/nvim-dap",
|
||||
optional = true,
|
||||
@ -103,7 +113,7 @@ return {
|
||||
"mason.nvim",
|
||||
opts = function(_, opts)
|
||||
opts.ensure_installed = opts.ensure_installed or {}
|
||||
vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "delve" })
|
||||
vim.list_extend(opts.ensure_installed, { "gomodifytags", "impl", "goimports", "delve" })
|
||||
end,
|
||||
},
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ return {
|
||||
},
|
||||
}
|
||||
end
|
||||
for _, language in ipairs({ "typescript", "javascript" }) do
|
||||
for _, language in ipairs({ "typescript", "javascript", "typescriptreact", "javascriptreact" }) do
|
||||
if not dap.configurations[language] then
|
||||
dap.configurations[language] = {
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
return {
|
||||
{
|
||||
"mfussenegger/nvim-lint",
|
||||
event = "BufReadPost",
|
||||
event = "LazyFile",
|
||||
opts = {
|
||||
-- Event to trigger linters
|
||||
events = { "BufWritePost", "BufReadPost", "InsertLeave" },
|
||||
@ -27,7 +27,9 @@ return {
|
||||
|
||||
local lint = require("lint")
|
||||
for name, linter in pairs(opts.linters) do
|
||||
lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name] or {}, linter)
|
||||
if type(linter) == "table" and type(lint.linters) == "table" then
|
||||
lint.linters[name] = vim.tbl_deep_extend("force", lint.linters[name], linter)
|
||||
end
|
||||
end
|
||||
lint.linters_by_ft = opts.linters_by_ft
|
||||
|
||||
@ -43,13 +45,12 @@ return {
|
||||
end
|
||||
|
||||
function M.lint()
|
||||
local lint = require("lint")
|
||||
local names = lint.linters_by_ft[vim.bo.filetype] or {}
|
||||
local ctx = { filename = vim.api.nvim_buf_get_name(0) }
|
||||
ctx.dirname = vim.fn.fnamemodify(ctx.filename, ":h")
|
||||
names = vim.tbl_filter(function(name)
|
||||
local linter = lint.linters[name]
|
||||
return linter and not (linter.condition and not linter.condition(ctx))
|
||||
return linter and not (type(linter) == "table" and linter.condition and not linter.condition(ctx))
|
||||
end, names)
|
||||
|
||||
if #names > 0 then
|
||||
|
62
lua/lazyvim/plugins/extras/ui/dashboard.lua
Normal file
62
lua/lazyvim/plugins/extras/ui/dashboard.lua
Normal file
@ -0,0 +1,62 @@
|
||||
return {
|
||||
{ "goolord/alpha-nvim", enabled = false },
|
||||
{ "echasnovski/mini.starter", enabled = false },
|
||||
{
|
||||
"glepnir/dashboard-nvim",
|
||||
event = "VimEnter",
|
||||
dependencies = {
|
||||
-- disable alpha
|
||||
{ "goolord/alpha-nvim", enabled = false },
|
||||
},
|
||||
opts = function()
|
||||
local logo = [[
|
||||
██╗ █████╗ ███████╗██╗ ██╗██╗ ██╗██╗███╗ ███╗ Z
|
||||
██║ ██╔══██╗╚══███╔╝╚██╗ ██╔╝██║ ██║██║████╗ ████║ Z
|
||||
██║ ███████║ ███╔╝ ╚████╔╝ ██║ ██║██║██╔████╔██║ z
|
||||
██║ ██╔══██║ ███╔╝ ╚██╔╝ ╚██╗ ██╔╝██║██║╚██╔╝██║ z
|
||||
███████╗██║ ██║███████╗ ██║ ╚████╔╝ ██║██║ ╚═╝ ██║
|
||||
╚══════╝╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═══╝ ╚═╝╚═╝ ╚═╝
|
||||
]]
|
||||
|
||||
logo = string.rep("\n", 8) .. logo .. "\n\n"
|
||||
|
||||
local opts = {
|
||||
theme = "doom",
|
||||
config = {
|
||||
header = vim.split(logo, "\n"),
|
||||
center = {
|
||||
{ action = "Telescope find_files", desc = " Find file", icon = " ", key = "f" },
|
||||
{ action = "ene | startinsert", desc = " New file", icon = " ", key = "n" },
|
||||
{ action = "Telescope oldfiles", desc = " Recent files", icon = " ", key = "r" },
|
||||
{ action = "Telescope live_grep", desc = " Find text", icon = " ", key = "g" },
|
||||
{ action = "e $MYVIMRC", desc = " Config", icon = " ", key = "c" },
|
||||
{ action = 'lua require("persistence").load()', desc = " Restore Session", icon = " ", key = "s" },
|
||||
{ action = "Lazy", desc = " Lazy", icon = " ", key = "l" },
|
||||
{ action = "qa", desc = " Quit", icon = " ", key = "q" },
|
||||
},
|
||||
footer = function()
|
||||
local stats = require("lazy").stats()
|
||||
local ms = (math.floor(stats.startuptime * 100 + 0.5) / 100)
|
||||
return { "⚡ Neovim loaded " .. stats.count .. " plugins in " .. ms .. "ms" }
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
||||
for _, button in ipairs(opts.config.center) do
|
||||
button.desc = button.desc .. string.rep(" ", 43 - #button.desc)
|
||||
end
|
||||
|
||||
-- close Lazy and re-open when the dashboard is ready
|
||||
if vim.o.filetype == "lazy" then
|
||||
vim.cmd.close()
|
||||
vim.api.nvim_create_autocmd("User", {
|
||||
pattern = "DashboardLoaded",
|
||||
callback = function()
|
||||
require("lazy").show()
|
||||
end,
|
||||
})
|
||||
end
|
||||
return opts
|
||||
end,
|
||||
},
|
||||
}
|
@ -2,6 +2,7 @@
|
||||
return {
|
||||
-- disable alpha
|
||||
{ "goolord/alpha-nvim", enabled = false },
|
||||
{ "glepnir/dashboard-nvim", enabled = false },
|
||||
|
||||
-- enable mini.starter
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ M.hl = {}
|
||||
|
||||
M.plugin = {
|
||||
"echasnovski/mini.hipatterns",
|
||||
event = "BufReadPre",
|
||||
event = "LazyFile",
|
||||
opts = function()
|
||||
local hi = require("mini.hipatterns")
|
||||
return {
|
||||
|
@ -18,7 +18,6 @@ local enabled = {
|
||||
}
|
||||
|
||||
local Config = require("lazy.core.config")
|
||||
local Plugin = require("lazy.core.plugin")
|
||||
Config.options.checker.enabled = false
|
||||
Config.options.change_detection.enabled = false
|
||||
Config.options.defaults.cond = function(plugin)
|
||||
|
@ -50,13 +50,12 @@ function M.format(opts)
|
||||
end, formatters.active)
|
||||
|
||||
if #client_ids == 0 then
|
||||
if opts and opts.force then
|
||||
Util.warn("No formatter available", { title = "LazyVim" })
|
||||
end
|
||||
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)
|
||||
@ -65,45 +64,6 @@ function M.format(opts)
|
||||
}, require("lazyvim.util").opts("nvim-lspconfig").format or {}))
|
||||
end
|
||||
|
||||
---@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.
|
||||
|
@ -2,7 +2,7 @@ return {
|
||||
-- lspconfig
|
||||
{
|
||||
"neovim/nvim-lspconfig",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
event = "LazyFile",
|
||||
dependencies = {
|
||||
{ "folke/neoconf.nvim", cmd = "Neoconf", config = false, dependencies = { "nvim-lspconfig" } },
|
||||
{ "folke/neodev.nvim", opts = {} },
|
||||
@ -41,9 +41,6 @@ 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
|
||||
@ -206,7 +203,7 @@ return {
|
||||
-- formatters
|
||||
{
|
||||
"nvimtools/none-ls.nvim",
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
event = "LazyFile",
|
||||
dependencies = { "mason.nvim" },
|
||||
opts = function()
|
||||
local nls = require("null-ls")
|
||||
|
@ -5,9 +5,6 @@ M._keys = nil
|
||||
|
||||
---@return (LazyKeys|{has?:string})[]
|
||||
function M.get()
|
||||
local format = function()
|
||||
require("lazyvim.plugins.lsp.format").format({ force = true })
|
||||
end
|
||||
if not M._keys then
|
||||
---@class PluginLspKeys
|
||||
-- stylua: ignore
|
||||
@ -28,8 +25,6 @@ function M.get()
|
||||
{ "[e", M.diagnostic_goto(false, "ERROR"), desc = "Prev Error" },
|
||||
{ "]w", M.diagnostic_goto(true, "WARN"), desc = "Next Warning" },
|
||||
{ "[w", M.diagnostic_goto(false, "WARN"), desc = "Prev Warning" },
|
||||
{ "<leader>cf", format, desc = "Format Document", has = "formatting" },
|
||||
{ "<leader>cf", format, desc = "Format Range", mode = "v", has = "rangeFormatting" },
|
||||
{ "<leader>ca", vim.lsp.buf.code_action, desc = "Code Action", mode = { "n", "v" }, has = "codeAction" },
|
||||
{
|
||||
"<leader>cA",
|
||||
|
@ -1,4 +1,3 @@
|
||||
local load_textobjects = false
|
||||
return {
|
||||
-- Treesitter is a new parser generator tool that we can
|
||||
-- use in Neovim to power faster and more accurate
|
||||
@ -7,17 +6,10 @@ return {
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
version = false, -- last release is way too old and doesn't work on Windows
|
||||
build = ":TSUpdate",
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
event = { "LazyFile", "VeryLazy" },
|
||||
dependencies = {
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
init = function()
|
||||
-- disable rtp plugin, as we only need its queries for mini.ai
|
||||
-- In case other textobject modules are enabled, we will load them
|
||||
-- once nvim-treesitter is loaded
|
||||
require("lazy.core.loader").disable_rtp_plugin("nvim-treesitter-textobjects")
|
||||
load_textobjects = true
|
||||
end,
|
||||
},
|
||||
},
|
||||
cmd = { "TSUpdateSync" },
|
||||
@ -59,6 +51,15 @@ return {
|
||||
node_decremental = "<bs>",
|
||||
},
|
||||
},
|
||||
textobjects = {
|
||||
move = {
|
||||
enable = true,
|
||||
goto_next_start = { ["]f"] = "@function.outer", ["]c"] = "@class.outer" },
|
||||
goto_next_end = { ["]F"] = "@function.outer", ["]C"] = "@class.outer" },
|
||||
goto_previous_start = { ["[f"] = "@function.outer", ["[c"] = "@class.outer" },
|
||||
goto_previous_end = { ["[F"] = "@function.outer", ["[C"] = "@class.outer" },
|
||||
},
|
||||
},
|
||||
},
|
||||
---@param opts TSConfig
|
||||
config = function(_, opts)
|
||||
@ -74,21 +75,6 @@ return {
|
||||
end, opts.ensure_installed)
|
||||
end
|
||||
require("nvim-treesitter.configs").setup(opts)
|
||||
|
||||
if load_textobjects then
|
||||
-- PERF: no need to load the plugin, if we only need its queries for mini.ai
|
||||
if opts.textobjects then
|
||||
for _, mod in ipairs({ "move", "select", "swap", "lsp_interop" }) do
|
||||
if opts.textobjects[mod] and opts.textobjects[mod].enable then
|
||||
local Loader = require("lazy.core.loader")
|
||||
Loader.disabled_rtp_plugins["nvim-treesitter-textobjects"] = nil
|
||||
local plugin = require("lazy.core.config").plugins["nvim-treesitter-textobjects"]
|
||||
require("lazy.core.loader").source_runtime(plugin.dir, "plugin")
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ return {
|
||||
-- tabs, which include filetype icons and close buttons.
|
||||
{
|
||||
"akinsho/bufferline.nvim",
|
||||
event = "VeryLazy",
|
||||
event = "LazyFile",
|
||||
keys = {
|
||||
{ "<leader>bp", "<Cmd>BufferLineTogglePin<CR>", desc = "Toggle pin" },
|
||||
{ "<leader>bP", "<Cmd>BufferLineGroupClose ungrouped<CR>", desc = "Delete non-pinned buffers" },
|
||||
@ -166,9 +166,12 @@ return {
|
||||
-- indent guides for Neovim
|
||||
{
|
||||
"lukas-reineke/indent-blankline.nvim",
|
||||
event = { "BufReadPost", "BufNewFile" },
|
||||
event = "LazyFile",
|
||||
opts = {
|
||||
indent = { char = "│" },
|
||||
indent = {
|
||||
char = "│",
|
||||
tab_char = "│",
|
||||
},
|
||||
scope = { enabled = false },
|
||||
exclude = {
|
||||
filetypes = {
|
||||
@ -194,7 +197,7 @@ return {
|
||||
{
|
||||
"echasnovski/mini.indentscope",
|
||||
version = false, -- wait till new 0.7.0 release to put it back on semver
|
||||
event = { "BufReadPre", "BufNewFile" },
|
||||
event = "LazyFile",
|
||||
opts = {
|
||||
-- symbol = "▏",
|
||||
symbol = "│",
|
||||
|
@ -299,4 +299,25 @@ function M.changelog()
|
||||
vim.diagnostic.disable(float.buf)
|
||||
end
|
||||
|
||||
---@param from string
|
||||
---@param to string
|
||||
function M.on_rename(from, to)
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
for _, client in ipairs(clients) do
|
||||
if client:supports_method("workspace/willRenameFiles") then
|
||||
local resp = client.request_sync("workspace/willRenameFiles", {
|
||||
files = {
|
||||
{
|
||||
oldUri = vim.uri_from_fname(from),
|
||||
newUri = vim.uri_from_fname(to),
|
||||
},
|
||||
},
|
||||
}, 1000)
|
||||
if resp and resp.result ~= nil then
|
||||
vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
93
lua/lazyvim/util/ui.lua
Normal file
93
lua/lazyvim/util/ui.lua
Normal file
@ -0,0 +1,93 @@
|
||||
local M = {}
|
||||
|
||||
---@alias Sign {name:string, text:string, texthl:string}
|
||||
|
||||
---@return Sign[]
|
||||
---@param buf number
|
||||
---@param lnum number
|
||||
function M.get_signs(buf, lnum)
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
return vim.tbl_map(function(sign)
|
||||
return vim.fn.sign_getdefined(sign.name)[1]
|
||||
end, vim.fn.sign_getplaced(buf, { group = "*", lnum = lnum })[1].signs)
|
||||
end
|
||||
|
||||
---@return Sign?
|
||||
---@param buf number
|
||||
---@param lnum number
|
||||
function M.get_mark(buf, lnum)
|
||||
local marks = vim.fn.getmarklist(buf)
|
||||
vim.list_extend(marks, vim.fn.getmarklist())
|
||||
for _, mark in ipairs(marks) do
|
||||
if mark.pos[2] == lnum and mark.mark:match("[a-zA-Z]") then
|
||||
return { text = mark.mark:sub(2), texthl = "DiagnosticHint" }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
---@param sign? Sign
|
||||
---@param len? number
|
||||
function M.icon(sign, len)
|
||||
sign = sign or {}
|
||||
len = len or 2
|
||||
local text = vim.fn.strcharpart(sign.text or "", 0, len) ---@type string
|
||||
text = text .. string.rep(" ", len - vim.fn.strchars(text))
|
||||
return sign.texthl and ("%#" .. sign.texthl .. "#" .. text .. "%*") or text
|
||||
end
|
||||
|
||||
function M.foldtext()
|
||||
local ok = pcall(vim.treesitter.get_parser, vim.api.nvim_get_current_buf())
|
||||
local ret = ok and vim.treesitter.foldtext and vim.treesitter.foldtext()
|
||||
if not ret or type(ret) == "string" then
|
||||
ret = { { vim.api.nvim_buf_get_lines(0, vim.v.lnum - 1, vim.v.lnum, false)[1], {} } }
|
||||
end
|
||||
table.insert(ret, { " " .. require("lazyvim.config").icons.misc.dots })
|
||||
|
||||
if not vim.treesitter.foldtext then
|
||||
return table.concat(
|
||||
vim.tbl_map(function(line)
|
||||
return line[1]
|
||||
end, ret),
|
||||
" "
|
||||
)
|
||||
end
|
||||
return ret
|
||||
end
|
||||
|
||||
function M.statuscolumn()
|
||||
local win = vim.g.statusline_winid
|
||||
if vim.wo[win].signcolumn == "no" then
|
||||
return ""
|
||||
end
|
||||
local buf = vim.api.nvim_win_get_buf(win)
|
||||
|
||||
---@type Sign?,Sign?,Sign?
|
||||
local left, right, fold
|
||||
for _, s in ipairs(M.get_signs(buf, vim.v.lnum)) do
|
||||
if s.name:find("GitSign") then
|
||||
right = s
|
||||
elseif not left then
|
||||
left = s
|
||||
end
|
||||
end
|
||||
|
||||
vim.api.nvim_win_call(win, function()
|
||||
if vim.fn.foldclosed(vim.v.lnum) >= 0 then
|
||||
fold = { text = vim.opt.fillchars:get().foldclose or "", texthl = "Folded" }
|
||||
end
|
||||
end)
|
||||
|
||||
local nu = ""
|
||||
if vim.wo[win].number and vim.v.virtnum == 0 then
|
||||
nu = vim.wo[win].relativenumber and vim.v.relnum ~= 0 and vim.v.relnum or vim.v.lnum
|
||||
end
|
||||
|
||||
return table.concat({
|
||||
M.icon(M.get_mark(buf, vim.v.lnum) or left),
|
||||
[[%=]],
|
||||
nu .. " ",
|
||||
M.icon(fold or right),
|
||||
}, "")
|
||||
end
|
||||
|
||||
return M
|
4
queries/lua/highlights.scm
Normal file
4
queries/lua/highlights.scm
Normal file
@ -0,0 +1,4 @@
|
||||
;; extends
|
||||
|
||||
((identifier) @namespace.builtin
|
||||
(#eq? @namespace.builtin "vim"))
|
Reference in New Issue
Block a user