From 9dae85a4a367ac98a8d44d46d0d8dbc1a9f3f75b Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Mon, 19 Feb 2024 04:30:05 -0600 Subject: [PATCH] refactor(nvim): general cleanup of deprecated functions and diags --- dots/.config/nvim/after/ftplugin/cs.lua | 2 +- dots/.config/nvim/after/ftplugin/jinja2.lua | 2 +- dots/.config/nvim/after/ftplugin/nix.lua | 3 +-- dots/.config/nvim/lua/core/autocmds.lua | 2 +- dots/.config/nvim/lua/core/globals.lua | 2 -- dots/.config/nvim/lua/core/lsp.lua | 18 ------------------ .../nvim/lua/plugins/configs/heirline.lua | 15 +++++++-------- dots/.config/nvim/lua/plugins/configs/tint.lua | 6 +++--- 8 files changed, 14 insertions(+), 36 deletions(-) diff --git a/dots/.config/nvim/after/ftplugin/cs.lua b/dots/.config/nvim/after/ftplugin/cs.lua index 25107080..fd869e1f 100644 --- a/dots/.config/nvim/after/ftplugin/cs.lua +++ b/dots/.config/nvim/after/ftplugin/cs.lua @@ -1 +1 @@ -vim.api.nvim_buf_set_option(0, "commentstring", "// %s") +vim.opt_local.commentstring = "// %s" diff --git a/dots/.config/nvim/after/ftplugin/jinja2.lua b/dots/.config/nvim/after/ftplugin/jinja2.lua index b224a9a0..b8f2361d 100644 --- a/dots/.config/nvim/after/ftplugin/jinja2.lua +++ b/dots/.config/nvim/after/ftplugin/jinja2.lua @@ -1 +1 @@ -vim.api.nvim_buf_set_option(0, "commentstring", "{# %s #}") +vim.opt_local.commentstring = "{# %s #}" diff --git a/dots/.config/nvim/after/ftplugin/nix.lua b/dots/.config/nvim/after/ftplugin/nix.lua index b8d0b952..cb2ddb1d 100644 --- a/dots/.config/nvim/after/ftplugin/nix.lua +++ b/dots/.config/nvim/after/ftplugin/nix.lua @@ -2,8 +2,7 @@ local opt_local = vim.opt_local opt_local.tabstop = 2 opt_local.shiftwidth = 2 - -vim.api.nvim_buf_set_option(0, "commentstring", "# %s") +opt_local.commenstring = "# %s" vim.keymap.set("n", "fr", function() local cmd = { diff --git a/dots/.config/nvim/lua/core/autocmds.lua b/dots/.config/nvim/lua/core/autocmds.lua index 257c3b8d..1402adc8 100644 --- a/dots/.config/nvim/lua/core/autocmds.lua +++ b/dots/.config/nvim/lua/core/autocmds.lua @@ -21,7 +21,7 @@ M.setup = function() title = "Strip Trail Space", ---@param win integer The window handle 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, }) end, { desc = "Toggles intercepting BufWritePre to strip trail space" }) diff --git a/dots/.config/nvim/lua/core/globals.lua b/dots/.config/nvim/lua/core/globals.lua index c2b1b82c..71d3e8c2 100755 --- a/dots/.config/nvim/lua/core/globals.lua +++ b/dots/.config/nvim/lua/core/globals.lua @@ -1,5 +1,3 @@ -local g = vim.g - local M = {} M.setup = function() end diff --git a/dots/.config/nvim/lua/core/lsp.lua b/dots/.config/nvim/lua/core/lsp.lua index b05f6c8b..4f1098e3 100644 --- a/dots/.config/nvim/lua/core/lsp.lua +++ b/dots/.config/nvim/lua/core/lsp.lua @@ -11,24 +11,6 @@ M.setup = function() lspSymbol("Info", "󰋼", 10) lspSymbol("Hint", "", 10) - local border = { - { "╭", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╮", "FloatBorder" }, - { "│", "FloatBorder" }, - { "╯", "FloatBorder" }, - { "─", "FloatBorder" }, - { "╰", "FloatBorder" }, - { "│", "FloatBorder" }, - } - - local orig_util_open_floating_preview = vim.lsp.util.open_floating_preview - function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) - opts = opts or {} - opts.border = opts.border or border - return orig_util_open_floating_preview(contents, syntax, opts, ...) - end - vim.diagnostic.config({ virtual_text = false, virtual_lines = true, diff --git a/dots/.config/nvim/lua/plugins/configs/heirline.lua b/dots/.config/nvim/lua/plugins/configs/heirline.lua index 61fead3b..fcb44c6f 100644 --- a/dots/.config/nvim/lua/plugins/configs/heirline.lua +++ b/dots/.config/nvim/lua/plugins/configs/heirline.lua @@ -342,16 +342,16 @@ return { -- also, we are adding a nice icon for terminal buffers. local StatusLineFileFlags = { { - condition = function(self) - return vim.api.nvim_buf_get_option(self.bufnr, "modified") + condition = function() + return vim.bo.modified end, provider = "  ", hl = { fg = colors.springGreen }, }, { - condition = function(self) - return not vim.api.nvim_buf_get_option(self.bufnr, "modifiable") - or vim.api.nvim_buf_get_option(self.bufnr, "readonly") + condition = function() + return not vim.bo.modifiable + or vim.bo.readonly end, provider = " ", hl = { fg = colors.roninYellow }, @@ -393,8 +393,8 @@ return { -- a nice "x" button to close the buffer local StatusLineCloseButton = { - condition = function(self) - return not vim.api.nvim_buf_get_option(self.bufnr, "modified") + condition = function() + return not vim.bo.modified end, { provider = " 󰅙 ", @@ -979,7 +979,6 @@ return { }, { provider = function(self) - local branch = self.status_dict.head return " " .. self.status_dict.head end, hl = { fg = colors.sumiInk0, bg = colors.autumnGreen }, diff --git a/dots/.config/nvim/lua/plugins/configs/tint.lua b/dots/.config/nvim/lua/plugins/configs/tint.lua index 3f47e9e7..c4ee9368 100644 --- a/dots/.config/nvim/lua/plugins/configs/tint.lua +++ b/dots/.config/nvim/lua/plugins/configs/tint.lua @@ -12,12 +12,12 @@ return { local ignoredFiletypes = { "DiffviewFiles", "DiffviewFileHistory", "neo-tree" } local ignoredBuftypes = { "terminal" } - local isDiff = vim.api.nvim_win_get_option(winid, "diff") + local isDiff = vim.api.nvim_get_option_value("diff", { win = winid }) local isFloating = vim.api.nvim_win_get_config(winid).relative ~= "" local isIgnoredBuftype = - vim.tbl_contains(ignoredBuftypes, vim.api.nvim_buf_get_option(bufid, "buftype")) + vim.tbl_contains(ignoredBuftypes, vim.api.nvim_get_option_value("buftype", { buf = bufid })) local isIgnoredFiletype = - vim.tbl_contains(ignoredFiletypes, vim.api.nvim_buf_get_option(bufid, "filetype")) + vim.tbl_contains(ignoredFiletypes, vim.api.nvim_get_option_value("filetype", { buf = bufid })) return isDiff or isFloating or isIgnoredBuftype or isIgnoredFiletype end,