From f005a8303d5e275a07ec423a0b42c5e0f4083c21 Mon Sep 17 00:00:00 2001 From: jdhao Date: Wed, 26 Mar 2025 22:33:39 +0100 Subject: [PATCH] Nvim version bump (#385) * update nvim version to 0.11.0 * replace deprecated nvim_err_write/nvim_err_writeln call * replace deprecated func for diagnostic and lsp * use vim.hl instead * use new way to define diagnostic signs --- README.md | 2 +- init.lua | 2 +- lua/config/hlslens.lua | 4 ++-- lua/config/lsp.lua | 39 +++++++++++++++++---------------------- lua/custom-autocmd.lua | 2 +- lua/globals.lua | 3 ++- lua/utils.lua | 4 ++-- plugin/command.lua | 3 ++- viml_conf/options.vim | 1 + 9 files changed, 29 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index b4a7bef..e3b9542 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ Windows - Neovim minimum version + Neovim minimum version Latest release diff --git a/init.lua b/init.lua index cd15458..aa7d3c3 100644 --- a/init.lua +++ b/init.lua @@ -13,7 +13,7 @@ vim.loader.enable() local utils = require("utils") -local expected_version = "0.10.4" +local expected_version = "0.11.0" utils.is_compatible_version(expected_version) local config_dir = vim.fn.stdpath("config") diff --git a/lua/config/hlslens.lua b/lua/config/hlslens.lua index 0f59bca..e216a64 100644 --- a/lua/config/hlslens.lua +++ b/lua/config/hlslens.lua @@ -16,7 +16,7 @@ local activate_hlslens = function(direction) if not status then local start_idx, _ = string.find(msg, "E486", 1, true) local msg_part = string.sub(msg, start_idx) - api.nvim_err_writeln(msg_part) + api.nvim_echo({ { msg_part } }, true, { err = true }) return end @@ -40,7 +40,7 @@ local check_cursor_word = function() local result = cursor_word == "" if result then local msg = "E348: No string under cursor" - api.nvim_err_writeln(msg) + api.nvim_echo({ { msg } }, true, { err = true }) end return result, cursor_word diff --git a/lua/config/lsp.lua b/lua/config/lsp.lua index 1496010..a9633d5 100644 --- a/lua/config/lsp.lua +++ b/lua/config/lsp.lua @@ -30,12 +30,18 @@ local custom_attach = function(client, bufnr) map("n", "gd", vim.lsp.buf.definition, { desc = "go to definition" }) map("n", "", vim.lsp.buf.definition) - map("n", "K", vim.lsp.buf.hover) + map("n", "K", function() + vim.lsp.buf.hover { border = "rounded" } + end) map("n", "", vim.lsp.buf.signature_help) map("n", "rn", vim.lsp.buf.rename, { desc = "varialbe rename" }) map("n", "gr", vim.lsp.buf.references, { desc = "show references" }) - map("n", "[d", diagnostic.goto_prev, { desc = "previous diagnostic" }) - map("n", "]d", diagnostic.goto_next, { desc = "next diagnostic" }) + map("n", "[d", function() + diagnostic.jump { count = -1, float = true } + end, { desc = "previous diagnostic" }) + map("n", "]d", function() + diagnostic.jump { count = 1, float = true } + end, { desc = "next diagnostic" }) -- this puts diagnostics from opened files to quickfix map("n", "qw", diagnostic.setqflist, { desc = "put window diagnostics to qf" }) -- this puts diagnostics from current buffer to quickfix @@ -278,28 +284,17 @@ if utils.executable("lua-language-server") then } end --- Change diagnostic signs. -fn.sign_define("DiagnosticSignError", { text = "🆇", texthl = "DiagnosticSignError" }) -fn.sign_define("DiagnosticSignWarn", { text = "âš ī¸", texthl = "DiagnosticSignWarn" }) -fn.sign_define("DiagnosticSignInfo", { text = "â„šī¸", texthl = "DiagnosticSignInfo" }) -fn.sign_define("DiagnosticSignHint", { text = "", texthl = "DiagnosticSignHint" }) - -- global config for diagnostic diagnostic.config { underline = false, virtual_text = false, - signs = true, + signs = { + text = { + [diagnostic.severity.ERROR] = "🆇", + [diagnostic.severity.WARN] = "âš ī¸", + [diagnostic.severity.INFO] = "â„šī¸", + [diagnostic.severity.HINT] = "", + }, + }, severity_sort = true, } - --- lsp.handlers["textDocument/publishDiagnostics"] = lsp.with(lsp.diagnostic.on_publish_diagnostics, { --- underline = false, --- virtual_text = false, --- signs = true, --- update_in_insert = false, --- }) - --- Change border of documentation hover window, See https://github.com/neovim/neovim/pull/13998. -lsp.handlers["textDocument/hover"] = lsp.with(vim.lsp.handlers.hover, { - border = "rounded", -}) diff --git a/lua/custom-autocmd.lua b/lua/custom-autocmd.lua index e03a022..3cbe54d 100644 --- a/lua/custom-autocmd.lua +++ b/lua/custom-autocmd.lua @@ -22,7 +22,7 @@ api.nvim_create_autocmd({ "TextYankPost" }, { pattern = "*", group = yank_group, callback = function() - vim.highlight.on_yank { higroup = "YankColor", timeout = 300 } + vim.hl.on_yank { higroup = "YankColor", timeout = 300 } end, }) diff --git a/lua/globals.lua b/lua/globals.lua index 7e65176..e0bdad6 100644 --- a/lua/globals.lua +++ b/lua/globals.lua @@ -27,7 +27,8 @@ if utils.executable("python3") then vim.g.python3_host_prog = fn.exepath("python3") end else - api.nvim_err_writeln("Python3 executable not found! You must install Python3 and set its PATH correctly!") + local msg = "Python3 executable not found! You must install Python3 and set its PATH correctly!" + api.nvim_echo({ { msg } }, true, { err = true }) return end diff --git a/lua/utils.lua b/lua/utils.lua index a1a3777..d77dc1a 100644 --- a/lua/utils.lua +++ b/lua/utils.lua @@ -61,7 +61,7 @@ function M.is_compatible_version(expected_version) if expect_ver == nil then local msg = string.format("Unsupported version string: %s", expected_version) - vim.api.nvim_err_writeln(msg) + vim.api.nvim_echo({ { msg } }, true, { err = true }) return false end @@ -73,7 +73,7 @@ function M.is_compatible_version(expected_version) expected_version, _ver ) - vim.api.nvim_err_writeln(msg) + vim.api.nvim_echo({ { msg } }, true, { err = true }) end return true diff --git a/plugin/command.lua b/plugin/command.lua index 560dea1..006e372 100644 --- a/plugin/command.lua +++ b/plugin/command.lua @@ -50,7 +50,8 @@ vim.api.nvim_create_user_command("JSONFormat", function(context) local cmd_str = string.format("%s,%s!python -m json.tool", line1, line2) vim.fn.execute(cmd_str) else - vim.api.nvim_err_write(string.format("unsupported range: %s", range)) + local msg = string.format("unsupported range: %s", range) + vim.api.nvim_echo({ { msg } }, true, { err = true }) end end, { desc = "Format JSON string", diff --git a/viml_conf/options.vim b/viml_conf/options.vim index 1e3d2ae..d0e813d 100644 --- a/viml_conf/options.vim +++ b/viml_conf/options.vim @@ -124,6 +124,7 @@ set pumheight=10 " Maximum number of items to show in popup menu set pumblend=5 " pseudo transparency for completion menu set winblend=0 " pseudo transparency for floating window +set winborder=none " Insert mode key word completion setting set complete+=kspell complete-=w complete-=b complete-=u complete-=t