A Vim plugin to autocomplete Tailwind class names without LSP.
It also lets you look up a Tailwind class's CSS properties.
Showing completions for text-zinc-
:
Showing class information for text-zinc-600
in the command-line area:
v3.3.5
Install like every other Vim plugin :)
These options customise the completion items (see :help complete-items
).
g:tailwind_complete_item_info
- whether to set theinfo
text (defaultv:true
).g:tailwind_complete_item_menu
- whether to set themenu
text (defaultv:true
).g:tailwind_complete_item_menu_length
- maximum length of themenu
text (default40
).g:tailwind_complete_items_max
- maximum number of items to show (default:50
).
For user-defined autocompletion (via <C-X><C-U>
):
setlocal completefunc=tailwind#Complete
Or for omnicompletion (via <C-X><C-O>
):
setlocal omnifunc=tailwind#Complete
I have the following snippet in my vimrc to set this up:
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
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
:
nmap <silent> <buffer> gk <Plug>(tailwind-lookup)
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
class.
Copyright Andrew Stewart. Released under the MIT licence.