https://github.com/airblade/vim-tcs
Integrates tcs (Tailwind class sorter) with Vim
https://github.com/airblade/vim-tcs
tailwindcss vim vim-plugin
Last synced: about 2 months ago
JSON representation
Integrates tcs (Tailwind class sorter) with Vim
- Host: GitHub
- URL: https://github.com/airblade/vim-tcs
- Owner: airblade
- License: mit
- Created: 2023-01-25T15:00:44.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-04-20T10:33:33.000Z (about 3 years ago)
- Last Synced: 2025-03-31T03:44:02.990Z (about 1 year ago)
- Topics: tailwindcss, vim, vim-plugin
- Language: Vim Script
- Homepage:
- Size: 5.86 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.markdown
Awesome Lists containing this project
README
# tcs-vim
Integrates [tcs](https://github.com/airblade/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:
```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 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.