Intelligent Tailwind CSS tooling for coc.nvim

Overview

coc-tailwindcss3

fork from a vscode-tailwindcss

Intelligent Tailwind CSS tooling for coc.nvim.

coc-tailwindcss3-screenshot

Motivation

There are two coc.nvim extensions to "tailwindcss". Unfortunately, neither is currently maintained and will not work with "tailwindcss3"...

I have created @yaegassy/coc-tailwindcss3 which supports "tailwindcss3".

Install

CocInstall:

:CocInstall @yaegassy/coc-tailwindcss3

scoped packages

vim-plug:

Plug 'yaegassy/coc-tailwindcss3', {'do': 'yarn install --frozen-lockfile'}

Prepare

Create tailwindCSS configuration in your project.

this extension need the configuration exists in your project

npx tailwindcss init

Configuration options

  • tailwindCSS.enable: Enable coc-tailwindcss3 extension, default: true
  • tailwindCSS.trace.server: Trace level of tailwindCSS language server, default: off
  • tailwindCSS.custom.serverPath: Custom path to server module. If there is no setting, the built-in module will be used, default: ""
  • tailwindCSS.emmetCompletions: Enable class name completions when using Emmet-style syntax, for example div.bg-red-500.uppercase, default: false
  • tailwindCSS.includeLanguages: Enable features in languages that are not supported by default. Add a mapping here between the new language and an already supported language. E.g.: {"plaintext": "html"}, default: { "eelixir": "html", "elixir": "html", "eruby": "html", "htmldjango": "html", "html.twig": "html" }
  • tailwindCSS.files.exclude: Configure glob patterns to exclude from all IntelliSense features. Inherits all glob patterns from the #files.exclude# setting, default: ["/.git/", "/node_modules/", "/.hg/"]
  • tailwindCSS.classAttributes: The HTML attributes for which to provide class completions, hover previews, linting etc, default: ["class", "className", "ngClass"]
  • tailwindCSS.validate: Enable linting. Rules can be configured individually using the tailwindcss.lint.* settings, default: true
  • tailwindCSS.lint.cssConflict: Class names on the same HTML element which apply the same CSS property or properties, valid option ["ignore", "warning", "error"], default: warning
  • tailwindCSS.lint.invalidApply: Unsupported use of the @apply directive, valid option ["ignore", "warning", "error"], default: error
  • tailwindCSS.lint.invalidScreen: Unknown screen name used with the @screen directive, valid option ["ignore", "warning", "error"], default: error
  • tailwindCSS.lint.invalidVariant: Unknown variant name used with the @variants directive, valid option ["ignore", "warning", "error"], default: error
  • tailwindCSS.lint.invalidConfigPath: Unknown or invalid path used with the theme helper, valid option ["ignore", "warning", "error"], default: error
  • tailwindCSS.lint.invalidTailwindDirective: Unknown value used with the @tailwind directive, valid option ["ignore", "warning", "error"], default: error
  • tailwindCSS.lint.recommendedVariantOrder: Class variants not in the recommended order (applies in JIT mode only), valid option ["ignore", "warning", "error"], default: error
  • tailwindCSS.inspectPort: Enable the Node.js inspector agent for the language server and listen on the specified port, default: null

Commands

  • tailwindCSS.showOutput: Tailwind CSS: Show Output

Custom Server Path

tailwindCSS.custom.serverPath: Custom path to server module. If there is no setting, the built-in module will be used, default: ""

This setting allows you to use the tailwind's language server module installed in any location.

Usage Example 1 (vsix)

prepare:

mkdir -p /tmp/tailwindcss-language-server
cd /tmp/tailwindcss-language-server
curl -LO https://github.com/tailwindlabs/tailwindcss-intellisense/releases/download/v0.8.1/vscode-tailwindcss-0.8.1.vsix
unzip vscode-tailwindcss-0.8.1.vsix

setting:

{
  "tailwindCSS.custom.serverPath": "/tmp/tailwindcss-language-server/extension/dist/server/tailwindServer.js"
}

Usage Example 2 (Use extensions installed in VSCode)

setting:

{
  "tailwindCSS.custom.serverPath": "/path/to/.vscode/extensions/bradlc.vscode-tailwindcss-0.8.1/dist/tailwindServer.js
}

Usage Example 3 (npm)

prepare:

npm i -g @tailwindcss/[email protected]

setting:

{
  "tailwindCSS.custom.serverPath": "/path/to/.nvm/versions/node/v16.14.2/bin/tailwindcss-language-server"
}

Thanks

License

MIT


This extension is built with create-coc-extension

Comments
  • Adding another className regex (PureScript)

    Adding another className regex (PureScript)

    Hi there, I would like to give coc-tailwindcss3 a shot with PureScript (React).

    I didn't get it to work yet. Once it's working I would like to open a pull request to add it to the list of class regexes (similar to reason and elm).

    Debugging

    Classes look like this:

    element progress { className: "w-56 flex" }
    

    The coc-config is this: Is the regex fine? Do I need to set a different value? Escaping okay?

      "tailwindCSS.headwind.classRegex": {
        "purescript": "\\bclassName\\s*:\\s*\\\"([_a-zA-Z0-9\\s\\-\\:\\/]+)\\\""
      },
    

    What I tried so far

    • Different regexes
    • Using purs (the extension name) instead of purescript
    • Made sure the project setup is working because in index.html the extension is working fine
    • Made sure coc-settings.json is recognized because I can disable the language server (and html stops working)
    • Ran CocCommand tailwindCSS.forceActivate in case the file wouldn't be recognized
    • Check that regex works, but could still be an issue (escaping or other mistake)

    Screenshots

    HTML :heavy_check_mark:

    image

    PureScript :-1:

    image

    Regex on regex101.com

    image

    help wanted 
    opened by andys8 7
  • Support twind

    Support twind

    Hi, thank you for this amazing coc extension. Do you have plans to allow this extension be compatible with the https://twind.dev/ ?!

    Another ref: https://github.com/tw-in-js/vscode-twind-intellisense

    opened by igorbrasileiro 6
  • Headwind integration

    Headwind integration

    First off, thank you for creating this extension! I'd like to know if there are any plans to re-integrate Headwind with this, and if not, if you have any pointers on how one could integrate it themselves.

    opened by zachschultz 5
  • It doesn't recognize SvelteKit project

    It doesn't recognize SvelteKit project

    Hi, the extension is not working on my SvelteKit project.

    TailwindCSS is properly installed and the IntelliSense works perfectly on VSCode.

    Here's my project's structure: Screenshot_145

    Here's everything I've tried so far:

    • Opening nvim in the root folder and in the src folder
    • Using tailwindCSS.forceActivate
    • Opening my tailwind.config.cjs file
    • Renaming it to tailwind.config.js
    • Reinstalling the extension and the COC plugin
    • Creating an index.html file to see if it works with basic html files

    Nothing works, so I really don't know what to do, thanks for reading.

    opened by pepperoni21 4
  • Support autocompletion in `tw` tag function from twin.macro

    Support autocompletion in `tw` tag function from twin.macro

    This is not so much an issue as a question.

    I understand there is a way to add additional attributes that support auto-completion with tailwindCSS.classAttributes, but I don't know if it's possible to use that mechanism to autocomplete when using tw from twin.macro.

    Examples from the twin.macro documentation:

    import tw from 'twin.macro'
    
    const Input = ({ hasHover }) => (
      <input css={[tw`border`, hasHover && tw`hover:border-black`]} />
    )
    
    import tw, { css } from 'twin.macro'
    
    const hoverStyles = css`
      &:hover {
        border-color: black;
        ${tw`text-black`}
      }
    `
    const Input = ({ hasHover }) => (
      <input css={[tw`border`, hasHover && hoverStyles]} />
    )
    
    help wanted 
    opened by tupton 3
  • Question: enable for typescriptreact

    Question: enable for typescriptreact

    Hi, when I work on typescriptreact files this extension doesn't seem to enable itself. Is that intentional? I tried to check the options and set tailwindCSS.includedLanguages but that didn't seem to do much.

    How does one enable this extension for typescriptreact files?

    opened by alextes 3
  • Clojure/ClojureScript support?

    Clojure/ClojureScript support?

    I realize this is probably going to be too big of an ask and wishful thinking but I was wondering if you knew how I could get the tailwind autocompletion working with Clojure and Clojurescript, particularly when using the reagent and/or hiccup libraries which allows for a great Clojure-ish way of writing html that looks like:

    (defn simple-component []
      [:div
       [:p "Classes can be added in a traditional manner using a clojure hashmap with a :class keyword like:"]
       [:p {:class "text-2xl font-extrabold mt-6"}]
       [:p "or can be added using a shortcut syntax of just a '.' after an html element like:"]
       [:p.text-2xl.font-extrabold.mt-6]])
    

    If it's even possible I imagine the traditional way would be the only way to make it happen. I haven't wrapped my head around how you actually identify when to trigger the autocompletion but I imagine you recognize an eligible file and then look for the 'class' keyword as a trigger?

    In this case, maybe if someone puts something like "tailwindCSS.includeLanguages": { "clojure": "html"} (which would be for files that end in .clj, .cljs, or .cljc) in the coc config file you can search for the :class keyword, or maybe anything that starts with a :<anything>. as anything after that . would be a css class, and then trigger the tailwind autocompletion.

    opened by Chase-Lambert 3
  • TypeError: import_coc2.RelativePattern is not a constructor

    TypeError: import_coc2.RelativePattern is not a constructor

    After installing this extension, I get the following error after nvim startup: (output of :CocInfo)

    22-04-25T17:08:47.389 ERROR (pid:2806) [server] - unhandledRejection  Promise {                                                                                                                                                    
         <rejected> TypeError: import_coc2.RelativePattern is not a constructor
             at didOpenTextDocument (/home/stefan/.local/share/nvim/plugged/coc-tailwindcss3/lib/index.js:1036:64)
             at Array.forEach (<anonymous>)                                                                                                                                                                         
             at Object.activate (/home/stefan/.local/share/nvim/plugged/coc-tailwindcss3/lib/index.js:1042:39)
             at /home/stefan/.local/share/nvim/plugged/coc.nvim/build/index.js:231:1411                                                                                                                             
             at new Promise (<anonymous>)                                                                                                                                                                           
             at Object.activate (/home/stefan/.local/share/nvim/plugged/coc.nvim/build/index.js:231:1369)
             at i5.activate (/home/stefan/.local/share/nvim/plugged/coc.nvim/build/index.js:228:7366)
             at /home/stefan/.local/share/nvim/plugged/coc.nvim/build/index.js:230:283
             at new Promise (<anonymous>)
            at s (/home/stefan/.local/share/nvim/plugged/coc.nvim/build/index.js:230:45)
     } 
    

    And the plugin is not usable for me :-(

    opened by stfnwp 2
  • Adding a hyphen breaks autocomplete

    Adding a hyphen breaks autocomplete

    When I start typing, I get autocomplete suggestions. Here I'm going to add a padding, px:

    Screenshot 2022-10-06 at 14 32 01

    But, when I add hyphen (-) the px styles disappear:

    Screenshot 2022-10-06 at 14 32 07

    The current example is in Vue, but I've also got the same behavior in React.

    bug 
    opened by believer 1
  • feat: dash force completions feature

    feat: dash force completions feature

    There are a number of tailwindcss completion items that contain "dash" (-).

    When you type a "dash", the completion menu disappears, so you can avoid this problem by adding a "dash" with vim's iskeyword option

    However, Since coc.nvim v0.0.82, the iskeyword option in vim does not seem to be respected in completion.

    Added the feature to "force completion" when entering "dash".

    opened by yaegassy 1
  • feat: add regex match log for headwind in showOutput

    feat: add regex match log for headwind in showOutput

    DEMO (mp4)

    https://user-images.githubusercontent.com/188642/179870603-c288314b-7a46-4d0f-ab56-dfc9c4e520c0.mp4

    Related issue

    • https://github.com/yaegassy/coc-tailwindcss3/issues/8
    opened by yaegassy 0
  • feat: add document colorizer for tailwindcss

    feat: add document colorizer for tailwindcss

    Hi, recently I saw that document-color.nvim implements the document colorizer feature. I think it is very cool and useful. So I try to implements the some feature in coc-tailwindcss3.

    opened by PHSix 2
  • feat: css language mode server integration for TailwindCSS

    feat: css language mode server integration for TailwindCSS

    Description

    To edit css-related files, it is convenient to use coc-css. A language server with vscode-css-languageservice feature is started.

    However, this language server has some minor problems, such as issuing warnings for TailwindCSS-specific syntax, etc. e.g. @tailwind, @apply, @screen, @layer and more.

    To solve these problems, tailwindcss-intellisense seems to provide a dedicated css language server for TailwindCSS.

    REF:

    • https://github.com/tailwindlabs/tailwindcss-intellisense/blob/master/packages/vscode-tailwindcss/src/cssServer.ts

    Usage

    Prepare

    1:

    the language server module for this css requires v0.8.0 or later of vscode-tailwindcss. Please check here for an example of using the server module installed with vsix.

    • https://github.com/yaegassy/coc-tailwindcss3#usage-example-1-vsix
    • https://github.com/yaegassy/coc-tailwindcss3#usage-example-2-use-extensions-installed-in-vscode

    The npm package @tailwindcss/language-server does not yet include this server module.

    Note: To be published in npm in the near future. https://github.com/tailwindlabs/tailwindcss-intellisense/issues/536

    2:

    Add the g:coc_filetype_map setting to your ".vimrc/init.vim". Add a configuration entry mapping the file type named *.tailwindcss to tailwindcss.

    This is an example of the css.tailwindcss filetype. Of course, you can also use another css-related filetype, such as scss.tailwindcss.

    let g:coc_filetype_map = {
     \ 'css.tailwindcss': 'tailwindcss',
     \ }
    

    3:

    Add tailwindCSS.custom.cssModeServerPath to coc-settings.json. The file path of the css server module must be set correctly for your environment.

    {
      "tailwindCSS.custom.cssModeServerPath": "/path/to/tailwindcss-language-server/extension/dist/tailwindModeServer.js",
    }
    

    Edit

    1. Open the css-related file.
    2. Change the filetype to css.tailwindcss.
      • :set filetype=css.tailwindcss
      • The css mode server provided by tailwindcss-intellisense starts up.
    opened by yaegassy 0
Vitest for coc.nvim

coc-vitest Vitest for coc.nvim Install vim-plug: Plug 'yaegassy/coc-vitest', {'do': 'yarn install --frozen-lockfile'} CocInstall: Not supported at thi

yaegassy 8 Sep 4, 2022
Solidity language server for coc.nvim

coc-solidity coc.nvim extension for solidity. Language server provided by solidity-ls. solidity-ls has no tolerance. Means that some features will onl

7c00 40 Dec 5, 2022
Typos integration with coc.nvim

coc-typos Typos integration with coc.nvim. It checks typos with opened buffer automatically. Install Install typos by: cargo install typos-cli Make s

Neoclide 31 Aug 22, 2022
Marksman (Markdown LSP server) extension for coc.nvim

coc-marksman fork from a marksman-vscode Integrates Marksman language server into coc.nvim for delightful Markdown note taking experience. coc-marksma

yaegassy 17 Nov 18, 2022
Alpine.js Language Features (Volar) extension for coc.nvim

[Experimental] coc-volar-alpinejs fork from vscode-alpine-language-features Alpine Language Features extension for coc.nvim Note @volar/alpine-languag

yaegassy 6 Oct 12, 2022
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
An application to map out game reserves using aerial photography, intelligent image stitching and AI driven recognition focus.

Map Out Game Reserves Using Aerial Photographs An application to map out game reserves using aerial photography, intelligent image stitching and AI dr

COS 301 - 2022 4 Sep 29, 2022
⏪ Rewinds – Remix Tailwind Starter Kit with Tailwind CSS, Headless UI, Radix UI, and more

⏪ Rewinds – Remix Tailwind Starter Kit Rewinds is a Remix starter kit with Tailwind CSS v3 family of libraries. This is an example demo to combine the

M Haidar Hanif 81 Dec 24, 2022
Component oriented framework with Virtual dom (fast, stable, with tooling)

Bobril Main site bobril.com Changelog of npm version: https://github.com/Bobris/Bobril/blob/master/CHANGELOG.md Component oriented framework inspired

Boris Letocha 359 Dec 4, 2022
A Typescript Hardhat-based template to develop evm-based smart contracts with all the tooling you need.

EVM-based Smart Contract Scaffold A Typescript Hardhat-based template to develop evm-based smart contracts with all the tooling you need. Features Use

Flair 8 Oct 24, 2022
Official moon configurations for popular JavaScript developer tooling.

moon development configs This repository is a collection of moon owned and maintained configurations and presets for common developer tools -- primari

moonrepo 8 Nov 10, 2022
Connect Web Integration illustrates the integration of Connect-Web in various JS frameworks and tooling

Connect Web Integration Connect Web Integration is a repository of example projects using Connect-Web with various JS frameworks and tooling. It provi

Buf 43 Dec 29, 2022
An NPM package to help you get started with modern javascript tooling easier & faster

MODERNIZE.JS Creating config files for webpack and babel can be an hell of stress, this NPM package helps you get started with writing code as soon as

Kelechi Okoronkwo 5 Sep 22, 2022
A Tailwind plugin that allows to create multiple groups utilities such as group-card or group-1 and works with Tailwind 3 features and all variations.

Tailwind Labeled Groups A plugin that allows to create multiple groups utilities such as group-card or group-1 and works with Tailwind 3 features and

Max 18 Nov 21, 2022
♦ Crowd funding project using Smart Contracts on the Ethereum. Created with Next.js and Tailwind CSS.

Crowdcoin ♦ Crowd funding project using Smart Contracts on the Ethereum. Created with Next.js and Tailwind CSS. Project from "Ethereum and Solidity: T

Luiz Fernando Veríssimo 2 Dec 14, 2022
Personal developer portfolio written with NextJS and Tailwind CSS.

Developer Portfolio This is a Next.js, Tailwind CSS blogging starter template. Probably the most feature rich nextjs markdown blogging template out th

Max Geller 1 Dec 20, 2021
The 2048 game built with Angular & Tailwind CSS

Ng2048 This project was generated with Angular CLI version 13.1.2. Development server Run ng serve for a dev server. Navigate to http://localhost:4200

CodeWithAhsan 10 Mar 10, 2022