danro / LESS-sublime

LESS syntax highlighting for Sublime Text.
https://sublime.wbond.net/packages/LESS
500 stars 92 forks source link

Adds unwanted semi colon after pseudo classes #22

Closed sekoyo closed 11 years ago

sekoyo commented 11 years ago

Great work by the way.

One minor annoyance I have discovered so far:

If I start typing: a.button:hover

as soon as I type the colon it adds a semi colon - great for css attributes but not for pseudo classes!

mlms13 commented 11 years ago

Has this always been the case? I was pretty sure it was working as expected before, but I've also noticed this within the past couple months.

crates commented 11 years ago

Having the same issue here. It's awfully annoying.

crates commented 11 years ago

Found a comment over at https://github.com/sergeche/emmet-sublime/issues/130 that suggests that you can set "auto_match_enabled": false in your user preferences to disable this nuisance.

Shame that it also disables the actual auto match tool, which some might find useful.

danro commented 11 years ago

Hey guys, the auto-semicolon thing isn't part of the LESS package. It's defined in Sublime's default CSS package, under CSS/Default (YOUR OS).sublime-keymap

I typically remove all this stuff from my default packages, which is admittedly trickier in ST3 now. If you're using ST3, you will have to disable the default packages in your User preferences. Example:

"ignored_packages":
[
    "CSS",
    "JavaScript",
    "Vintage"
],

And then you'll need to name your custom CSS package something like CSS- so that it overrides the default. You can grab a copy of the default package by unzipping the CSS.sublime-package file, found in the app directory. On OSX, it lives here: /Applications/Sublime\ Text.app/Contents/MacOS/Packages - not sure about Windows or Linux.

Hope that helps.

aaronmw commented 11 years ago

It's a scoping issue / bug, I think? The way scopes in CSS documents work is a bit bizarre in that you aren't considered to be in scope unless your cursor is surrounded by characters by in that scope. For example:

a:hover { background|: red; }

My cursor's right after the background property name, but a scope check says I'm just in regular ol' "source.css.less" (using the LESS package here, but same goes for CSS).

Move it one character left:

a:hover { backgroun|d: red; }

And now my scope is: source.css.less support.type.propert-name.css

It's impossible to write a key binding to handle the colon press differently, because the cursor is always out of any scope when you want to insert a colon. Same's true for a semi-colon. Or a curly brace.

You can, however, just kill matching for css in general with the following key binding that basically says "when I insert a colon in CSS, just insert a colon":

{ "keys": [":"], "command": "insert_snippet", "args": {"contents": ":$0"}, "context": [ { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, { "operand": "source.css -comment -name", "operator": "equal", "match_all": false, "key": "selector" } ] }