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

Table-like formatting #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions autoload/ctrlp/cmdpalette.vim
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ import json
path_to_script = vim.eval('expand("<sfile>")')
path_to_commands = path_to_script.replace('cmdpalette.vim', 'internal_commands.txt')
with open(path_to_commands) as commands_file:
internal_commands = [l.strip() for l in commands_file.readlines()]
internal_commands = [l.rstrip() for l in commands_file.readlines()]
Copy link
Author

Choose a reason for hiding this comment

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

I left 2 leading spaces, because ctrlp adds 2, so 4 make a tab. It made it easier(if not possible) to align the rest of the table.


# obtain the custom commands
vim.command('redir => custom_commands')
vim.command('silent command')
vim.command('redir END')

# convert to list, remove empties, discard 4 first columns and take first word
custom_commands = [x[4:].split()[0] + '\t(custom command)'
custom_commands = [' ' + x[4:].split()[0] + ' *'
Copy link
Author

Choose a reason for hiding this comment

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

2 leading spaces also here. I replaced (custom command) with an asterisk, because that string cannot be aligned, and it makes the table less readable.

for x in vim.eval('custom_commands').split('\n')
if x.strip()]
# remove header
Expand Down Expand Up @@ -99,7 +99,7 @@ func! ctrlp#cmdpalette#accept(mode, str)
call ctrlp#exit()
redraw
call feedkeys(':', 'n')
call feedkeys(split(a:str, '\t')[0], 'n')
call feedkeys(strpart(split(a:str, '\t')[0], 2), 'n')
Copy link
Author

Choose a reason for hiding this comment

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

The leading spaces are removed here, before the command is inserted in the command line.

if g:ctrlp_cmdpalette_execute == 1
call feedkeys("\<CR>", 'n')
endif
Expand Down
Loading