Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pandoc: Table edit commands #313

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Pandoc: Table edit commands #313

wants to merge 2 commits into from

Conversation

randomizedthinking
Copy link

The table edit function of vimwiki is quite nice. Here the code is ported to pandoc with minor modifications. It would serve as a good starting point to add more functionalities.

My initial test shows everything works:

:PandocTable       " create a table
<Tab>, <S-Tab>     " jump between cells
gqq                " format a table
...

Let me know how you think.

@fmoralesc
Copy link
Member

fmoralesc commented May 21, 2019

Thanks! I like the idea. Some comments:

  1. The tbl.vim file should be table.vim. No need to be too concise ;)
  2. We should treat this as a proper module, there should be a pandoc#table#Init() function that sets the configuration, creates the commands and sets the autocommands (check the structure of other modules, and :help vim-pandoc-devel). No need to touch plugin/pandoc.vim and ftplugin/pandoc.vim. Those are just for general settings. This way people can disable this functionality if they want.
  3. We should have the MIT license header at the top of the file, or we should add it to the top of the repository. cc @alerque
  4. There are some TODO items in the script. Do you want to complete those before we integrate the functionality? Should we treat this as WIP?

@alerque
Copy link
Member

alerque commented May 21, 2019

Yes a license file should be placed in the top of the repository. Individual files shouldn't bother with it in their headers.

@fmoralesc
Copy link
Member

I agree with using the MIT license, do you too @alerque? Since I am the main contributor to the code, I think I can do it on my own, but do you think there might be trouble in doing it without contacting other contributors?

@alerque
Copy link
Member

alerque commented May 21, 2019

Yes I'm fine with MIT and it's a pretty good choice for plugins. Since you are the main contributor and the license wasn't clear before I don't think adding a permissive license like MIT is an issue. It can be a concern if implementing a more restrictive license and previous contributors can whine about that, but I don't think that is a concern here. I'd just go for it.

@fmoralesc
Copy link
Member

Moved that to #314.

@randomizedthinking
Copy link
Author

@fmoralesc Good that you liked the idea.

Regarding the comments you have:

  • For 1. and 2., good suggestion and I can change the implementation into a module;
  • For 4., I checked the two TODO items in the file, one is for improvement and another one is a question on whether a condition check is needed for cursor on the column separator. I tested and confirmed that the current implementation works at such corner cases. So we can leave the TODO items as it is for now.

Let me know how you think.

@randomizedthinking
Copy link
Author

Now it is converted to a module. Please review.

Per my simple tests, it works out greatly.

autoload/pandoc/tbl.vim Outdated Show resolved Hide resolved
autoload/pandoc/tbl.vim Outdated Show resolved Hide resolved
@fmoralesc
Copy link
Member

We will probably need to add some documentation too.

@randomizedthinking
Copy link
Author

Agree, documentation is needed. I can write a simple draft when having time.

@fmoralesc
Copy link
Member

Copying the documentation from vimwiki can be a start. We will need to add references to it and other things later.

@fmoralesc
Copy link
Member

Ping @randomizedthinking Any update on the docs?

@randomizedthinking
Copy link
Author

randomizedthinking commented Jun 12, 2019 via email

@randomizedthinking
Copy link
Author

A simple write-up for the table editing is now added. Please review...

@Konfekt
Copy link
Contributor

Konfekt commented Jun 26, 2019

Could

inoremap <expr> <buffer> <Tab> pandoc#table#kbd_tab()
inoremap <expr> <buffer> <S-Tab> pandoc#table#kbd_shift_tab()

be made optional? Some may have overriden <tab>, for example, for tab-completion (say by vim-mucomplete).

Perhaps one could mention (or incorporate) https://github.com/dhruvasagar/vim-table-mode that aligns the table automatically.

Copy link
Member

@alerque alerque left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides the binding issue everything looks pretty good to me, if we can get that dealt with I think we can merge this.

command! -buffer PandocTableMoveColumnRight call pandoc#table#move_column_right()

" Table mappings
inoremap <expr> <buffer> <Tab> pandoc#table#kbd_tab()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As @Konfekt noted in issue comments, can you please wrap these bindings in a check to make sure they are not already bound to a different key and that this key isn't already bound to something else?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This vim-script idiom comes to mind.

nnoremap <silent><script><buffer>
\ <Plug>PandocTableMoveColumnRight :PandocTableMoveColumnRight<CR>

" Table autocmds
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these global? I think it's best to use <buffer> as the pattern.

In any case, what are they for?

function! pandoc#table#Init()
" Table commands
command! -buffer -nargs=* PandocTable call pandoc#table#create(<f-args>)
command! -buffer PandocTableAlignQ call pandoc#table#align_or_cmd('gqq')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These commands need to be documented.

@alerque
Copy link
Member

alerque commented Jan 31, 2020

Hmmmm, there are also some lint errors that need cleaning up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants