Skip to content

Commit

Permalink
chore(build): Build/linting infrastructure updates. (#276)
Browse files Browse the repository at this point in the history
* Move npm/linting config files to root directory
* Apply prettier/eslint autofixes
* Update CONTRIBUTING.md
  • Loading branch information
joshdick authored Jul 11, 2021
1 parent 4bd214f commit d954737
Show file tree
Hide file tree
Showing 15 changed files with 4,896 additions and 2,472 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"env": {
"es6": true,
"node": true
},
"extends": "eslint:recommended",
"rules": {
"no-console": ["off"]
}
}
1 change: 1 addition & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Thank you!
-->

- [ ] I have carefully read and followed the [Installation section of the README](https://github.com/joshdick/onedark.vim#installation)
- [ ] I have searched through the [closed issues](https://github.com/joshdick/onedark.vim/issues?q=is%3Aissue+is%3Aclosed) to see if there is an existing solution for my issue

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
build/node_modules
node_modules
File renamed without changes.
1 change: 0 additions & 1 deletion build/.husky/pre-commit → .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
cd build
npm test
File renamed without changes.
6 changes: 6 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"arrowParens": "avoid",
"printWidth": 120,
"singleQuote": true,
"trailingComma": "none"
}
34 changes: 17 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,48 @@ The basic idea is that these files are generated by a build tool that substitute

Here are the locations of the files that are generated by the build system, along with the locations of the corresponding templates they are generated from:

| Theme Location | Template Location |
|----------------------------------------------|------------------------------------------|
| `autoload/onedark.vim` | `build/templates/autoload.template.vim` |
| `term/One Dark.Xresources` | `build/templates/One Dark.Xresources` |
| `term/One Dark.itermcolors` | `build/templates/One Dark.itermcolors` |
| `term/One Dark.terminal` | `build/templates/One Dark.terminal` |
| `term/One Dark.alacritty` | `build/templates/One Dark.alacritty` |
| `term/One Dark.colorscheme` | `build/templates/One Dark.colorscheme` |
| Theme Location | Template Location |
| --------------------------- | --------------------------------------- |
| `autoload/onedark.vim` | `build/templates/autoload.template.vim` |
| `term/One Dark.Xresources` | `build/templates/One Dark.Xresources` |
| `term/One Dark.itermcolors` | `build/templates/One Dark.itermcolors` |
| `term/One Dark.terminal` | `build/templates/One Dark.terminal` |
| `term/One Dark.alacritty` | `build/templates/One Dark.alacritty` |
| `term/One Dark.colorscheme` | `build/templates/One Dark.colorscheme` |

### Configure It

1) Install [Node.js](https://nodejs.org/en/) (Installing via [nvm](https://github.com/creationix/nvm) or [homebrew](https://brew.sh) are both better options than the official Node.js installer.)
1. Install [Node.js](https://nodejs.org/en/) (Installing via [nvm](https://github.com/creationix/nvm) or [homebrew](https://brew.sh) are both better options than the official Node.js installer.)

2) Run the following from within the root of this repository. This will install the build system's dependencies and will automatically configure a Git pre-commit hook that runs `npm test` (see below).
2. Run the following from within the root of this repository. This will install the build system's dependencies and will automatically configure a Git pre-commit hook that runs `npm test` (see below).

```bash
> cd build
> npm install
```

That's it!

### Use It

The build system consists of a single Node.js script, `build.js`, which supports two commands:
The build system consists of a single Node.js script, `build/build.js`, which supports two commands:

* Running `./build.js` or `npm run build` generates theme files from the templates, **overwriting changes to the theme files without confirmation.**
* Running `./build.js check` or `npm test` checks that the theme files match the template-generated output, **without modifying theme files**. This command ensures that the theme files perfectly match the templates they are generated from, which is useful for detecting changes that were made to generated theme files but that should have been made in the templates. (In addition to running `./build.js check`, `npm test` also runs [eslint](http://eslint.org) linting on the build system code to catch and prevent simple problems with changes to that code.)
- Running `./build/build.js` or `npm run build` generates theme files from the templates, **overwriting changes to the theme files without confirmation.**
- Running `./build/build.js check` or `npm test` checks that the theme files match the template-generated output, **without modifying theme files**. This command ensures that the theme files perfectly match the templates they are generated from, which is useful for detecting changes that were made to generated theme files but that should have been made in the templates.
- In addition to running `./build/build.js check`, `npm test` also runs linting and style checks on certain files to catch and prevent simple problems and stylistic inconsistency. If `npm test` reports any issues, many reported issues can be automatically fixed by running `npm run lint:fix`.)

The basic development workflow looks like this:

1. Make changes to the appropriate template files in `build/templates`, then run `npm run build` from inside the `build` directory.
1. Make changes to the appropriate template files in `build/templates`, then run `npm run build`.

2. Commit your change in Git. `npm test` will automatically run before your commit is finalized. If the test fails, fix any inconsistencies between the template files and theme files (or linting errors in `build.js` if applicable), then try committing again.
2. Commit your changes with Git. `npm test` will automatically run before your commit is finalized. If the test fails, fix any inconsistencies between the template files and theme files (or linting/style errors if applicable), then try committing again.

## Style Guidelines

Please match the existing comment and whitespace style in all template files.

For the "Language-Specific Highlighting" portion of onedark.vim, blocks for each language should be organized alphabetically ("Markdown" comes before "PHP").

Any changes to the JavaScript code in the build system should pass against the included eslint rules; you can manually check for linting errors by running `npm test` from inside the `build` directory.
All code changes should pass against the included linting and style checks. These checks are run via [husky](https://www.npmjs.com/package/husky) and [lint-staged](https://www.npmjs.com/package/lint-staged) when you attempt to commit changes. You can manually check for linting and stylistic issues by running `npm test`, and many reported issues can be automatically fixed by running `npm run lint:fix`.

## Thanks!

Expand Down
84 changes: 42 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ A dark Vim/Neovim color scheme for the GUI and 16/256/true-color terminals, base

onedark.vim includes support for the following Vim and Neovim plugins:

* [airblade/vim-gitgutter](https://github.com/airblade/vim-gitgutter)
* [dense-analysis/ale](https://github.com/dense-analysis/ale)
* [easymotion/vim-easymotion](https://github.com/easymotion/vim-easymotion)
* [itchyny/lightline.vim](https://github.com/itchyny/lightline.vim)
* [lewis6991/gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim)
* [mhinz/vim-signify](https://github.com/mhinz/vim-signify)
* [neoclide/coc.nvim](https://github.com/neoclide/coc.nvim)
* [neomake/neomake](https://github.com/neomake/neomake)
* [Neovim LSP](https://neovim.io/doc/user/lsp.html)
* [plasticboy/vim-markdown](https://github.com/plasticboy/vim-markdown)
* [prabirshrestha/vim-lsp](https://github.com/prabirshrestha/vim-lsp)
* [tpope/vim-fugitive](https://github.com/tpope/vim-fugitive)
* [vim-airline/vim-airline](https://github.com/vim-airline/vim-airline)
- [airblade/vim-gitgutter](https://github.com/airblade/vim-gitgutter)
- [dense-analysis/ale](https://github.com/dense-analysis/ale)
- [easymotion/vim-easymotion](https://github.com/easymotion/vim-easymotion)
- [itchyny/lightline.vim](https://github.com/itchyny/lightline.vim)
- [lewis6991/gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim)
- [mhinz/vim-signify](https://github.com/mhinz/vim-signify)
- [neoclide/coc.nvim](https://github.com/neoclide/coc.nvim)
- [neomake/neomake](https://github.com/neomake/neomake)
- [Neovim LSP](https://neovim.io/doc/user/lsp.html)
- [plasticboy/vim-markdown](https://github.com/plasticboy/vim-markdown)
- [prabirshrestha/vim-lsp](https://github.com/prabirshrestha/vim-lsp)
- [tpope/vim-fugitive](https://github.com/tpope/vim-fugitive)
- [vim-airline/vim-airline](https://github.com/vim-airline/vim-airline)

## Installation

Expand Down Expand Up @@ -77,11 +77,11 @@ onedark.vim includes support for the following Vim and Neovim plugins:

**Note:** All options should be set **before** the `colorscheme onedark` line in your `~/.vimrc`.

* `g:onedark_hide_endofbuffer`: Set to `1` if you want to hide end-of-buffer filler lines (~) for a cleaner look; `0` otherwise (the default).
- `g:onedark_hide_endofbuffer`: Set to `1` if you want to hide end-of-buffer filler lines (~) for a cleaner look; `0` otherwise (the default).

* `g:onedark_termcolors` **(see [Troubleshooting](#troubleshooting) (below) for more information about this option)**: Set to `256` for 256-color terminals (the default), or set to `16` to use your terminal emulator's native 16 colors.
- `g:onedark_termcolors` **(see [Troubleshooting](#troubleshooting) (below) for more information about this option)**: Set to `256` for 256-color terminals (the default), or set to `16` to use your terminal emulator's native 16 colors.

* `g:onedark_terminal_italics`: Set to `1` if your terminal emulator supports italics; `0` otherwise (the default).
- `g:onedark_terminal_italics`: Set to `1` if your terminal emulator supports italics; `0` otherwise (the default).

## lightline.vim Colorscheme

Expand All @@ -91,8 +91,8 @@ This repository includes a companion [lightline.vim](https://github.com/itchyny/

The lightline.vim colorscheme:

* Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
* Works with both color modes available in onedark.vim (16 or 256 colors), as specified in the configuration for onedark.vim.
- Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
- Works with both color modes available in onedark.vim (16 or 256 colors), as specified in the configuration for onedark.vim.

### Installation

Expand All @@ -114,9 +114,9 @@ This repository includes a companion [vim-airline](https://github.com/vim-airlin

The vim-airline theme:

* Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
* Works with both color modes available in onedark.vim (16 or 256 colors), as specified in the configuration for onedark.vim.
* Is based on vim-airline's ["tomorrow" theme](https://github.com/vim-airline/vim-airline-themes/blob/master/autoload/airline/themes/tomorrow.vim).
- Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
- Works with both color modes available in onedark.vim (16 or 256 colors), as specified in the configuration for onedark.vim.
- Is based on vim-airline's ["tomorrow" theme](https://github.com/vim-airline/vim-airline-themes/blob/master/autoload/airline/themes/tomorrow.vim).

### Installation

Expand Down Expand Up @@ -146,23 +146,23 @@ However, you can use the `g:onedark_termcolors` option to control onedark.vim's

**When Vim/Neovim are configured to use 24-bit color, the `g:onedark_termcolors` option is ignored. However, `g:onedark_termcolors` can still coexist with 24-bit color configuration.** For instance, when tmux 2.1 or earlier and/or older Vim/Neovim versions that don't support 24-bit color are used, the `g:onedark_termcolors` option will take effect.

* **256-color mode** is enabled by default with no additional configuration, but colors are less accurate since they are approximated using a 256-color palette. The background color will appear darker than in the preview image, and most other colors will appear brighter than in the preview image. If you don't want to change your terminal's color palette as described in the 16-color mode section below, and your terminal doesn't support 24-bit color, 256-color mode is your only option.
- **256-color mode** is enabled by default with no additional configuration, but colors are less accurate since they are approximated using a 256-color palette. The background color will appear darker than in the preview image, and most other colors will appear brighter than in the preview image. If you don't want to change your terminal's color palette as described in the 16-color mode section below, and your terminal doesn't support 24-bit color, 256-color mode is your only option.

Although 256-color mode is enabled by default (when not using 24-bit color as described above), you can explicitly enable it by adding the following line to your `~/.vimrc`:
Although 256-color mode is enabled by default (when not using 24-bit color as described above), you can explicitly enable it by adding the following line to your `~/.vimrc`:

```vim
let g:onedark_termcolors=256
```
```vim
let g:onedark_termcolors=256
```

* **16-color mode** is the preferred option, since its colors are more accurate than those of 256-color mode. However, you'll need to set your terminal emulator's color palette to this color scheme's custom 16-color palette, since 16-color mode will cause the color scheme to use your terminal emulator's native 16 colors. If you don't use the custom 16-color palette in your terminal emulator when 16-color mode is enabled, onedark.vim's colors will not display correctly in Vim.
- **16-color mode** is the preferred option, since its colors are more accurate than those of 256-color mode. However, you'll need to set your terminal emulator's color palette to this color scheme's custom 16-color palette, since 16-color mode will cause the color scheme to use your terminal emulator's native 16 colors. If you don't use the custom 16-color palette in your terminal emulator when 16-color mode is enabled, onedark.vim's colors will not display correctly in Vim.

The canonical version of the 16-color palette is an [Xresources](https://en.wikipedia.org/wiki/X_resources) file located in this repository at `term/One Dark.Xresources`. Color schemes for various terminal emulators are also provided in `term/`. (The [iTerm2](https://iterm2.com/) color scheme works with iTerm2 versions 2.9.x and later.) You should be able to easily convert the Xresources color scheme for use with your terminal emulator of choice either by hand, or automatically by using [termcolors](https://github.com/stayradiated/termcolors).
The canonical version of the 16-color palette is an [Xresources](https://en.wikipedia.org/wiki/X_resources) file located in this repository at `term/One Dark.Xresources`. Color schemes for various terminal emulators are also provided in `term/`. (The [iTerm2](https://iterm2.com/) color scheme works with iTerm2 versions 2.9.x and later.) You should be able to easily convert the Xresources color scheme for use with your terminal emulator of choice either by hand, or automatically by using [termcolors](https://github.com/stayradiated/termcolors).

Assuming your terminal emulator is configured to use the custom 16-color palette as described above, add the following line to your `~/.vimrc` to enable 16-color mode:
Assuming your terminal emulator is configured to use the custom 16-color palette as described above, add the following line to your `~/.vimrc` to enable 16-color mode:

```vim
let g:onedark_termcolors=16
```
```vim
let g:onedark_termcolors=16
```

### Why do all comments look like they're highlighted?

Expand Down Expand Up @@ -254,18 +254,18 @@ Several other themes and projects have reused code and/or colors from this proje

If onedark.vim isn't meeting your needs, try one of its relatives!

* [drewtempelmeyer/palenight.vim](https://github.com/drewtempelmeyer/palenight.vim)
* [KeitaNakamura/neodark.vim](https://github.com/KeitaNakamura/neodark.vim)
* [base16-onedark.vim](https://github.com/chriskempson/base16-vim/blob/master/colors/base16-onedark.vim)
* Associated base16 scheme: [tilal6991/base16-onedark-scheme](https://github.com/tilal6991/base16-onedark-scheme)
* [rakr/vim-one](https://github.com/rakr/vim-one)
* For Neovim >= 0.5 with treesitter support: [navarasu/onedark.nvim](https://github.com/navarasu/onedark.nvim)
* Neovim-only Lua port: [ii14/onedark.nvim](https://github.com/ii14/onedark.nvim)
- [drewtempelmeyer/palenight.vim](https://github.com/drewtempelmeyer/palenight.vim)
- [KeitaNakamura/neodark.vim](https://github.com/KeitaNakamura/neodark.vim)
- [base16-onedark.vim](https://github.com/chriskempson/base16-vim/blob/master/colors/base16-onedark.vim)
- Associated base16 scheme: [tilal6991/base16-onedark-scheme](https://github.com/tilal6991/base16-onedark-scheme)
- [rakr/vim-one](https://github.com/rakr/vim-one)
- For Neovim >= 0.5 with treesitter support: [navarasu/onedark.nvim](https://github.com/navarasu/onedark.nvim)
- Neovim-only Lua port: [ii14/onedark.nvim](https://github.com/ii14/onedark.nvim)

### Preview images

Preview images were taken using:

* [iTerm2](https://iterm2.com) terminal emulator on macOS
* 13 pt. [PragmataPro Mono](http://www.fsd.it/fonts/pragmatapro.htm#.VlDa1q6rTOY) font
* [vim-polyglot](https://github.com/sheerun/vim-polyglot) plug-in
- [iTerm2](https://iterm2.com) terminal emulator on macOS
- 13 pt. [PragmataPro Mono](http://www.fsd.it/fonts/pragmatapro.htm#.VlDa1q6rTOY) font
- [vim-polyglot](https://github.com/sheerun/vim-polyglot) plug-in
28 changes: 0 additions & 28 deletions build/.eslintrc.json

This file was deleted.

Loading

0 comments on commit d954737

Please sign in to comment.