Compare commits

...

137 commits

Author SHA1 Message Date
d603c6166b
Match nim type on single chars as well 2022-12-21 07:34:25 -07:00
Joey Yakimowich-Payne
59ef315245 Add nimRawString 2021-09-22 15:03:14 -06:00
Joey Yakimowich-Payne
8ec157091d Fix triple strings in pragmas 2021-09-22 14:58:59 -06:00
Joey Yakimowich-Payne
90a5ca3b1d Add double hash comment 2021-07-15 15:57:14 -06:00
Joey Yakimowich-Payne
f4e8d827ad Add more conditionals 2021-07-15 11:00:12 -06:00
Joey Yakimowich-Payne
42ed5af80d Move when to conditional 2021-06-20 14:39:24 -06:00
Joey Yakimowich-Payne
d7bf641592 Add more keywords 2021-06-20 14:37:40 -06:00
Joey Yakimowich-Payne
e32dbc3022 Fix pragma order 2021-06-20 14:34:30 -06:00
Joey Yakimowich-Payne
65a8caac8f Add type, pragma, additional keywords 2021-06-20 14:28:11 -06:00
Yasuhiro Matsumoto
7a8737a453 vint: Use single quotes 2020-10-16 16:43:59 +03:00
Yasuhiro Matsumoto
74ed699e82 vint: Use v:version 2020-10-16 16:43:59 +03:00
Yasuhiro Matsumoto
711af55cb5 vint: Use get(l:, 'py_res', '') 2020-10-16 16:43:59 +03:00
Yasuhiro Matsumoto
dc109e5a20 vint: Use ==# 2020-10-16 16:43:59 +03:00
Yasuhiro Matsumoto
e88782bda7 vint: setloclist() is not a command or function 2020-10-16 16:43:59 +03:00
Yasuhiro Matsumoto
cdccc96c56 vint: Use abort attributes 2020-10-16 16:43:59 +03:00
Yasuhiro Matsumoto
7cead42bb1 vint: Use =~# 2020-10-16 16:43:59 +03:00
Yasuhiro Matsumoto
5cff46c7d5 vint: Use v:version 2020-10-16 16:43:59 +03:00
Yasuhiro Matsumoto
d37b228985 vint: Use single quotes. 2020-10-16 16:43:59 +03:00
Yasuhiro Matsumoto
413244f3c3 Use pyx or pyxfile 2020-10-16 16:43:59 +03:00
silvetie
88f5e708a7 Added the "let" keyword 2019-04-26 20:39:40 +03:00
erw7
21731384b8 Remove quickrun settings 2018-12-16 22:37:16 +02:00
Zahary Karadjov
f16af986a8 Regain compatibility with the latest syntastic release 2018-12-16 22:34:12 +02:00
nepeckman
358e2e0130 Added func as a function keyword 2018-12-13 11:23:48 +02:00
Yuriy Glukhov
f5473ff98b Fixed json parsing: true/false undefined 2018-12-13 11:23:16 +02:00
Yuriy Glukhov
b0c4c6c731 Enable folding 2018-09-19 19:05:39 +03:00
Yuriy Glukhov
7d1211cc15 nimble file support 2018-08-16 18:14:41 +03:00
Siddhant Goel
089ea2ca19 Replace usage of reserved async keyword 2018-08-09 19:46:03 +03:00
zah
d1c7e21661
Merge pull request #88 from magnostherobot/mtr/nopythonexit
Check for python support before queuing autocmd
2018-08-03 18:17:15 +03:00
Tom Harley
1da465eedf Check for python support before queuing autocmd
Versions of Vim compiled without python support will error when attempting
to run `:py nimTerminateAll()`, a autocommand for the `VimLeavePre` event.
A simple check for python support prevents this.
2018-07-31 16:37:35 +01:00
zah
704dd5d63c
Merge pull request #86 from magnostherobot/mtr/listfullpaths
Include --listfullpaths in makeprg
2018-05-20 21:34:26 +03:00
Tom Harley
dfe55309a4 Include --listfullpaths in makeprg
Before this change, running `:make` on a file with errors when not
in the same directory as the file would open a buffer in the cwd.
This change fixes this: the compiler outputs the full path to the
file, so a buffer is always opened for the correct file.

`--listfullpaths` was used instead of `--listFullPaths` to be
consistent with `autoload/nim.vim`.
2018-05-20 16:57:12 +01:00
zah
bdc19809d2
Merge pull request #84 from erw7/fix-numerical-syntax2
Fix numerical syntax
2018-02-27 18:13:04 +02:00
erw7
e3806c600c Fix numerical syntax
Fix an issue that is not highlighted when floating point suffix is
omitted in cases like 1exp+10.
2018-02-17 17:11:41 +09:00
zah
88b1a88667
Merge pull request #81 from erw7/improve-numrical-syntax
Change regular expression to more readable
2018-02-10 12:42:51 +02:00
zah
124697270e
Merge pull request #82 from erw7/fix-completion
Fix completion
2018-02-10 12:19:04 +02:00
erw7
28c74af3a2 Fix completion
* Fix position where the completion starts.
* Change to remove filename from word.
* Change to filter completions.
2018-02-10 12:24:35 +09:00
erw7
c6c230b6fc Change regular expression to more readable 2018-02-10 12:20:46 +09:00
zah
f1d99dd8bd
Merge pull request #80 from erw7/fix-numerical-syntax
Fix numerical syntax
2018-02-06 15:11:02 +02:00
erw7
43de5bb9a1 Fix numerical syntax 2018-02-03 18:34:25 +09:00
Zahary Karadjov
8167c50bd4 Add vtref and vtptr as keyworkds 2017-11-29 17:35:56 +02:00
zah
ae63bd2121
Merge pull request #72 from timakro/master
No error when missing python, main features work
2017-10-31 16:21:27 +02:00
Tim Schumacher
46b74a4c75
No error when missing python, main features work 2017-10-30 20:11:33 +01:00
zah
cf2464f819 Merge pull request #68 from unclechu/patch-3
added `echo` keyword
2017-10-08 22:43:04 +03:00
zah
921b6996cc Merge pull request #70 from unclechu/patch-5
added keywords `chr` and `varargs`
2017-10-07 21:02:19 +03:00
zah
08815fe8e1 Merge branch 'master' into patch-3 2017-10-07 21:01:50 +03:00
zah
c297467dde Merge pull request #69 from unclechu/patch-4
more lower-case builtin keywords
2017-10-07 21:00:30 +03:00
Viacheslav Lotsmanov
1b094305a9 added keywords chr and varargs
also `openArray` with uppercase
2017-10-07 22:16:49 +05:00
Viacheslav Lotsmanov
df3c0ad89e more lower-case builtin keywords 2017-10-07 22:08:41 +05:00
Viacheslav Lotsmanov
01f1f1e9ee added echo keyword 2017-10-07 21:51:48 +05:00
zah
3569f68bc9 Merge pull request #67 from unclechu/patch-2
added `void` type keyword
2017-10-07 15:53:04 +03:00
zah
3db9fd6077 Merge pull request #66 from unclechu/patch-1
added `writeLine` keyword
2017-10-07 15:52:33 +03:00
Viacheslav Lotsmanov
22acd370fa added void type keyword 2017-10-07 13:16:38 +05:00
Viacheslav Lotsmanov
bb4f890a15 added writeLine keyword
`writeLn` is deprecated now
2017-10-07 03:28:37 +05:00
zah
b531222c20 Merge pull request #65 from nve3pd/master
corresponded to python3
2017-10-02 17:13:45 +03:00
nve3pd
2b841ff6f2 corresponded to python3 2017-09-28 21:30:32 +09:00
zah
1415361e3a Merge pull request #64 from superfunc/master
Fix markdown formatting
2017-07-25 19:18:44 +03:00
superfunc
43c802b360 Fix markdown formatting 2017-07-23 09:05:18 -07:00
Zahary Karadjov
dcf25798f4 merge various improvements from https://github.com/Angluca
* recognize NimScript files
* automatically set up tab width in Nim buffers
* remove the NimLog in the python module, which is just a debugging aid
2016-05-19 19:50:46 +03:00
zah
7adbb71442 Merge pull request #50 from rogercloud/master
add windows support when creating nim-log.txt
2016-05-19 19:40:20 +03:00
Zahary Karadjov
10018be367 remove some obsolete system procs 2016-05-19 19:39:06 +03:00
zah
bb7ee4d969 Merge pull request #46 from Perelandric/writeln_to_writeLine
Highlights new names from recent renamings
2016-05-19 19:36:59 +03:00
zah
d72da053ce Merge pull request #42 from rhysd/highlight-result
Added highlight for special variable 'result'
2016-05-19 19:36:21 +03:00
zah
711facd988 Merge pull request #31 from miyakogi/support_neocomplete
Add default configuration for neocomplete
2016-05-19 19:35:31 +03:00
Zahary Karadjov
55eaae0bb0 add a license 2016-05-19 19:32:27 +03:00
Zahary Karadjov
1f62902041 proper indentation for concept definitions 2016-05-19 19:27:38 +03:00
zah
01b2ac58df Merge pull request #47 from FedericoCeratto/patch-2
Update Nim name and website
2016-05-19 19:24:05 +03:00
zah
d5c75dd6ff Merge pull request #53 from Tyler-Anderson/patch-1
changing nimrod to nim
2016-05-19 19:23:24 +03:00
zah
3f73ac346b Merge pull request #54 from def-/master
Update keywords and add new comment syntax
2016-05-19 19:22:27 +03:00
def
91673015d4 Update keywords and add new comment syntax 2016-01-29 00:09:15 +01:00
Tyler Anderson
5edd68793a changing nimrod to nim
changing nimrod to nim in readme to update the info to the current language name of nim as well as the current nim.vim name.
2015-12-27 23:55:28 -08:00
Roger Shi
89f0a10aa3 add windows support when creating nim-log.txt 2015-08-24 15:50:07 +08:00
Federico Ceratto
2edab5cbc4 Update Nim name and website 2015-07-04 22:11:46 +01:00
patrick dw
36fbc8a251 Highlights new names from recent renamings 2015-06-20 12:12:14 -05:00
rhysd
db7f06b431 Add highlight for special variable 'result' 2015-05-23 17:52:11 +09:00
Zahary Karadjov
597cca20eb Force the Nim compiler to output full paths
This fixes calling "nim check" from a directory
outside of the project tree
2015-05-10 21:01:09 +03:00
miyakogi
45b0bf9c1b Add default configuration for neocomplete 2015-01-24 16:42:25 +09:00
zah
cb6d4e34eb Merge pull request #27 from Normangorman/range_highlighting_fix
modify number matching regex to fix #26
2015-01-03 14:40:57 +02:00
Benjamin Gorman
14a9a9d3d8 modify number matching regex to fix issue #26 2015-01-02 03:19:50 +00:00
Zahary Karadjov
05fdf7eac6 some final Nimrod to Nim renames 2014-09-04 22:53:02 +03:00
Zahary Karadjov
6b9264fb84 Merge branch 'master' of github.com:zah/nimrod.vim 2014-09-04 22:47:57 +03:00
Zahary Karadjov
8d2db427b4 more renames 2014-09-04 22:47:42 +03:00
Zahary Karadjov
eecfe9b81f Rename Nimrod to Nim 2014-09-04 22:44:36 +03:00
zah
c1e0659fff Merge pull request #24 from gradha/pr_adds_missing_exceptions
Adds missing exceptions for highlighting.
2014-08-06 12:27:26 +03:00
Grzegorz Adam Hankiewicz
b71a49f219 Adds missing exceptions for highlighting. 2014-08-05 18:32:23 +02:00
zah
aa586b5397 Merge pull request #18 from gradha/pr_silences_babel_paths_during_checks
Disables hints for check command.
2014-03-08 13:41:26 +02:00
Zahary Karadjov
e27dd52829 move expandtab to the ftplugin for more consistency 2014-03-06 11:35:47 +02:00
zah
a66891c72e Merge pull request #21 from flaviut/master
Make tabs automaticly turn into spaces
2014-03-06 11:31:22 +02:00
zah
27609d4d10 Merge pull request #20 from flaviut/master
Reccomend Synastic
2014-03-06 11:29:20 +02:00
flaviut
02b735ae7c Make tabs automaticly turn into spaces 2014-03-05 17:56:54 -05:00
flaviut
b952e2bc23 Reccomend Synastic 2014-03-05 17:51:38 -05:00
zah
65a29ec92b Merge pull request #19 from flaviut/master
Add Vundle information to readme
2014-03-04 01:23:05 +02:00
flaviut
ab0b173d0b Make readme more consistant
Added text under instructions, added link to final step
2014-03-03 17:12:57 -05:00
flaviut
bdcff60d77 Added Vundle installation instructions
Also changed section headings to `#`s in order to make deeper nesting possible
2014-03-03 17:09:25 -05:00
Grzegorz Adam Hankiewicz
6de870a10a Disables hints for check command.
Paths for babel packages being reported by the compiler are considered
errors and interfere with syntastic's :lnext and :lprevious support.
2013-12-10 11:09:14 +01:00
Zahary Karadjov
f6bd6cfd25 basic QuickRun support; implements #6 2013-12-10 01:36:15 +02:00
Zahary Karadjov
d2f05bc1a6 fixes #17 2013-12-09 23:45:56 +02:00
Zahary Karadjov
f947b48cda more auto-indenting improvements 2013-08-25 14:47:26 +03:00
Zahary Karadjov
bebdd7bb99 various auto-indenting improvements; fixes #10 2013-08-25 00:44:19 +03:00
Zahary Karadjov
3d9f5fac08 re-integrate with the latest version of syntastic 2013-08-24 17:31:17 +03:00
zah
1b3ba4a4b9 Merge pull request #16 from DAddYE/patch-2
Added all ctypes
2013-07-30 09:01:34 -07:00
Davide D'Agostino
53bf9e840d Added all ctypes 2013-07-30 01:47:45 -07:00
zah
0ce7957473 Merge pull request #12 from gradha/pr_updates_keyword_list
Updates keyword list using nimrod's doc/keywords.txt.
2013-07-15 03:03:28 -07:00
Grzegorz Adam Hankiewicz
1d7ceef137 Updates keyword list using nimrod's doc/keywords.txt. 2013-07-14 22:22:00 +02:00
Zahary Karadjov
fa9bd5972b caas works satisfactory now with the latest version of nimrod
modified buffers are handled properly now
nimrod threads are terminated at program exit
added commands for service shutdown/restart
2013-05-05 19:39:04 +03:00
Zahary Karadjov
0b09eeede5 remove some hard-coded paths 2013-05-01 22:26:48 +03:00
Zahary Karadjov
ffc49b7c2a the caas service is fully integrated now.
this commit enables it by default if your project has a nimrod.cfg config, but
the results won't be satisfactory as the compiler still cannot survive the long-
running interaction with the IDE and breaks after a couple of commands.
2013-05-01 21:24:10 +03:00
Zahary Karadjov
43696ec2e3 work-in-progress towards integrating the compiler service 2013-04-29 09:50:12 +03:00
zah
84d07e0209 Merge pull request #8 from gradha/disable_silence_invoking_idetools
Disables silence when invoking idetools. Refs #4.
2013-04-11 00:34:24 -07:00
Grzegorz Adam Hankiewicz
63d5050ca0 Disables silence when invoking idetools. Refs #4.
After some time editing with the "silent!" bit removed everything seems
to work fine, so maybe the silencing was done when there was no error
log.
2013-04-10 22:42:41 +02:00
Zahary Karadjov
4c3f2313b0 add nimrod library paths to vim's path variable 2013-04-10 14:43:18 +03:00
Zahary Karadjov
ca3142c5e2 implements #7 2013-04-10 13:50:06 +03:00
zah
a5c3f6902e Merge pull request #5 from gradha/pr_documents_nimlog_buffer
Adds note about log://nimrod to debug idetool interactions.
2013-03-25 01:37:36 -07:00
Grzegorz Adam Hankiewicz
ba7b7d6d02 Adds note about log://nimrod to debug idetool interactions. 2013-03-24 23:44:40 +01:00
zah
444b90f879 Merge pull request #3 from gradha/pr_fix_column_position_for_idetools
Fixes the column position when invoking idetools.
2013-02-03 22:30:41 -08:00
Grzegorz Adam Hankiewicz
aa10e421b2 Fixes the column position when invoking idetools.
Vim starts counting columns from 1 but the nimrod idetools command
starts from zero. This can be verified writing a call to the quit() proc
with a two level identation and trying to invoke idetools on the
whitespace before the word.
2013-02-03 17:49:05 +01:00
zah
dbe7e8fdb8 Merge pull request #2 from gradha/pr_expands_builtin_exceptions
Adds more exceptions as keywords.
2013-02-01 07:12:41 -08:00
Grzegorz Adam Hankiewicz
00ee58f98b Adds more exceptions as keywords. 2013-02-01 13:33:31 +01:00
Zahary Karadjov
15a6f3e4ac disabled autosuggest as it really too slow for now. fix for nimdoc comments auto-formatting 2012-11-20 00:27:01 +02:00
zah
53f24a6015 Merge pull request #1 from gradha/pr_replace_readme
Adds basic readme based on syntastic's one.
2012-11-10 13:51:22 -08:00
Grzegorz Adam Hankiewicz
184f5fdb61 Adds basic readme based on syntastic's one. 2012-11-10 22:24:18 +01:00
Zahary Karadjov
732e821bcd use unix file endings 2012-11-10 22:24:40 +02:00
Zahary Karadjov
ecc3d1f633 fixed the "cannot reload GotoDefinition while executing" error
errors are redirected to a log buffer now instead of echoerr
2012-11-09 18:51:59 +02:00
Zahary Karadjov
95533181c2 omni-completion improvements 2012-11-09 01:09:56 +02:00
Zahary Karadjov
81c2f4aa69 added support for compiler-assisted "go to definition" and omnicompletion 2012-11-08 19:07:21 +02:00
Zahary Karadjov
b26c3696e9 syntax updates for unsigned integers 2012-06-14 14:35:24 +03:00
Zahary Karadjov
f8ac24360f support for int and float literals like 42'i32 2011-12-15 15:17:58 +02:00
Zahary Karadjov
d5276eed2c syntax checking for included files 2011-12-15 15:16:46 +02:00
Zahary Karadjov
cf6bd5bc64 Better errorformat parsing and support for syntastic (https://github.com/scrooloose/syntastic) 2011-11-10 23:18:48 +02:00
Zahary Karadjov
d70493af95 macros and templates are higlighted as procs 2011-11-04 17:39:01 +02:00
Zahary Karadjov
0224eb03d2 added automatic discovery of nimrod library paths and any tags files residing there 2011-08-28 17:41:18 +03:00
Zahary Karadjov
03615f8caa nimrod compiler is now set automatically 2011-08-28 01:54:33 +03:00
Zahary Karadjov
bc5515054e any tab in nimrod code is displayed as error 2011-08-27 23:31:26 +03:00
Zahary Karadjov
d92a73496f more up-to-date list of nimrod keywords and proper handling of multi-line strings 2011-08-27 19:44:08 +03:00
Zahary Karadjov
44750377f7 few fixes for the commenting and line wrapping behaviour 2011-08-26 15:48:16 +03:00
Zahary Karadjov
32b82b89cf generalised the indent rule for procs to handle templates, macros 2011-08-26 15:31:13 +03:00
Zahary Karadjov
a53642d1e8 added indenting rules, compiler settings and filetype detection 2011-08-26 13:50:09 +03:00
Kearn Holliday
932641228a Version 1.1@2: hopefully this one actually works now, removed pesky ^M chars -
12 changed files with 911 additions and 192 deletions

22
LICENSE Normal file
View file

@ -0,0 +1,22 @@
The MIT License (MIT)
Copyright (c) 2012-2016, Zahary Karadjov and Contributors.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

6
README
View file

@ -1,6 +0,0 @@
This is a mirror of http://www.vim.org/scripts/script.php?script_id=2632
Syntax file for Nimrod.
This file is basically a modified python.vim (http://www.vim.org/scripts/script.php?script_id=790) ... you might recognize it.
I have no idea if it works because I haven't actually tried to code in Nimrod and have next to nothing to test it with :P

121
README.markdown Normal file
View file

@ -0,0 +1,121 @@
# Nim language support for Vim
This provides [Nim](http://nim-lang.org) language support for Vim:
* Syntax highlighting
* Auto-indent
* Build/jump to errors within Vim
* Project navigation and Jump to Definition (cgats or compiler-assisted
idetools).
The source of this script comes mainly from
http://www.vim.org/scripts/script.php?script_id=2632, which comes from a
modified python.vim (http://www.vim.org/scripts/script.php?script_id=790).
# Installation
Installing `nim.vim` is easy but first you need to have either pathogen plugin or vundle
installed. If you already have one working then skip to the [final step](README.markdown#final-step).
It is also recommened that you use the [syntastic](https://github.com/scrooloose/syntastic) plugin for best results.
## Pathogen
### Step 1: Install pathogen.vim
First I'll show you how to install tpope's
[pathogen.vim](https://github.com/tpope/vim-pathogen) so that it's easy to
install `nimrod.vim`. Do this in your Terminal so that you get the
`pathogen.vim` file and the directories it needs:
mkdir -p ~/.vim/autoload ~/.vim/bundle; \
curl -so ~/.vim/autoload/pathogen.vim \
https://raw.github.com/tpope/vim-pathogen/master/autoload/pathogen.vim
Next you *need to add this* to your `~/.vimrc`:
call pathogen#infect()
### Step 2: Install nimrod.vim as a pathogen bundle
You now have pathogen installed and can put `nimrod.vim` into `~/.vim/bundle`
like this:
cd ~/.vim/bundle
git clone git://github.com/zah/nim.vim.git
You may also want to install synastic by calling
git clone https://github.com/scrooloose/syntastic.git
## Vundle
Vundle is a more automatic way to install vim plugins that works by cloning
the git reposotory.
### Step 1: Install Vundle
Add the vundle script to your vim:
git clone https://github.com/gmarik/vundle.git ~/.vim/bundle/vundle
Modify your ~/.vimrc to get vundle running, lightly adapted from [Vundle's readme](https://github.com/gmarik/Vundle.vim/blob/master/README.md)
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/vundle/
call vundle#rc()
" alternatively, pass a path where Vundle should install bundles
"let path = '~/some/path/here'
"call vundle#rc(path)
" let Vundle manage Vundle, required
Bundle 'gmarik/vundle'
filetype plugin indent on " required
### Step 2: Install nim.vim
On the line after `Bundle 'gmarik/vundle'`, add `Bundle 'zah/nim.vim'`. You may also want
to add `Bundle 'scrooloose/syntastic'`. Save `~/.vimrc` and restart vim. Execute `:BundleInstall`
and wait for nim.vim to be installed.
## Final Step
Next you *need to add this* to your `~/.vimrc`:
fun! JumpToDef()
if exists("*GotoDefinition_" . &filetype)
call GotoDefinition_{&filetype}()
else
exe "norm! \<C-]>"
endif
endf
" Jump to tag
nn <M-g> :call JumpToDef()<cr>
ino <M-g> <esc>:call JumpToDef()<cr>i
The `JumpToDef` function hooks the `nim.vim` plugin to invoke the nim
compiler with the appropriate idetools command. Pressing meta+g will then jump
to the definition of the word your cursor is on. This uses the nim compiler
instead of ctags, so it works on any nimrod file which is compilable without
requiring you to maintain a database file.
# Other recomended Vim plugins
* https://github.com/scrooloose/syntastic (copied bits from its readme)
* https://github.com/Shougo/neocomplcache
# If something goes wrong
Since you are using vim, on source code which might have syntax problems,
invoking an external tool which may have its own share of bugs, sometimes stuff
just doesn't work as expected. In these situations if you want to debug the
issue you can type ``:e log://nim`` and a buffer will open with the log of
the plugin's invocations and nim's idetool answers.
This can give you a hint of where the problem is and allow you to easily
reproduce on the commandline the idetool parameters the vim plugin is
generating so you can prepare a test case for either this plugin or the nimrod
compiler.

237
autoload/nim.vim Normal file
View file

@ -0,0 +1,237 @@
let g:nim_log = []
let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
if !exists('g:nim_caas_enabled')
let g:nim_caas_enabled = 0
endif
if !executable('nim')
echoerr "the Nim compiler must be in your system's PATH"
endif
if has('pythonx')
exe 'pyxfile ' . fnameescape(s:plugin_path) . '/nim_vim.py'
endif
fun! nim#init() abort
let cmd = printf('nim --dump.format:json --verbosity:0 dump %s', s:CurrentNimFile())
let raw_dumpdata = system(cmd)
if !v:shell_error && expand('%:e') ==# 'nim'
let false = 0 " Needed for eval of json
let true = 1 " Needed for eval of json
let dumpdata = eval(trim(substitute(raw_dumpdata, "\n", '', 'g'), ""))
let b:nim_project_root = dumpdata['project_path']
let b:nim_defined_symbols = dumpdata['defined_symbols']
let b:nim_caas_enabled = g:nim_caas_enabled || index(dumpdata['defined_symbols'], 'forcecaas') != -1
for path in dumpdata['lib_paths']
if finddir(path) ==# path
let &l:path = path . ',' . &l:path
endif
endfor
else
let b:nim_caas_enabled = 0
endif
endf
fun! s:UpdateNimLog() abort
setlocal buftype=nofile
setlocal bufhidden=hide
setlocal noswapfile
for entry in g:nim_log
call append(line('$'), split(entry, "\n"))
endfor
let g:nim_log = []
match Search /^nim\ .*/
endf
augroup NimVim
au!
au BufEnter log://nim call s:UpdateNimLog()
if has('pythonx')
" au QuitPre * :pyx nimTerminateAll()
au VimLeavePre * :pyx nimTerminateAll()
endif
augroup END
command! NimLog :e log://nim
command! NimTerminateService
\ :exe printf("pyx nimTerminateService('%s')", b:nim_project_root)
command! NimRestartService
\ :exe printf("pyx nimRestartService('%s')", b:nim_project_root)
fun! s:CurrentNimFile() abort
let save_cur = getpos('.')
call cursor(0, 0, 0)
let PATTERN = '\v^\#\s*included from \zs.*\ze'
let l = search(PATTERN, 'n')
if l != 0
let f = matchstr(getline(l), PATTERN)
let l:to_check = expand('%:h') . '/' . f
else
let l:to_check = expand('%')
endif
call setpos('.', save_cur)
return l:to_check
endf
let g:nim_symbol_types = {
\ 'skParam': 'v',
\ 'skVar': 'v',
\ 'skLet': 'v',
\ 'skTemp': 'v',
\ 'skForVar': 'v',
\ 'skConst': 'v',
\ 'skResult': 'v',
\ 'skGenericParam': 't',
\ 'skType': 't',
\ 'skField': 'm',
\ 'skProc': 'f',
\ 'skMethod': 'f',
\ 'skIterator': 'f',
\ 'skConverter': 'f',
\ 'skMacro': 'f',
\ 'skTemplate': 'f',
\ 'skEnumField': 'v',
\ }
fun! NimExec(op) abort
let isDirty = getbufvar(bufnr('%'), '&modified')
if isDirty
let tmp = tempname() . bufname('%') . '_dirty.nim'
silent! exe ':w ' . tmp
let cmd = printf('idetools %s --trackDirty:"%s,%s,%d,%d" "%s"',
\ a:op, tmp, expand('%:p'), line('.'), col('.')-1, s:CurrentNimFile())
else
let cmd = printf('idetools %s --track:"%s,%d,%d" "%s"',
\ a:op, expand('%:p'), line('.'), col('.')-1, s:CurrentNimFile())
endif
if b:nim_caas_enabled
exe printf("pyx nimExecCmd('%s', '%s', False)", b:nim_project_root, cmd)
let output = get(l:, 'py_res', '')
else
let output = system('nim ' . cmd)
endif
call add(g:nim_log, 'nim ' . cmd . "\n" . output)
return output
endf
fun! NimExecAsync(op, Handler) abort
let result = NimExec(a:op)
call a:Handler(result)
endf
fun! NimComplete(findstart, base) abort
if b:nim_caas_enabled ==# 0
return -1
endif
if a:findstart
if synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name') ==# 'Comment'
return -1
endif
let line = getline('.')
let start = col('.') - 1
while start > 0 && line[start - 1] =~? '\w'
let start -= 1
endwhile
return start
else
let result = []
let sugOut = NimExec('--suggest')
for line in split(sugOut, '\n')
let lineData = split(line, '\t')
if len(lineData) > 0 && lineData[0] ==# 'sug'
let word = split(lineData[2], '\.')[-1]
if a:base ==? '' || word =~# '^' . a:base
let kind = get(g:nim_symbol_types, lineData[1], '')
let c = { 'word': word, 'kind': kind, 'menu': lineData[3], 'dup': 1 }
call add(result, c)
endif
endif
endfor
return result
endif
endf
if !exists('g:neocomplcache_omni_patterns')
let g:neocomplcache_omni_patterns = {}
endif
let g:neocomplcache_omni_patterns['nim'] = '[^. *\t]\.\w*'
if !exists('g:neocomplete#sources#omni#input_patterns')
let g:neocomplete#sources#omni#input_patterns = {}
endif
let g:neocomplete#sources#omni#input_patterns['nim'] = '[^. *\t]\.\w*'
let g:nim_completion_callbacks = {}
fun! NimAsyncCmdComplete(cmd, output) abort
call add(g:nim_log, a:output)
echom g:nim_completion_callbacks
if has_key(g:nim_completion_callbacks, a:cmd)
let Callback = get(g:nim_completion_callbacks, a:cmd)
call Callback(a:output)
" remove(g:nim_completion_callbacks, a:cmd)
else
echom 'ERROR, Unknown Command: ' . a:cmd
endif
return 1
endf
fun! GotoDefinition_nim_ready(def_output) abort
if v:shell_error
echo 'nim was unable to locate the definition. exit code: ' . v:shell_error
" echoerr a:def_output
return 0
endif
let rawDef = matchstr(a:def_output, 'def\t\([^\n]*\)')
if rawDef == ''
echo 'the current cursor position does not match any definitions'
return 0
endif
let defBits = split(rawDef, '\t')
let file = defBits[4]
let line = defBits[5]
exe printf('e +%d %s', line, file)
return 1
endf
fun! GotoDefinition_nim() abort
call NimExecAsync('--def', function('GotoDefinition_nim_ready'))
endf
fun! FindReferences_nim() abort
"setloclist()
endf
" Syntastic syntax checking
fun! SyntaxCheckers_nim_nim_GetLocList() abort
let makeprg = 'nim check --hints:off --listfullpaths ' . s:CurrentNimFile()
let errorformat = &errorformat
return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat })
endf
function! SyntaxCheckers_nim_nim_IsAvailable() abort
return executable('nim')
endfunction
if exists('g:SyntasticRegistry')
call g:SyntasticRegistry.CreateAndRegisterChecker({
\ 'filetype': 'nim',
\ 'name': 'nim'})
endif

99
autoload/nim_vim.py Normal file
View file

@ -0,0 +1,99 @@
from sys import version_info
import threading, subprocess, signal, os, platform, getpass
if version_info[0] == 3:
import queue as Queue
else:
import Queue
try:
import vim
except ImportError:
class Vim:
def command(self, x):
print("Executing vim command: " + x)
vim = Vim()
class NimThread(threading.Thread):
def __init__(self, project_path):
super(NimThread, self).__init__()
self.tasks = Queue.Queue()
self.responses = Queue.Queue()
self.nim = subprocess.Popen(
["nim", "serve", "--server.type:stdin", project_path],
cwd = os.path.dirname(project_path),
stdin = subprocess.PIPE,
stdout = subprocess.PIPE,
stderr = subprocess.STDOUT,
universal_newlines = True,
bufsize = 1)
def postNimCmd(self, msg, async_ = True):
self.tasks.put((msg, async_))
if not async_:
return self.responses.get()
def run(self):
while True:
(msg, async_) = self.tasks.get()
if msg == "quit":
self.nim.terminate()
break
self.nim.stdin.write(msg + "\n")
result = ""
while True:
line = self.nim.stdout.readline()
result += line
if line == "\n":
if not async_:
self.responses.put(result)
else:
self.asyncOpComplete(msg, result)
break
def nimVimEscape(expr):
return expr.replace("\\", "\\\\").replace('"', "\\\"").replace("\n", "\\n")
class NimVimThread(NimThread):
def asyncOpComplete(self, msg, result):
cmd = "/usr/local/bin/mvim --remote-expr 'NimAsyncCmdComplete(1, \"" + nimVimEscape(result) + "\")'"
os.system (cmd)
NimProjects = {}
def nimStartService(project):
target = NimVimThread(project)
NimProjects[project] = target
target.start()
return target
def nimTerminateService(project):
if NimProjects.has_key(project):
NimProjects[project].postNimCmd("quit")
del NimProjects[project]
def nimRestartService(project):
nimTerminateService(project)
nimStartService(project)
def nimExecCmd(project, cmd, async_ = True):
target = None
if NimProjects.has_key(project):
target = NimProjects[project]
else:
target = nimStartService(project)
result = target.postNimCmd(cmd, async_)
if not async_:
vim.command('let l:py_res = "' + nimVimEscape(result) + '"')
def nimTerminateAll():
for thread in NimProjects.values():
thread.postNimCmd("quit")

18
autoload/simulator.py Normal file
View file

@ -0,0 +1,18 @@
#!/bin/env python
from nimrod_vim import execNimCmd
proj = "/foo"
while True:
line = raw_input("enter command: ")
async = False
if line == "quit":
async = True
print execNimCmd(proj, line, async)
if line == "quit":
break

25
compiler/nim.vim Normal file
View file

@ -0,0 +1,25 @@
if exists('current_compiler')
finish
endif
let current_compiler = 'nim'
if exists(':CompilerSet') != 2 " older Vim always used :setlocal
command -nargs=* CompilerSet setlocal <args>
endif
let s:cpo_save = &cpo
set cpo-=C
CompilerSet makeprg=nim\ c\ --verbosity:0\ --listfullpaths\ $*\ %:p
CompilerSet errorformat=
\%-GHint:\ %m,
\%E%f(%l\\,\ %c)\ Error:\ %m,
\%W%f(%l\\,\ %c)\ Hint:\ %m
let &cpo = s:cpo_save
unlet s:cpo_save
let g:syntastic_nim_checkers = ['nim']

4
ftdetect/nim.vim Normal file
View file

@ -0,0 +1,4 @@
augroup nim_vim
au BufNewFile,BufRead *.nim,*.nims,*.nimble set filetype=nim
augroup END

29
ftplugin/nim.vim Normal file
View file

@ -0,0 +1,29 @@
if exists('b:nim_loaded')
finish
endif
let b:nim_loaded = 1
let s:cpo_save = &cpo
set cpo&vim
:call nim#init()
setlocal formatoptions-=t formatoptions+=croql
setlocal comments=:##,:#
setlocal commentstring=#\ %s
setlocal omnifunc=NimComplete
setlocal suffixesadd=.nim
setlocal expandtab "Make sure that only spaces are used
setlocal foldmethod=indent
setlocal foldlevel=99 " Don't fold newly opened buffers by default
setl tabstop=2
setl softtabstop=2
setl shiftwidth=2
compiler nim
let &cpo = s:cpo_save
unlet s:cpo_save

142
indent/nim.vim Normal file
View file

@ -0,0 +1,142 @@
" Only load this indent file when no other was loaded.
if exists('b:did_indent')
finish
endif
let b:did_indent = 1
" Some preliminary settings
setlocal nolisp " Make sure lisp indenting doesn't supersede us
setlocal autoindent " indentexpr isn't much help otherwise
setlocal indentexpr=GetNimIndent(v:lnum)
setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif
" Only define the function once.
if exists('*GetNimIndent')
finish
endif
function! s:FindStartLine(fromln, pattern)
let lnum = a:fromln
let safechoice = indent(lnum)
while getline(lnum) !~ a:pattern
if indent(lnum) == 0 || lnum == 1
return safechoice
endif
let lnum = lnum - 1
endwhile
return indent(lnum)
endfunction
function! GetNimIndent(lnum)
" Search backwards for the previous non-empty line.
let plnum = prevnonblank(a:lnum - 1)
if plnum == 0
" This is the first non-empty line, use zero indent.
return 0
endif
" If the start of the line is in a string don't change the indent.
if has('syntax_items') && synIDattr(synID(a:lnum, 1, 1), 'name') =~# 'String$'
return -1
endif
let pline = getline(plnum)
let cline = getline(a:lnum)
let pline_len = strlen(pline)
let plindent = indent(plnum)
let clindent = indent(a:lnum)
" Remove any trailing comment from previous line.
" Use syntax highlighting attributes when possible.
if has('syntax_items')
" If the last character in the line is a comment, do a binary search for
" the start of the comment. synID() is slow, a linear search would take
" too long on a long line.
if synIDattr(synID(plnum, pline_len, 1), 'name') =~# 'Comment$'
let min = 1
let max = pline_len
while min < max
let col = (min + max) / 2
if synIDattr(synID(plnum, col, 1), 'name') =~# 'Comment$'
let max = col
else
let min = col + 1
endif
endwhile
let pline = strpart(pline, 0, min - 1)
endif
else
let col = 0
while col < pline_len
if pline[col] == '#'
let pline = strpart(pline, 0, col)
break
endif
let col = col + 1
endwhile
endif
if cline =~# '^\s*\(if\|when\|for\|while\|case\|of\|try\)\>'
" This is a benign line, do nothing
return -1
endif
" If the current line begins with a keyword that lines up with "try"
if cline =~# '^\s*\(except\|finally\)\>'
let lnum = a:lnum - 1
while lnum >= 1
if getline(lnum) =~# '^\s*\(try\|except\)\>'
let ind = indent(lnum)
if ind >= clindent
return -1 " indent is already less than this
endif
return ind " line up with previous try or except
endif
let lnum = lnum - 1
endwhile
return -1 " no matching "try"!
endif
" If the current line begins with a header keyword, dedent
if cline =~# '^\s*\(elif\|else\)\>'
return s:FindStartLine(a:lnum, '^\s*\(if\|when\|elif\|of\)')
endif
if pline =~# ':\s*$'
"return s:FindStartLine(plnum, '(^\s*\(if\|when\|else\|elif\|case\|of\|try\|except\|finally\)\>)\|\<do\>') + &sw
return s:FindStartLine(plnum, '^\s*\(if\|when\|else\|elif\|for\|while\|case\|of\|try\|except\|finally\)\>') + &sw
endif
if pline =~# '=\s*$'
return s:FindStartLine(plnum, '^\s*\(proc\|template\|macro\|iterator\)\>') + &sw
endif
" if we got here, this should be the begging of a multi-line if expression for example
if pline =~# '^\s*\(if\|when\|proc\|iterator\|macro\|template\|for\|while\)[^:]*$'
return plindent + &sw
endif
if pline =~# '\(type\|import\|const\|var\|let\)\s*$'
\ || pline =~# '=\s*\(object\|enum\|tuple\|concept\)'
return plindent + &sw
endif
" If the previous line was a stop-execution statement...
if pline =~# '^\s*\(break\|continue\|raise\|return\)\>'
" See if the user has already dedented
if indent(a:lnum) > plindent - &sw
" If not, recommend one dedent
return plindent - &sw
endif
" Otherwise, trust the user
return -1
endif
return -1
endfunction
" vim:sw=2

214
syntax/nim.vim Normal file
View file

@ -0,0 +1,214 @@
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if v:version < 600
syntax clear
elseif exists('b:current_syntax')
finish
endif
" Keep user-supplied options
if !exists('nim_highlight_numbers')
let nim_highlight_numbers = 1
endif
if !exists('nim_highlight_builtins')
let nim_highlight_builtins = 1
endif
if !exists('nim_highlight_exceptions')
let nim_highlight_exceptions = 1
endif
if !exists('nim_highlight_space_errors')
let nim_highlight_space_errors = 1
endif
if !exists('nim_highlight_special_vars')
let nim_highlight_special_vars = 1
endif
if exists('nim_highlight_all')
let nim_highlight_numbers = 1
let nim_highlight_builtins = 1
let nim_highlight_exceptions = 1
let nim_highlight_space_errors = 1
let nim_highlight_special_vars = 1
endif
syn region nimBrackets contained extend keepend matchgroup=Bold start=+\(\\\)\@<!\[+ end=+]\|$+ skip=+\\\s*$\|\(\\\)\@<!\\]+ contains=@tclCommandCluster
syn keyword nimKeyword addr and as asm atomic
syn keyword nimKeyword bind block break
syn keyword nimKeyword case cast concept const continue converter
syn keyword nimKeyword defer discard distinct div do
syn keyword nimKeyword elif else end enum except export
syn keyword nimKeyword finally for from
syn keyword nimKeyword generic
syn keyword nimKeyword if import in include interface is isnot iterator
syn keyword nimKeyword let
syn keyword nimKeyword mixin using mod
syn keyword nimKeyword nil not notin
syn keyword nimKeyword object of or out
syn keyword nimKeyword proc func method macro template nextgroup=nimFunction skipwhite
syn keyword nimKeyword ptr
syn keyword nimKeyword raise ref return
syn keyword nimKeyword shared shl shr static
syn keyword nimKeyword try tuple type
syn keyword nimKeyword var vtref vtptr
syn keyword nimKeyword while with without
syn keyword nimKeyword xor
syn keyword nimKeyword yield
syn keyword nimKeyword lent sink iterable owned auto any
syn match nimFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained
syn match nimPragma "[a-zA-Z_][a-zA-Z0-9_]*" contained
syn match nimClass "[a-zA-Z_][a-zA-Z0-9_]*" contained
syn match nimType "\v<[A-Z][a-zA-Z0-9_]*>"
syn keyword nimRepeat for while
syn keyword nimConditional if elif else case of when try except return finally
syn keyword nimOperator and in is not or xor shl shr div
syn match nimComment "#.*$" contains=nimTodo,@Spell
syn region nimComment start="#\[" end="\]#" contains=nimTodo,@Spell
syn region nimComment start="##\[" end="\]##" contains=nimTodo,@Spell
syn keyword nimTodo TODO FIXME XXX contained
syn keyword nimBoolean true false
" Strings
syn region nimPragmaSection start=+{\.+ skip=+\\\\\|\\`\|\\:\|\\$+ end=+\.}+ keepend contains=nimString,nimTripleString,nimRawString,nimEscape,nimEscapeError,@Spell,nimPragma
syn region nimString start=+'+ skip=+\\\\\|\\'\|\\$+ excludenl end=+'+ end=+$+ keepend contains=nimEscape,nimEscapeError,@Spell
syn region nimFunction start=+`+ skip=+\\\\\|\\`\|\\$+ excludenl end=+`+ end=+$+ keepend contains=nimEscape,nimEscapeError,@Spell
syn region nimString start=+"+ skip=+\\\\\|\\"\|\\$+ excludenl end=+"+ end=+$+ keepend contains=nimEscape,nimEscapeError,@Spell
syn region nimTripleString start=+\z('''\|"""\)+ end="\z1" skip=+\\\\\|\\"+ contains=@Spell
syn region nimRawString matchgroup=Normal start=+[rR]"+ end=+"+ skip=+\\\\\|\\"+ contains=@Spell
syn match nimEscape +\\[abfnrtv'"\\]+ contained
syn match nimEscape "\\\o\{1,3}" contained
syn match nimEscape "\\x\x\{2}" contained
syn match nimEscape "\(\\u\x\{4}\|\\U\x\{8}\)" contained
syn match nimEscape "\\$"
syn match nimEscapeError "\\x\x\=\X" display contained
if nim_highlight_numbers == 1
" numbers (including longs and complex)
let s:dec_num = '\d%(_?\d)*'
let s:int_suf = '%(''%(%(i|I|u|U)%(8|16|32|64)|u|U))'
let s:float_suf = '%(''%(%(f|F)%(32|64|128)?|d|D))'
let s:exp = '%([eE][+-]?'.s:dec_num.')'
exe 'syn match nimNumber /\v<0[bB][01]%(_?[01])*%('.s:int_suf.'|'.s:float_suf.')?>/'
exe 'syn match nimNumber /\v<0[ocC]\o%(_?\o)*%('.s:int_suf.'|'.s:float_suf.')?>/'
exe 'syn match nimNumber /\v<0[xX]\x%(_?\x)*%('.s:int_suf.'|'.s:float_suf.')?>/'
exe 'syn match nimNumber /\v<'.s:dec_num.'%('.s:int_suf.'|'.s:exp.'?'.s:float_suf.'?)>/'
exe 'syn match nimNumber /\v<'.s:dec_num.'\.'.s:dec_num.s:exp.'?'.s:float_suf.'?>/'
unlet s:dec_num s:int_suf s:float_suf s:exp
endif
if nim_highlight_builtins == 1
" builtin functions, types and objects, not really part of the syntax
syn keyword nimBuiltin int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 float64
syn keyword nimBuiltin bool void chr char string cstring pointer range array openarray openArray seq varargs varArgs
syn keyword nimBuiltin set Byte Natural Positive Conversion
syn keyword nimBuiltin BiggestInt BiggestFloat cchar cschar cshort cint csize cuchar cushort
syn keyword nimBuiltin clong clonglong cfloat cdouble clongdouble cuint culong culonglong cchar
syn keyword nimBuiltin typedesc stmt expr any untyped typed
syn keyword nimBuiltin CompileDate CompileTime nimversion nimVersion nimmajor nimMajor
syn keyword nimBuiltin nimminor nimMinor nimpatch nimPatch cpuendian cpuEndian hostos hostOS hostcpu hostCPU inf
syn keyword nimBuiltin neginf nan QuitSuccess QuitFailure dbglinehook dbgLineHook stdin
syn keyword nimBuiltin stdout stderr defined new high low sizeof succ pred
syn keyword nimBuiltin inc dec newseq newSeq len incl excl card ord chr ze ze64
syn keyword nimBuiltin tou8 toU8 tou16 toU16 tou32 toU32 abs min max add repr
syn match nimBuiltin "\<contains\>"
syn keyword nimBuiltin tofloat toFloat tobiggestfloat toBiggestFloat toint toInt tobiggestint toBiggestInt
syn keyword nimBuiltin addquitproc addQuitProc
syn keyword nimBuiltin copy setlen setLen newstring newString zeromem zeroMem copymem copyMem movemem moveMem
syn keyword nimBuiltin equalmem equalMem alloc alloc0 realloc dealloc assert
syn keyword nimBuiltin echo swap getrefcount getRefcount getcurrentexception getCurrentException Msg
syn keyword nimBuiltin getoccupiedmem getOccupiedMem getfreemem getFreeMem gettotalmem getTotalMem isnil isNil seqtoptr seqToPtr
syn keyword nimBuiltin find pop GC_disable GC_enable GC_fullCollect
syn keyword nimBuiltin GC_setStrategy GC_enableMarkAndSweep GC_Strategy
syn keyword nimBuiltin GC_disableMarkAnd Sweep GC_getStatistics GC_ref
syn keyword nimBuiltin GC_ref GC_ref GC_unref GC_unref GC_unref quit
syn keyword nimBuiltin OpenFile OpenFile CloseFile EndOfFile readChar
syn keyword nimBuiltin FlushFile readfile readFile readline readLine write writeln writeLn writeline writeLine
syn keyword nimBuiltin getfilesize getFileSize ReadBytes ReadChars readbuffer readBuffer writebytes writeBytes
syn keyword nimBuiltin writechars writeChars writebuffer writeBuffer setfilepos setFilePos getfilepos getFilePos
syn keyword nimBuiltin filehandle fileHandle countdown countup items lines
syn keyword nimBuiltin FileMode File RootObj FileHandle ByteAddress Endianness
endif
if nim_highlight_exceptions == 1
" builtin exceptions and warnings
syn keyword nimException E_Base EAsynch ESynch ESystem EIO EOS
syn keyword nimException ERessourceExhausted EArithmetic EDivByZero
syn keyword nimException EOverflow EAccessViolation EAssertionFailed
syn keyword nimException EControlC EInvalidValue EOutOfMemory EInvalidIndex
syn keyword nimException EInvalidField EOutOfRange EStackOverflow
syn keyword nimException ENoExceptionToReraise EInvalidObjectAssignment
syn keyword nimException EInvalidObject EInvalidLibrary EInvalidKey
syn keyword nimException EInvalidObjectConversion EFloatingPoint
syn keyword nimException EFloatInvalidOp EFloatDivByZero EFloatOverflow
syn keyword nimException EFloatInexact EDeadThread EResourceExhausted
syn keyword nimException EFloatUnderflow
endif
if nim_highlight_space_errors == 1
" trailing whitespace
syn match nimSpaceError display excludenl "\S\s\+$"ms=s+1
" any tabs are illegal in nim
syn match nimSpaceError display "\t"
endif
if nim_highlight_special_vars
syn keyword nimSpecialVar result
endif
syn sync match nimSync grouphere NONE "):$"
syn sync maxlines=200
syn sync minlines=2000
if v:version >= 508 || !exists('did_nim_syn_inits')
if v:version <= 508
let did_nim_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
" The default methods for highlighting. Can be overridden later
HiLink nimBrackets Operator
HiLink nimKeyword Keyword
HiLink nimFunction Function
HiLink nimPragma Pragma
HiLink nimType Type
HiLink nimConditional Conditional
HiLink nimRepeat Repeat
HiLink nimString String
HiLink nimTripleString String
HiLink nimRawString String
HiLink nimBoolean Boolean
HiLink nimEscape Special
HiLink nimOperator Operator
HiLink nimPreCondit PreCondit
HiLink nimComment Comment
HiLink nimTodo Todo
HiLink nimDecorator Define
HiLink nimSpecialVar Identifier
if nim_highlight_numbers == 1
HiLink nimNumber Number
endif
if nim_highlight_builtins == 1
HiLink nimBuiltin Special
endif
if nim_highlight_exceptions == 1
HiLink nimException Exception
endif
if nim_highlight_space_errors == 1
HiLink nimSpaceError Error
endif
delcommand HiLink
endif
let b:current_syntax = 'nim'

View file

@ -1,186 +0,0 @@
" Vim syntax file
" Language: Nimrod
" Maintainer: Kearn Holliday (thekearnman at gmail dot com)
" Updated: 2009-05-15
"
" Options to control nimrod syntax highlighting:
"
" For highlighted numbers:
"
let nimrod_highlight_numbers = 1
"
" For highlighted builtin functions:
"
let nimrod_highlight_builtins = 1
"
" For highlighted standard exceptions:
"
let nimrod_highlight_exceptions = 1
"
" Highlight erroneous whitespace:
"
let nimrod_highlight_space_errors = 1
"
" If you want all possible nimrod highlighting (the same as setting the
" preceding options):
"
" let nimrod_highlight_all = 1
"
" For version 5.x: Clear all syntax items
" For version 6.x: Quit when a syntax file was already loaded
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn region nimrodBrackets contained extend keepend matchgroup=Bold start=+\(\\\)\@<!\[+ end=+]\|$+ skip=+\\\s*$\|\(\\\)\@<!\\]+ contains=@tclCommandCluster
syn keyword nimrodStatement addr as asm
syn keyword nimrodStatement block break
syn keyword nimrodStatement case cast const continue converter
syn keyword nimrodStatement discard div
syn keyword nimrodStatement elif else end enum except exception echo
syn keyword nimrodStatement finally for from generic
syn keyword nimrodStatement if implies import include isnot iterator
syn keyword nimrodStatement lambda
syn keyword nimrodStatement macro method mod
syn keyword nimrodStatement nil notin
syn keyword nimrodStatement object of out
syn keyword nimrodStatement proc ptr
syn keyword nimrodStatement raise ref return
syn keyword nimrodStatement template try tuple type
syn keyword nimrodStatement var
syn keyword nimrodStatement when where while with without
syn keyword nimrodStatement yield
syn match nimrodFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained
syn match nimrodClass "[a-zA-Z_][a-zA-Z0-9_]*" contained
syn keyword nimrodRepeat for while
syn keyword nimrodConditional if elif else case of
syn keyword nimrodOperator and in is not or xor shl shr
syn match nimrodComment "#.*$" contains=nimrodTodo,@Spell
syn keyword nimrodTodo TODO FIXME XXX contained
" strings
syn region nimrodString matchgroup=Normal start=+[uU]\=`+ end=+`+ skip=+\\\\\|\\"+ contains=nimrodEscape,@Spell
syn region nimrodString matchgroup=Normal start=+[uU]\="+ end=+"+ skip=+\\\\\|\\"+ contains=nimrodEscape,@Spell
syn region nimrodRawString matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+ contains=@Spell
syn match nimrodEscape +\\[abfnrtv'"\\]+ contained
syn match nimrodEscape "\\\o\{1,3}" contained
syn match nimrodEscape "\\x\x\{2}" contained
syn match nimrodEscape "\(\\u\x\{4}\|\\U\x\{8}\)" contained
syn match nimrodEscape "\\$"
if exists("nimrod_highlight_all")
let nimrod_highlight_numbers = 1
let nimrod_highlight_builtins = 1
let nimrod_highlight_exceptions = 1
let nimrod_highlight_space_errors = 1
endif
if exists("nimrod_highlight_numbers")
" numbers (including longs and complex)
syn match nimrodNumber "\<0x\x\+[Ll]\=\>"
syn match nimrodNumber "\<\d\+[LljJ]\=\>"
syn match nimrodNumber "\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
syn match nimrodNumber "\<\d\+\.\([eE][+-]\=\d\+\)\=[jJ]\=\>"
syn match nimrodNumber "\<\d\+\.\d\+\([eE][+-]\=\d\+\)\=[jJ]\=\>"
endif
if exists("nimrod_highlight_builtins")
" builtin functions, types and objects, not really part of the syntax
syn keyword nimrodBuiltin int int8 int16 int32 int64 float float32 float64 bool
syn keyword nimrodBuiltin char string cstring pointer range array openarray seq
syn keyword nimrodBuiltin set Byte Natural Positive TObject PObject Conversion TResult TAddress
syn keyword nimrodBuiltin BiggestInt BiggestFloat cchar cschar cshort cint
syn keyword nimrodBuiltin clong clonglong cfloat cdouble clongdouble
syn keyword nimrodBuiltin cstringArray TEndian PFloat32 PFloat64 PInt64 PInt32
syn keyword nimrodBuiltin TGC_Strategy TFile TFileMode TFileHandle isMainModule
syn keyword nimrodBuiltin CompileDate CompileTime NimrodVersion NimrodMajor
syn keyword nimrodBuiltin NimrodMinor NimrodPatch cpuEndian hostOS hostCPU inf
syn keyword nimrodBuiltin neginf nan QuitSuccess QuitFailure dbgLineHook stdin
syn keyword nimrodBuiltin stdout stderr defined new high low sizeof succ pred
syn keyword nimrodBuiltin inc dec newSeq len incl excl card ord chr ze ze64
syn keyword nimrodBuiltin toU8 toU16 toU32 abs min max add repr
syn match nimrodBuiltin "\<contains\>"
syn keyword nimrodBuiltin toFloat toBiggestFloat toInt toBiggestInt addQuitProc
syn keyword nimrodBuiltin copy setLen newString zeroMem copyMem moveMem
syn keyword nimrodBuiltin equalMem alloc alloc0 realloc dealloc setLen assert
syn keyword nimrodBuiltin swap getRefcount getCurrentException Msg
syn keyword nimrodBuiltin getOccupiedMem getFreeMem getTotalMem isNil seqToPtr
syn keyword nimrodBuiltin find pop GC_disable GC_enable GC_fullCollect
syn keyword nimrodBuiltin GC_setStrategy GC_enableMarkAnd Sweep
syn keyword nimrodBuiltin GC_disableMarkAnd Sweep GC_getStatistics GC_ref
syn keyword nimrodBuiltin GC_ref GC_ref GC_unref GC_unref GC_unref quit
syn keyword nimrodBuiltin OpenFile OpenFile CloseFile EndOfFile readChar
syn keyword nimrodBuiltin FlushFile readFile write readLine writeln writeln
syn keyword nimrodBuiltin getFileSize ReadBytes ReadChars readBuffer writeBytes
syn keyword nimrodBuiltin writeChars writeBuffer setFilePos getFilePos
syn keyword nimrodBuiltin fileHandle countdown countup items lines
endif
if exists("nimrod_highlight_exceptions")
" builtin exceptions and warnings
syn keyword nimrodException E_Base EAsynch ESynch ESystem EIO EOS
syn keyword nimrodException ERessourceExhausted EArithmetic EDivByZero
syn keyword nimrodException EOverflow EAccessViolation EAssertionFailed
syn keyword nimrodException EControlC EInvalidValue EOutOfMemory EInvalidIndex
syn keyword nimrodException EInvalidField EOutOfRange EStackOverflow
syn keyword nimrodException ENoExceptionToReraise EInvalidObjectAssignment
syn keyword nimrodException EInvalidObject
endif
if exists("nimrod_highlight_space_errors")
" trailing whitespace
syn match nimrodSpaceError display excludenl "\S\s\+$"ms=s+1
" mixed tabs and spaces
syn match nimrodSpaceError display " \+\t"
syn match nimrodSpaceError display "\t\+ "
endif
syn sync match nimrodSync grouphere NONE "):$"
syn sync maxlines=200
syn sync minlines=2000
if version >= 508 || !exists("did_nimrod_syn_inits")
if version <= 508
let did_nimrod_syn_inits = 1
command -nargs=+ HiLink hi link <args>
else
command -nargs=+ HiLink hi def link <args>
endif
" The default methods for highlighting. Can be overridden later
HiLink nimrodBrackets Operator
HiLink nimrodStatement Statement
HiLink nimrodFunction Function
HiLink nimrodConditional Conditional
HiLink nimrodRepeat Repeat
HiLink nimrodString String
HiLink nimrodRawString String
HiLink nimrodEscape Special
HiLink nimrodOperator Operator
HiLink nimrodPreCondit PreCondit
HiLink nimrodComment Comment
HiLink nimrodTodo Todo
HiLink nimrodDecorator Define
if exists("nimrod_highlight_numbers")
HiLink nimrodNumber Number
endif
if exists("nimrod_highlight_builtins")
HiLink nimrodBuiltin Number
endif
if exists("nimrod_highlight_exceptions")
HiLink nimrodException Exception
endif
if exists("nimrod_highlight_space_errors")
HiLink nimrodSpaceError Error
endif
delcommand HiLink
endif
let b:current_syntax = "nimrod"