Compare commits
No commits in common. "master" and "1.0" have entirely different histories.
12 changed files with 194 additions and 911 deletions
22
LICENSE
22
LICENSE
|
|
@ -1,22 +0,0 @@
|
|||
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
Normal file
6
README
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
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
121
README.markdown
|
|
@ -1,121 +0,0 @@
|
|||
# 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
237
autoload/nim.vim
|
|
@ -1,237 +0,0 @@
|
|||
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
|
||||
|
|
@ -1,99 +0,0 @@
|
|||
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")
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
#!/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
|
||||
|
||||
|
|
@ -1,25 +0,0 @@
|
|||
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']
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
augroup nim_vim
|
||||
au BufNewFile,BufRead *.nim,*.nims,*.nimble set filetype=nim
|
||||
augroup END
|
||||
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
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
142
indent/nim.vim
|
|
@ -1,142 +0,0 @@
|
|||
" 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
214
syntax/nim.vim
|
|
@ -1,214 +0,0 @@
|
|||
" 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'
|
||||
|
||||
188
syntax/nimrod.vim
Normal file
188
syntax/nimrod.vim
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
" Vim syntax file
|
||||
" Language: Nimrod
|
||||
" Maintainer: Kearn Holliday (thekearnman at gmail dot com)
|
||||
" Updated: 2009-05-14
|
||||
"
|
||||
" 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 region nimrodRawString matchgroup=Normal start=+[uU]\=[rR]"+ end=+"+ skip=+\\\\\|\\"+ contains=@Spell
|
||||
syn region nimrodRawString matchgroup=Normal start=+[uU]\=[rR]"""+ end=+"""+ contains=@Spell
|
||||
syn region nimrodRawString matchgroup=Normal start=+[uU]\=[rR]'''+ end=+'''+ 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 contains add repr
|
||||
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"
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue