refactor: replace deprecated API calls (#4568)

* chore: bump plugins version

* refactor: replace deprecated API calls

* chore(lsp): update skipped servers list

* ci: update workflows

* ci: update release names in installer script

* ci: use action-setup-vim
This commit is contained in:
kylo252 2024-05-28 13:46:11 +02:00 committed by GitHub
parent 64764a2656
commit 3715ae645d
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: B5690EEEBB952194
24 changed files with 91 additions and 115 deletions

View file

@ -17,7 +17,7 @@ jobs:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: install commitlint
run: |
npm install --save-dev @commitlint/cli

View file

@ -13,9 +13,9 @@ on:
jobs:
stylua-check:
name: "Formatting check with Stylua"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Lint with stylua
uses: JohnnyMorganz/stylua-action@v2
@ -27,18 +27,18 @@ jobs:
shfmt-check:
name: "Formatting check with shfmt"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v3
uses: actions/setup-go@v5
with:
go-version: "1.18"
go-version: '^1.21'
- name: Use shfmt
run: |
go install mvdan.cc/sh/v3/cmd/shfmt@v3.6
go install mvdan.cc/sh/v3/cmd/shfmt@latest
# https://google.github.io/styleguide/shellguide.html
- name: Check formatting

View file

@ -21,10 +21,10 @@ jobs:
include:
- runner: ubuntu-latest
os: linux
neovim: v0.9.5
neovim: v0.10.0
- runner: macos-latest
os: osx
neovim: v0.9.5
neovim: v0.10.0
- runner: ubuntu-22.04
os: linux
neovim: nightly
@ -33,14 +33,13 @@ jobs:
neovim: nightly
runs-on: ${{ matrix.runner }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install neovim binary from release
env:
RELEASE_VER: ${{ matrix.neovim }}
run: |
echo "$HOME/.local/bin" >> "$GITHUB_PATH"
bash ./utils/installer/install-neovim-from-release
- name: Install neovim binary
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.neovim }}
- name: Install LunarVim
timeout-minutes: 4
@ -72,13 +71,13 @@ jobs:
shell: pwsh
steps:
# it's not currently possbile to run tests on windows, see nvim-lua/plenary.nvim#255
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install neovim binary
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: v0.9.1
version: v0.10.0
- name: Install LunarVim
timeout-minutes: 4

View file

@ -13,9 +13,9 @@ on:
jobs:
lua-linter:
name: "Linting with luacheck"
runs-on: ubuntu-20.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: leafo/gh-actions-lua@v8
- uses: leafo/gh-actions-luarocks@v4
@ -30,7 +30,7 @@ jobs:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
with:

View file

@ -26,7 +26,7 @@ jobs:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Install neovim binary
uses: rhysd/action-setup-vim@v1

View file

@ -1,7 +1,7 @@
local M = {}
if vim.fn.has "nvim-0.9" ~= 1 then
vim.notify("Please upgrade your Neovim base installation. Lunarvim requires v0.9+", vim.log.levels.WARN)
if vim.fn.has "nvim-0.10" ~= 1 then
vim.notify("Please upgrade your Neovim base installation. Lunarvim requires v0.10+", vim.log.levels.WARN)
vim.wait(5000, function()
---@diagnostic disable-next-line: redundant-return-value
return false

View file

@ -89,7 +89,7 @@ function M.get_sections()
val = function()
local alpha_wins = vim.tbl_filter(function(win)
local buf = vim.api.nvim_win_get_buf(win)
return vim.api.nvim_buf_get_option(buf, "filetype") == "alpha"
return vim.api.nvim_get_option_value("filetype", { buf = buf }) == "alpha"
end, vim.api.nvim_list_wins())
if vim.api.nvim_win_get_height(alpha_wins[#alpha_wins]) < 36 then

View file

@ -105,17 +105,17 @@ function M.load_defaults()
if lvim.builtin.breadcrumbs.active then
require("lvim.core.breadcrumbs").get_winbar()
end
local statusline_hl = vim.api.nvim_get_hl_by_name("StatusLine", true)
local cursorline_hl = vim.api.nvim_get_hl_by_name("CursorLine", true)
local normal_hl = vim.api.nvim_get_hl_by_name("Normal", true)
local statusline_hl = vim.api.nvim_get_hl(0, { name = "StatusLine" })
local cursorline_hl = vim.api.nvim_get_hl(0, { name = "CursorLine" })
local normal_hl = vim.api.nvim_get_hl(0, { name = "Normal" })
vim.api.nvim_set_hl(0, "CmpItemKindCopilot", { fg = "#6CC644" })
vim.api.nvim_set_hl(0, "CmpItemKindTabnine", { fg = "#CA42F0" })
vim.api.nvim_set_hl(0, "CmpItemKindCrate", { fg = "#F64D00" })
vim.api.nvim_set_hl(0, "CmpItemKindEmoji", { fg = "#FDE030" })
vim.api.nvim_set_hl(0, "SLCopilot", { fg = "#6CC644", bg = statusline_hl.background })
vim.api.nvim_set_hl(0, "SLGitIcon", { fg = "#E8AB53", bg = cursorline_hl.background })
vim.api.nvim_set_hl(0, "SLBranchName", { fg = normal_hl.foreground, bg = cursorline_hl.background })
vim.api.nvim_set_hl(0, "SLSeparator", { fg = cursorline_hl.background, bg = statusline_hl.background })
vim.api.nvim_set_hl(0, "SLCopilot", { fg = "#6CC644", bg = statusline_hl.bg })
vim.api.nvim_set_hl(0, "SLGitIcon", { fg = "#E8AB53", bg = cursorline_hl.bg })
vim.api.nvim_set_hl(0, "SLBranchName", { fg = normal_hl.fg, bg = cursorline_hl.bg })
vim.api.nvim_set_hl(0, "SLSeparator", { fg = cursorline_hl.fg, bg = statusline_hl.bg })
end,
},
},

View file

@ -1,7 +1,6 @@
local M = {}
-- local Log = require "lvim.core.log"
local icons = lvim.icons.kind
M.config = function()
@ -94,18 +93,21 @@ M.setup = function()
end
end
local function isempty(s)
return s == nil or s == ""
end
M.get_filename = function()
local filename = vim.fn.expand "%:t"
local extension = vim.fn.expand "%:e"
local f = require "lvim.utils.functions"
if not f.isempty(filename) then
if not isempty(filename) then
local file_icon, hl_group
local devicons_ok, devicons = pcall(require, "nvim-web-devicons")
if lvim.use_icons and devicons_ok then
file_icon, hl_group = devicons.get_icon(filename, extension, { default = true })
if f.isempty(file_icon) then
if isempty(file_icon) then
file_icon = lvim.icons.kind.File
end
else
@ -135,8 +137,8 @@ M.get_filename = function()
-- file_icon = lvim.icons.ui.DebugConsole
-- end
local navic_text = vim.api.nvim_get_hl_by_name("Normal", true)
vim.api.nvim_set_hl(0, "Winbar", { fg = navic_text.foreground })
local navic_text_hl = vim.api.nvim_get_hl(0, { name = "Normal" })
vim.api.nvim_set_hl(0, "Winbar", { fg = navic_text_hl.fg })
return " " .. "%#" .. hl_group .. "#" .. file_icon .. "%*" .. " " .. "%#Winbar#" .. filename .. "%*"
end
@ -157,7 +159,7 @@ local get_gps = function()
return ""
end
if not require("lvim.utils.functions").isempty(gps_location) then
if not isempty(gps_location) then
return "%#NavicSeparator#" .. lvim.icons.ui.ChevronRight .. "%* " .. gps_location
else
return ""
@ -172,19 +174,18 @@ M.get_winbar = function()
if excludes() then
return
end
local f = require "lvim.utils.functions"
local value = M.get_filename()
local gps_added = false
if not f.isempty(value) then
if not isempty(value) then
local gps_value = get_gps()
value = value .. " " .. gps_value
if not f.isempty(gps_value) then
if not isempty(gps_value) then
gps_added = true
end
end
if not f.isempty(value) and f.get_buf_option "mod" then
if not isempty(value) and vim.api.nvim_get_option_value("mod", { buf = 0 }) then
-- TODO: replace with circle
local mod = "%#LspCodeLens#" .. lvim.icons.ui.Circle .. "%*"
if gps_added then
@ -196,7 +197,7 @@ M.get_winbar = function()
local num_tabs = #vim.api.nvim_list_tabpages()
if num_tabs > 1 and not f.isempty(value) then
if num_tabs > 1 and not isempty(value) then
local tabpage_number = tostring(vim.api.nvim_tabpage_get_number(0))
value = value .. "%=" .. tabpage_number .. "/" .. tostring(num_tabs)
end

View file

@ -207,7 +207,7 @@ function M.buf_kill(kill_command, bufnr, force)
force = true
else return
end
elseif api.nvim_buf_get_option(bufnr, "buftype") == "terminal" then
elseif api.nvim_get_option_value("buftype", { buf = 0 }) == "terminal" then
choice = fn.confirm(fmt([[Close "%s"?]], bufname), "&Yes\n&No\n&Cancel")
if choice == 1 then
force = true

View file

@ -134,7 +134,7 @@ M.config = function()
active = true,
on_config_done = nil,
enabled = function()
local buftype = vim.api.nvim_buf_get_option(0, "buftype")
local buftype = vim.api.nvim_get_option_value("buftype", { buf = 0 })
if buftype == "prompt" then
return false
end

View file

@ -148,7 +148,7 @@ M.setup_ui = function()
title = "dap-ui",
icon = "",
on_open = function(win)
vim.api.nvim_buf_set_option(vim.api.nvim_win_get_buf(win), "filetype", "markdown")
vim.api.nvim_set_option_value("filetype", "markdown", { buf = vim.api.nvim_win_get_buf(win) })
end,
})

View file

@ -126,7 +126,7 @@ local function make_auto_lsp_info(ft)
end
function M.toggle_popup(ft)
local clients = vim.lsp.get_active_clients()
local clients = vim.lsp.get_clients()
local client_names = {}
local bufnr = vim.api.nvim_get_current_buf()
local ts_active_buffers = vim.tbl_keys(vim.treesitter.highlighter.active)

View file

@ -81,19 +81,19 @@ function M.icon_setup()
end
local function get_hl_by_name(name)
local ret = vim.api.nvim_get_hl_by_name(name.group, true)
local ret = vim.api.nvim_get_hl(0, { name = name.group })
return string.format("#%06x", ret[name.property])
end
local found, icon_hl = pcall(get_hl_by_name, { group = "NvimTreeFolderIcon", property = "foreground" })
local found, icon_color = pcall(get_hl_by_name, { group = "NvimTreeFolderIcon", property = "fg" })
if not found then
icon_hl = "#42A5F5"
icon_color = "#42A5F5"
end
devicons.set_icon {
lir_folder_icon = {
icon = lvim.builtin.lir.icon,
color = icon_hl,
color = icon_color,
name = "LirFolderNode",
},
}

View file

@ -93,7 +93,7 @@ return {
},
lsp = {
function()
local buf_clients = vim.lsp.get_active_clients { bufnr = 0 }
local buf_clients = vim.lsp.get_clients { bufnr = 0 }
if #buf_clients == 0 then
return "LSP Inactive"
end
@ -146,7 +146,7 @@ return {
spaces = {
function()
local shiftwidth = vim.api.nvim_buf_get_option(0, "shiftwidth")
local shiftwidth = vim.api.nvim_get_option_value("shiftwidth", { buf = 0 })
return lvim.icons.ui.Tab .. " " .. shiftwidth
end,
padding = 1,

View file

@ -52,12 +52,12 @@ function Popup:display(content_provider)
-- window options
for key, value in pairs(self.win_opts) do
vim.api.nvim_win_set_option(self.win_id or 0, key, value)
vim.api.nvim_set_option_value(key, value, { win = self.win_id or 0, scope = "local" })
end
-- buffer options
for key, value in pairs(self.buf_opts) do
vim.api.nvim_buf_set_option(self.buffer, key, value)
vim.api.nvim_set_option_value(key, value, { buf = self.buffer })
end
end

View file

@ -6,7 +6,9 @@ local skipped_servers = {
"azure_pipelines_ls",
"basedpyright",
"biome",
"bzl",
"ccls",
"css_variables",
"cssmodules_ls",
"custom_elements_ls",
"denols",
@ -25,6 +27,7 @@ local skipped_servers = {
"golangci_lint_ls",
"gradle_ls",
"graphql",
"harper_ls",
"hdl_checker",
"hydra_lsp",
"htmx",
@ -71,7 +74,9 @@ local skipped_servers = {
"swift_mesonls",
"templ",
"tflint",
"tinymist",
"unocss",
"vale_ls",
"vacuum",
"verible",
"v_analyzer",

View file

@ -5,7 +5,7 @@ local autocmds = require "lvim.core.autocmds"
local function add_lsp_buffer_options(bufnr)
for k, v in pairs(lvim.lsp.buffer_options) do
vim.api.nvim_buf_set_option(bufnr, k, v)
vim.api.nvim_set_option_value(k, v, { buf = bufnr })
end
end

View file

@ -4,7 +4,7 @@ local tbl = require "lvim.utils.table"
local Log = require "lvim.core.log"
function M.is_client_active(name)
local clients = vim.lsp.get_active_clients()
local clients = vim.lsp.get_clients()
return tbl.find_first(clients, function(client)
return client.name == name
end)
@ -12,7 +12,7 @@ end
function M.get_active_clients_by_ft(filetype)
local matches = {}
local clients = vim.lsp.get_active_clients()
local clients = vim.lsp.get_clients()
for _, client in pairs(clients) do
local supported_filetypes = client.config.filetypes or {}
if client.name ~= "null-ls" and vim.tbl_contains(supported_filetypes, filetype) then

View file

@ -1,16 +0,0 @@
local M = {}
function M.isempty(s)
return s == nil or s == ""
end
function M.get_buf_option(opt)
local status_ok, buf_option = pcall(vim.api.nvim_buf_get_option, 0, opt)
if not status_ok then
return nil
else
return buf_option
end
end
return M

View file

@ -12,7 +12,7 @@
"commit": "33eb067"
},
"bufferline.nvim": {
"commit": "73540cb"
"commit": "73edc1f"
},
"cmp-buffer": {
"commit": "3022dbc"
@ -21,7 +21,7 @@
"commit": "d250c63"
},
"cmp-nvim-lsp": {
"commit": "5af77f5"
"commit": "39e2eda"
},
"cmp-path": {
"commit": "91ff86c"
@ -30,7 +30,7 @@
"commit": "05a9ab2"
},
"friendly-snippets": {
"commit": "3e9a3f5"
"commit": "dd2fd12"
},
"gitsigns.nvim": {
"commit": "805610a"
@ -39,7 +39,7 @@
"commit": "9637670"
},
"lazy.nvim": {
"commit": "bef521a"
"commit": "8f19915"
},
"lir.nvim": {
"commit": "7a9d45d"
@ -51,61 +51,61 @@
"commit": "08bbc93"
},
"mason-lspconfig.nvim": {
"commit": "273fdde"
"commit": "a4caa0d"
},
"mason.nvim": {
"commit": "751b1fc"
"commit": "49ff59a"
},
"neodev.nvim": {
"commit": "ce9a2e8"
},
"nlsp-settings.nvim": {
"commit": "707b431"
"commit": "d92035e"
},
"none-ls.nvim": {
"commit": "3a48266"
},
"nvim-autopairs": {
"commit": "14e9737"
"commit": "c15de7e"
},
"nvim-cmp": {
"commit": "cd2cf0c"
"commit": "5260e5e"
},
"nvim-dap": {
"commit": "13ce59d"
"commit": "5a2f712"
},
"nvim-dap-ui": {
"commit": "34160a7"
},
"nvim-lspconfig": {
"commit": "aa5f4f4"
"commit": "eadcee1"
},
"nvim-navic": {
"commit": "8649f69"
},
"nvim-tree.lua": {
"commit": "64f61e4"
"commit": "2bc725a"
},
"nvim-treesitter": {
"commit": "d5a1c2b"
"commit": "30de5e7"
},
"nvim-ts-context-commentstring": {
"commit": "0bdccb9"
"commit": "cb06438"
},
"nvim-web-devicons": {
"commit": "5b90678"
"commit": "e37bb1f"
},
"onedarker.nvim": {
"commit": "b00dd21"
},
"plenary.nvim": {
"commit": "08e3019"
"commit": "a3e3bc8"
},
"project.nvim": {
"commit": "8c6bad7"
},
"schemastore.nvim": {
"commit": "8c46453"
"commit": "9a5992a"
},
"structlog.nvim": {
"commit": "45b26a2"
@ -114,16 +114,16 @@
"commit": "9ef21b2"
},
"telescope.nvim": {
"commit": "6312868"
"commit": "d829aa6"
},
"toggleterm.nvim": {
"commit": "066cccf"
"commit": "fee58a0"
},
"tokyonight.nvim": {
"commit": "67afeaf"
"commit": "b9b494f"
},
"vim-illuminate": {
"commit": "e522e0d"
"commit": "5eeb795"
},
"which-key.nvim": {
"commit": "4433e5e"

View file

@ -41,8 +41,8 @@ _G.load_config = function()
require("vim.lsp.log").set_format_func(vim.inspect)
local nvim_lsp = require "lspconfig"
local on_attach = function(_, bufnr)
local function buf_set_option(...)
vim.api.nvim_buf_set_option(bufnr, ...)
local function buf_set_option(k, v)
vim.api.nvim_set_option_value(k, v, { buf = bufnr })
end
buf_set_option("omnifunc", "v:lua.vim.lsp.omnifunc")

View file

@ -11,7 +11,7 @@ mkdir -p "${SNAPSHOT_DIR}"
export SNAPSHOT_PATH="${REPO_DIR}/snapshots/${SNAPSHOT_NAME}"
time lvim --headless \
-c "luafile ./utils/ci/generate_new_lockfile.lua"
-c "source ./utils/ci/generate_new_lockfile.lua"
temp=$(mktemp)

View file

@ -6,23 +6,14 @@ declare -r LV_INSTALL_PREFIX="${INSTALL_PREFIX:-"$HOME/.local"}"
declare -r RELEASE_VER="${RELEASE_VER:-latest}" # can be set to nightly
declare ARCHIVE_NAME
declare RELEASE_NAME
declare OS
OS="$(uname -s)"
if [ "$OS" == "Linux" ]; then
ARCHIVE_NAME="nvim-linux64"
RELEASE_NAME="nvim-linux64"
elif [ "$OS" == "Darwin" ]; then
if [ "$RELEASE_VER" == "nightly" ]; then
ARCHIVE_NAME="nvim-macos-x86_64"
RELEASE_NAME="nvim-macos-x86_64"
else
ARCHIVE_NAME="nvim-macos"
# for some reason the archive has a different name
RELEASE_NAME="nvim-osx64"
fi
else
echo "$OS platform is not supported currently"
exit 1
@ -77,12 +68,8 @@ function install_neovim() {
pushd "$DOWNLOAD_DIR"
tar -xzf "$DOWNLOAD_DIR/$ARCHIVE_NAME.tar.gz"
popd
if [ ! -d "$DOWNLOAD_DIR/$RELEASE_NAME" ]; then
# fallback to archive name
RELEASE_NAME="$ARCHIVE_NAME"
fi
# https://dev.to/ackshaey/macos-vs-linux-the-cp-command-will-trip-you-up-2p00
cp -r "$DOWNLOAD_DIR/$RELEASE_NAME/." "$LV_INSTALL_PREFIX"
cp -r "$DOWNLOAD_DIR/$ARCHIVE_NAME/." "$LV_INSTALL_PREFIX"
echo "Installation complete!"
echo "Now you can run $LV_INSTALL_PREFIX/bin/nvim"
}