-
Notifications
You must be signed in to change notification settings - Fork 9
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
space as separator #36
Comments
Haskell is tricky. Let me start by explaining how the plugin works in general. The easiest example is something like this: function_call(x, y, z) Suppose your cursor is on \ {
\ 'start': '(\_s*',
\ 'end': ')',
\ 'delimiter': ',\_s*',
\ 'brackets': ['([{''"', ')]}''"'],
\ }, So, all it does is search backwards to the start, and then go forward, character by character, skipping nested brackets, until it gets to the end. Ruby is one example where it's not necessary to have brackets: function_call x, y, z So, instead of looking for a \ {
\ 'start': '\k\{1,}[?!]\= \ze\s*[^=,*/%<>+-]',
\ 'end': '\s*\%(\<do\>\|#\)',
\ 'delimiter': ',\s*',
\ 'brackets': ['([{''"', ')]}''"'],
\ }, The pattern is a bit more complicated, but it mostly describes what I put above. The "end" is either a Now, haskell functions are similar to ruby ones in that they don't have brackets, but the problem is that the delimiter and the function call look the same way. So, in the case of The key really is finding some way to indicate what the start of the list/function call is. In the particular case you point out, it's actually quite simple, because it's a function definition and not a function call. So I can say, "the first keyword on the line is the start": \ {
\ 'start': '^\s*\k\{1,} \ze\s*[^=,*/%<>+-]',
\ 'end': '\s*\%(=\|--\)',
\ 'brackets': ['([{"', ')]}"'],
\ 'single_line': 1,
\ 'delimited_by_whitespace': 1,
\ }, (The This definition is adapted from ruby, but I've added a If we wanted to get the function calls working, I don't think there's a 100% reliable way. We'd need to figure out the right "start pattern" to determine where the start of a call is. For instance, I think it's common to do something like \ {
\ 'start': '\%(^\s*\|[=(]\s*\)\k\{1,} \ze\s*[^=,*/%<>+-]',
\ 'end': '\s*\%(=\|--\)',
\ 'brackets': ['([{"', ')]}"'],
\ 'single_line': 1,
\ 'delimited_by_whitespace': 1,
\ }, Unfortunately, it gets confused in this case: distance (Point x y) (Point x' y') = sqrt $ dx + dy
where dx = (x - x') ** 2
dy = (y - y') ** 2 Trying to move the second argument of the definition, This is probably a lot of info and I'm not sure how much of it you understand re: vimscript, but I've created a branch with the simpler definition logic and you could try it out: #37. I'd like to provide at least some support, and I'd appreciate ideas on how to detect the start of a function more reliably. But it's regexes and bracket-counting (which, surprisingly, has worked really, really well so far), so I hope you can manage your expectations on the completeness of the solution :). |
Is it possible to provide some config with additional separators? In Haskell we are using space as separator between function and argument, example:
atm if I'm trying to apply :SidewaysRight to x - it's not working
The text was updated successfully, but these errors were encountered: