Name | Date | Size | #Lines | LOC | ||
---|---|---|---|---|---|---|
.. | - | - | ||||
autoload/ | 12-May-2024 | - | 27 | 23 | ||
ftdetect/ | 12-May-2024 | - | 28 | 23 | ||
ftplugin/ | 12-May-2024 | - | 13 | 9 | ||
syntax/ | 12-May-2024 | - | 88 | 75 | ||
README.md | D | 12-May-2024 | 1.7 KiB | 66 | 46 | |
gn-format.py | D | 12-May-2024 | 2.2 KiB | 63 | 34 |
README.md
1# GN vim syntax plugin 2 3## Installation with a plugin manager 4 5You can use modern plugin managers to download the GN repo and manage the vim 6plugin: 7 8Example config for [vim-plug](https://github.com/junegunn/vim-plug): 9 10``` 11Plug 'https://gn.googlesource.com/gn', { 'rtp': 'misc/vim' } 12``` 13 14Or, for [Vundle](https://github.com/VundleVim/Vundle.vim) users: 15 16``` 17Plugin 'https://gn.googlesource.com/gn', { 'rtp': 'misc/vim' } 18``` 19 20## Manual installation 21 22If you don't use a plugin manager or would prefer to manage the GN repo 23yourself, you can add this explicitly to `rtp` in your `.vimrc`: 24 25``` 26set runtimepath+=/path/to/gn/misc/vim 27" ... 28filetype plugin indent on " or a similar command to turn on filetypes in vim 29``` 30 31## Formatting GN files 32 33### vim-codefmt (recommended) 34 35[vim-codefmt](https://github.com/google/vim-codefmt) supports the GN filetype 36natively. Add the following to your `.vimrc`: 37 38```vim 39" Install vim-codefmt and its dependencies 40Plug 'google/vim-maktaba' 41Plug 'google/vim-codefmt' 42 43" Install this plugin: 44Plug 'https://gn.googlesource.com/gn', { 'rtp': 'misc/vim' } 45 46" Optional: configure vim-codefmt to autoformat upon saving the buffer. 47augroup CodeFmt 48 autocmd! 49 autocmd FileType gn AutoFormatBuffer gn 50 " Other file types... 51augroup END 52``` 53 54This will autoformat your files every time you save. If you prefer not to format 55files upon saving, vim-codefmt can format the buffer by calling `:FormatCode`. 56 57### Included format integration 58 59If you cannot include vim-codefmt, you can use the limited `gn format` 60integration included in this plugin. Add the following to your `.vimrc`: 61 62```vim 63" Replace <F1> with whichever hotkey you prefer: 64nnoremap <silent> <F1> :pyxf <path-to-this-plugin>/gn-format.py<CR> 65``` 66