Skip to content

Commit

Permalink
break change
Browse files Browse the repository at this point in the history
  • Loading branch information
cht committed Feb 16, 2022
1 parent 16e5796 commit e9813a2
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 4 deletions.
31 changes: 31 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# CSV-tools

## Setup
should not setup or

```lua
require("csvtools").setup({
before = 5,
after = 5,
})
```

the number should be as small as possible

Above is the default setting

## Defaut key

| command | use |
| -- | -- |
| TopWindow | open a top window to show the key of csv|
| CloseWindow | close the top window|

| key | use |
| -- | -- |
|\<leader\> td| close the topwindow ,both topwindow and csv buffer has |
|\<leader\> tf| open a new topwindow |

## TODO

* Make the top line and csv shown as a table
1 change: 1 addition & 0 deletions ftdetect/csv-tools.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
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()
"au FIiletype csv autocmd CursorMoved csv lua require"csvtools".Highlight()
6 changes: 3 additions & 3 deletions lua/csvtools.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ local M = {
winid = nil,
buf = nil,
mainwindowbuf = nil,
before = 10,
after = 10,
before = 5,
after = 5,
}
local highlight = require("csvtools.topbarhighlight")
function M.NewWindow()
Expand Down Expand Up @@ -53,7 +53,6 @@ local function getrange (line,length)
end
function M.Highlight()
if vim.o.filetype == "csv" then

M.mainwindowbuf = vim.api.nvim_get_current_buf()
local line ,_ = unpack(vim.api.nvim_win_get_cursor(0))
local length = vim.api.nvim_buf_line_count(M.mainwindowbuf)
Expand All @@ -69,6 +68,7 @@ function M.Highlight()
end
end
function M.add_mappings()
M.mainwindowbuf = vim.api.nvim_get_current_buf()
--print(M.mainwindowbuf)
local opts = { nowait = true, noremap = true, silent = true }
--vim.api.nvim_buf_set_keymap(M.mainwindowbuf, "n", "<leader>td", ":lua require'csvtools'.CloseWindow<cr>", opts)
Expand Down
3 changes: 2 additions & 1 deletion plugin/csv-tool.vim
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
au FileType csv lua require"csvtools".NewWindow()
"au FileType csv lua require"csvtools".NewWindow()
au FileType csv lua require"csvtools".add_mappings()
hi def link WhidHeader Number
hi def link WhidSubHeader Statement

0 comments on commit e9813a2

Please sign in to comment.