Skip to content

Integrates tcs (Tailwind class sorter) with Vim

License

Notifications You must be signed in to change notification settings

airblade/vim-tcs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

tcs-vim

Integrates tcs (Tailwind class sorter) with Vim.

Whenever you write an HTML file, the plugin waits for the Tailwind build process to finish and then runs the HTML through tcs.

Installation

Install tcs somewhere on your PATH.

Install this plugin like every other vim plugin :)

Set g:tcs_css to point to the CSS file which Tailwind CLI generates.

I have this snippet in my vimrc:

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 autoread |
      \ endif
autocmd BufWritePost *.html,*.slim if s:is_tailwind() |
      \   call TcsAsync() |
      \ endif

Configuration

g:tcs_executable - path to the tcs script. Default: 'tcs'.

g:tcs_delay_ms - how long to wait in milliseconds for Tailwind's build to finish after saving an HTML file. Default: 250.

Tailwind doesn't touch the output CSS file if there is no change to the CSS, in which case there's no way to detect the build has finished. Instead we just give it time to finish.

g:tcs_css - path to Tailwind's output CSS file. This needs to be set.

g:tcs_sticky_cursor - whether the cursor should stick to any Tailwind class it's on if the class is moved to a different spot. Default: v:true.

Intellectual property

Copyright Andrew Stewart. Released under the MIT licence.

About

Integrates tcs (Tailwind class sorter) with Vim

Topics

Resources

License

Stars

Watchers

Forks