Skip to content

Commit e3f28f1

Browse files
soifouSaghen
andauthored
feat(brackets): add css pseudo-class exceptions (#2054)
* feat(brackets): add css pseudo-class exceptions Detect CSS pseudo-class and pseudo-element selectors like `:root`, `::before`, `div:hover` or `div::after` to prevent automatic insertion of brackets in these contexts. Closes #2052 * feat(brackets): add html to css pseudo-class exceptions --------- Co-authored-by: Liam Dyer <[email protected]>
1 parent 16b6ba0 commit e3f28f1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lua/blink/cmp/completion/brackets/config.lua

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
local css_exceptions = function(ctx)
2+
local str = string.sub(ctx.line, 1, ctx.cursor[2] or #ctx.line)
3+
return not str:find('[%w_-]*::?[%w-]*$')
4+
end
15
local typescript_exceptions = function(ctx) return ctx.line:find('^%s*import%s') == nil end
26

37
return {
@@ -49,6 +53,11 @@ return {
4953
and ctx.line:find('^%s*from%s') == nil
5054
and ctx.line:find('^%s*except%s') == nil
5155
end,
56+
-- ignore pseudo-classes and pseudo-elements
57+
css = css_exceptions,
58+
scss = css_exceptions,
59+
less = css_exceptions,
60+
html = css_exceptions, -- remove after adding treesitter based language detection
5261
-- ignore `import ...` statements
5362
javascript = typescript_exceptions,
5463
javascriptreact = typescript_exceptions,

0 commit comments

Comments
 (0)