Make vim-endwise customizable? #4

Open
opened 2019-05-24 09:54:25 +00:00 by benie · 0 comments
Owner

While the goal was to make it customizable, this turned out to be a tall
order. Every language has vastly different requirements.

So Tim Pope failed to make vim-endwise customizable so this is likely a bunch of
work. However to make this a truly useful plugin it should be able to support
arbitrary insertions per filetype.

The ideal mechanism would be to have an entry point, called in the appropriate
ftplugin/*.vim script which takes a list of 2 or 3 element lists the first
element containing a regex to match for the trigger text, the second element
containing the end point insertion text, and the optional flags to control the
behaviour of things like indentation of the cursor.

" ftplugin/markdown.vim
call endwise#register([['```\w\+', '```', 'i0']])
" ftplugin/cmake.vim
call endwise#register([
\ ['if\w*(.*)', 'endif()'],
\ ['foreach\w*(.*)', 'endforeach()'],
\ ['while\w*(.*)', 'endwhile()'],
\ ['macro\w*(.*)', 'endmacro()'],
\ ['function\w*(.*)', 'endfunction()'],
\])
> While the goal was to make it customizable, this turned out to be a tall > order. Every language has vastly different requirements. So Tim Pope failed to make vim-endwise customizable so this is likely a bunch of work. However to make this a truly useful plugin it should be able to support arbitrary insertions per filetype. The ideal mechanism would be to have an entry point, called in the appropriate `ftplugin/*.vim` script which takes a `list` of 2 or 3 element `list`s the first element containing a regex to match for the trigger text, the second element containing the end point insertion text, and the optional flags to control the behaviour of things like indentation of the cursor. ```vim " ftplugin/markdown.vim call endwise#register([['```\w\+', '```', 'i0']]) ``` ```vim " ftplugin/cmake.vim call endwise#register([ \ ['if\w*(.*)', 'endif()'], \ ['foreach\w*(.*)', 'endforeach()'], \ ['while\w*(.*)', 'endwhile()'], \ ['macro\w*(.*)', 'endmacro()'], \ ['function\w*(.*)', 'endfunction()'], \]) ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: config/vim#4
No description provided.