-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cht
committed
Feb 16, 2022
1 parent
41dec58
commit ed2a770
Showing
4 changed files
with
91 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
au BufRead,BufNewFile *.csv,*.dat,*.tsv,*.tab set filetype=csv | ||
au FileType csv command! -buffer CloseTopWindow lua require"csvtools".CloseWindow() | ||
au FileType csv command! -buffer TopWindow lua require"csvtools".NewWindow() | ||
autocmd! InsertEnter *.csv,*.bat,*.tsv,*.tab lua require"csvtools".deleteMark() | ||
"au FIiletype csv autocmd CursorMoved csv lua require"csvtools".Highlight() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
local M = {} | ||
local function Split(s, delimiter) | ||
local result = {}; | ||
for match in (s..delimiter):gmatch("(.-)"..delimiter) do | ||
table.insert(result, match); | ||
end | ||
return result; | ||
end | ||
local ns_id = vim.api.nvim_create_namespace('demo') | ||
function M.OverFlow(line_num, header) | ||
local bnr = vim.fn.bufnr('%') | ||
local line = unpack(vim.api.nvim_buf_get_lines(0, line_num-1 , line_num , true)) | ||
local output = Split(line,',') | ||
for count=1,#header do | ||
if output[count] == nil then | ||
output[count] = '' | ||
end | ||
local len = string.len(output[count]) | ||
if len < header[count] then | ||
for _=1, header[count]-len do | ||
output[count] = output[count]..' ' | ||
end | ||
elseif len > header[count] then | ||
--print(len," ",header[count]) | ||
output[count] = output[count]:sub(1,header[count]-2) | ||
output[count] = output[count]..'..' | ||
--print("len=" , string.len(output[count])) | ||
end | ||
--print(header[count]) | ||
end | ||
local virt_text = {} | ||
for count=1,#output do | ||
if count % 2 == 0 then | ||
table.insert(virt_text,{output[count],"WhidHeader"}) | ||
else | ||
table.insert(virt_text,{output[count],"WhidSubHeader"}) | ||
end | ||
table.insert(virt_text,{"|"}) | ||
--table.insert(virt_text,{text,"WhidHeader"}) | ||
--print(output[count]) | ||
end | ||
local opts = { | ||
end_line = 10, | ||
id = 1, | ||
virt_text = virt_text, | ||
virt_text_pos = 'overlay', | ||
-- virt_text_win_col = 20, | ||
} | ||
--highlighttop2(bnr, text) | ||
--print("sss") | ||
return { | ||
markid = vim.api.nvim_buf_set_extmark(bnr, ns_id, line_num - 1 , 0, opts), | ||
ns_id = ns_id, | ||
id = 1, | ||
} | ||
end | ||
return M |