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

[WIP] Refactor editors code #1507

Open
wants to merge 46 commits into
base: develop
Choose a base branch
from
Open

Conversation

ZyX-I
Copy link
Contributor

@ZyX-I ZyX-I commented Dec 5, 2015

There are three long-term targets here: Vim without +python, neovim (ref #1287) and emacs. Main idea is reducing the necessity to communicate with the editor to nearly one stage. This PR is doing refactoring of the code, not adding new applications to support.

TODO:

  • Create new way to describe powerline requirements.
  • Update all segments which can be updated to use this new way.
  • (partial: missing type conversions) Update all segment listers to use this new way.
  • Remove dependency on the vim module: import it once at startup and pass it around.
  • Update development documentation regarding vim segments.
  • Create documentation describing how to create new Vim segments.
  • Create documentation describing how to add new editors support.
  • Move non-vim-specific editor segments to powerline.segments.editors module.
  • Make all remaining powerline.segments.vim* modules powerline.segments.editors.
  • Move all vim listers to powerline.listers.editors since they are not vim-specific. Requires doing something with buffer, window, tabpage, bufnr, winnr, tabnr segment_info keys.
  • Make documentation for listers point to new location.
  • Make documentation for segments point to new location.
  • Make cvs_col_current segment non-editor-specific. Requires abstracting buffer lines access.

ZyX-I added 16 commits July 13, 2017 23:03
Reasoning:

1. Support other editors in the future without rewriting all bindings.
2. Support Vim without +python.
Also removes `except ImportError: vim = object()` hack.

Removed code from powerline.bindings.vim that is no longer used.
EditorParameter('buffer') is buffer number only when using VimVimEditor.
- Fix typo: segment_info key is named input, not inputs
- Fix typo: parameter name is tabpage, not tab
Still not enough to run with is_old_vim = True
It does not raise exceptions now, but still does not work correctly.
Fixes:
- Conversion function did not recognize used keyword argument.
- Number of tab pages did not have a type.
- Updating tabpage or window parameters did not trigger updating buffer 
  parameter (also updating tabpage should have updated window), which resulted 
  in incorrect buffer names shown in the tabline when there are many tabs.

Refactoring:
- EditorObj objects used by listers are now EditorIterable subclasses.
- powerline.editors.vim.VimTabAmount is now powerline.editors.EditorTabAmount.
- Constant dictionaries used by segments_to_reqs_iter were moved to module 
  constants.
ZyX-I added 14 commits July 13, 2017 23:03
This variant also supports Neovim, ref powerline#1287.
Still known issues:

1. When opening new tab in old vim mode new window in new tab appears as 
   unfocused.
2. When opening new tab in new vim mode it raises AttributeError.

Fixed issues:

1. Tabline does not work at all.
2. Opening new tab spawns AttributeError when determining width.
3. TypeError when trying to use string tab number as integer.
4. Generated code looks like crap (VimVimEditor, conv_code).
5. Conversion code generated for listers does not actually work due to numerous 
   issues.
6. In some places tabline theme number is off-by-one.
7. Listing buffers lists only buffers that are shown in the current tab.
Statusline after `tab sp` with new bindings is now fine. Still bad with old 
bindings.

Also found an issue: message from startup screen disappears.
Known issue: with old vim if one tab contains modified buffer all tabs are shown 
as modified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant