From 67a322c26cd82534c8f9536fd788f579559a91c8 Mon Sep 17 00:00:00 2001 From: jdhao Date: Wed, 7 Sep 2022 23:35:18 +0800 Subject: [PATCH] refactor: use nvim_err_writeln for error msg --- init.lua | 7 ++++--- lua/config/hlslens.lua | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/init.lua b/init.lua index 23449f9..de5909b 100644 --- a/init.lua +++ b/init.lua @@ -8,15 +8,16 @@ -- Email: jdhao@hotmail.com -- Blog: https://jdhao.github.io/ +local api = vim.api +local utils = require "utils" + -- check if we have the latest stable version of nvim local expected_ver = "0.7.2" - -local utils = require "utils" local nvim_ver = utils.get_nvim_version() if nvim_ver ~= expected_ver then local msg = string.format("Unsupported nvim version: expect %s, but got %s instead!", expected_ver, nvim_ver) - vim.api.nvim_echo({ { msg, "ErrorMsg" } }, false, {}) + api.nvim_err_writeln(msg) return end diff --git a/lua/config/hlslens.lua b/lua/config/hlslens.lua index 5b2199d..59ce9a3 100644 --- a/lua/config/hlslens.lua +++ b/lua/config/hlslens.lua @@ -1,3 +1,4 @@ +local api = vim.api local keymap = vim.keymap require('hlslens').setup({ @@ -12,7 +13,7 @@ local activate_hlslens = function(direction) msg = msg:sub(13) if not status then - vim.api.nvim_echo({{msg, "ErrorMsg"}}, false, {}) + api.nvim_err_writeln(msg) return end require('hlslens').start()