Skip to content

Commit 4d6901e

Browse files
author
cht
committed
update show message
1 parent 8e23c89 commit 4d6901e

3 files changed

Lines changed: 33 additions & 10 deletions

File tree

lua/csvtools.lua

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
local api = vim.api
22
local highlight = require("csvtools.highlight")
33
local overflow = require("csvtools.overflowtext")
4+
local getheader = require("csvtools.header")
45
local M = {
56
before = 20,
67
after = 20,
@@ -16,9 +17,9 @@ local Status = {
1617
header = {},
1718
overflowtext = {},
1819
}
19-
function M.printheader()
20-
return Status.header
21-
end
20+
--function M.printheader()
21+
-- return Status.header
22+
--end
2223
function M.Ifclear()
2324
if M.clearafter then
2425
M.clearafter = false
@@ -43,7 +44,7 @@ function M.NewWindow()
4344
local win = vim.api.nvim_get_current_win()
4445
api.nvim_buf_set_lines(buf, 0, -1, false, { messages })
4546
api.nvim_win_set_buf(win, buf)
46-
Status.header = highlight.highlighttop(buf, messages)
47+
highlight.highlighttop(buf, messages)
4748
Status.winid = win
4849
Status.buf = buf
4950
M.add_mappings()
@@ -87,6 +88,7 @@ local function getrangeoverflow(line, length)
8788
end
8889
function M.Highlight()
8990
if vim.o.filetype == "csv" then
91+
Status.header = getheader.Header()
9092
if M.showoverflow then
9193
for count = 1, #Status.overflowtext do
9294
vim.api.nvim_buf_del_extmark(

lua/csvtools/header.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
local M = {}
2+
3+
--@param buf winbuf
4+
--@param line string
5+
function M.Header()
6+
local line = unpack(vim.api.nvim_buf_get_lines(0, 0, 1, true))
7+
local header = {}
8+
local cout = 1
9+
local length = 0
10+
for i = 1, #line do
11+
if line:sub(i, i) ~= "," then
12+
length = length + 1
13+
else
14+
table.insert(header, length)
15+
length = 0
16+
cout = cout + 1
17+
end
18+
end
19+
return header
20+
end
21+
return M

lua/csvtools/highlight.lua

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,25 @@ local M = {}
44
--@param buf winbuf
55
--@param line string
66
function M.highlighttop(buf, line)
7-
local header = {}
7+
--local header = {}
88
local cout = 1
9-
local length = 0
9+
--local length = 0
1010
for i = 1, #line do
1111
if line:sub(i, i) ~= "|" then
12-
length = length + 1
12+
--length = length + 1
1313
if cout % 2 == 0 then
1414
--print(line:sub(i, i))
1515
api.nvim_buf_add_highlight(buf, -1, "WhidHeader", 0, i - 1, i)
1616
else
1717
api.nvim_buf_add_highlight(buf, -1, "WhidSubHeader", 0, i - 1, i)
1818
end
1919
else
20-
table.insert(header, length)
21-
length = 0
20+
--table.insert(header, length)
21+
--length = 0
2222
cout = cout + 1
2323
end
2424
end
25-
return header
25+
--return header
2626
end
2727

2828
--@param buf winbuf

0 commit comments

Comments
 (0)