-
-
Notifications
You must be signed in to change notification settings - Fork 102
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
Fix a problem with the do
Elixir keyword
#61
Conversation
Before this commit, this use of the `do` keyword in Elixir would be autocompleted with an `end` by vim-endwise: do # stuff end But this would not: defmodule A do # no `end` here By replacing a whitespace match (\s) with a wildcard (*) in the Elixir regex, this now works.
@@ -19,7 +19,7 @@ augroup endwise " {{{1 | |||
autocmd FileType elixir | |||
\ let b:endwise_addition = 'end' | | |||
\ let b:endwise_words = 'case,cond,bc,lc,inlist,inbits,if,unless,try,receive,function,fn,do' | | |||
\ let b:endwise_pattern = '^\s*\zs\%(case\|cond\|bc\|lc\|inlist\|inbits\|if\|unless\|try\|receive\|function\|fn\|do\)\>\%(.*[^:]\<end\>\)\@!' | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, I just replaced the whitespace match \s
with the .
wildcard.
See Ruby for an example of how to do this properly. I don't know Elixir but I'm guessing loosening the regex for all keywords will have unintended consequences. I already reverted the previous attempt so build your submission on the latest so it will merge properly. |
Also consider if this enables other keywords to be removed. I see |
Yep, I think this needs a little revision. I'll try to do it when I'll have some spare time. Thanks for now! |
I took a stab at this in another PR, but I think I've over thought it at first glance. Elixir actually has a much more consistent syntax than Ruby. All "blocks" in Elixir use the Could Elixir's end wise be as simple as auto-completing the |
Cited example has a I think the proposed logic is solid. You might look at the |
Thanks @tpope. I'll have a look. |
I'm so sorry, yesterday I was in a hurry and read the Erlang example, not the Elixir ones 😭. Yes then, |
My first time hacking a plugin, please be forgiving. Based on the discussion above by @rbishop this works for me. Not sure it is worthy of a merge as I only know enough Elixir to be dangerous.
|
@gwww closer would be
Try that a few days and if it works send a pull request. |
I'm not sure if this matters at all, but I noticed elixir-lang/vim-elixir has a lot of keywords defined: https://github.com/elixir-lang/vim-elixir/blob/7a0a1688601da4ae48e862e5840c832f04e63364/syntax/elixir.vim#L106-L120 Would this mean that |
Not if we're matching on |
As of my last comment in #60, the
do
Elixir keyword didn't work with stuff like:Now it does; I tested this behavior also with
def func do...end
,case [...] do...end
and some other constructs, everything seems to work and, more importantly, nothing seems to be broken.