Git Product home page Git Product logo

Comments (9)

firedev avatar firedev commented on August 27, 2024

Now I caught it.

Given:

= javascript "▐script"

Expected:

= javascript 'script'

Actual:

- javascript "script"

from switch.vim.

firedev avatar firedev commented on August 27, 2024

Tripped on this again. Why do we even need this?

from switch.vim.

AndrewRadev avatar AndrewRadev commented on August 27, 2024

Sorry for not taking care of this sooner, I've been a bit busy.

For this particular issue, I think it makes sense to limit haml switching to only the beggining of the line (with the cursor before or at the sign). Originally, I made it work on the entire line, since it was more convenient, but it can be confusing sometimes. I've pushed a commit that implements the change. Could you try it out for some time and let me know if it feels better?

from switch.vim.

firedev avatar firedev commented on August 27, 2024

No problem, thanks! But is it really needed? It's just one symbol, you can replace it with ^r= or something.

from switch.vim.

firedev avatar firedev commented on August 27, 2024

It works fine.

Here is what became apparent now. To change hashes to new syntax I am doing /=> and then 'n-n-n-n-' until there is nothing left.

When I change hashrocket from this position:

(:receipt_id => cashbox_operation.receipt

It works one-way only, after the switch the cursor is too far to the right:

(receipt_id: ▐cashbox_operation.receipt

And that what causes parser to look for other targets. I don't know what is the best behaviour here, but it is certainly something to be aware of.

from switch.vim.

AndrewRadev avatar AndrewRadev commented on August 27, 2024

Well, I tried to expand it to include whitespace, but that's not enough -- switching when on the = leaves your cursor on the first symbol of the value, not on the whitespace preceding it. I tried expanding it to include one non-whitespace symbol after the whitespace (it's a key-value pair, so there will definitely be a value), and that works, but only if the value itself is not switchable. E.g. switching this works:

foo = {
  :some_key => bar,
  some_key: bar,
}

Because the cursor ends up on "b". But if it's a string, it doesn't (cursor ends up on ", switches the string quotes):

foo = {
  :some_key => "bar",
  some_key: "bar",
}

So I don't know if it even makes sense to do it. It will work in some cases, but not in others, so that might be confusing.

Usually when I do this, I just do it on the key itself. So, if you're doing this in bulk, I'd just recommend searching for /\k\s*=> instead. Or, if you're expecting string keys, even /\S\s*=> would work just fine. It's more characters to type, but if you're just running it once and replacing it everywhere with an n-n-n-n-, it shouldn't be a big deal.

No problem, thanks! But is it really needed? It's just one symbol, you can replace it with ^r= or something.

You're right that, in this case, it's not a big deal. Originally I made this for eruby tags, which also have a few prefixes. So, for instance, you can't just go to the beginning of the line, you have to go backwards to <%=. And doing a T= wouldn't always work, since there might be an = sign somewhere else on the line. For haml and slim, it's not so important, although it's still a bit convenient to toggle it while in the middle of something else. With this change, it's definitely not very useful :).

But if this was the core issue, maybe it makes sense for me to put it back the way it was. Your thoughts?

from switch.vim.

firedev avatar firedev commented on August 27, 2024

To my taste I think it's better to leave it as it is now, it's not too aggressive, yes it sometimes changes strings to symbols after converting hash, but that is not much of a problem.

I get your point about erb, but I am barely using it these days, so I can't comment.

from switch.vim.

firedev avatar firedev commented on August 27, 2024

After thinking about it for a while I thunk I'd rather had disabled -/= switch for Slim and HAML so you get best of both worlds.

from switch.vim.

AndrewRadev avatar AndrewRadev commented on August 27, 2024

Yeah, I guess the -/= switch is not that useful anyway. I've pushed a commit that disables it for now. If anyone has a problem with this, they can open an issue.

from switch.vim.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.