This is an add-on for vim providing support for editing NWScript.
- syntax highlighting
- auto-indention
- auto-wrapping of comments
- code snippets for UltiSnips
- shortcut for generating ctags files
- Vim/Neovim
- Universal Ctags for ctags support
If you use vim-plug, add the following
to your .vimrc
:
Plug 'squattingmonk/vim-nwscript'
Then run :PlugInstall
.
This plugin has sensible (read: opinionated) defaults. If you don't like one of
the behaviors below, you can change it in your .vimrc
using one of the
settings below (default values are shown).
This plugin is divided into several modules and will be expanded over time. By
default, all modules are enabled, but you can enable or disable them
selectively in your .vimrc
:
" Whitelist modules
let g:nwscript#modules#enabled = ['ctags', 'fold', 'format']
" Blacklist modules
let g:nwscript#modules#disabled = []
By default, comments will auto-wrap at column 80, preserving any indentation.
Pressing <cr>
(insert mode) or o
/O
(normal mode) will continue a comment
block.
let g:nwscript#format#textwidth = 80
let g:nwscript#format#options = 'croqwa2lj'
All trailing whitespace is removed when saving the file.
let g:nwscript#format#whitespace = 1
Code between brackets is automatically folded.
let g:nwscript#fold#method = 'syntax'
let g:nwscript#fold#level = &foldlevel
let g:nwscript#fold#column = 1
This plugin comes with an options file to generate tags for NWScript files. If
you wish to use your own options file, you can set the path to it in your
.vimrc
:
let g:nwscript#ctags#file = '/your/path/to/nwscript.ctags'
To generate a tags file, you can run :NWScriptTagGen
or press
<localleader>tt
while in normal mode. Alternatively, you can set your own
mapping:
nmap <localleader>tt <Plug>NWScriptTagGen
The tags file will be placed into your project's git root, nasher root, or the directory of the current file if no git or nasher project was detected. The generation is recursive, so any nwscript file in the project will be searched for tags.
You can also add extra directories outside of your project that will be tagged:
let g:nwscript#ctags#includes = ['~/.local/share/nwscript']
To generate a tag file for the current project and all included directories,
you can run :NWScriptTagGenAll
or press <localleader>TT
while in normal
mode. Alternatively, you can set your own mapping:
nmap <localleader>TT <Plug>NWScriptTagGenAll