An open API service indexing awesome lists of open source software.

https://github.com/airblade/vim-tailwind

A Vim plugin to autocomplete Tailwind classes without LSP. Also looks up Tailwind classes' CSS properties.
https://github.com/airblade/vim-tailwind

completion tailwindcss vim vim-plugin

Last synced: over 1 year ago
JSON representation

A Vim plugin to autocomplete Tailwind classes without LSP. Also looks up Tailwind classes' CSS properties.

Awesome Lists containing this project

README

          

# vim-tailwind

A Vim plugin to autocomplete Tailwind class names without LSP.

It also lets you look up a Tailwind class's CSS properties.

## Screenshots

Showing completions for `text-zinc-`:

![Screenshot of completions for `text-zinc-`](completions.png?raw=true)

Showing class information for `text-zinc-600` in the command-line area:

![Screenshot of completions for `text-zinc-`](class-lookup.png?raw=true)

## Tailwind version

v3.3.5

## Installation

Install like every other Vim plugin :)

## Configuration

These options customise the completion items (see `:help complete-items`).

- `g:tailwind_complete_item_info` - whether to set the `info` text (default `v:true`).
- `g:tailwind_complete_item_menu` - whether to set the `menu` text (default `v:true`).
- `g:tailwind_complete_item_menu_length` - maximum length of the `menu` text (default `40`).
- `g:tailwind_complete_items_max` - maximum number of items to show (default: `50`).

## Usage

### Autocompletion

For user-defined autocompletion (via ``):

```vim
setlocal completefunc=tailwind#Complete
```

Or for omnicompletion (via ``):

```vim
setlocal omnifunc=tailwind#Complete
```

I have the following snippet in my vimrc to set this up:

```vim
function! s:is_tailwind()
return !empty(findfile('tailwind.config.js', '.;')) ||
\ !empty(findfile('config/tailwind.config.js', '.;'))
endfunction

autocmd BufEnter *.html,*.slim if s:is_tailwind() |
\ setlocal omnifunc=tailwind#Complete |
\ endif
```

### Lookup

Unless you have `K` mapped already, press `K` in normal mode with your cursor on a Tailwind class.

To map some other key, e.g. `gk`:

```vim
nmap gk (tailwind-lookup)
```

## Caveats

The plugin ignores modifiers, e.g. `sm:` or `hover:`. They affect when the CSS is applied, not what the CSS actually is, so they are irrelevant here.

The plugin ignores `@media` at-rules. This only affects the [`.container`](https://tailwindcss.com/docs/container) class.

## Intellectual property

Copyright Andrew Stewart. Released under the MIT licence.