├── ftdetect └── jjdescription.vim ├── images └── screenshot.webp ├── .gitreview ├── .github └── pull_request_template.md ├── ftplugin └── jjdescription.vim ├── README.md ├── syntax └── jjdescription.vim └── LICENSE /ftdetect/jjdescription.vim: -------------------------------------------------------------------------------- 1 | au BufRead,BufNewFile *.jjdescription set filetype=jjdescription 2 | -------------------------------------------------------------------------------- /images/screenshot.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/avm99963/vim-jjdescription/HEAD/images/screenshot.webp -------------------------------------------------------------------------------- /.gitreview: -------------------------------------------------------------------------------- 1 | [gerrit] 2 | host=gerrit.avm99963.com 3 | port=29418 4 | project=vim/jjdescription 5 | defaultbranch=main 6 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 16 | -------------------------------------------------------------------------------- /ftplugin/jjdescription.vim: -------------------------------------------------------------------------------- 1 | " jjdescription filetype plugin 2 | " Language: jjdescription file 3 | " Maintainer: Adrià Vilanova 4 | " Source: Based on ftplugin/gitcommit.vim 5 | " Last Change: 2025 May 08 6 | 7 | " Only do this when not done yet for this buffer 8 | if (exists("b:did_ftplugin")) 9 | finish 10 | endif 11 | 12 | let b:did_ftplugin = 1 13 | 14 | setlocal nomodeline tabstop=8 formatoptions+=tl textwidth=72 15 | setlocal formatoptions-=c formatoptions-=r formatoptions-=o formatoptions-=q formatoptions+=n 16 | setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}]\\s\\+\\\|^\\s*[-*+]\\s\\+ 17 | 18 | let b:undo_ftplugin = 'setl modeline< tabstop< formatoptions< tw< com< cms< formatlistpat<' 19 | 20 | let &l:comments = ':JJ:' 21 | let &l:commentstring = 'JJ:%s' 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # .jjdescription files plugin for Vim 2 | This plugin adds syntax highlighting and some sensible options for 3 | .jjdescription files. These are temporary files created by [JJ][1] and opened 4 | in your configured editor when you run `jj describe`, so you can write a 5 | description for your change. 6 | 7 | ![Screenshot showing the syntax highlighting](./images/screenshot.webp) 8 | 9 | ## Installation 10 | Use your favorite plugin manager to install the `avm99963/vim-jjdescription` 11 | plugin. For instance, with [vim-plug][2] you should add the following to the 12 | appropriate section in your `.vimrc`: 13 | 14 | ``` vimscript 15 | Plug 'avm99963/vim-jjdescription' 16 | ``` 17 | 18 | ## Credits 19 | This plugin is based on the native syntax highlighting and ftplugin for 20 | gitcommit, which is the format of the analogous temporary files used by Git. 21 | This is the reason why this plugin is licensed with the Vim license. 22 | 23 | [1]: https://github.com/martinvonz/jj 24 | [2]: https://github.com/junegunn/vim-plug 25 | -------------------------------------------------------------------------------- /syntax/jjdescription.vim: -------------------------------------------------------------------------------- 1 | " jjdescription syntax file 2 | " Language: jjdescription file 3 | " Maintainer: Adrià Vilanova 4 | " Filenames: *.jjdescription 5 | " Source: Based on syntax/gitcommit.vim 6 | " Last Change: 2025 May 08 7 | 8 | if exists("b:current_syntax") 9 | finish 10 | endif 11 | 12 | scriptencoding utf-8 13 | 14 | syn include @Diff syntax/diff.vim 15 | 16 | syn case match 17 | syn sync minlines=50 18 | syn sync linebreaks=1 19 | 20 | if has("spell") 21 | syn spell toplevel 22 | endif 23 | 24 | if get(g:, 'jjdescription_summary_length') < 0 25 | syn match jjdescriptionSummary "^.*$" contained containedin=jjdescriptionFirstLine nextgroup=jjdescriptionOverflow contains=@Spell 26 | elseif get(g:, 'jjdescription_summary_length', 1) > 0 27 | exe 'syn match jjdescriptionSummary "^.*\%<' . (get(g:, 'jjdescription_summary_length', 50) + 1) . 'v." contained containedin=jjdescriptionFirstLine nextgroup=jjdescriptionOverflow contains=@Spell' 28 | endif 29 | syn match jjdescriptionOverflow ".*" contained contains=@Spell 30 | syn match jjdescriptionBlank "^.\+" contained contains=@Spell 31 | syn match jjdescriptionFirstLine "\%^.*" nextgroup=jjdescriptionBlank,jjdescriptionComment skipnl 32 | 33 | " The diff syntax is used when configuring JJ to output |diff.git()| 34 | " in a description template, as suggested by the documentation:[1] 35 | " 36 | " [templates] 37 | " draft_commit_description = ''' 38 | " concat( 39 | " coalesce(description, default_commit_description, "\n"), 40 | " surround( 41 | " "\nJJ: This commit contains the following changes:\n", "", 42 | " indent("JJ: ", diff.stat(72)), 43 | " ), 44 | " "\nJJ: ignore-rest\n", 45 | " diff.git(), 46 | " ) 47 | " ''' 48 | " 49 | " [1]: https://github.com/jj-vcs/jj/blob/v0.29.0/docs/config.md#default-description 50 | syn region jjdescriptionDiff start=/\%(^diff --\%(git\|cc\|combined\) \)\@=/ end=/^\%(diff --\|$\|@@\@!\|[^[:alnum:]\ +-]\S\@!\)\@=/ fold contains=@Diff 51 | 52 | syn match jjdescriptionComment "^JJ:.*" 53 | syn region jjdescriptionRest start=/^JJ: ignore-rest$/ end=/\%$/ contains=jjdescriptionComment,jjdescriptionDiff 54 | 55 | " Headers are comments which end with a colon, followed by a non-empty line. 56 | syn match jjdescriptionHeader "\%(^JJ:\s*\)\@<=\S.*:\%(\n^$\)\@!$" contained containedin=jjdescriptionComment 57 | 58 | " Sigils extracted from https://github.com/martinvonz/jj/blob/95283dd04f7047c48356de1addd3d59d35ec5bce/cli/src/diff_util.rs#L1542. 59 | syn match jjdescriptionType "\%(^JJ:\s*\)\@<=[CRMAD]\ze " contained containedin=jjdescriptionComment nextgroup=jjdescriptionFile skipwhite 60 | syn match jjdescriptionFile ".*" contained 61 | 62 | syn region jjdescriptionSelected start=/^\z(^JJ:\s*\)This commit contains the following changes:$/ end=/^\z1$\|^\z1\@!/ contains=jjdescriptionHeader,jjdescriptionSelectedType containedin=jjdescriptionComment contained transparent fold 63 | 64 | syn match jjdescriptionSelectedType "\%(^JJ:\s*\)\@<=[CRMAD]\ze " contained nextgroup=jjdescriptionSelectedFile skipwhite 65 | syn match jjdescriptionSelectedFile ".*" contained 66 | 67 | hi def link jjdescriptionSummary Keyword 68 | hi def link jjdescriptionComment Comment 69 | hi def link jjdescriptionSelectedType jjdescriptionType 70 | hi def link jjdescriptionType Type 71 | hi def link jjdescriptionHeader PreProc 72 | hi def link jjdescriptionSelectedFile jjdescriptionFile 73 | hi def link jjdescriptionFile Constant 74 | hi def link jjdescriptionBlank Error 75 | 76 | let b:current_syntax = "jjdescription" 77 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | VIM LICENSE 2 | 3 | I) There are no restrictions on distributing unmodified copies of Vim except 4 | that they must include this license text. You can also distribute 5 | unmodified parts of Vim, likewise unrestricted except that they must 6 | include this license text. You are also allowed to include executables 7 | that you made from the unmodified Vim sources, plus your own usage 8 | examples and Vim scripts. 9 | 10 | II) It is allowed to distribute a modified (or extended) version of Vim, 11 | including executables and/or source code, when the following four 12 | conditions are met: 13 | 1) This license text must be included unmodified. 14 | 2) The modified Vim must be distributed in one of the following five ways: 15 | a) If you make changes to Vim yourself, you must clearly describe in 16 | the distribution how to contact you. When the maintainer asks you 17 | (in any way) for a copy of the modified Vim you distributed, you 18 | must make your changes, including source code, available to the 19 | maintainer without fee. The maintainer reserves the right to 20 | include your changes in the official version of Vim. What the 21 | maintainer will do with your changes and under what license they 22 | will be distributed is negotiable. If there has been no negotiation 23 | then this license, or a later version, also applies to your changes. 24 | The current maintainers are listed here: https://github.com/orgs/vim/people. 25 | If this changes it will be announced in appropriate places (most likely 26 | vim.sf.net, www.vim.org and/or comp.editors). When it is completely 27 | impossible to contact the maintainer, the obligation to send him 28 | your changes ceases. Once the maintainer has confirmed that he has 29 | received your changes they will not have to be sent again. 30 | b) If you have received a modified Vim that was distributed as 31 | mentioned under a) you are allowed to further distribute it 32 | unmodified, as mentioned at I). If you make additional changes the 33 | text under a) applies to those changes. 34 | c) Provide all the changes, including source code, with every copy of 35 | the modified Vim you distribute. This may be done in the form of a 36 | context diff. You can choose what license to use for new code you 37 | add. The changes and their license must not restrict others from 38 | making their own changes to the official version of Vim. 39 | d) When you have a modified Vim which includes changes as mentioned 40 | under c), you can distribute it without the source code for the 41 | changes if the following three conditions are met: 42 | - The license that applies to the changes permits you to distribute 43 | the changes to the Vim maintainer without fee or restriction, and 44 | permits the Vim maintainer to include the changes in the official 45 | version of Vim without fee or restriction. 46 | - You keep the changes for at least three years after last 47 | distributing the corresponding modified Vim. When the maintainer 48 | or someone who you distributed the modified Vim to asks you (in 49 | any way) for the changes within this period, you must make them 50 | available to him. 51 | - You clearly describe in the distribution how to contact you. This 52 | contact information must remain valid for at least three years 53 | after last distributing the corresponding modified Vim, or as long 54 | as possible. 55 | e) When the GNU General Public License (GPL) applies to the changes, 56 | you can distribute the modified Vim under the GNU GPL version 2 or 57 | any later version. 58 | 3) A message must be added, at least in the output of the ":version" 59 | command and in the intro screen, such that the user of the modified Vim 60 | is able to see that it was modified. When distributing as mentioned 61 | under 2)e) adding the message is only required for as far as this does 62 | not conflict with the license used for the changes. 63 | 4) The contact information as required under 2)a) and 2)d) must not be 64 | removed or changed, except that the person himself can make 65 | corrections. 66 | 67 | III) If you distribute a modified version of Vim, you are encouraged to use 68 | the Vim license for your changes and make them available to the 69 | maintainer, including the source code. The preferred way to do this is 70 | by e-mail or by uploading the files to a server and e-mailing the URL. 71 | If the number of changes is small (e.g., a modified Makefile) e-mailing a 72 | context diff will do. The e-mail address to be used is 73 | 74 | 75 | IV) It is not allowed to remove this license from the distribution of the Vim 76 | sources, parts of it or from a modified version. You may use this 77 | license for previous Vim releases instead of the license that they came 78 | with, at your option. 79 | --------------------------------------------------------------------------------