From 642d6f331439c3dc0c32274e13bee46abb227920 Mon Sep 17 00:00:00 2001 From: Olivier Roques Date: Thu, 27 Jan 2022 18:43:54 +0100 Subject: [PATCH] fix: invalid reference to fn --- lua/hardline.lua | 4 ++-- lua/hardline/common.lua | 18 ++++++++---------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/lua/hardline.lua b/lua/hardline.lua index 9e88fd2..551f990 100644 --- a/lua/hardline.lua +++ b/lua/hardline.lua @@ -95,7 +95,7 @@ local function load_sections(sections) item = load_section(section.item), } end - common.echo('WarningMsg', 'Invalid section.') + common.echo('Invalid section', 'WarningMsg') return '' end return vim.tbl_map(load_section, sections) @@ -103,7 +103,7 @@ end local function remove_hidden_sections(sections) local filter = function(section) - return not section.hide or section.hide <= fn.winwidth(0) + return not section.hide or section.hide <= vim.fn.winwidth(0) end return vim.tbl_filter(filter, sections) end diff --git a/lua/hardline/common.lua b/lua/hardline/common.lua index 41f1245..f5d7c1d 100644 --- a/lua/hardline/common.lua +++ b/lua/hardline/common.lua @@ -1,5 +1,3 @@ -local cmd, fn = vim.cmd, vim.fn -local g = vim.g local fmt = string.format local M = {} @@ -18,17 +16,17 @@ M.modes = { ['t'] = {text = 'TERMINAL', state = 'command'}, } -function M.echo(hlgroup, msg) - cmd(fmt('echohl %s', hlgroup)) - cmd(fmt('echo "[hardline] %s"', msg)) - cmd('echohl None') +function M.echo(msg, hlgroup) + vim.api.nvim_echo({{fmt('[hardline] %s', msg), hlgroup}}, false, {}) end function M.set_cache_autocmds(augroup) - cmd(fmt('augroup %s', augroup)) - cmd('autocmd!') - cmd(fmt('autocmd CursorHold,BufWritePost * unlet! b:%s', augroup)) - cmd('augroup END') + vim.cmd(fmt([[ + augroup %s + autocmd! + autocmd CursorHold,BufWritePost * unlet! b:%s + augroup END + ]], augroup, augroup)) end return M