Skip to content

Commit e9813a2

Browse files
author
cht
committed
break change
1 parent 16e5796 commit e9813a2

4 files changed

Lines changed: 37 additions & 4 deletions

File tree

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# CSV-tools
2+
3+
## Setup
4+
should not setup or
5+
6+
```lua
7+
require("csvtools").setup({
8+
before = 5,
9+
after = 5,
10+
})
11+
```
12+
13+
the number should be as small as possible
14+
15+
Above is the default setting
16+
17+
## Defaut key
18+
19+
| command | use |
20+
| -- | -- |
21+
| TopWindow | open a top window to show the key of csv|
22+
| CloseWindow | close the top window|
23+
24+
| key | use |
25+
| -- | -- |
26+
|\<leader\> td| close the topwindow ,both topwindow and csv buffer has |
27+
|\<leader\> tf| open a new topwindow |
28+
29+
## TODO
30+
31+
* Make the top line and csv shown as a table

ftdetect/csv-tools.vim

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
au BufRead,BufNewFile *.csv,*.dat,*.tsv,*.tab set filetype=csv
22
au FileType csv command! -buffer CloseTopWindow lua require"csvtools".CloseWindow()
33
au FileType csv command! -buffer TopWindow lua require"csvtools".NewWindow()
4+
"au FIiletype csv autocmd CursorMoved csv lua require"csvtools".Highlight()

lua/csvtools.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ local M = {
44
winid = nil,
55
buf = nil,
66
mainwindowbuf = nil,
7-
before = 10,
8-
after = 10,
7+
before = 5,
8+
after = 5,
99
}
1010
local highlight = require("csvtools.topbarhighlight")
1111
function M.NewWindow()
@@ -53,7 +53,6 @@ local function getrange (line,length)
5353
end
5454
function M.Highlight()
5555
if vim.o.filetype == "csv" then
56-
5756
M.mainwindowbuf = vim.api.nvim_get_current_buf()
5857
local line ,_ = unpack(vim.api.nvim_win_get_cursor(0))
5958
local length = vim.api.nvim_buf_line_count(M.mainwindowbuf)
@@ -69,6 +68,7 @@ function M.Highlight()
6968
end
7069
end
7170
function M.add_mappings()
71+
M.mainwindowbuf = vim.api.nvim_get_current_buf()
7272
--print(M.mainwindowbuf)
7373
local opts = { nowait = true, noremap = true, silent = true }
7474
--vim.api.nvim_buf_set_keymap(M.mainwindowbuf, "n", "<leader>td", ":lua require'csvtools'.CloseWindow<cr>", opts)

plugin/csv-tool.vim

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1-
au FileType csv lua require"csvtools".NewWindow()
1+
"au FileType csv lua require"csvtools".NewWindow()
2+
au FileType csv lua require"csvtools".add_mappings()
23
hi def link WhidHeader Number
34
hi def link WhidSubHeader Statement

0 commit comments

Comments
 (0)