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

Table-like formatting #11

wants to merge 2 commits into from

Conversation

mg979
Copy link

@mg979 mg979 commented Feb 13, 2018

I edited mostly the text file, so that it looks like a 3-columns table in vim. First tab is still there, so fuzzy search works as before. It needed 3 small changes in the plugin too.

@@ -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.

@@ -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.

@fisadev
Copy link
Owner

fisadev commented Mar 13, 2018

Nice! I'll test it and merge it today :)

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.

2 participants