mirror of
https://github.com/ViViDboarder/vim-settings.git
synced 2024-12-22 18:37:34 +00:00
Now using v0.7+ API functions in many places
This preserves backwards compatibility still, but that will be removed at some point when dropping .6. At that point, another refactor can simplify many of the functions used.
This commit is contained in:
parent
03df97c0d2
commit
92550be390
@ -194,17 +194,9 @@ use({
|
||||
end,
|
||||
})
|
||||
|
||||
-- Custom status line
|
||||
use({
|
||||
"SmiteshP/nvim-gps",
|
||||
requires = "nvim-treesitter/nvim-treesitter",
|
||||
disable = vim.fn.has("nvim-0.7.0") == 1,
|
||||
})
|
||||
-- Replaces gps for 0.7+
|
||||
use({
|
||||
"SmiteshP/nvim-navic",
|
||||
requires = "neovim/nvim-lspconfig",
|
||||
disable = vim.fn.has("nvim-0.7.0") ~= 1,
|
||||
})
|
||||
|
||||
use({
|
||||
@ -212,7 +204,7 @@ use({
|
||||
config = function()
|
||||
require("plugins.lualine").config_lualine()
|
||||
end,
|
||||
after = vim.fn.has("nvim-0.7.0") == 1 and "nvim-navic" or "nvim-gps",
|
||||
after = "nvim-navic",
|
||||
})
|
||||
|
||||
-- On Mac, update colors when dark mode changes
|
||||
@ -253,8 +245,6 @@ use({
|
||||
"neovim/nvim-lspconfig",
|
||||
"williamboman/mason-lspconfig.nvim",
|
||||
},
|
||||
-- Only supports >=0.7.0
|
||||
disable = vim.fn.has("nvim-0.7.0") ~= 1,
|
||||
})
|
||||
|
||||
-- Lua dev for vim
|
||||
@ -266,7 +256,6 @@ use({
|
||||
-- Rust analyzer
|
||||
use({
|
||||
"simrat39/rust-tools.nvim",
|
||||
disable = vim.fn.has("nvim-0.7.0") ~= 1,
|
||||
})
|
||||
|
||||
-- Better display of lsp diagnostics
|
||||
@ -296,14 +285,6 @@ use({
|
||||
branch = utils.map_version_rule({
|
||||
[">=0.8.0"] = utils.nil_val,
|
||||
[">=0.7.0"] = "0.7-compat",
|
||||
["<0.7.0"] = utils.nil_val, -- use pinned commits
|
||||
}),
|
||||
commit = utils.map_version_rule({
|
||||
[">=0.8.0"] = utils.nil_val,
|
||||
[">=0.7.0"] = utils.nil_val, -- Use pinned branch
|
||||
[">=0.6.0"] = "4b403d2d724f48150ded41189ae4866492a8158b",
|
||||
[">=0.5.1"] = "739a98c12bedaa2430c4a3c08d1d22ad6c16513e",
|
||||
[">=0.5.0"] = "3e7390735501d0507bf2c2b5c2e7a16f58deeb81",
|
||||
}),
|
||||
requires = { "nvim-lua/plenary.nvim", "neovim/nvim-lspconfig" },
|
||||
})
|
||||
@ -332,8 +313,6 @@ use({
|
||||
commit = utils.map_version_rule({
|
||||
[">=0.8.0"] = utils.nil_val,
|
||||
[">=0.7.0"] = "4cccb6f494eb255b32a290d37c35ca12584c74d0",
|
||||
[">=0.6.0"] = "bc25a6a5",
|
||||
[">=0.5.0"] = "a189323454d1215c682c7ad7db3e6739d26339c4",
|
||||
}),
|
||||
config = function()
|
||||
require("utils").require_with_local("plugins.treesitter").setup()
|
||||
@ -352,10 +331,6 @@ use({
|
||||
use({
|
||||
"nvim-treesitter/nvim-treesitter-textobjects",
|
||||
requires = "nvim-treesitter/nvim-treesitter",
|
||||
commit = utils.map_version_rule({
|
||||
[">=0.7.0"] = utils.nil_val,
|
||||
["<0.7.0"] = "eca3bf30334f85259d41dc060d50994f8f91ef7d",
|
||||
}),
|
||||
})
|
||||
|
||||
-- Completion
|
||||
@ -369,28 +344,16 @@ use({
|
||||
config = function()
|
||||
require("plugins.completion").config_cmp()
|
||||
end,
|
||||
commit = utils.map_version_rule({
|
||||
[">=0.7.0"] = utils.nil_val,
|
||||
[">=0.5.0"] = "bba6fb67fdafc0af7c5454058dfbabc2182741f4",
|
||||
}),
|
||||
requires = {
|
||||
{
|
||||
"hrsh7th/cmp-nvim-lsp",
|
||||
after = "nvim-cmp",
|
||||
commit = utils.map_version_rule({
|
||||
[">=0.7.0"] = utils.nil_val,
|
||||
["<0.7.0"] = "3cf38d9c957e95c397b66f91967758b31be4abe6",
|
||||
}),
|
||||
},
|
||||
{ "hrsh7th/cmp-buffer", after = "nvim-cmp" },
|
||||
{ "f3fora/cmp-spell", after = "nvim-cmp" },
|
||||
{
|
||||
"saadparwaiz1/cmp_luasnip",
|
||||
after = "nvim-cmp",
|
||||
commit = utils.map_version_rule({
|
||||
[">0.7.0"] = utils.nil_val,
|
||||
[">=0.5.0"] = "b10829736542e7cc9291e60bab134df1273165c9",
|
||||
}),
|
||||
},
|
||||
"L3MON4D3/LuaSnip",
|
||||
},
|
||||
@ -430,10 +393,7 @@ use({
|
||||
},
|
||||
tag = utils.map_version_rule({
|
||||
-- Follow stable release tag
|
||||
[">=0.7.0"] = "0.1.0",
|
||||
[">=0.6.0"] = "nvim-0.6",
|
||||
["<0.6.0"] = "nvim-0.5.1",
|
||||
["==0.5.0"] = "nvim-0.5.0",
|
||||
[">=0.7.0"] = "0.1.*",
|
||||
}),
|
||||
config = function()
|
||||
require("plugins.telescope")
|
||||
|
@ -5,23 +5,6 @@ function M.get_color(synID, what, mode)
|
||||
return vim.fn.synIDattr(vim.fn.synIDtrans(vim.fn.hlID(synID)), what, mode)
|
||||
end
|
||||
|
||||
-- Create an autocmd
|
||||
-- TODO: Remove this and use nvim_create_autocmd and nvim_create_augroup when dropping .6
|
||||
function M.autocmd(group, cmds, clear)
|
||||
clear = clear == nil and false or clear
|
||||
if type(cmds) == "string" then
|
||||
cmds = { cmds }
|
||||
end
|
||||
vim.cmd("augroup " .. group)
|
||||
if clear then
|
||||
vim.cmd([[au!]])
|
||||
end
|
||||
for _, cmd in ipairs(cmds) do
|
||||
vim.cmd("autocmd " .. cmd)
|
||||
end
|
||||
vim.cmd([[augroup END]])
|
||||
end
|
||||
|
||||
-- Terminal escape a given string
|
||||
function M.t(str)
|
||||
return vim.api.nvim_replace_termcodes(str, true, true, true)
|
||||
@ -195,38 +178,13 @@ end
|
||||
-- Calls keymap_set with preferred defaults
|
||||
function M.keymap_set(mode, lhs, rhs, opts)
|
||||
opts = vim.tbl_extend("keep", opts, { noremap = true, silent = true })
|
||||
-- TODO: Remove this check when dropping 0.6 support
|
||||
if vim.fn.has("nvim-0.7") == 1 then
|
||||
vim.keymap.set(mode, lhs, rhs, opts)
|
||||
else
|
||||
-- Desc is not supported in 0.6
|
||||
opts["desc"] = nil
|
||||
if type(mode) ~= "string" then
|
||||
for _, m in pairs(mode) do
|
||||
M.keymap_set(m, lhs, rhs, opts)
|
||||
end
|
||||
return
|
||||
end
|
||||
-- Buffer requires a different function
|
||||
local buffer = M.tbl_pop(opts, "buffer")
|
||||
if buffer == nil then
|
||||
vim.api.nvim_set_keymap(mode, lhs, rhs, opts)
|
||||
else
|
||||
vim.api.nvim_buf_set_keymap(buffer, mode, lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns a curried function for passing data into vim.keymap.set
|
||||
function M.curry_keymap(mode, prefix, default_opts)
|
||||
default_opts = vim.tbl_extend("keep", default_opts or {}, { noremap = true, silent = true })
|
||||
|
||||
-- TODO: Remove when dropping 0.6
|
||||
if vim.fn.has("nvim-0.7") ~= 1 then
|
||||
-- NOTE: This is incompatible with a lua function on rhs and a bool buffer instead of number
|
||||
return M.keymap_group(mode, prefix, default_opts)
|
||||
end
|
||||
|
||||
return function(lhs, rhs, opts)
|
||||
opts = vim.tbl_extend("keep", opts or {}, default_opts)
|
||||
local opt_mode = M.tbl_pop(opts, "mode")
|
||||
@ -234,19 +192,6 @@ function M.curry_keymap(mode, prefix, default_opts)
|
||||
end
|
||||
end
|
||||
|
||||
-- Returns a function used to create keymaps with consistent prefixes
|
||||
function M.keymap_group(mode, prefix, default_opts)
|
||||
-- TODO: Remove when dropping 0.6 since curry_keymap exists
|
||||
return function(lhs, rhs, opts)
|
||||
opts = opts or default_opts
|
||||
if opts ~= nil and default_opts ~= nil and opts ~= default_opts then
|
||||
opts = vim.tbl_extend("keep", opts, default_opts)
|
||||
end
|
||||
local opt_mode = M.tbl_pop(opts, "mode")
|
||||
M.keymap_set(opt_mode or mode, prefix .. lhs, rhs, opts)
|
||||
end
|
||||
end
|
||||
|
||||
-- Diagnostics signs
|
||||
M.diagnostic_signs = {
|
||||
Error = "🔥",
|
||||
|
Loading…
Reference in New Issue
Block a user