Skip to content

Commit

Permalink
docs(readme): add basic README
Browse files Browse the repository at this point in the history
  • Loading branch information
dzfrias committed Jan 19, 2023
1 parent 9daeb4e commit b96c074
Showing 1 changed file with 95 additions and 1 deletion.
96 changes: 95 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,95 @@
# Classy
# nvim-classy
nvim-classy hides your HTML `class` attributes so your code goes from looking
like this:
```html
<div class="centered flex popout bring-to-front hover-effect">
<p class="whitespace main-paragraph">"Text"</p>
</div>
```
to this:
```html
<div class=".">
<p class=".">Text</p>
</div>
```
Of course, when you put your cursor on one of lines, the `"."`s will expand
into their normal form.

Multiple filetypes are supported and its incredibly easy to configure your own!

This plugin was heavily inspired by the VSCode plugin,
[Inline Fold](https://github.com/moalamri/vscode-inline-fold).

## Installation
Install with your favorite package manager!

For example, with [packer.nvim](https://github.com/wbthomason/packer.nvim):
```lua
use {
'dzfrias/nvim-classy',
requires = 'nvim-treesitter/nvim-treesitter',
}
```
This plugin has out-of-the-box configuration, so just install it and it should
work!

### Treesitter
It will not work without
[nvim-treesitter](https://github.com/nvim-treesitter/nvim-treesitter) and the
appropriate grammar must be installed.

For example, to use it with HTML, make sure treesitter is installed and run
`:TSInstall html`.

## Commands
nvim-classy has two main commands:
- `:ClassyConceal`
- `:ClassyUnconceal`

These commands allow for fine-grained control over the plugin.

### ClassyConceal
ClassyConceal turns on concealing for the current file. It is updated every
time the buffer is modified. This is run automatically by classy if the
`auto_start` option is set to `true` (the default).

### ClassyUnconceal
This command wipes every conceal set by nvim-classy from the buffer.

## Configuration
The behavior of nvim-classy can be fully customized.

Here are the available options and their default values:
```lua
{
conceal_char = ".",
conceal_hl_group = "",
filetypes = {
html = [[ ((attribute_name) @attr_name (#eq? @attr_name "class") (quoted_attribute_value (attribute_value) @attr_value)) ]],
javascript = [[
;; jsx
((property_identifier) @attr_name (#eq? @attr_name "class") [(jsx_expression (_)?) (string)] @attr_value) ]],
svelte = [[ ((attribute_name) @attr_name (#eq? @attr_name "class") (quoted_attribute_value (attribute_value) @attr_value)) ]],
},
auto_start = true,
}
```
**conceal_char**:
The character to conceal the classes. Note that this can only be a single
character due to the limitations of nvim, so setting it to a string will use
the first character.

**conceal_hl_group**:
The highlight group of the conceal character. Set it to `string` if you'd like
the `conceal_char` to be the same color as the expanded classes.

**filetypes**:
Contains queries of the filetypes that classy supports. To write your own, make
sure to include an `@attr_value` capture so classy knows what to conceal!
Make sure to read about writing treesitter queries!

**auto_start**:
If `true`, runs `:ClassyConceal` when you start editing the file.

## License
This plugin is licensed under the MIT license.

0 comments on commit b96c074

Please sign in to comment.