mirror of
https://github.com/joshdick/onedark.vim.git
synced 2025-11-08 11:03:49 -05:00
chore(build): Build/linting infrastructure updates. (#276)
* Move npm/linting config files to root directory * Apply prettier/eslint autofixes * Update CONTRIBUTING.md
This commit is contained in:
10
.eslintrc.json
Normal file
10
.eslintrc.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"es6": true,
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"rules": {
|
||||||
|
"no-console": ["off"]
|
||||||
|
}
|
||||||
|
}
|
||||||
1
.github/ISSUE_TEMPLATE.md
vendored
1
.github/ISSUE_TEMPLATE.md
vendored
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
Thank you!
|
Thank you!
|
||||||
-->
|
-->
|
||||||
|
|
||||||
- [ ] I have carefully read and followed the [Installation section of the README](https://github.com/joshdick/onedark.vim#installation)
|
- [ ] 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
|
- [ ] 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
|
||||||
|
|
||||||
|
|||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1 +1 @@
|
|||||||
build/node_modules
|
node_modules
|
||||||
|
|||||||
@@ -1,2 +1 @@
|
|||||||
cd build
|
|
||||||
npm test
|
npm test
|
||||||
6
.prettierrc
Normal file
6
.prettierrc
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
{
|
||||||
|
"arrowParens": "avoid",
|
||||||
|
"printWidth": 120,
|
||||||
|
"singleQuote": true,
|
||||||
|
"trailingComma": "none"
|
||||||
|
}
|
||||||
@@ -15,7 +15,7 @@ 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:
|
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 |
|
| Theme Location | Template Location |
|
||||||
|----------------------------------------------|------------------------------------------|
|
| --------------------------- | --------------------------------------- |
|
||||||
| `autoload/onedark.vim` | `build/templates/autoload.template.vim` |
|
| `autoload/onedark.vim` | `build/templates/autoload.template.vim` |
|
||||||
| `term/One Dark.Xresources` | `build/templates/One Dark.Xresources` |
|
| `term/One Dark.Xresources` | `build/templates/One Dark.Xresources` |
|
||||||
| `term/One Dark.itermcolors` | `build/templates/One Dark.itermcolors` |
|
| `term/One Dark.itermcolors` | `build/templates/One Dark.itermcolors` |
|
||||||
@@ -25,12 +25,11 @@ Here are the locations of the files that are generated by the build system, alon
|
|||||||
|
|
||||||
### Configure It
|
### 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
|
```bash
|
||||||
> cd build
|
|
||||||
> npm install
|
> npm install
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -38,16 +37,17 @@ That's it!
|
|||||||
|
|
||||||
### Use 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/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 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:
|
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
|
## Style Guidelines
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ 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").
|
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!
|
## Thanks!
|
||||||
|
|
||||||
|
|||||||
66
README.md
66
README.md
@@ -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:
|
onedark.vim includes support for the following Vim and Neovim plugins:
|
||||||
|
|
||||||
* [airblade/vim-gitgutter](https://github.com/airblade/vim-gitgutter)
|
- [airblade/vim-gitgutter](https://github.com/airblade/vim-gitgutter)
|
||||||
* [dense-analysis/ale](https://github.com/dense-analysis/ale)
|
- [dense-analysis/ale](https://github.com/dense-analysis/ale)
|
||||||
* [easymotion/vim-easymotion](https://github.com/easymotion/vim-easymotion)
|
- [easymotion/vim-easymotion](https://github.com/easymotion/vim-easymotion)
|
||||||
* [itchyny/lightline.vim](https://github.com/itchyny/lightline.vim)
|
- [itchyny/lightline.vim](https://github.com/itchyny/lightline.vim)
|
||||||
* [lewis6991/gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim)
|
- [lewis6991/gitsigns.nvim](https://github.com/lewis6991/gitsigns.nvim)
|
||||||
* [mhinz/vim-signify](https://github.com/mhinz/vim-signify)
|
- [mhinz/vim-signify](https://github.com/mhinz/vim-signify)
|
||||||
* [neoclide/coc.nvim](https://github.com/neoclide/coc.nvim)
|
- [neoclide/coc.nvim](https://github.com/neoclide/coc.nvim)
|
||||||
* [neomake/neomake](https://github.com/neomake/neomake)
|
- [neomake/neomake](https://github.com/neomake/neomake)
|
||||||
* [Neovim LSP](https://neovim.io/doc/user/lsp.html)
|
- [Neovim LSP](https://neovim.io/doc/user/lsp.html)
|
||||||
* [plasticboy/vim-markdown](https://github.com/plasticboy/vim-markdown)
|
- [plasticboy/vim-markdown](https://github.com/plasticboy/vim-markdown)
|
||||||
* [prabirshrestha/vim-lsp](https://github.com/prabirshrestha/vim-lsp)
|
- [prabirshrestha/vim-lsp](https://github.com/prabirshrestha/vim-lsp)
|
||||||
* [tpope/vim-fugitive](https://github.com/tpope/vim-fugitive)
|
- [tpope/vim-fugitive](https://github.com/tpope/vim-fugitive)
|
||||||
* [vim-airline/vim-airline](https://github.com/vim-airline/vim-airline)
|
- [vim-airline/vim-airline](https://github.com/vim-airline/vim-airline)
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
@@ -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`.
|
**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
|
## lightline.vim Colorscheme
|
||||||
|
|
||||||
@@ -91,8 +91,8 @@ This repository includes a companion [lightline.vim](https://github.com/itchyny/
|
|||||||
|
|
||||||
The lightline.vim colorscheme:
|
The lightline.vim colorscheme:
|
||||||
|
|
||||||
* Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
|
- 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.
|
- Works with both color modes available in onedark.vim (16 or 256 colors), as specified in the configuration for onedark.vim.
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
@@ -114,9 +114,9 @@ This repository includes a companion [vim-airline](https://github.com/vim-airlin
|
|||||||
|
|
||||||
The vim-airline theme:
|
The vim-airline theme:
|
||||||
|
|
||||||
* Depends on `autoload/onedark.vim` for its colors, and must therefore be used in conjunction with it.
|
- 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.
|
- 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).
|
- Is based on vim-airline's ["tomorrow" theme](https://github.com/vim-airline/vim-airline-themes/blob/master/autoload/airline/themes/tomorrow.vim).
|
||||||
|
|
||||||
### Installation
|
### Installation
|
||||||
|
|
||||||
@@ -146,7 +146,7 @@ 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.
|
**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`:
|
||||||
|
|
||||||
@@ -154,7 +154,7 @@ However, you can use the `g:onedark_termcolors` option to control onedark.vim's
|
|||||||
let g:onedark_termcolors=256
|
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).
|
||||||
|
|
||||||
@@ -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!
|
If onedark.vim isn't meeting your needs, try one of its relatives!
|
||||||
|
|
||||||
* [drewtempelmeyer/palenight.vim](https://github.com/drewtempelmeyer/palenight.vim)
|
- [drewtempelmeyer/palenight.vim](https://github.com/drewtempelmeyer/palenight.vim)
|
||||||
* [KeitaNakamura/neodark.vim](https://github.com/KeitaNakamura/neodark.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)
|
- [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)
|
- Associated base16 scheme: [tilal6991/base16-onedark-scheme](https://github.com/tilal6991/base16-onedark-scheme)
|
||||||
* [rakr/vim-one](https://github.com/rakr/vim-one)
|
- [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)
|
- 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)
|
- Neovim-only Lua port: [ii14/onedark.nvim](https://github.com/ii14/onedark.nvim)
|
||||||
|
|
||||||
### Preview images
|
### Preview images
|
||||||
|
|
||||||
Preview images were taken using:
|
Preview images were taken using:
|
||||||
|
|
||||||
* [iTerm2](https://iterm2.com) terminal emulator on macOS
|
- [iTerm2](https://iterm2.com) terminal emulator on macOS
|
||||||
* 13 pt. [PragmataPro Mono](http://www.fsd.it/fonts/pragmatapro.htm#.VlDa1q6rTOY) font
|
- 13 pt. [PragmataPro Mono](http://www.fsd.it/fonts/pragmatapro.htm#.VlDa1q6rTOY) font
|
||||||
* [vim-polyglot](https://github.com/sheerun/vim-polyglot) plug-in
|
- [vim-polyglot](https://github.com/sheerun/vim-polyglot) plug-in
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"env": {
|
|
||||||
"es6": true,
|
|
||||||
"node": true
|
|
||||||
},
|
|
||||||
"extends": "eslint:recommended",
|
|
||||||
"rules": {
|
|
||||||
"no-console": [
|
|
||||||
"off"
|
|
||||||
],
|
|
||||||
"indent": [
|
|
||||||
"error",
|
|
||||||
"tab"
|
|
||||||
],
|
|
||||||
"linebreak-style": [
|
|
||||||
"error",
|
|
||||||
"unix"
|
|
||||||
],
|
|
||||||
"quotes": [
|
|
||||||
"error",
|
|
||||||
"single"
|
|
||||||
],
|
|
||||||
"semi": [
|
|
||||||
"error",
|
|
||||||
"never"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
158
build/build.js
158
build/build.js
@@ -1,9 +1,9 @@
|
|||||||
#!/usr/bin/env node
|
#!/usr/bin/env node
|
||||||
|
|
||||||
const _ = require('lodash') // ships with termcolors; only used because of termcolors customization
|
const _ = require('lodash'); // ships with termcolors; only used because of termcolors customization
|
||||||
const termcolors = require('termcolors')
|
const termcolors = require('termcolors');
|
||||||
const { readFileSync, writeFileSync } = require('fs')
|
const { readFileSync, writeFileSync } = require('fs');
|
||||||
const { resolve } = require('path')
|
const { resolve } = require('path');
|
||||||
|
|
||||||
const baseColors = Object.freeze({
|
const baseColors = Object.freeze({
|
||||||
red: { gui: '#E06C75', cterm: '204', cterm16: '1' }, // alternate cterm: 168
|
red: { gui: '#E06C75', cterm: '204', cterm16: '1' }, // alternate cterm: 168
|
||||||
@@ -16,7 +16,7 @@ const baseColors = Object.freeze({
|
|||||||
cyan: { gui: '#56B6C2', cterm: '38', cterm16: '6' }, // alternate cterm: 73
|
cyan: { gui: '#56B6C2', cterm: '38', cterm16: '6' }, // alternate cterm: 73
|
||||||
white: { gui: '#ABB2BF', cterm: '145', cterm16: '7' },
|
white: { gui: '#ABB2BF', cterm: '145', cterm16: '7' },
|
||||||
black: { gui: '#282C34', cterm: '235', cterm16: '0' }
|
black: { gui: '#282C34', cterm: '235', cterm16: '0' }
|
||||||
})
|
});
|
||||||
|
|
||||||
const specialColors = Object.freeze({
|
const specialColors = Object.freeze({
|
||||||
comment_grey: { gui: '#5C6370', cterm: '59', cterm16: '15' },
|
comment_grey: { gui: '#5C6370', cterm: '59', cterm16: '15' },
|
||||||
@@ -25,155 +25,161 @@ const specialColors = Object.freeze({
|
|||||||
visual_grey: { gui: '#3E4452', cterm: '237', cterm16: '15' },
|
visual_grey: { gui: '#3E4452', cterm: '237', cterm16: '15' },
|
||||||
menu_grey: { cterm16: '8' }, // vim theme handles gui/cterm values
|
menu_grey: { cterm16: '8' }, // vim theme handles gui/cterm values
|
||||||
special_grey: { gui: '#3B4048', cterm: '238', cterm16: '15' },
|
special_grey: { gui: '#3B4048', cterm: '238', cterm16: '15' },
|
||||||
vertsplit: { gui: '#181A1F', cterm: '59', cterm16: '15' },
|
vertsplit: { gui: '#181A1F', cterm: '59', cterm16: '15' }
|
||||||
})
|
});
|
||||||
|
|
||||||
const colors = Object.assign({}, baseColors, specialColors)
|
const colors = Object.assign({}, baseColors, specialColors);
|
||||||
|
|
||||||
const templateMap = Object.freeze({
|
const templateMap = Object.freeze({
|
||||||
'templates/autoload.template.vim': '../autoload/onedark.vim',
|
'templates/autoload.template.vim': '../autoload/onedark.vim',
|
||||||
'templates/One Dark.Xresources': '../term/One Dark.Xresources'
|
'templates/One Dark.Xresources': '../term/One Dark.Xresources'
|
||||||
})
|
});
|
||||||
|
|
||||||
const shouldCheck = String(process.argv[2]).toLowerCase() === 'check'
|
const shouldCheck = String(process.argv[2]).toLowerCase() === 'check';
|
||||||
|
|
||||||
const handleError = (message, cause) => {
|
const handleError = (message, cause) => {
|
||||||
console.error('Error:', message)
|
console.error('Error:', message);
|
||||||
if (cause) console.error('Cause:', cause)
|
if (cause) console.error('Cause:', cause);
|
||||||
process.exit(-1)
|
process.exit(-1);
|
||||||
}
|
};
|
||||||
|
|
||||||
console.log(
|
console.log(
|
||||||
shouldCheck ?
|
shouldCheck
|
||||||
'Checking for inconsistencies between templates and existing output files...'
|
? 'Checking for inconsistencies between templates and existing output files...'
|
||||||
:
|
: 'Generating output files from templates...'
|
||||||
'Generating output files from templates...'
|
);
|
||||||
)
|
|
||||||
|
|
||||||
Object.keys(templateMap).forEach(templateFilename => {
|
Object.keys(templateMap).forEach(templateFilename => {
|
||||||
|
|
||||||
// Read the template
|
// Read the template
|
||||||
const templatePath = resolve(__dirname, templateFilename)
|
const templatePath = resolve(__dirname, templateFilename);
|
||||||
let templateText
|
let templateText;
|
||||||
try {
|
try {
|
||||||
templateText = readFileSync(templatePath, 'utf8')
|
templateText = readFileSync(templatePath, 'utf8');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(`Error reading template ${templatePath}`, e)
|
handleError(`Error reading template ${templatePath}`, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compile the template
|
// Compile the template
|
||||||
let template
|
let template;
|
||||||
try {
|
try {
|
||||||
template = _.template(templateText)
|
template = _.template(templateText);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(`Error compiling template ${templatePath}`, e)
|
handleError(`Error compiling template ${templatePath}`, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute the template (generate the output)
|
// Execute the template (generate the output)
|
||||||
let output
|
let output;
|
||||||
try {
|
try {
|
||||||
output = template(colors)
|
output = template(colors);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(`Error running template ${templatePath}`, e)
|
handleError(`Error running template ${templatePath}`, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
let outputPath = resolve(__dirname, templateMap[templateFilename])
|
let outputPath = resolve(__dirname, templateMap[templateFilename]);
|
||||||
try {
|
try {
|
||||||
const existingOutput = readFileSync(outputPath, 'utf8')
|
const existingOutput = readFileSync(outputPath, 'utf8');
|
||||||
// Only need to do something if the generated output differs from what's already on disk
|
// Only need to do something if the generated output differs from what's already on disk
|
||||||
if (output !== existingOutput) {
|
if (output !== existingOutput) {
|
||||||
if (shouldCheck) { // Check generated output against existing output file
|
if (shouldCheck) {
|
||||||
handleError(`Changes were made to ${templateMap[templateFilename]} that are inconsistent with its template (${templateFilename}).\nDo you need to [re]build?`)
|
// Check generated output against existing output file
|
||||||
} else { // Overwrite existing output file
|
handleError(
|
||||||
|
`Changes were made to ${templateMap[templateFilename]} that are inconsistent with its template (${templateFilename}).\nDo you need to [re]build?`
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
// Overwrite existing output file
|
||||||
try {
|
try {
|
||||||
writeFileSync(outputPath, output, 'utf8')
|
writeFileSync(outputPath, output, 'utf8');
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(`Error writing to output file ${outputPath}`, e)
|
handleError(`Error writing to output file ${outputPath}`, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError(`Error reading existing output file ${outputPath}`, e)
|
handleError(`Error reading existing output file ${outputPath}`, e);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
})
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Use the Xresources theme as a color source since it was generated above via templating
|
// Use the Xresources theme as a color source since it was generated above via templating
|
||||||
const xresources = readFileSync(resolve(__dirname, '../term/One Dark.Xresources'), 'utf8')
|
const xresources = readFileSync(resolve(__dirname, '../term/One Dark.Xresources'), 'utf8');
|
||||||
const terminalPalette = termcolors.xresources.import(xresources)
|
const terminalPalette = termcolors.xresources.import(xresources);
|
||||||
|
|
||||||
let alacrittyTemplate, itermTemplate, kittyTemplate, konsoleTemplate, terminalAppTemplate
|
let alacrittyTemplate, itermTemplate, kittyTemplate, konsoleTemplate, terminalAppTemplate;
|
||||||
|
|
||||||
// Compile custom terminal color templates based on ones that ship with termcolors
|
// Compile custom terminal color templates based on ones that ship with termcolors
|
||||||
try {
|
try {
|
||||||
alacrittyTemplate = termcolors.export(
|
alacrittyTemplate = termcolors.export(
|
||||||
readFileSync(resolve(__dirname, 'templates/One Dark.alacritty')),
|
readFileSync(resolve(__dirname, 'templates/One Dark.alacritty')),
|
||||||
_.partialRight(_.mapValues, function (color) {
|
_.partialRight(_.mapValues, function (color) {
|
||||||
return color.toHex().slice(1)
|
return color.toHex().slice(1);
|
||||||
})
|
})
|
||||||
)
|
);
|
||||||
|
|
||||||
itermTemplate = termcolors.export(
|
itermTemplate = termcolors.export(
|
||||||
// From termcolors/lib/formats/iterm.js
|
// From termcolors/lib/formats/iterm.js
|
||||||
readFileSync(resolve(__dirname, 'templates/One Dark.itermcolors')),
|
readFileSync(resolve(__dirname, 'templates/One Dark.itermcolors')),
|
||||||
_.partialRight(_.mapValues, function (color) {
|
_.partialRight(_.mapValues, function (color) {
|
||||||
return color.toAvgRgbArray()
|
return color.toAvgRgbArray();
|
||||||
})
|
})
|
||||||
)
|
);
|
||||||
|
|
||||||
kittyTemplate = termcolors.export(
|
kittyTemplate = termcolors.export(
|
||||||
readFileSync(resolve(__dirname, 'templates/One Dark.kitty')),
|
readFileSync(resolve(__dirname, 'templates/One Dark.kitty')),
|
||||||
_.partialRight(_.mapValues, function (color) {
|
_.partialRight(_.mapValues, function (color) {
|
||||||
return color.toHex().slice(1)
|
return color.toHex().slice(1);
|
||||||
})
|
})
|
||||||
)
|
);
|
||||||
|
|
||||||
konsoleTemplate = termcolors.export(
|
konsoleTemplate = termcolors.export(
|
||||||
// From termcolors/lib/formats/konsole.js
|
// From termcolors/lib/formats/konsole.js
|
||||||
readFileSync(resolve(__dirname, 'templates/One Dark.colorscheme')),
|
readFileSync(resolve(__dirname, 'templates/One Dark.colorscheme')),
|
||||||
_.partialRight(_.mapValues, function (color) {
|
_.partialRight(_.mapValues, function (color) {
|
||||||
return color.toRgbArray().join()
|
return color.toRgbArray().join();
|
||||||
})
|
})
|
||||||
)
|
);
|
||||||
|
|
||||||
// From termcolors/lib/formats/terminal-app.js
|
// From termcolors/lib/formats/terminal-app.js
|
||||||
const code = [
|
const code = [
|
||||||
Buffer.from('62706c6973743030d40102030405061516582476657273696f6e58246f626a65637473592461726368697665725424746f7012000186a0a307080f55246e756c6cd3090a0b0c0d0e554e535247425c4e53436f6c6f7253706163655624636c6173734f1027', 'hex'),
|
Buffer.from(
|
||||||
Buffer.from('0010018002d2101112135a24636c6173736e616d655824636c6173736573574e53436f6c6f72a21214584e534f626a6563745f100f4e534b657965644172636869766572d1171854726f6f74800108111a232d32373b41484e5b628c8e9095a0a9b1b4bdcfd2d700000000000001010000000000000019000000000000000000000000000000d9', 'hex')
|
'62706c6973743030d40102030405061516582476657273696f6e58246f626a65637473592461726368697665725424746f7012000186a0a307080f55246e756c6cd3090a0b0c0d0e554e535247425c4e53436f6c6f7253706163655624636c6173734f1027',
|
||||||
]
|
'hex'
|
||||||
|
),
|
||||||
|
Buffer.from(
|
||||||
|
'0010018002d2101112135a24636c6173736e616d655824636c6173736573574e53436f6c6f72a21214584e534f626a6563745f100f4e534b657965644172636869766572d1171854726f6f74800108111a232d32373b41484e5b628c8e9095a0a9b1b4bdcfd2d700000000000001010000000000000019000000000000000000000000000000d9',
|
||||||
|
'hex'
|
||||||
|
)
|
||||||
|
];
|
||||||
|
|
||||||
terminalAppTemplate = termcolors.export(
|
terminalAppTemplate = termcolors.export(
|
||||||
readFileSync(resolve(__dirname, 'templates/One Dark.terminal')),
|
readFileSync(resolve(__dirname, 'templates/One Dark.terminal')),
|
||||||
// From termcolors/lib/formats/terminal-app.js
|
// From termcolors/lib/formats/terminal-app.js
|
||||||
_.partialRight(_.mapValues, function (color) {
|
_.partialRight(_.mapValues, function (color) {
|
||||||
var srgb = color.toAvgRgbArray()
|
var srgb = color.toAvgRgbArray();
|
||||||
srgb = srgb.map(function (n) {
|
srgb = srgb
|
||||||
return n.toFixed(10).toString()
|
.map(function (n) {
|
||||||
}).join(' ')
|
return n.toFixed(10).toString();
|
||||||
var output = code[0].toString('binary') + srgb + code[1].toString('binary')
|
|
||||||
output = (Buffer.from(output, 'binary')).toString('base64')
|
|
||||||
return output.match(/.{1,68}/g).join('\n\t')
|
|
||||||
})
|
})
|
||||||
)
|
.join(' ');
|
||||||
|
var output = code[0].toString('binary') + srgb + code[1].toString('binary');
|
||||||
|
output = Buffer.from(output, 'binary').toString('base64');
|
||||||
|
return output.match(/.{1,68}/g).join('\n\t');
|
||||||
|
})
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError('Error compiling terminal color template', e)
|
handleError('Error compiling terminal color template', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
writeFileSync(resolve(__dirname, '../term/One Dark.alacritty'), alacrittyTemplate(terminalPalette))
|
writeFileSync(resolve(__dirname, '../term/One Dark.alacritty'), alacrittyTemplate(terminalPalette));
|
||||||
writeFileSync(resolve(__dirname, '../term/One Dark.itermcolors'), itermTemplate(terminalPalette))
|
writeFileSync(resolve(__dirname, '../term/One Dark.itermcolors'), itermTemplate(terminalPalette));
|
||||||
writeFileSync(resolve(__dirname, '../term/One Dark.kitty'), kittyTemplate(terminalPalette))
|
writeFileSync(resolve(__dirname, '../term/One Dark.kitty'), kittyTemplate(terminalPalette));
|
||||||
writeFileSync(resolve(__dirname, '../term/One Dark.colorscheme'), konsoleTemplate(terminalPalette))
|
writeFileSync(resolve(__dirname, '../term/One Dark.colorscheme'), konsoleTemplate(terminalPalette));
|
||||||
writeFileSync(resolve(__dirname, '../term/One Dark.terminal'), terminalAppTemplate(terminalPalette))
|
writeFileSync(resolve(__dirname, '../term/One Dark.terminal'), terminalAppTemplate(terminalPalette));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
handleError('Error writing terminal color file', e)
|
handleError('Error writing terminal color file', e);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
handleError('Error reading Xresources terminal color file', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (e) {
|
console.log('Success!');
|
||||||
handleError('Error reading Xresources terminal color file', e)
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Success!')
|
|
||||||
|
|
||||||
|
|||||||
2197
build/package-lock.json
generated
2197
build/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,28 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "onedark.vim-builder",
|
|
||||||
"version": "1.0.0",
|
|
||||||
"description": "Builds the onedark.vim Vim colorscheme and associated files",
|
|
||||||
"main": "build.js",
|
|
||||||
"scripts": {
|
|
||||||
"build": "node build.js",
|
|
||||||
"test": "eslint build.js && node build.js check",
|
|
||||||
"prepare": "cd .. && husky install build/.husky"
|
|
||||||
},
|
|
||||||
"author": {
|
|
||||||
"name": "Josh Dick",
|
|
||||||
"email": "josh@joshdick.net",
|
|
||||||
"url": "http://joshdick.net"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/joshdick/onedark.vim.git"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"eslint": "^7.29.0",
|
|
||||||
"husky": "^6.0.0"
|
|
||||||
},
|
|
||||||
"dependencies": {
|
|
||||||
"termcolors": "0.7.3"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
4610
package-lock.json
generated
Normal file
4610
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
45
package.json
Normal file
45
package.json
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
"name": "onedark.vim-builder",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Builds the onedark.vim Vim colorscheme and associated files",
|
||||||
|
"main": "build.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "node build/build.js",
|
||||||
|
"test": "npm run lint && node build/build.js check",
|
||||||
|
"prepare": "husky install",
|
||||||
|
"lint": "run-p eslint:check prettier:check",
|
||||||
|
"lint:fix": "run-s eslint:fix prettier:fix",
|
||||||
|
"eslint:check": "eslint '**/*.js'",
|
||||||
|
"eslint:fix": "eslint --fix '**/*.js'",
|
||||||
|
"prettier:check": "prettier --check '**/*.{js,json,md}'",
|
||||||
|
"prettier:fix": "prettier --write '**/*.{js,json,md}'"
|
||||||
|
},
|
||||||
|
"author": {
|
||||||
|
"name": "Josh Dick",
|
||||||
|
"email": "josh@joshdick.net",
|
||||||
|
"url": "http://joshdick.net"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/joshdick/onedark.vim.git"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint": "^7.30.0",
|
||||||
|
"husky": "^6.0.0",
|
||||||
|
"lint-staged": "^11.0.0",
|
||||||
|
"npm-run-all": "^4.1.5",
|
||||||
|
"prettier": "^2.3.2"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"termcolors": "0.7.3"
|
||||||
|
},
|
||||||
|
"lint-staged": {
|
||||||
|
"*.{js,json,md}": [
|
||||||
|
"prettier --check"
|
||||||
|
],
|
||||||
|
"*.{js}": [
|
||||||
|
"eslint"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user