Compare commits

..

17 Commits

Author SHA1 Message Date
720b17f970 fix(bufferline): fix bufferline when restoring a session 2023-10-08 22:59:50 +02:00
b9a2aa868b fix(cmp): properly set cmp group_indexk 2023-10-08 22:25:09 +02:00
502d32490b fix(options): set sessionoptions the same as persistence 2023-10-08 20:24:45 +02:00
51e25a94b4 fix(plugins): make sure init specs are loaded first 2023-10-08 20:24:45 +02:00
1eac633c4f perf(util): closure for get_clients to prevent loading vim.lsp cascade early 2023-10-08 20:24:45 +02:00
3f67ac3c73 chore(main): release 9.6.0 (#1632)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-08 19:53:20 +02:00
33c677a55e fix(yaml): yaml schemas are a dict, not a list, so merge properly. Fixes #1636 2023-10-08 19:29:00 +02:00
e11a3cbe80 fix(config): trigger LazyFile additionally on BufWritePre for saving unnamed files 2023-10-08 15:17:50 +02:00
639a6e7545 feat(extra): add extra util.dot that configures multiple ft and treesitter langs when needed 2023-10-08 13:45:57 +02:00
80e6696343 chore(main): release 9.5.0 (#1631)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-08 12:58:53 +02:00
eebdceca17 fix(util): fixup typo vim.lsp.get_active_clients 2023-10-08 12:56:27 +02:00
c9bbb922e5 feat(treesitter): add diff, jsonc and yaml by default 2023-10-08 12:56:27 +02:00
6e3fb589d5 chore(main): release 9.4.1 (#1628)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2023-10-08 11:42:13 +02:00
4e0a05808c fix(config): dont append LazyVim early to the rtp when bootstrapping 2023-10-08 11:33:03 +02:00
6b837e9165 style: lua annotations and handle deprecated methods 2023-10-08 10:45:38 +02:00
21ee35f710 fix(util): fixed lsp willRenameFiles support check 2023-10-08 10:44:17 +02:00
25f3587f3f refactor(keymaps): move safe keymap.set wrapper to util and add message not to use it in a personal config 2023-10-08 10:28:01 +02:00
15 changed files with 176 additions and 45 deletions

View File

@ -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)

View File

@ -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

View File

@ -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 })

View File

@ -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 })

View File

@ -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

View File

@ -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,
},
}

View File

@ -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,

View File

@ -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 } },

View 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,
},
}

View File

@ -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

View File

@ -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

View File

@ -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",

View File

@ -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

View File

@ -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