Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
720b17f970 | |||
b9a2aa868b | |||
502d32490b | |||
51e25a94b4 | |||
1eac633c4f | |||
3f67ac3c73 | |||
33c677a55e | |||
e11a3cbe80 | |||
639a6e7545 | |||
80e6696343 | |||
eebdceca17 | |||
c9bbb922e5 | |||
6e3fb589d5 | |||
4e0a05808c | |||
6b837e9165 | |||
21ee35f710 | |||
25f3587f3f |
33
CHANGELOG.md
33
CHANGELOG.md
@ -1,5 +1,38 @@
|
||||
# Changelog
|
||||
|
||||
## [9.6.0](https://github.com/LazyVim/LazyVim/compare/v9.5.0...v9.6.0) (2023-10-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **extra:** add extra `util.dot` that configures multiple ft and treesitter langs when needed ([639a6e7](https://github.com/LazyVim/LazyVim/commit/639a6e7545830602c09711b3757a28537baf8e75))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **config:** trigger LazyFile additionally on BufWritePre for saving unnamed files ([e11a3cb](https://github.com/LazyVim/LazyVim/commit/e11a3cbe800a1216062f7cefd25827f6fdad9daa))
|
||||
* **yaml:** yaml schemas are a dict, not a list, so merge properly. Fixes [#1636](https://github.com/LazyVim/LazyVim/issues/1636) ([33c677a](https://github.com/LazyVim/LazyVim/commit/33c677a55e97ee115ad7050856856df7cd96b3e1))
|
||||
|
||||
## [9.5.0](https://github.com/LazyVim/LazyVim/compare/v9.4.1...v9.5.0) (2023-10-08)
|
||||
|
||||
|
||||
### Features
|
||||
|
||||
* **treesitter:** add diff, jsonc and yaml by default ([c9bbb92](https://github.com/LazyVim/LazyVim/commit/c9bbb922e58b223d49785cddbed2feeea536237e))
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **util:** fixup typo vim.lsp.get_active_clients ([eebdcec](https://github.com/LazyVim/LazyVim/commit/eebdceca1723801e1889d2a65bd676d17139fc6c))
|
||||
|
||||
## [9.4.1](https://github.com/LazyVim/LazyVim/compare/v9.4.0...v9.4.1) (2023-10-08)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* **config:** dont append LazyVim early to the rtp when bootstrapping ([4e0a058](https://github.com/LazyVim/LazyVim/commit/4e0a05808cb0997e0ac7d939421f68e9dfa5d74d))
|
||||
* **util:** fixed lsp willRenameFiles support check ([21ee35f](https://github.com/LazyVim/LazyVim/commit/21ee35f7108f4eefbce84d88a002572b168fc357))
|
||||
|
||||
## [9.4.0](https://github.com/LazyVim/LazyVim/compare/v9.3.1...v9.4.0) (2023-10-08)
|
||||
|
||||
|
||||
|
@ -3,7 +3,7 @@ local M = {}
|
||||
|
||||
M.lazy_version = ">=10.8.0"
|
||||
M.use_lazy_file = true
|
||||
M.lazy_file_events = { "BufReadPost", "BufNewFile" }
|
||||
M.lazy_file_events = { "BufReadPost", "BufNewFile", "BufWritePre" }
|
||||
|
||||
---@class LazyVimOptions
|
||||
local defaults = {
|
||||
@ -268,7 +268,10 @@ 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)
|
||||
local plugin = require("lazy.core.config").spec.plugins.LazyVim
|
||||
if plugin then
|
||||
vim.opt.rtp:append(plugin.dir)
|
||||
end
|
||||
|
||||
M.use_lazy_file = M.use_lazy_file and vim.fn.argc(-1) > 0
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
|
@ -1,25 +1,9 @@
|
||||
-- This file is automatically loaded by lazyvim.config.init
|
||||
local Util = require("lazyvim.util")
|
||||
|
||||
local function map(mode, lhs, rhs, opts)
|
||||
local keys = require("lazy.core.handler").handlers.keys
|
||||
---@cast keys LazyKeysHandler
|
||||
local modes = type(mode) == "string" and { mode } or mode
|
||||
|
||||
modes = vim.tbl_filter(function(mode)
|
||||
return not (keys.have and keys:have(lhs, mode))
|
||||
end, modes)
|
||||
|
||||
-- do not create the keymap if a lazy keys handler exists
|
||||
if #modes > 0 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(modes, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
-- DO NOT USE THIS IN YOU OWN CONFIG!!
|
||||
-- use `vim.keymap.set` instead
|
||||
local map = Util.safe_keymap_set
|
||||
|
||||
-- better up/down
|
||||
map({ "n", "x" }, "j", "v:count == 0 ? 'gj' : 'j'", { expr = true, silent = true })
|
||||
|
@ -24,7 +24,7 @@ opt.pumblend = 10 -- Popup blend
|
||||
opt.pumheight = 10 -- Maximum number of entries in a popup
|
||||
opt.relativenumber = true -- Relative line numbers
|
||||
opt.scrolloff = 4 -- Lines of context
|
||||
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize" }
|
||||
opt.sessionoptions = { "buffers", "curdir", "tabpages", "winsize", "help", "globals", "skiprtp" }
|
||||
opt.shiftround = true -- Round indent
|
||||
opt.shiftwidth = 2 -- Size of an indent
|
||||
opt.shortmess:append({ W = true, I = true, c = true, C = true })
|
||||
|
@ -67,12 +67,12 @@ return {
|
||||
select = true,
|
||||
}), -- Accept currently selected item. Set `select` to `false` to only confirm explicitly selected items.
|
||||
}),
|
||||
sources = cmp.config.sources({
|
||||
{ name = "nvim_lsp" },
|
||||
{ name = "luasnip" },
|
||||
{ name = "buffer" },
|
||||
{ name = "path" },
|
||||
}),
|
||||
sources = {
|
||||
{ name = "nvim_lsp", group_index = 1 },
|
||||
{ name = "luasnip", group_index = 1 },
|
||||
{ name = "buffer", group_index = 2 },
|
||||
{ name = "path", group_index = 2 },
|
||||
},
|
||||
formatting = {
|
||||
format = function(_, item)
|
||||
local icons = require("lazyvim.config").icons.kinds
|
||||
|
@ -17,9 +17,8 @@ return {
|
||||
},
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, 1, { name = "codeium", group_index = 2 })
|
||||
table.insert(opts.sources, 1, { name = "codeium", group_index = 1 })
|
||||
opts.sorting = opts.sorting or require("cmp.config.default")().sorting
|
||||
end,
|
||||
},
|
||||
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ return {
|
||||
},
|
||||
---@param opts cmp.ConfigSchema
|
||||
opts = function(_, opts)
|
||||
table.insert(opts.sources, 1, { name = "copilot", group_index = 2 })
|
||||
table.insert(opts.sources, 1, { name = "copilot", group_index = 1 })
|
||||
opts.sorting = opts.sorting or require("cmp.config.default")().sorting
|
||||
table.insert(opts.sorting.comparators, 1, require("copilot_cmp.comparators").prioritize)
|
||||
end,
|
||||
|
@ -35,8 +35,11 @@ return {
|
||||
},
|
||||
-- lazy-load schemastore when needed
|
||||
on_new_config = function(new_config)
|
||||
new_config.settings.yaml.schemas = new_config.settings.yaml.schemas or {}
|
||||
vim.list_extend(new_config.settings.yaml.schemas, require("schemastore").yaml.schemas())
|
||||
new_config.settings.yaml.schemas = vim.tbl_deep_extend(
|
||||
"force",
|
||||
new_config.settings.yaml.schemas or {},
|
||||
require("schemastore").yaml.schemas()
|
||||
)
|
||||
end,
|
||||
settings = {
|
||||
redhat = { telemetry = { enabled = false } },
|
||||
|
62
lua/lazyvim/plugins/extras/util/dot.lua
Normal file
62
lua/lazyvim/plugins/extras/util/dot.lua
Normal file
@ -0,0 +1,62 @@
|
||||
---@type string
|
||||
local xdg_config = vim.env.XDG_CONFIG_HOME or vim.env.HOME .. "/.config"
|
||||
|
||||
---@param path string
|
||||
local function have(path)
|
||||
return vim.loop.fs_stat(xdg_config .. "/" .. path) ~= nil
|
||||
end
|
||||
|
||||
return {
|
||||
|
||||
-- Add Hyprland Parser
|
||||
{
|
||||
"luckasRanarison/tree-sitter-hypr",
|
||||
enabled = have("hypr"),
|
||||
event = "BufRead */hypr/*.conf",
|
||||
config = function()
|
||||
-- Fix ft detection for hyprland
|
||||
vim.filetype.add({
|
||||
pattern = { [".*/hypr/.*%.conf"] = "hypr" },
|
||||
})
|
||||
require("nvim-treesitter.parsers").get_parser_configs().hypr = {
|
||||
install_info = {
|
||||
url = "https://github.com/luckasRanarison/tree-sitter-hypr",
|
||||
files = { "src/parser.c" },
|
||||
branch = "master",
|
||||
},
|
||||
filetype = "hypr",
|
||||
}
|
||||
end,
|
||||
},
|
||||
|
||||
-- add some stuff to treesitter
|
||||
{
|
||||
"nvim-treesitter/nvim-treesitter",
|
||||
opts = function(_, opts)
|
||||
local function add(lang)
|
||||
if type(opts.ensure_installed) ~= "table" then
|
||||
table.insert(opts.ensure_installed, lang)
|
||||
end
|
||||
end
|
||||
|
||||
vim.filetype.add({
|
||||
extension = { rasi = "rasi" },
|
||||
pattern = {
|
||||
[".*/waybar/config"] = "jsonc",
|
||||
[".*/mako/config"] = "dosini",
|
||||
[".*/kitty/*.conf"] = "bash",
|
||||
},
|
||||
})
|
||||
|
||||
add("git_config")
|
||||
|
||||
if have("fish") then
|
||||
add("fish")
|
||||
end
|
||||
|
||||
if have("rofi") or have("wofi") then
|
||||
add("rasi")
|
||||
end
|
||||
end,
|
||||
},
|
||||
}
|
@ -82,7 +82,7 @@ function M.get_formatters(bufnr)
|
||||
}
|
||||
|
||||
---@type lsp.Client[]
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = bufnr })
|
||||
local clients = require("lazyvim.util").get_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
|
||||
|
@ -66,7 +66,7 @@ end
|
||||
---@param method string
|
||||
function M.has(buffer, method)
|
||||
method = method:find("/") and method or "textDocument/" .. method
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = buffer })
|
||||
local clients = require("lazyvim.util").get_clients({ bufnr = buffer })
|
||||
for _, client in ipairs(clients) do
|
||||
if client.supports_method(method) then
|
||||
return true
|
||||
@ -83,7 +83,7 @@ function M.resolve(buffer)
|
||||
end
|
||||
local spec = M.get()
|
||||
local opts = require("lazyvim.util").opts("nvim-lspconfig")
|
||||
local clients = vim.lsp.get_active_clients({ bufnr = buffer })
|
||||
local clients = require("lazyvim.util").get_clients({ bufnr = buffer })
|
||||
for _, client in ipairs(clients) do
|
||||
local maps = opts.servers[client.name] and opts.servers[client.name].keys or {}
|
||||
vim.list_extend(spec, maps)
|
||||
@ -98,7 +98,6 @@ function M.on_attach(_, buffer)
|
||||
for _, keys in pairs(keymaps) do
|
||||
if not keys.has or M.has(buffer, keys.has) then
|
||||
local opts = Keys.opts(keys)
|
||||
---@diagnostic disable-next-line: no-unknown
|
||||
opts.has = nil
|
||||
opts.silent = opts.silent ~= false
|
||||
opts.buffer = buffer
|
||||
|
@ -40,16 +40,19 @@ return {
|
||||
{ "<bs>", desc = "Decrement selection", mode = "x" },
|
||||
},
|
||||
---@type TSConfig
|
||||
---@diagnostic disable-next-line: missing-fields
|
||||
opts = {
|
||||
highlight = { enable = true },
|
||||
indent = { enable = true },
|
||||
ensure_installed = {
|
||||
"bash",
|
||||
"c",
|
||||
"diff",
|
||||
"html",
|
||||
"javascript",
|
||||
"jsdoc",
|
||||
"json",
|
||||
"jsonc",
|
||||
"lua",
|
||||
"luadoc",
|
||||
"luap",
|
||||
@ -58,6 +61,7 @@ return {
|
||||
"python",
|
||||
"query",
|
||||
"regex",
|
||||
"toml",
|
||||
"tsx",
|
||||
"typescript",
|
||||
"vim",
|
||||
|
@ -82,6 +82,17 @@ return {
|
||||
},
|
||||
},
|
||||
},
|
||||
config = function(_, opts)
|
||||
require("bufferline").setup(opts)
|
||||
-- Fix bufferline when restoring a session
|
||||
vim.api.nvim_create_autocmd("BufAdd", {
|
||||
callback = function()
|
||||
vim.schedule(function()
|
||||
pcall(nvim_bufferline)
|
||||
end)
|
||||
end,
|
||||
})
|
||||
end,
|
||||
},
|
||||
|
||||
-- statusline
|
||||
|
@ -3,12 +3,16 @@ local Util = require("lazy.core.util")
|
||||
local M = {}
|
||||
|
||||
M.root_patterns = { ".git", "lua" }
|
||||
function M.get_clients(...)
|
||||
local fn = vim.lsp.get_clients or vim.lsp.get_active_clients
|
||||
return fn(...)
|
||||
end
|
||||
|
||||
---@param on_attach fun(client, buffer)
|
||||
function M.on_attach(on_attach)
|
||||
vim.api.nvim_create_autocmd("LspAttach", {
|
||||
callback = function(args)
|
||||
local buffer = args.buf
|
||||
local buffer = args.buf ---@type number
|
||||
local client = vim.lsp.get_client_by_id(args.data.client_id)
|
||||
on_attach(client, buffer)
|
||||
end,
|
||||
@ -22,9 +26,11 @@ end
|
||||
|
||||
function M.fg(name)
|
||||
---@type {foreground?:number}?
|
||||
---@diagnostic disable-next-line: deprecated
|
||||
local hl = vim.api.nvim_get_hl and vim.api.nvim_get_hl(0, { name = name }) or vim.api.nvim_get_hl_by_name(name, true)
|
||||
local fg = hl and hl.fg or hl.foreground
|
||||
return fg and { fg = string.format("#%06x", fg) }
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
local fg = hl and (hl.fg or hl.foreground)
|
||||
return fg and { fg = string.format("#%06x", fg) } or nil
|
||||
end
|
||||
|
||||
---@param fn fun()
|
||||
@ -60,7 +66,7 @@ function M.get_root()
|
||||
---@type string[]
|
||||
local roots = {}
|
||||
if path then
|
||||
for _, client in pairs(vim.lsp.get_active_clients({ bufnr = 0 })) do
|
||||
for _, client in pairs(M.get_clients({ bufnr = 0 })) do
|
||||
local workspace = client.config.workspace_folders
|
||||
local paths = workspace and vim.tbl_map(function(ws)
|
||||
return vim.uri_to_fname(ws.uri)
|
||||
@ -227,7 +233,7 @@ function M.lazy_notify()
|
||||
vim.notify = temp
|
||||
|
||||
local timer = vim.loop.new_timer()
|
||||
local check = vim.loop.new_check()
|
||||
local check = assert(vim.loop.new_check())
|
||||
|
||||
local replay = function()
|
||||
timer:stop()
|
||||
@ -253,6 +259,7 @@ function M.lazy_notify()
|
||||
timer:start(500, 0, replay)
|
||||
end
|
||||
|
||||
---@return _.lspconfig.options
|
||||
function M.lsp_get_config(server)
|
||||
local configs = require("lspconfig.configs")
|
||||
return rawget(configs, server)
|
||||
@ -263,6 +270,7 @@ end
|
||||
function M.lsp_disable(server, cond)
|
||||
local util = require("lspconfig.util")
|
||||
local def = M.lsp_get_config(server)
|
||||
---@diagnostic disable-next-line: undefined-field
|
||||
def.document_config.on_new_config = util.add_hook_before(def.document_config.on_new_config, function(config, root_dir)
|
||||
if cond(root_dir, config) then
|
||||
config.enabled = false
|
||||
@ -302,9 +310,10 @@ end
|
||||
---@param from string
|
||||
---@param to string
|
||||
function M.on_rename(from, to)
|
||||
local clients = vim.lsp.get_active_clients()
|
||||
local clients = M.get_clients()
|
||||
for _, client in ipairs(clients) do
|
||||
if client:supports_method("workspace/willRenameFiles") then
|
||||
if client.supports_method("workspace/willRenameFiles") then
|
||||
---@diagnostic disable-next-line: invisible
|
||||
local resp = client.request_sync("workspace/willRenameFiles", {
|
||||
files = {
|
||||
{
|
||||
@ -312,7 +321,7 @@ function M.on_rename(from, to)
|
||||
newUri = vim.uri_from_fname(to),
|
||||
},
|
||||
},
|
||||
}, 1000)
|
||||
}, 1000, 0)
|
||||
if resp and resp.result ~= nil then
|
||||
vim.lsp.util.apply_workspace_edit(resp.result, client.offset_encoding)
|
||||
end
|
||||
@ -320,4 +329,28 @@ function M.on_rename(from, to)
|
||||
end
|
||||
end
|
||||
|
||||
-- Wrapper around vim.keymap.set that will
|
||||
-- not create a keymap if a lazy key handler exists.
|
||||
-- It will also set `silent` to true by default.
|
||||
function M.safe_keymap_set(mode, lhs, rhs, opts)
|
||||
local keys = require("lazy.core.handler").handlers.keys
|
||||
---@cast keys LazyKeysHandler
|
||||
local modes = type(mode) == "string" and { mode } or mode
|
||||
|
||||
---@param m string
|
||||
modes = vim.tbl_filter(function(m)
|
||||
return not (keys.have and keys:have(lhs, m))
|
||||
end, modes)
|
||||
|
||||
-- do not create the keymap if a lazy keys handler exists
|
||||
if #modes > 0 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(modes, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
return M
|
||||
|
Reference in New Issue
Block a user