• Stars
    star
    300
  • Rank 133,883 (Top 3 %)
  • Language
    Vim Script
  • Created over 7 years ago
  • Updated about 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Vim bundle for http://styled-components.com based javascript files.

This project is not currently maintained. If you'd like to help, or for further info, see #77

vim-styled-components

Vim bundle for styled-components, diet-cola, emotion, experimental glamor/styled, and astroturf content in javascript files.

After massive issues with the syntax highlighting of the previous version, this newly implemented plugin now only highlights CSS in javascript template strings, if the current APIs of the supported libraries are present. Thus there is no more bleeding of keywords into non-CSS sections of the file.

Note however, that this plugin does not provide (all existing) CSS rules. You should have an up to date vim runtime (for CSS2 rules) and - as long as CSS3 rules are not included - an additional plugin for CSS3 rules. (I recommend hail2u/vim-css3-syntax but feel free to use whatever you like.)

Table of Contents

Installation

See the documentation for the specific vim package manager for details on how to install packages for vim.

Install via Vundle

Add to vimrc:

Plugin 'styled-components/vim-styled-components'

Install via:

:so ~/.vimrc
:PluginInstall

Install via vim-plug

Add to vimrc:

Plug 'styled-components/vim-styled-components', { 'branch': 'main' }

Install via:

:so ~/.vimrc
:PlugInstall

Install via pathogen

Run:

git clone https://github.com/styled-components/vim-styled-components/ ~/.vim/bundle/vim-styled-components

Support

As vim doesn't supply the most exhaustive javascript and/or typescript support itself most vim users opt for using third party plugins to enhance syntax highlighting and omnicomplete, etc. Some of which might share the syntax definition names, but others doesn't. This fact requires one to go into the details of the syntax definition to makes sure the syntax definitions are correctly supported by this plugin. Please open an issue if you find incompatibilities with any plugins.

This is the list of plugins that are (somewhat) supported:

Caveats

Specificity of styling APIs

As only the official APIs are supported and they are necessary to indicate highlighting sections in your javascript file, renaming of the appropriate functions or externally defining the CSS rules in template strings will lead to missing highlighting. This means the following will not be correctly highlighted:

import styled as unstyled from 'styled-components';

unstyled`
  background-color: papayawhip;
  color: palevioletred;
`;

Neither will this:

import dc from 'diet-cola';

const mainStyles = `
  background-color: papayawhip;
  color: palevioletred;
`;

const Button = styled('h1')(mainStyles);

Breaking syntax highlighting in very long files

Syntax highlighting in vim works by comparing a list of previous lines to determine the current line's syntax items. For very long files the list of previous lines can exceed the maximum threshold. If this is the case for you, you can opt in to trade off quality with speed for syntax highlighting:

autocmd BufEnter *.{js,jsx,ts,tsx} :syntax sync fromstart
autocmd BufLeave *.{js,jsx,ts,tsx} :syntax sync clear

Note: Use at own risk! The first line will make vim consider all lines in the file for syntax highlighting if it encounters a javascript/typescript file, the second one will reset this value if it leaves the buffer again. (This will also reset previously set syntax-syncing settings, that you or other plugins might have set.)

Contributing

Contributions are very welcome. ๐Ÿ™‡

Browse existing issues or create a new one here.

Submit pull requests here. This project uses the git flow model for development. Please base your feature branch on the develop branch and follow the code style convention used in the already existing files.

Acknowledgements

A huge thanks goes to Bram Moolenaar for authoring/maintaining Vim.

Lots of love to Glen Maddern and Max Stoiber for creating styled-components.

And of course sylvainbannier for the initial workaround here.

License

Copyright (c) 2016 Karl Fleischmann. Distributed under the same terms as Vim itself. See :help license.

More Repositories

1

styled-components

Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress ๐Ÿ’…
TypeScript
39,930
star
2

polished

A lightweight toolset for writing styles in JavaScript โœจ
JavaScript
7,562
star
3

awesome-styled-components

A curated list of awesome styled-components resources ๐Ÿ’…
3,283
star
4

xstyled

A utility-first CSS-in-JS framework built for React. ๐Ÿ’…๐Ÿ‘ฉโ€๐ŸŽคโšก๏ธ
MDX
2,254
star
5

jest-styled-components

๐Ÿ”ง ๐Ÿ’… Jest utilities for Styled Components
JavaScript
1,577
star
6

vue-styled-components

Visual primitives for the component age. A simple port for Vue of styled-components ๐Ÿ’…
JavaScript
1,362
star
7

styled-theming

Create themes for your app using styled-components
JavaScript
1,168
star
8

css-to-react-native

Convert CSS text to a React Native stylesheet object
JavaScript
1,117
star
9

babel-plugin-styled-components

Improve the debugging experience and add server-side rendering support to styled-components
JavaScript
1,063
star
10

vscode-styled-components

Syntax highlighting for styled-components
JavaScript
911
star
11

stylelint-processor-styled-components

Lint your styled components with stylelint!
JavaScript
657
star
12

styled-components-website

The styled-components website and documentation
MDX
607
star
13

webstorm-styled-components

styled-components highlighting support in IntelliJ editors
Kotlin
377
star
14

comparison

Comparing different ways to style components
JavaScript
183
star
15

elm-styled

Styling your Html Elements with typed Css ๐Ÿ’…
Elm
180
star
16

babel-plugin-polished

Compile polished helper functions at build time
JavaScript
138
star
17

styled-elements

Styled components for the DOM.
JavaScript
87
star
18

stylelint-config-styled-components

The shareable stylelint config for stylelint-processor-styled-components
JavaScript
71
star
19

spec

Design Requirements and Spec for a Component-oriented CSS Solution
61
star
20

color-schemer

A React app to help you select a color scheme, built with styled-components and polished
JavaScript
55
star
21

styled-components-codemods

Automatic codemods to upgrade your styled-components code to newer versions.
JavaScript
52
star
22

styled-components-experimentation

A place to play with things that shouldn't be in core
JavaScript
31
star
23

s-c.sh

The styled-components URL shortener!
30
star
24

styled-components-native-code-mod

JavaScript
28
star
25

styled-components.github.io

The styled-components homepage
JavaScript
22
star
26

brand

Logo and brand related materials
11
star
27

benchmark

JavaScript
9
star
28

todomvc

The Speedometer 2.0 React TodoMVC example rebuilt with styled-components
JavaScript
6
star
29

babel-plugin-styled-components-ssr

[EXPERIMENTAL]
JavaScript
2
star
30

use-styled-hook

tbd
1
star