mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
Merge pull request #57 from jdhao/fix-trailing-space
fix: trailing white sapces do not show as expected
This commit is contained in:
commit
6b59c268f9
@ -21,14 +21,22 @@ local function ime_state()
|
|||||||
end
|
end
|
||||||
|
|
||||||
local function trailing_space()
|
local function trailing_space()
|
||||||
-- Get the positions of trailing whitespaces from plugin 'jdhao/whitespace.nvim'.
|
local line_num = nil
|
||||||
local trailing_space_pos = vim.b.trailing_whitespace_pos
|
|
||||||
|
for i=1, fn.line('$') do
|
||||||
|
local linetext = fn.getline(i)
|
||||||
|
-- To prevent invalid escape error, we wrap the regex string with `[[]]`.
|
||||||
|
local idx = fn.match(linetext, [[\v\s+$]])
|
||||||
|
|
||||||
|
if idx ~= -1 then
|
||||||
|
line_num = i
|
||||||
|
break
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local msg = ""
|
local msg = ""
|
||||||
if #trailing_space_pos > 0 then
|
if line_num ~= nil then
|
||||||
-- Note that lua index is 1-based, not zero based!!!
|
msg = string.format("[%d]trailing", line_num)
|
||||||
local line = trailing_space_pos[1][1]
|
|
||||||
msg = string.format("[%d]trailing", line)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return msg
|
return msg
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user