From a734e7f73f7c23fe2278f748814e82687164bf8a Mon Sep 17 00:00:00 2001 From: Patrick Stevens <3138005+Smaug123@users.noreply.github.com> Date: Tue, 26 Mar 2024 00:27:53 +0000 Subject: [PATCH] Fix up neovim deprecations (#40) --- home-manager/nvim/init.lua | 1 - home-manager/nvim/ionide-vim.lua | 16 ++++++++-------- home-manager/nvim/lspconfig.lua | 2 +- home-manager/nvim/venv-selector.lua | 14 +++++++------- 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/home-manager/nvim/init.lua b/home-manager/nvim/init.lua index bc4f1a7..b26a7be 100644 --- a/home-manager/nvim/init.lua +++ b/home-manager/nvim/init.lua @@ -225,7 +225,6 @@ if status then end whichkey.register({ - -- TODO: this isn't working for the FSI ones - maybe we've moved to a different buffer by the time we ask for the keymap? [vim.api.nvim_get_var("maplocalleader")] = { DisplayAllMappingsWithTelescope, "View all mappings", diff --git a/home-manager/nvim/ionide-vim.lua b/home-manager/nvim/ionide-vim.lua index 43fef16..ecd9067 100644 --- a/home-manager/nvim/ionide-vim.lua +++ b/home-manager/nvim/ionide-vim.lua @@ -64,16 +64,16 @@ local function BuildFSharpProjects(projects) local cur_win = vim.api.nvim_get_current_win() local cur_buf = vim.api.nvim_win_get_buf(cur_win) if cur_buf ~= context.buf then - vim.api.nvim_win_close(context.window, 1) + vim.api.nvim_win_close(context.window, true) end print("All builds successful") end else local handle - local stdout = vim.loop.new_pipe(false) - local stderr = vim.loop.new_pipe(false) + local stdout = vim.uv.new_pipe(false) + local stderr = vim.uv.new_pipe(false) - handle, _ = vim.loop.spawn( + handle, _ = vim.uv.spawn( "dotnet", { args = { "build", context.projects[context.completed + 1] }, @@ -112,10 +112,10 @@ local function BuildFSharpProjects(projects) return end - vim.loop.read_start(stdout, function(err, data) + vim.uv.read_start(stdout, function(err, data) on_output(context, "OUT", err, data) end) - vim.loop.read_start(stderr, function(err, data) + vim.uv.read_start(stderr, function(err, data) on_output(context, "ERR", err, data) end) end @@ -134,8 +134,8 @@ local function BuildFSharpProjects(projects) local buf = vim.api.nvim_create_buf(false, true) -- No listed, scratch buffer -- Calculate window size and position here (example: full width, 10 lines high at the bottom) - local width = vim.api.nvim_get_option("columns") - local height = vim.api.nvim_get_option("lines") + local width = vim.api.nvim_get_option_value("columns", {}) + local height = vim.api.nvim_get_option_value("lines", {}) local win_height = math.min(10, math.floor(height * 0.2)) -- 20% of total height or 10 lines local original_win = vim.api.nvim_get_current_win() local win_opts = { diff --git a/home-manager/nvim/lspconfig.lua b/home-manager/nvim/lspconfig.lua index e8f1275..c30821b 100644 --- a/home-manager/nvim/lspconfig.lua +++ b/home-manager/nvim/lspconfig.lua @@ -7,7 +7,7 @@ local coq = require("coq") require("lspconfig")["lua_ls"].setup({ on_init = function(client) local path = client.workspace_folders[1].name - if vim.loop.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then + if vim.uv.fs_stat(path .. "/.luarc.json") or vim.loop.fs_stat(path .. "/.luarc.jsonc") then return end diff --git a/home-manager/nvim/venv-selector.lua b/home-manager/nvim/venv-selector.lua index 84f6cd7..b8c8eb5 100644 --- a/home-manager/nvim/venv-selector.lua +++ b/home-manager/nvim/venv-selector.lua @@ -66,8 +66,8 @@ function CreateVenv() if requirements_path then print("Installing requirements from " .. requirements_path) local handle - local stdout = vim.loop.new_pipe(false) - local stderr = vim.loop.new_pipe(false) + local stdout = vim.uv.new_pipe(false) + local stderr = vim.uv.new_pipe(false) local function on_output(context, prefix, err, data) if err or data then @@ -114,8 +114,8 @@ function CreateVenv() local buf = vim.api.nvim_create_buf(false, true) -- No listed, scratch buffer -- Calculate window size and position here (example: full width, 10 lines high at the bottom) - local width = vim.api.nvim_get_option("columns") - local height = vim.api.nvim_get_option("lines") + local width = vim.api.nvim_get_option_value("columns", {}) + local height = vim.api.nvim_get_option_value("lines", {}) local win_height = math.min(10, math.floor(height * 0.2)) -- 20% of total height or 10 lines local original_win = vim.api.nvim_get_current_win() local win_opts = { @@ -137,7 +137,7 @@ function CreateVenv() buf = buf, } - handle, _ = vim.loop.spawn( + handle, _ = vim.uv.spawn( -- TODO: do we need to escape this? Don't know whether spawn goes via a shell venv_dir .. "/bin/python", { @@ -161,10 +161,10 @@ function CreateVenv() return end - vim.loop.read_start(stdout, function(err, data) + vim.uv.read_start(stdout, function(err, data) on_output(context, "OUT", err, data) end) - vim.loop.read_start(stderr, function(err, data) + vim.uv.read_start(stderr, function(err, data) on_output(context, "ERR", err, data) end) else