From df25b87c73e0f8e2f1d1407769f816c51554aeeb Mon Sep 17 00:00:00 2001 From: Julien Vincent Date: Sun, 13 Oct 2024 12:18:04 +0100 Subject: [PATCH] Don't set ft when calling prepare_buffer in tests --- tests/nvim-paredit/barf_spec.lua | 4 +++- tests/nvim-paredit/cursor_spec.lua | 4 +++- tests/nvim-paredit/deletions_spec.lua | 12 +++++++--- tests/nvim-paredit/element_drag_spec.lua | 7 +++++- tests/nvim-paredit/element_raise_spec.lua | 4 +++- .../form_and_element_wrap_spec.lua | 4 +++- tests/nvim-paredit/form_drag_spec.lua | 7 +++++- tests/nvim-paredit/form_raise_spec.lua | 4 +++- tests/nvim-paredit/form_unwrap_spec.lua | 4 +++- tests/nvim-paredit/indentation_spec.lua | 4 +++- tests/nvim-paredit/operator_motion_spec.lua | 8 +++++++ tests/nvim-paredit/pair_drag_spec.lua | 8 +++++-- tests/nvim-paredit/slurp_spec.lua | 14 +++++++++-- .../text_object_selections_spec.lua | 24 ++++++++++++++----- tests/nvim-paredit/utils.lua | 2 -- 15 files changed, 86 insertions(+), 24 deletions(-) diff --git a/tests/nvim-paredit/barf_spec.lua b/tests/nvim-paredit/barf_spec.lua index 1de18c7..291d64a 100644 --- a/tests/nvim-paredit/barf_spec.lua +++ b/tests/nvim-paredit/barf_spec.lua @@ -5,7 +5,9 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all local expect = require("tests.nvim-paredit.utils").expect describe("barfing ::", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) describe("barfing forwards", function() it("should barf different form types -", function() diff --git a/tests/nvim-paredit/cursor_spec.lua b/tests/nvim-paredit/cursor_spec.lua index c469ef5..b803f86 100644 --- a/tests/nvim-paredit/cursor_spec.lua +++ b/tests/nvim-paredit/cursor_spec.lua @@ -3,7 +3,9 @@ local ts = require("nvim-treesitter.ts_utils") local prepare_buffer = require("tests.nvim-paredit.utils").prepare_buffer describe("cursor pos api tests", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) it("should place cursor inside form at the beginning", function() prepare_buffer({ diff --git a/tests/nvim-paredit/deletions_spec.lua b/tests/nvim-paredit/deletions_spec.lua index 9b7436e..a26b40f 100644 --- a/tests/nvim-paredit/deletions_spec.lua +++ b/tests/nvim-paredit/deletions_spec.lua @@ -5,7 +5,9 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all local expect = require("tests.nvim-paredit.utils").expect describe("form deletions", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) it("should delete the form", function() prepare_buffer({ @@ -92,7 +94,9 @@ describe("form deletions", function() end) describe("form inner deletions", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) it("should delete everything in the form", function() prepare_buffer({ @@ -179,7 +183,9 @@ describe("form inner deletions", function() end) describe("element deletions", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) it("should delete the element under cursor", function() prepare_buffer({ diff --git a/tests/nvim-paredit/element_drag_spec.lua b/tests/nvim-paredit/element_drag_spec.lua index 6b8a9f4..9825f91 100644 --- a/tests/nvim-paredit/element_drag_spec.lua +++ b/tests/nvim-paredit/element_drag_spec.lua @@ -5,8 +5,13 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all local expect = require("tests.nvim-paredit.utils").expect describe("element-dragging", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) local parser = vim.treesitter.get_parser(0) + if not parser then + return error("Failed to get parser for language") + end it("should drag the element forwards", function() prepare_buffer({ diff --git a/tests/nvim-paredit/element_raise_spec.lua b/tests/nvim-paredit/element_raise_spec.lua index d7814c4..b67921f 100644 --- a/tests/nvim-paredit/element_raise_spec.lua +++ b/tests/nvim-paredit/element_raise_spec.lua @@ -4,7 +4,9 @@ local prepare_buffer = require("tests.nvim-paredit.utils").prepare_buffer local expect = require("tests.nvim-paredit.utils").expect describe("element raising", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) it("should raise the element", function() prepare_buffer({ diff --git a/tests/nvim-paredit/form_and_element_wrap_spec.lua b/tests/nvim-paredit/form_and_element_wrap_spec.lua index b9cb10a..8d68a3b 100644 --- a/tests/nvim-paredit/form_and_element_wrap_spec.lua +++ b/tests/nvim-paredit/form_and_element_wrap_spec.lua @@ -3,7 +3,9 @@ local prepare_buffer = require("tests.nvim-paredit.utils").prepare_buffer local expect = require("tests.nvim-paredit.utils").expect describe("element and form wrap", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) it("should not wrap if cursor is whitespace", function() prepare_buffer({ diff --git a/tests/nvim-paredit/form_drag_spec.lua b/tests/nvim-paredit/form_drag_spec.lua index 013e6e4..d045feb 100644 --- a/tests/nvim-paredit/form_drag_spec.lua +++ b/tests/nvim-paredit/form_drag_spec.lua @@ -5,8 +5,13 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all local expect = require("tests.nvim-paredit.utils").expect describe("form-dragging", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) local parser = vim.treesitter.get_parser(0) + if not parser then + return error("Failed to get parser for language") + end it("should drag the form forwards", function() expect_all(paredit.drag_form_forwards, { diff --git a/tests/nvim-paredit/form_raise_spec.lua b/tests/nvim-paredit/form_raise_spec.lua index 0112fbf..bed6a2e 100644 --- a/tests/nvim-paredit/form_raise_spec.lua +++ b/tests/nvim-paredit/form_raise_spec.lua @@ -5,7 +5,9 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all local expect = require("tests.nvim-paredit.utils").expect describe("form raising", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) it("should raise the form", function() expect_all(paredit.raise_form, { diff --git a/tests/nvim-paredit/form_unwrap_spec.lua b/tests/nvim-paredit/form_unwrap_spec.lua index bf308bf..da1d827 100644 --- a/tests/nvim-paredit/form_unwrap_spec.lua +++ b/tests/nvim-paredit/form_unwrap_spec.lua @@ -3,7 +3,9 @@ local prepare_buffer = require("tests.nvim-paredit.utils").prepare_buffer local expect = require("tests.nvim-paredit.utils").expect describe("form uwrap (e.g. splice)", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) local unwrap = paredit.unwrap it("should uwrap list under cursor", function() diff --git a/tests/nvim-paredit/indentation_spec.lua b/tests/nvim-paredit/indentation_spec.lua index 53ab897..5770bcb 100644 --- a/tests/nvim-paredit/indentation_spec.lua +++ b/tests/nvim-paredit/indentation_spec.lua @@ -10,7 +10,9 @@ local opts = vim.tbl_deep_extend("force", defaults.defaults, { }) describe("forward slurping indentation", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) local function slurp_forwards() paredit.slurp_forwards(opts) end diff --git a/tests/nvim-paredit/operator_motion_spec.lua b/tests/nvim-paredit/operator_motion_spec.lua index 19347c6..d6d4a8b 100644 --- a/tests/nvim-paredit/operator_motion_spec.lua +++ b/tests/nvim-paredit/operator_motion_spec.lua @@ -7,6 +7,10 @@ local defaults = require("nvim-paredit.defaults") describe("motions with operator pending", function() before_each(function() + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) + keybindings.setup_keybindings({ keys = defaults.default_keys, }) @@ -152,6 +156,10 @@ end) describe("motions with operator pending and v:count", function() before_each(function() + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) + keybindings.setup_keybindings({ keys = defaults.default_keys, }) diff --git a/tests/nvim-paredit/pair_drag_spec.lua b/tests/nvim-paredit/pair_drag_spec.lua index 139f7df..42e34b6 100644 --- a/tests/nvim-paredit/pair_drag_spec.lua +++ b/tests/nvim-paredit/pair_drag_spec.lua @@ -5,7 +5,9 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all local expect = require("tests.nvim-paredit.utils").expect describe("paired-element-auto-dragging", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) it("should drag map pairs forward", function() prepare_buffer({ content = "{:a 1 :b 2}", @@ -70,7 +72,9 @@ describe("paired-element-auto-dragging", function() end) describe("paired-element-dragging", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) it("should drag vector elements forwards", function() prepare_buffer({ content = "'[a b c d]", diff --git a/tests/nvim-paredit/slurp_spec.lua b/tests/nvim-paredit/slurp_spec.lua index 60a69ff..e552025 100644 --- a/tests/nvim-paredit/slurp_spec.lua +++ b/tests/nvim-paredit/slurp_spec.lua @@ -5,8 +5,13 @@ local expect_all = require("tests.nvim-paredit.utils").expect_all local expect = require("tests.nvim-paredit.utils").expect describe("slurping backward", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) local parser = vim.treesitter.get_parser(0) + if not parser then + return error("Failed to get parser for language") + end it("should slurp different form types", function() expect_all(paredit.slurp_backwards, { @@ -125,8 +130,13 @@ describe("slurping backward", function() end) describe("slurping forward", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) local parser = vim.treesitter.get_parser(0) + if not parser then + return error("Failed to get parser for language") + end it("should slurp forward different form types", function() expect_all(paredit.slurp_forwards, { diff --git a/tests/nvim-paredit/text_object_selections_spec.lua b/tests/nvim-paredit/text_object_selections_spec.lua index 5925f7b..0e56fbe 100644 --- a/tests/nvim-paredit/text_object_selections_spec.lua +++ b/tests/nvim-paredit/text_object_selections_spec.lua @@ -7,7 +7,9 @@ local expect = require("tests.nvim-paredit.utils").expect local utils = require("tests.nvim-paredit.utils") describe("form deletions", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) before_each(function() keybindings.setup_keybindings({ @@ -101,7 +103,9 @@ describe("form deletions", function() end) describe("top level form deletions", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) before_each(function() keybindings.setup_keybindings({ @@ -135,7 +139,9 @@ describe("top level form deletions", function() end) describe("form selections", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) before_each(function() keybindings.setup_keybindings({ @@ -163,7 +169,9 @@ describe("form selections", function() end) describe("top form selections", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) before_each(function() keybindings.setup_keybindings({ @@ -191,7 +199,9 @@ describe("top form selections", function() end) describe("element deletions", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) before_each(function() keybindings.setup_keybindings({ @@ -213,7 +223,9 @@ describe("element deletions", function() end) describe("element selections", function() - vim.api.nvim_buf_set_option(0, "filetype", "clojure") + vim.api.nvim_set_option_value("filetype", "clojure", { + buf = 0, + }) before_each(function() keybindings.setup_keybindings({ diff --git a/tests/nvim-paredit/utils.lua b/tests/nvim-paredit/utils.lua index 9b3c454..af7883f 100644 --- a/tests/nvim-paredit/utils.lua +++ b/tests/nvim-paredit/utils.lua @@ -9,8 +9,6 @@ function M.feedkeys(keys) end function M.prepare_buffer(params) - vim.api.nvim_buf_set_option(0, "filetype", "clojure") - local content = params.content if type(content) == "string" then content = { content }