-
Notifications
You must be signed in to change notification settings - Fork 45
Contributing
Here's how to change Workbench cope:
- Talk with us! File an issue on GitHub or join us on Gitter and let's get excited about what you want to do.
- Fork this repo, as per GitHub's forking documentation:
- Click "Fork"
- Clone your fork
- Set up your development environment
-
git remote add upstream https://github.com/CJWorkbench/cjworkbench
(so you can track our master branch later)
- Create your change:
- Make sure your
master
is the same asupstream/master
:git fetch upstream
git checkout master
git pull
-
git merge --ff-only upstream/master
(orgit reset --hard upstream/master
if you wrote changes tomaster
accidentally and wish to delete them)
git checkout master
- Create a new branch:
git branch my-great-feature
- Write a test that fails (
bin/dev unittest
,bin/dev npm test
,bin/integration-test
) - Write code until the test passes
-
bin/dev reformat-code
to conform to our coding style -
bin/integration-test
to ensure you haven't broken something critical - Commit with a commit message referencing the GitHub issue
- Make sure your
- Submit a pull request:
git push origin my-great-feature
- Browse to https://github.com/CJWorkbench/cjworkbench and submit a pull request for your branch
- Iterate! We'll review your code; we may ask questions or propose changes. We may ask you to add commits to your pull request; we may also ask you to merge or rebase from our master.
Workbench's Python code follows Black conventions. Workbench won't build images (and so bin/dev integration-test
will fail) if your code isn't byte-perfect. Integrate Black with your text editor to avoid silly mistakes: for instance, you can configure your editor to run black
on a file automatically when saving.
Workbench's JavaScript code follows StandardJS conventions. Workbench won't build images (and so bin/dev integration-test
will fail) if your code isn't byte-perfect. Integrate StandardJS with your text editor to avoid silly mistakes: for instance, you can configure your editor to run standard --fix
on a file automatically while saving.
These plugins and configuration will make Neovim offer autocomplete suggestions, check code against a language server (warning on unused imports, typos, etc), and auto-reformat files on save.
Since dependencies are installed into Docker containers, the configuration depends on Docker containers, too. Docker images will be built on first use: their Dockerfiles are in the docker/
subdirectory of this repository.
Here's some copy/pasteable code for your ~/.config/nvim/init.vim
. It depends on vim-plug.
call plug#begin('~/.local/share/nvim/plugged')
Plug 'w0rp/ale'
Plug 'Shougo/deoplete.nvim'
call plug#end()
" Assume cjworkbench is cloned at ~/src/cjworkbench/cjworkbench/
" (and modules are in ~/src/cjworkbench/modulename/, etc.)
let s:cjworkbench_dir = $HOME.'/src/cjworkbench'
if getcwd() =~ s:cjworkbench_dir.'/'
au FileType python,javascript nnoremap K :ALEHover<CR>
au FileType python,javascript nnoremap <C-g>d :ALEGoToDefinition<CR>
au FileType python,javascript nnoremap <C-g>r :ALEFindReferences<CR>
let g:deoplete#enable_at_startup = 1
let g:deoplete#min_pattern_length = 0
let g:ale_set_quickfix = 1
let g:deoplete#sources = {'_': ['ale']}
" Global executables won't work: we want to run within Docker containers.
let g:ale_use_global_executables = 0
let g:ale_javascript_tsserver_executable = s:cjworkbench_dir.'/cjworkbench/docker/tsserver/run.sh'
let g:ale_python_pyls_executable = s:cjworkbench_dir.'/cjworkbench/docker/lsp/python/run.sh'
let g:ale_python_black_executable = s:cjworkbench_dir.'/cjworkbench/docker/lsp/python/black.sh'
let g:ale_linters_explicit = 1
let g:ale_linters = {
\ 'javascript': ['tsserver'],
\ 'python': ['pyls'],
\}
let g:ale_fix_on_save = 1
" ale's 'standard' plugin relies on tmpfiles that don't get passed to
" Docker. Build our own 'standard' command.
let g:ale_fixers = {
\ 'javascript': [{buffer -> {'command': s:cjworkbench_dir.'/cjworkbench/docker/tsserver/standard.sh'}}],
\ 'python': ['black'],
\}
endif
In nvim, run :PlugInstall
to install the plugins. Then whenever you start nvim
from within ~/src/cjworkbench/
, the CJWorkbench rules will apply. On your first load of a Python file and your first load of a JavaScript file, docker build
will run; that will take a few minutes and download a few hundred MB.