From a53642d1e84d8237cdbd8a7db256de781bc2b3fe Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 26 Aug 2011 13:50:09 +0300 Subject: [PATCH 01/98] added indenting rules, compiler settings and filetype detection --- compiler/nimrod.vim | 17 ++++++ ftdetect/nimrod.vim | 2 + ftplugin/nimrod.vim | 9 ++++ indent/nimrod.vim | 123 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 151 insertions(+) create mode 100644 compiler/nimrod.vim create mode 100644 ftdetect/nimrod.vim create mode 100644 ftplugin/nimrod.vim create mode 100644 indent/nimrod.vim diff --git a/compiler/nimrod.vim b/compiler/nimrod.vim new file mode 100644 index 0000000..f7dd598 --- /dev/null +++ b/compiler/nimrod.vim @@ -0,0 +1,17 @@ +if exists("current_compiler") + finish +endif + +let current_compiler = "nimrod" + +if exists(":CompilerSet") != 2 " older Vim always used :setlocal + command -nargs=* CompilerSet setlocal +endif + +CompilerSet makeprg=nimrod\ c\ $* + +CompilerSet errorformat= + \%f(%l,\ %c)\ Error:\ %m, + \%f(%l,\ %c)\ Hint:\ %m, + \%f(%l,\ %c)\ Warning:\ %m + diff --git a/ftdetect/nimrod.vim b/ftdetect/nimrod.vim new file mode 100644 index 0000000..4384a66 --- /dev/null +++ b/ftdetect/nimrod.vim @@ -0,0 +1,2 @@ +au BufNewFile,BufRead *.nim set filetype=nimrod + diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim new file mode 100644 index 0000000..6950def --- /dev/null +++ b/ftplugin/nimrod.vim @@ -0,0 +1,9 @@ +if (exists("b:did_ftplugin")) + finish +endif + +let b:did_ftplugin = 1 + +let s:cpo_save = &cpo +set cpo&vim + diff --git a/indent/nimrod.vim b/indent/nimrod.vim new file mode 100644 index 0000000..8adcd1b --- /dev/null +++ b/indent/nimrod.vim @@ -0,0 +1,123 @@ +" 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=GetNimrodIndent(v:lnum) +setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif + +" Only define the function once. +if exists("*GetNimrodIndent") + finish +endif + +function! GetNimrodIndent(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 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 pline =~ ':\s*$' + \ || pline =~ '\(type\|import\|const\|var\)\s*$' + \ || pline =~ 'proc.*=\s*$' + \ || pline =~ '=\s*\(object\|enum\)' + 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 + + " If the current line begins with a keyword that lines up with "try" + if getline(a:lnum) =~ '^\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 getline(a:lnum) =~ '^\s*\(elif\|else\)\>' + + " Unless the previous line was a one-liner + "if getline(plnumstart) =~ '^\s*\(for\|if\|try\)\>' + "return plindent + "endif + + " Or the user has already dedented + if clindent <= plindent - &sw + return -1 + endif + + return plindent - &sw + endif + + return -1 + +endfunction + +" vim:sw=2 + From 32b82b89cfc764dbe45004d9c939a5432365bf00 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 26 Aug 2011 15:31:13 +0300 Subject: [PATCH 02/98] generalised the indent rule for procs to handle templates, macros --- indent/nimrod.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/nimrod.vim b/indent/nimrod.vim index 8adcd1b..d413f4e 100644 --- a/indent/nimrod.vim +++ b/indent/nimrod.vim @@ -66,8 +66,8 @@ function! GetNimrodIndent(lnum) endif if pline =~ ':\s*$' + \ || pline =~ '=\s*$' \ || pline =~ '\(type\|import\|const\|var\)\s*$' - \ || pline =~ 'proc.*=\s*$' \ || pline =~ '=\s*\(object\|enum\)' return plindent + &sw endif From 44750377f7deb1b87316e11235d6cdacd2dd4d45 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 26 Aug 2011 15:48:16 +0300 Subject: [PATCH 03/98] few fixes for the commenting and line wrapping behaviour --- compiler/nimrod.vim | 8 ++++++++ ftplugin/nimrod.vim | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/compiler/nimrod.vim b/compiler/nimrod.vim index f7dd598..8f52618 100644 --- a/compiler/nimrod.vim +++ b/compiler/nimrod.vim @@ -8,6 +8,9 @@ if exists(":CompilerSet") != 2 " older Vim always used :setlocal command -nargs=* CompilerSet setlocal endif +let s:cpo_save = &cpo +set cpo-=C + CompilerSet makeprg=nimrod\ c\ $* CompilerSet errorformat= @@ -15,3 +18,8 @@ CompilerSet errorformat= \%f(%l,\ %c)\ Hint:\ %m, \%f(%l,\ %c)\ Warning:\ %m +let &cpo = s:cpo_save +unlet s:cpo_save + +" vim: nowrap sw=2 sts=2 ts=8: + diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index 6950def..93924ca 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -7,3 +7,10 @@ let b:did_ftplugin = 1 let s:cpo_save = &cpo set cpo&vim +setlocal formatoptions-=t formatoptions+=croql +setlocal comments=:# +setlocal commentstring=#\ %s + +let &cpo = s:cpo_save +unlet s:cpo_save + From d92a73496fbf04a60c5bda094b1d8e1e15d9853f Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sat, 27 Aug 2011 19:44:08 +0300 Subject: [PATCH 04/98] more up-to-date list of nimrod keywords and proper handling of multi-line strings --- syntax/nimrod.vim | 166 +++++++++++++++++++++++----------------------- 1 file changed, 82 insertions(+), 84 deletions(-) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index 9f4a9d3..da8f80c 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -1,32 +1,3 @@ -" 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 @@ -35,58 +6,80 @@ elseif exists("b:current_syntax") finish endif +" Keep user-supplied options +if !exists("nimrod_highlight_numbers") + let nimrod_highlight_numbers = 1 +endif +if !exists("nimrod_highlight_builtins") + let nimrod_highlight_builtins = 1 +endif +if !exists("nimrod_highlight_exceptions") + let nimrod_highlight_exceptions = 1 +endif +if !exists("nimrod_highlight_space_errors") + let nimrod_highlight_space_errors = 1 +endif + +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 + syn region nimrodBrackets contained extend keepend matchgroup=Bold start=+\(\\\)\@" - 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]\=\>" + syn match nimrodNumber "\<[0-9_]\+[LljJ]\=\>" + syn match nimrodNumber "\.[0-9_]\+\([eE][+-]\=[0-9_]\+\)\=[jJ]\=\>" + syn match nimrodNumber "\<[0-9_]\+\.\([eE][+-]\=[0-9_]\+\)\=[jJ]\=\>" + syn match nimrodNumber "\<[0-9_]\+\.[0-9_]\+\([eE][+-]\=[0-9_]\+\)\=[jJ]\=\>" endif if exists("nimrod_highlight_builtins") @@ -153,29 +146,34 @@ if version >= 508 || !exists("did_nimrod_syn_inits") 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 nimrodBrackets Operator + HiLink nimrodKeyword Keyword + HiLink nimrodFunction Function + HiLink nimrodConditional Conditional + HiLink nimrodRepeat Repeat + HiLink nimrodString String + HiLink nimrodRawString String + HiLink nimrodBoolean Boolean + HiLink nimrodEscape Special + HiLink nimrodOperator Operator + HiLink nimrodPreCondit PreCondit + HiLink nimrodComment Comment + HiLink nimrodTodo Todo + HiLink nimrodDecorator Define + + if nimrod_highlight_numbers == 1 HiLink nimrodNumber Number endif - if exists("nimrod_highlight_builtins") + + if nimrod_highlight_builtins == 1 HiLink nimrodBuiltin Number endif - if exists("nimrod_highlight_exceptions") + + if nimrod_highlight_exceptions == 1 HiLink nimrodException Exception endif - if exists("nimrod_highlight_space_errors") + + if nimrod_highlight_space_errors == 1 HiLink nimrodSpaceError Error endif From bc5515054e69571f4e3fb6555624c301cf5343bf Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sat, 27 Aug 2011 23:31:26 +0300 Subject: [PATCH 05/98] any tab in nimrod code is displayed as error --- syntax/nimrod.vim | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index da8f80c..5870bb9 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -82,7 +82,7 @@ if nimrod_highlight_numbers == 1 syn match nimrodNumber "\<[0-9_]\+\.[0-9_]\+\([eE][+-]\=[0-9_]\+\)\=[jJ]\=\>" endif -if exists("nimrod_highlight_builtins") +if nimrod_highlight_builtins == 1 " 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 @@ -114,7 +114,7 @@ if exists("nimrod_highlight_builtins") syn keyword nimrodBuiltin fileHandle countdown countup items lines endif -if exists("nimrod_highlight_exceptions") +if nimrod_highlight_exceptions == 1 " builtin exceptions and warnings syn keyword nimrodException E_Base EAsynch ESynch ESystem EIO EOS syn keyword nimrodException ERessourceExhausted EArithmetic EDivByZero @@ -125,12 +125,11 @@ if exists("nimrod_highlight_exceptions") syn keyword nimrodException EInvalidObject endif -if exists("nimrod_highlight_space_errors") +if nimrod_highlight_space_errors == 1 " 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\+ " + " any tabs are illegal in nimrod + syn match nimrodSpaceError display "\t" endif syn sync match nimrodSync grouphere NONE "):$" @@ -182,4 +181,3 @@ endif let b:current_syntax = "nimrod" - From 03615f8caa92a69f9018689f87537b5d766fa8a0 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 28 Aug 2011 01:54:33 +0300 Subject: [PATCH 06/98] nimrod compiler is now set automatically --- compiler/nimrod.vim | 4 +--- ftplugin/nimrod.vim | 2 ++ 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/compiler/nimrod.vim b/compiler/nimrod.vim index 8f52618..ea73dd2 100644 --- a/compiler/nimrod.vim +++ b/compiler/nimrod.vim @@ -14,9 +14,7 @@ set cpo-=C CompilerSet makeprg=nimrod\ c\ $* CompilerSet errorformat= - \%f(%l,\ %c)\ Error:\ %m, - \%f(%l,\ %c)\ Hint:\ %m, - \%f(%l,\ %c)\ Warning:\ %m + \%f(%l\\,\ %c)\ %m let &cpo = s:cpo_save unlet s:cpo_save diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index 93924ca..24970de 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -11,6 +11,8 @@ setlocal formatoptions-=t formatoptions+=croql setlocal comments=:# setlocal commentstring=#\ %s +compiler nimrod + let &cpo = s:cpo_save unlet s:cpo_save From 0224eb03d22bcf84789e642e24370afeb7314b55 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 28 Aug 2011 17:41:18 +0300 Subject: [PATCH 07/98] added automatic discovery of nimrod library paths and any tags files residing there --- ftplugin/nimrod.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index 24970de..1ae76e8 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -13,6 +13,17 @@ setlocal commentstring=#\ %s compiler nimrod +if executable('nimrod') + let nimrod_paths = split(system('nimrod dump'),'\n') + let &l:tags = &g:tags + + for path in nimrod_paths + if finddir(path) == path + let &l:tags = path . "/tags," . &l:tags + endif + endfor +endif + let &cpo = s:cpo_save unlet s:cpo_save From d70493af95b87b8583ef660a2d57fb93b3c61258 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 4 Nov 2011 17:39:01 +0200 Subject: [PATCH 08/98] macros and templates are higlighted as procs --- syntax/nimrod.vim | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index 5870bb9..50ddbd8 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -33,20 +33,18 @@ syn keyword nimrodKeyword addr and as asm atomic syn keyword nimrodKeyword bind block break syn keyword nimrodKeyword case cast const continue converter syn keyword nimrodKeyword discard distinct div -syn keyword nimrodKeyword elif else end enum except +syn keyword nimrodKeyword elif else enum except syn keyword nimrodKeyword finally for from generic syn keyword nimrodKeyword if implies import in include is isnot iterator syn keyword nimrodKeyword lambda let -syn keyword nimrodKeyword macro method mod syn keyword nimrodKeyword nil not notin syn keyword nimrodKeyword object of or out -syn keyword nimrodKeyword proc nextgroup=nimrodFunction skipwhite +syn keyword nimrodKeyword proc method macro template nextgroup=nimrodFunction skipwhite syn keyword nimrodKeyword raise ref return -syn keyword nimrodKeyword shl shr -syn keyword nimrodKeyword template try tuple type +syn keyword nimrodKeyword shl shr xom mod and +syn keyword nimrodKeyword try tuple type syn keyword nimrodKeyword ptr var syn keyword nimrodKeyword when while with without -syn keyword nimrodKeyword xor syn keyword nimrodKeyword yield syn match nimrodFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained From cf6bd5bc64d1fdfa890fa6608d72b1e86e433f9b Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 10 Nov 2011 23:18:48 +0200 Subject: [PATCH 09/98] Better errorformat parsing and support for syntastic (https://github.com/scrooloose/syntastic) --- compiler/nimrod.vim | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/compiler/nimrod.vim b/compiler/nimrod.vim index ea73dd2..de3b49f 100644 --- a/compiler/nimrod.vim +++ b/compiler/nimrod.vim @@ -14,10 +14,18 @@ set cpo-=C CompilerSet makeprg=nimrod\ c\ $* CompilerSet errorformat= - \%f(%l\\,\ %c)\ %m + \%-GHint:\ %m, + \%E%f(%l\\,\ %c)\ Error:\ %m, + \%W%f(%l\\,\ %c)\ Hint:\ %m + +" Syntastic syntax checking +function! SyntaxCheckers_nimrod_GetLocList() + let makeprg = 'nimrod check %' + let errorformat = &errorformat + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endfunction let &cpo = s:cpo_save unlet s:cpo_save -" vim: nowrap sw=2 sts=2 ts=8: - From d5276eed2cc89c7c36019c00919f770d65824a5f Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 15 Dec 2011 15:16:46 +0200 Subject: [PATCH 10/98] syntax checking for included files --- compiler/nimrod.vim | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/compiler/nimrod.vim b/compiler/nimrod.vim index de3b49f..d37c919 100644 --- a/compiler/nimrod.vim +++ b/compiler/nimrod.vim @@ -20,7 +20,22 @@ CompilerSet errorformat= " Syntastic syntax checking function! SyntaxCheckers_nimrod_GetLocList() - let makeprg = 'nimrod check %' + 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) + + let makeprg = 'nimrod check ' . l:to_check let errorformat = &errorformat return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) From f8ac24360fa3bef99da7d20859d5f7d8ef1ee4ef Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 15 Dec 2011 15:17:58 +0200 Subject: [PATCH 11/98] support for int and float literals like 42'i32 --- syntax/nimrod.vim | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index 50ddbd8..0dac817 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -73,11 +73,10 @@ syn match nimrodEscapeError "\\x\x\=\X" display contained if nimrod_highlight_numbers == 1 " numbers (including longs and complex) - syn match nimrodNumber "\<0x\x\+[Ll]\=\>" - syn match nimrodNumber "\<[0-9_]\+[LljJ]\=\>" - syn match nimrodNumber "\.[0-9_]\+\([eE][+-]\=[0-9_]\+\)\=[jJ]\=\>" - syn match nimrodNumber "\<[0-9_]\+\.\([eE][+-]\=[0-9_]\+\)\=[jJ]\=\>" - syn match nimrodNumber "\<[0-9_]\+\.[0-9_]\+\([eE][+-]\=[0-9_]\+\)\=[jJ]\=\>" + syn match nimrodNumber "\v<0x\x+(\'(i|I|f|F)(8|16|32|64))?>" + syn match nimrodNumber "\v<[0-9_]+(\'(i|I|f|F)(8|16|32|64))?>" + syn match nimrodNumber "\v\.[0-9_]+([eE][+-]=[0-9_]+)=>" + syn match nimrodNumber "\v<[0-9_]+(\.[0-9_]+)?([eE][+-]?[0-9_]+)?(\'(f|F)(32|64))?>" endif if nimrod_highlight_builtins == 1 From b26c3696e92b6333e1e67d06f63121da6f431e32 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 14 Jun 2012 14:35:24 +0300 Subject: [PATCH 12/98] syntax updates for unsigned integers --- syntax/nimrod.vim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index 0dac817..e7e9a4a 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -73,15 +73,15 @@ syn match nimrodEscapeError "\\x\x\=\X" display contained if nimrod_highlight_numbers == 1 " numbers (including longs and complex) - syn match nimrodNumber "\v<0x\x+(\'(i|I|f|F)(8|16|32|64))?>" - syn match nimrodNumber "\v<[0-9_]+(\'(i|I|f|F)(8|16|32|64))?>" + syn match nimrodNumber "\v<0x\x+(\'(i|I|f|F|u|U)(8|16|32|64))?>" + syn match nimrodNumber "\v<[0-9_]+(\'(i|I|f|F|u|U)(8|16|32|64))?>" syn match nimrodNumber "\v\.[0-9_]+([eE][+-]=[0-9_]+)=>" syn match nimrodNumber "\v<[0-9_]+(\.[0-9_]+)?([eE][+-]?[0-9_]+)?(\'(f|F)(32|64))?>" endif if nimrod_highlight_builtins == 1 " 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 int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 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 From 81c2f4aa69c30f1a06002c9a49521ac2aa4aa088 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 8 Nov 2012 19:07:21 +0200 Subject: [PATCH 13/98] added support for compiler-assisted "go to definition" and omnicompletion --- compiler/nimrod.vim | 23 ----------- ftdetect/nimrod.vim | 2 +- ftplugin/nimrod.vim | 95 +++++++++++++++++++++++++++++++++++++++++---- 3 files changed, 88 insertions(+), 32 deletions(-) diff --git a/compiler/nimrod.vim b/compiler/nimrod.vim index d37c919..1219333 100644 --- a/compiler/nimrod.vim +++ b/compiler/nimrod.vim @@ -18,29 +18,6 @@ CompilerSet errorformat= \%E%f(%l\\,\ %c)\ Error:\ %m, \%W%f(%l\\,\ %c)\ Hint:\ %m -" Syntastic syntax checking -function! SyntaxCheckers_nimrod_GetLocList() - 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) - - let makeprg = 'nimrod check ' . l:to_check - let errorformat = &errorformat - - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) -endfunction - let &cpo = s:cpo_save unlet s:cpo_save diff --git a/ftdetect/nimrod.vim b/ftdetect/nimrod.vim index 4384a66..04ea13e 100644 --- a/ftdetect/nimrod.vim +++ b/ftdetect/nimrod.vim @@ -1,2 +1,2 @@ -au BufNewFile,BufRead *.nim set filetype=nimrod +au BufNewFile,BufRead *.nim set filetype=nimrod diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index 1ae76e8..264eb64 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -1,18 +1,12 @@ -if (exists("b:did_ftplugin")) +if exists("b:nimrod_loaded") finish endif -let b:did_ftplugin = 1 +let b:nimrod_loaded = 1 let s:cpo_save = &cpo set cpo&vim -setlocal formatoptions-=t formatoptions+=croql -setlocal comments=:# -setlocal commentstring=#\ %s - -compiler nimrod - if executable('nimrod') let nimrod_paths = split(system('nimrod dump'),'\n') let &l:tags = &g:tags @@ -24,6 +18,91 @@ if executable('nimrod') endfor endif +fun! CurrentNimrodFile() + 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 + +fun! NimComplete(findstart, base) + if a:findstart + if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' + return -1 + endif + return col('.') + else + let result = [] + let cmd = printf("nimrod idetools --suggest --track:\"%s,%d,%d\" \"%s\"", + \ expand('%:p'), line('.'), col('.'), CurrentNimrodFile()) + + let sugOut = system(cmd) + for line in split(sugOut, '\n') + let lineData = split(line, '\t') + if lineData[0] == "sug" + let c = { 'word': lineData[2], 'info': lineData[3] } + call add(result, c) + endif + endfor + return result + endif +endf + +if !exists("g:neocomplcache_omni_patterns") + let g:neocomplcache_omni_patterns = {} +endif + +let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*\' + +fun! GotoDefinition_nimrod() + let cmd = printf("nimrod idetools --def --track:\"%s,%d,%d\" \"%s\"", + \ expand('%:p'), line('.'), col('.'), CurrentNimrodFile()) + + let defOut = system(cmd) + if v:shell_error + echoerr "error executing nimrod. exit code: " . v:shell_error + echoerr defOut + return 0 + endif + + let rawDef = matchstr(defOut, 'def\t\([^\n]*\)') + if rawDef == "" + echo "nimrod was unable to locate the definition" + 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 + +" Syntastic syntax checking +fun! SyntaxCheckers_nimrod_GetLocList() + let makeprg = 'nimrod check ' . CurrentNimrodFile() + let errorformat = &errorformat + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endf + +setlocal formatoptions-=t formatoptions+=croql +setlocal comments=:# +setlocal commentstring=#\ %s +setlocal omnifunc=NimComplete +compiler nimrod + let &cpo = s:cpo_save unlet s:cpo_save From 95533181c2bd012886335e865ce9363db4278bde Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 9 Nov 2012 01:09:56 +0200 Subject: [PATCH 14/98] omni-completion improvements --- ftplugin/nimrod.vim | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index 264eb64..b03e83d 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -36,6 +36,26 @@ fun! CurrentNimrodFile() return l:to_check endf +let g:nimrod_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! NimComplete(findstart, base) if a:findstart if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' @@ -51,7 +71,8 @@ fun! NimComplete(findstart, base) for line in split(sugOut, '\n') let lineData = split(line, '\t') if lineData[0] == "sug" - let c = { 'word': lineData[2], 'info': lineData[3] } + let kind = get(g:nimrod_symbol_types, lineData[1], '') + let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 } call add(result, c) endif endfor @@ -63,7 +84,7 @@ if !exists("g:neocomplcache_omni_patterns") let g:neocomplcache_omni_patterns = {} endif -let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*\' +let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' fun! GotoDefinition_nimrod() let cmd = printf("nimrod idetools --def --track:\"%s,%d,%d\" \"%s\"", From ecc3d1f633da87cdf619ecc7e91729d33ad86d7b Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Fri, 9 Nov 2012 18:51:59 +0200 Subject: [PATCH 15/98] fixed the "cannot reload GotoDefinition while executing" error errors are redirected to a log buffer now instead of echoerr --- autoload/nimrod.vim | 132 ++++++++++++++++++++++++++++++++++++++++++++ ftplugin/nimrod.vim | 111 +------------------------------------ 2 files changed, 133 insertions(+), 110 deletions(-) create mode 100644 autoload/nimrod.vim diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim new file mode 100644 index 0000000..8d7074b --- /dev/null +++ b/autoload/nimrod.vim @@ -0,0 +1,132 @@ +fun! nimrod#init() +endf + +let g:nim_log = [] + +fun! s:UpdateNimLog() + 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 /^nimrod.*/ +endf + +augroup NimLog + au! + au BufEnter log://nimrod call s:UpdateNimLog() +augroup END + +fun! CurrentNimrodFile() + 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:nimrod_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) + let cmd = printf("nimrod idetools %s --track:\"%s,%d,%d\" \"%s\"", + \ a:op, expand('%:p'), line('.'), col('.'), CurrentNimrodFile()) + + call add(g:nim_log, cmd) + let output = system(cmd) + call add(g:nim_log, output) + return output +endf + +fun! NimComplete(findstart, base) + if a:findstart + if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' + return -1 + endif + return col('.') + else + let result = [] + let sugOut = NimExec("--suggest") + for line in split(sugOut, '\n') + let lineData = split(line, '\t') + if lineData[0] == "sug" + let kind = get(g:nimrod_symbol_types, lineData[1], '') + let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 } + call add(result, c) + endif + endfor + return result + endif +endf + +if !exists("g:neocomplcache_omni_patterns") + let g:neocomplcache_omni_patterns = {} +endif + +let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' + +fun! GotoDefinition_nimrod() + let defOut = NimExec("--def") + if v:shell_error + echo "nimrod was unable to locate the definition. exit code: " . v:shell_error + " echoerr defOut + return 0 + endif + + let rawDef = matchstr(defOut, '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("silent! e +%d %s", line, file) + return 1 +endf + +fun! FindReferences_nimrod() + setloclist() +endf + +" Syntastic syntax checking +fun! SyntaxCheckers_nimrod_GetLocList() + let makeprg = 'nimrod check ' . CurrentNimrodFile() + let errorformat = &errorformat + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endf + diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index b03e83d..e5ee894 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -7,116 +7,7 @@ let b:nimrod_loaded = 1 let s:cpo_save = &cpo set cpo&vim -if executable('nimrod') - let nimrod_paths = split(system('nimrod dump'),'\n') - let &l:tags = &g:tags - - for path in nimrod_paths - if finddir(path) == path - let &l:tags = path . "/tags," . &l:tags - endif - endfor -endif - -fun! CurrentNimrodFile() - 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:nimrod_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! NimComplete(findstart, base) - if a:findstart - if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' - return -1 - endif - return col('.') - else - let result = [] - let cmd = printf("nimrod idetools --suggest --track:\"%s,%d,%d\" \"%s\"", - \ expand('%:p'), line('.'), col('.'), CurrentNimrodFile()) - - let sugOut = system(cmd) - for line in split(sugOut, '\n') - let lineData = split(line, '\t') - if lineData[0] == "sug" - let kind = get(g:nimrod_symbol_types, lineData[1], '') - let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 } - call add(result, c) - endif - endfor - return result - endif -endf - -if !exists("g:neocomplcache_omni_patterns") - let g:neocomplcache_omni_patterns = {} -endif - -let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' - -fun! GotoDefinition_nimrod() - let cmd = printf("nimrod idetools --def --track:\"%s,%d,%d\" \"%s\"", - \ expand('%:p'), line('.'), col('.'), CurrentNimrodFile()) - - let defOut = system(cmd) - if v:shell_error - echoerr "error executing nimrod. exit code: " . v:shell_error - echoerr defOut - return 0 - endif - - let rawDef = matchstr(defOut, 'def\t\([^\n]*\)') - if rawDef == "" - echo "nimrod was unable to locate the definition" - 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 - -" Syntastic syntax checking -fun! SyntaxCheckers_nimrod_GetLocList() - let makeprg = 'nimrod check ' . CurrentNimrodFile() - let errorformat = &errorformat - - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) -endf +call nimrod#init() setlocal formatoptions-=t formatoptions+=croql setlocal comments=:# From 732e821bcda9b2487a066bb180fe8ff5370681c1 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sat, 10 Nov 2012 22:24:40 +0200 Subject: [PATCH 16/98] use unix file endings --- autoload/nimrod.vim | 264 ++++++++++++++++++++++---------------------- 1 file changed, 132 insertions(+), 132 deletions(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 8d7074b..d6bb12d 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -1,132 +1,132 @@ -fun! nimrod#init() -endf - -let g:nim_log = [] - -fun! s:UpdateNimLog() - 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 /^nimrod.*/ -endf - -augroup NimLog - au! - au BufEnter log://nimrod call s:UpdateNimLog() -augroup END - -fun! CurrentNimrodFile() - 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:nimrod_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) - let cmd = printf("nimrod idetools %s --track:\"%s,%d,%d\" \"%s\"", - \ a:op, expand('%:p'), line('.'), col('.'), CurrentNimrodFile()) - - call add(g:nim_log, cmd) - let output = system(cmd) - call add(g:nim_log, output) - return output -endf - -fun! NimComplete(findstart, base) - if a:findstart - if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' - return -1 - endif - return col('.') - else - let result = [] - let sugOut = NimExec("--suggest") - for line in split(sugOut, '\n') - let lineData = split(line, '\t') - if lineData[0] == "sug" - let kind = get(g:nimrod_symbol_types, lineData[1], '') - let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 } - call add(result, c) - endif - endfor - return result - endif -endf - -if !exists("g:neocomplcache_omni_patterns") - let g:neocomplcache_omni_patterns = {} -endif - -let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' - -fun! GotoDefinition_nimrod() - let defOut = NimExec("--def") - if v:shell_error - echo "nimrod was unable to locate the definition. exit code: " . v:shell_error - " echoerr defOut - return 0 - endif - - let rawDef = matchstr(defOut, '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("silent! e +%d %s", line, file) - return 1 -endf - -fun! FindReferences_nimrod() - setloclist() -endf - -" Syntastic syntax checking -fun! SyntaxCheckers_nimrod_GetLocList() - let makeprg = 'nimrod check ' . CurrentNimrodFile() - let errorformat = &errorformat - - return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) -endf - +fun! nimrod#init() +endf + +let g:nim_log = [] + +fun! s:UpdateNimLog() + 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 /^nimrod.*/ +endf + +augroup NimLog + au! + au BufEnter log://nimrod call s:UpdateNimLog() +augroup END + +fun! CurrentNimrodFile() + 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:nimrod_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) + let cmd = printf("nimrod idetools %s --track:\"%s,%d,%d\" \"%s\"", + \ a:op, expand('%:p'), line('.'), col('.'), CurrentNimrodFile()) + + call add(g:nim_log, cmd) + let output = system(cmd) + call add(g:nim_log, output) + return output +endf + +fun! NimComplete(findstart, base) + if a:findstart + if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' + return -1 + endif + return col('.') + else + let result = [] + let sugOut = NimExec("--suggest") + for line in split(sugOut, '\n') + let lineData = split(line, '\t') + if lineData[0] == "sug" + let kind = get(g:nimrod_symbol_types, lineData[1], '') + let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 } + call add(result, c) + endif + endfor + return result + endif +endf + +if !exists("g:neocomplcache_omni_patterns") + let g:neocomplcache_omni_patterns = {} +endif + +let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' + +fun! GotoDefinition_nimrod() + let defOut = NimExec("--def") + if v:shell_error + echo "nimrod was unable to locate the definition. exit code: " . v:shell_error + " echoerr defOut + return 0 + endif + + let rawDef = matchstr(defOut, '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("silent! e +%d %s", line, file) + return 1 +endf + +fun! FindReferences_nimrod() + setloclist() +endf + +" Syntastic syntax checking +fun! SyntaxCheckers_nimrod_GetLocList() + let makeprg = 'nimrod check ' . CurrentNimrodFile() + let errorformat = &errorformat + + return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) +endf + From 184f5fdb619dff2a4d59ea31236c441cbaa3eb1e Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Sat, 10 Nov 2012 22:17:26 +0100 Subject: [PATCH 17/98] Adds basic readme based on syntastic's one. --- README | 6 ----- README.markdown | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 6 deletions(-) delete mode 100644 README create mode 100644 README.markdown diff --git a/README b/README deleted file mode 100644 index 22605ce..0000000 --- a/README +++ /dev/null @@ -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 diff --git a/README.markdown b/README.markdown new file mode 100644 index 0000000..b978c40 --- /dev/null +++ b/README.markdown @@ -0,0 +1,72 @@ +Nimrod language support for Vim +------------------------------- + +This provides [Nimrod](http://nimrod-code.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 `nimrod.vim` is easy but first you need to have the pathogen plugin +installed. If you already have pathogen working then skip Step 1 and go to +Step 2. + +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/nimrod.vim.git + +Next you *need to add this* to your `~/.vimrc`: + + fun! JumpToDef() + if exists("*GotoDefinition_" . &filetype) + call GotoDefinition_{&filetype}() + else + exe "norm! \" + endif + endf + + " Jump to tag + nn :call JumpToDef() + ino :call JumpToDef()i + +The `JumpToDef` function hooks the `nimrod.vim` plugin to invoke the nimrod +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 nimrod 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 From 15a6f3e4acc54e6d10f319ed8202bae59c334c59 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Tue, 20 Nov 2012 00:26:36 +0200 Subject: [PATCH 18/98] disabled autosuggest as it really too slow for now. fix for nimdoc comments auto-formatting --- autoload/nimrod.vim | 4 ++-- ftplugin/nimrod.vim | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index d6bb12d..13ac84d 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -14,7 +14,7 @@ fun! s:UpdateNimLog() let g:nim_log = [] - match Search /^nimrod.*/ + match Search /^nimrod\ idetools.*/ endf augroup NimLog @@ -95,7 +95,7 @@ if !exists("g:neocomplcache_omni_patterns") let g:neocomplcache_omni_patterns = {} endif -let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' +" let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' fun! GotoDefinition_nimrod() let defOut = NimExec("--def") diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index e5ee894..5f97ed5 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -10,7 +10,7 @@ set cpo&vim call nimrod#init() setlocal formatoptions-=t formatoptions+=croql -setlocal comments=:# +setlocal comments=:##,:# setlocal commentstring=#\ %s setlocal omnifunc=NimComplete compiler nimrod From 00ee58f98b44abe5aced5968f11e0e759c93a4a6 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Fri, 1 Feb 2013 13:33:31 +0100 Subject: [PATCH 19/98] Adds more exceptions as keywords. --- syntax/nimrod.vim | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index e7e9a4a..a4b4032 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -119,7 +119,10 @@ if nimrod_highlight_exceptions == 1 syn keyword nimrodException EControlC EInvalidValue EOutOfMemory EInvalidIndex syn keyword nimrodException EInvalidField EOutOfRange EStackOverflow syn keyword nimrodException ENoExceptionToReraise EInvalidObjectAssignment - syn keyword nimrodException EInvalidObject + syn keyword nimrodException EInvalidObject EInvalidLibrary EInvalidKey + syn keyword nimrodException EInvalidObjectConversion EFloatingPoint + syn keyword nimrodException EFloatInvalidOp EFloatDivByZero EFloatOverflow + syn keyword nimrodException EFloatInexact EDeadThread endif if nimrod_highlight_space_errors == 1 From aa10e421b2b4585e411923c7ef26669420c68812 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Sun, 3 Feb 2013 17:49:05 +0100 Subject: [PATCH 20/98] 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. --- autoload/nimrod.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 13ac84d..328c2e4 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -62,7 +62,7 @@ let g:nimrod_symbol_types = { fun! NimExec(op) let cmd = printf("nimrod idetools %s --track:\"%s,%d,%d\" \"%s\"", - \ a:op, expand('%:p'), line('.'), col('.'), CurrentNimrodFile()) + \ a:op, expand('%:p'), line('.'), col('.')-1, CurrentNimrodFile()) call add(g:nim_log, cmd) let output = system(cmd) From ba7b7d6d026292933365b7e77fcf83e99fd6939d Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Sun, 24 Mar 2013 23:43:04 +0100 Subject: [PATCH 21/98] Adds note about log://nimrod to debug idetool interactions. --- README.markdown | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.markdown b/README.markdown index b978c40..c5bccb2 100644 --- a/README.markdown +++ b/README.markdown @@ -70,3 +70,17 @@ 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://nimrod`` and a buffer will open with the log of +the plugin's invocations and nimrod'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. From ca3142c5e27271ae1e36e87957b8fac9241ac172 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 10 Apr 2013 13:50:06 +0300 Subject: [PATCH 22/98] implements #7 --- ftplugin/nimrod.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index 5f97ed5..710b53e 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -13,6 +13,8 @@ setlocal formatoptions-=t formatoptions+=croql setlocal comments=:##,:# setlocal commentstring=#\ %s setlocal omnifunc=NimComplete +setlocal suffixesadd=.nim + compiler nimrod let &cpo = s:cpo_save From 4c3f2313b00bc033e16675bc7462f31c4510359b Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 10 Apr 2013 14:40:54 +0300 Subject: [PATCH 23/98] add nimrod library paths to vim's path variable --- ftplugin/nimrod.vim | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index 710b53e..d3b2b32 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -15,6 +15,17 @@ setlocal commentstring=#\ %s setlocal omnifunc=NimComplete setlocal suffixesadd=.nim +if executable('nimrod') + let nimrod_paths = split(system('nimrod dump'),'\n') + let &l:path = &g:path + + for path in nimrod_paths + if finddir(path) == path + let &l:path = path . "," . &l:path + endif + endfor +endif + compiler nimrod let &cpo = s:cpo_save From 63d5050ca0d8932c40b2b45134adab4b1ed0aa17 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Wed, 10 Apr 2013 22:42:41 +0200 Subject: [PATCH 24/98] 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. --- autoload/nimrod.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 328c2e4..f8d4da5 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -114,7 +114,7 @@ fun! GotoDefinition_nimrod() let defBits = split(rawDef, '\t') let file = defBits[4] let line = defBits[5] - exe printf("silent! e +%d %s", line, file) + exe printf("e +%d %s", line, file) return 1 endf From 43696ec2e34c8d46ada966d853f7aa908901c4d7 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 29 Apr 2013 09:49:56 +0300 Subject: [PATCH 25/98] work-in-progress towards integrating the compiler service --- autoload/nimrod.vim | 68 +++++++++++++++++++++++++-------- autoload/nimrod_vim.py | 87 ++++++++++++++++++++++++++++++++++++++++++ autoload/simulator.py | 18 +++++++++ 3 files changed, 158 insertions(+), 15 deletions(-) create mode 100644 autoload/nimrod_vim.py create mode 100644 autoload/simulator.py diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index f8d4da5..52f1bb7 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -1,18 +1,23 @@ +let g:nimrod_log = [] +let s:plugin_path = escape(expand(':p:h'), ' \') + +exe 'pyfile ' . fnameescape(s:plugin_path) . '/nimrod_vim.py' + fun! nimrod#init() + let b:nimrod_project_root = "/foo" + let b:nimrod_caas_enabled = 0 endf -let g:nim_log = [] - fun! s:UpdateNimLog() setlocal buftype=nofile setlocal bufhidden=hide setlocal noswapfile - for entry in g:nim_log + for entry in g:nimrod_log call append(line('$'), split(entry, "\n")) endfor - let g:nim_log = [] + let g:nimrod_log = [] match Search /^nimrod\ idetools.*/ endf @@ -22,7 +27,7 @@ augroup NimLog au BufEnter log://nimrod call s:UpdateNimLog() augroup END -fun! CurrentNimrodFile() +fun! s:CurrentNimrodFile() let save_cur = getpos('.') call cursor(0, 0, 0) @@ -61,15 +66,27 @@ let g:nimrod_symbol_types = { \ } fun! NimExec(op) - let cmd = printf("nimrod idetools %s --track:\"%s,%d,%d\" \"%s\"", - \ a:op, expand('%:p'), line('.'), col('.')-1, CurrentNimrodFile()) + let cmd = printf("idetools %s --track:\"%s,%d,%d\" \"%s\"", + \ a:op, expand('%:p'), line('.'), col('.')-1, s:CurrentNimrodFile()) + + if b:nimrod_caas_enabled + exe printf("py execNimCmd('%s', '%s', False)", b:nimrod_project_root, cmd) + let output = l:py_res + else + let syscmd = "nimrod " . cmd + call add(g:nimrod_log, syscmd) + let output = system(syscmd) + endif - call add(g:nim_log, cmd) - let output = system(cmd) - call add(g:nim_log, output) + call add(g:nimrod_log, output) return output endf +fun! NimExecAsync(op, Handler) + let result = NimExec(a:op) + call a:Handler(result) +endf + fun! NimComplete(findstart, base) if a:findstart if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' @@ -97,15 +114,32 @@ endif " let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' -fun! GotoDefinition_nimrod() - let defOut = NimExec("--def") +fun! StartNimrodThread() +endf + +let g:nimrod_completion_callbacks = {} + +fun! NimrodAsyncCmdComplete(cmd, output) + call add(g:nimrod_log, a:output) + echom g:nimrod_completion_callbacks + if has_key(g:nimrod_completion_callbacks, a:cmd) + let Callback = get(g:nimrod_completion_callbacks, a:cmd) + call Callback(a:output) + " remove(g:nimrod_completion_callbacks, a:cmd) + else + echom "ERROR, Unknown Command: " . a:cmd + endif + return 1 +endf + +fun! GotoDefinition_nimrod_ready(def_output) if v:shell_error echo "nimrod was unable to locate the definition. exit code: " . v:shell_error - " echoerr defOut + " echoerr a:def_output return 0 endif - let rawDef = matchstr(defOut, 'def\t\([^\n]*\)') + let rawDef = matchstr(a:def_output, 'def\t\([^\n]*\)') if rawDef == "" echo "the current cursor position does not match any definitions" return 0 @@ -118,13 +152,17 @@ fun! GotoDefinition_nimrod() return 1 endf +fun! GotoDefinition_nimrod() + call NimExecAsync("--def", function("GotoDefinition_nimrod_ready")) +endf + fun! FindReferences_nimrod() setloclist() endf " Syntastic syntax checking fun! SyntaxCheckers_nimrod_GetLocList() - let makeprg = 'nimrod check ' . CurrentNimrodFile() + let makeprg = 'nimrod check ' . s:CurrentNimrodFile() let errorformat = &errorformat return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) diff --git a/autoload/nimrod_vim.py b/autoload/nimrod_vim.py new file mode 100644 index 0000000..2c7201e --- /dev/null +++ b/autoload/nimrod_vim.py @@ -0,0 +1,87 @@ +import threading, Queue, subprocess, signal, os + +try: + import vim +except ImportError: + class Vim: + def command(self, x): + print("Executing vim command: " + x) + + vim = Vim() + +def disable_sigint(): + # Ignore the SIGINT signal by setting the handler to the standard + # signal handler SIG_IGN. + signal.signal(signal.SIGINT, signal.SIG_IGN) + +class NimrodThread(threading.Thread): + def __init__(self): + super(NimrodThread, self).__init__() + self.tasks = Queue.Queue() + self.responses = Queue.Queue() + self.nim = subprocess.Popen( + ["nimrod", "serve", "--server.type:stdin", "nimrod.nim"], + cwd = "/Users/zahary/Projects/nim/compiler", + stdin = subprocess.PIPE, + stdout = subprocess.PIPE, + stderr = subprocess.STDOUT, + universal_newlines = True, + preexec_fn = disable_sigint, + 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 vimEscapeExpr(expr): + return expr.replace("\\", "\\\\").replace('"', "\\\"").replace("\n", "\\n") + +class NimrodVimThread(NimrodThread): + def asyncOpComplete(self, msg, result): + cmd = "/usr/local/bin/mvim --remote-expr 'NimrodAsyncCmdComplete(1, \"" + vimEscapeExpr(result) + "\")'" + os.system (cmd) + +projects = {} + +log = open("/tmp/nim-log.txt", "w") + +def execNimCmd(project, cmd, async = True): + target = None + if projects.has_key(project): + target = projects[project] + else: + target = NimrodVimThread() + projects[project] = target + target.start() + + result = target.postNimCmd(cmd, async) + if result != None: + log.write(result) + log.flush() + + if not async: + vim.command('let l:py_res = "' + vimEscapeExpr(result) + '"') + diff --git a/autoload/simulator.py b/autoload/simulator.py new file mode 100644 index 0000000..10b244d --- /dev/null +++ b/autoload/simulator.py @@ -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 + From ffc49b7c2a79d78432788d6eddbf3560d4c8d8a5 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 1 May 2013 21:24:10 +0300 Subject: [PATCH 26/98] 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. --- autoload/nimrod.vim | 29 +++++++++++++++++++++++++++-- ftplugin/nimrod.vim | 11 ----------- 2 files changed, 27 insertions(+), 13 deletions(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 52f1bb7..87d5950 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -1,11 +1,34 @@ let g:nimrod_log = [] let s:plugin_path = escape(expand(':p:h'), ' \') +if !exists("g:nimrod_caas_enabled") + let g:nimrod_caas_enabled = 1 +endif + exe 'pyfile ' . fnameescape(s:plugin_path) . '/nimrod_vim.py' +if !executable('nimrod') + echoerr "the nimrod compiler must be in your system's PATH" +endif + fun! nimrod#init() - let b:nimrod_project_root = "/foo" - let b:nimrod_caas_enabled = 0 + let cmd = printf("nimrod --dump.format:json --verbosity:0 dump %s", s:CurrentNimrodFile()) + let raw_dumpdata = system(cmd) + if !v:shell_error + " the silent bit is to ignore a warning about trailing characters + let dumpdata = eval(substitute(raw_dumpdata, "\n", "", "g")) + + let b:nimrod_project_root = dumpdata['project_path'] + let b:nimrod_caas_enabled = g:nimrod_caas_enabled + + for path in dumpdata['lib_paths'] + if finddir(path) == path + let &l:path = path . "," . &l:path + endif + endfor + else + let b:nimrod_caas_enabled = 0 + endif endf fun! s:UpdateNimLog() @@ -27,6 +50,8 @@ augroup NimLog au BufEnter log://nimrod call s:UpdateNimLog() augroup END +command! NimLog :e log://nimrod + fun! s:CurrentNimrodFile() let save_cur = getpos('.') call cursor(0, 0, 0) diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index d3b2b32..710b53e 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -15,17 +15,6 @@ setlocal commentstring=#\ %s setlocal omnifunc=NimComplete setlocal suffixesadd=.nim -if executable('nimrod') - let nimrod_paths = split(system('nimrod dump'),'\n') - let &l:path = &g:path - - for path in nimrod_paths - if finddir(path) == path - let &l:path = path . "," . &l:path - endif - endfor -endif - compiler nimrod let &cpo = s:cpo_save From 0b09eeede5f8a1533c166fe97844834ceb2ee178 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 1 May 2013 22:26:48 +0300 Subject: [PATCH 27/98] remove some hard-coded paths --- autoload/nimrod_vim.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/autoload/nimrod_vim.py b/autoload/nimrod_vim.py index 2c7201e..120b9e9 100644 --- a/autoload/nimrod_vim.py +++ b/autoload/nimrod_vim.py @@ -15,13 +15,13 @@ def disable_sigint(): signal.signal(signal.SIGINT, signal.SIG_IGN) class NimrodThread(threading.Thread): - def __init__(self): + def __init__(self, project_path): super(NimrodThread, self).__init__() self.tasks = Queue.Queue() self.responses = Queue.Queue() self.nim = subprocess.Popen( - ["nimrod", "serve", "--server.type:stdin", "nimrod.nim"], - cwd = "/Users/zahary/Projects/nim/compiler", + ["nimrod", "serve", "--server.type:stdin", project_path], + cwd = os.path.dirname(project_path), stdin = subprocess.PIPE, stdout = subprocess.PIPE, stderr = subprocess.STDOUT, @@ -73,7 +73,7 @@ def execNimCmd(project, cmd, async = True): if projects.has_key(project): target = projects[project] else: - target = NimrodVimThread() + target = NimrodVimThread(project) projects[project] = target target.start() From fa9bd5972b36171d1ac9dfc6eda142e0610d70f7 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 5 May 2013 19:39:04 +0300 Subject: [PATCH 28/98] 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 --- autoload/nimrod.vim | 53 +++++++++++++++++++++++++++--------------- autoload/nimrod_vim.py | 49 +++++++++++++++++++++++--------------- 2 files changed, 64 insertions(+), 38 deletions(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 87d5950..518e014 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -5,21 +5,21 @@ if !exists("g:nimrod_caas_enabled") let g:nimrod_caas_enabled = 1 endif -exe 'pyfile ' . fnameescape(s:plugin_path) . '/nimrod_vim.py' - if !executable('nimrod') echoerr "the nimrod compiler must be in your system's PATH" endif +exe 'pyfile ' . fnameescape(s:plugin_path) . '/nimrod_vim.py' + fun! nimrod#init() let cmd = printf("nimrod --dump.format:json --verbosity:0 dump %s", s:CurrentNimrodFile()) let raw_dumpdata = system(cmd) if !v:shell_error - " the silent bit is to ignore a warning about trailing characters let dumpdata = eval(substitute(raw_dumpdata, "\n", "", "g")) let b:nimrod_project_root = dumpdata['project_path'] - let b:nimrod_caas_enabled = g:nimrod_caas_enabled + let b:nimrod_defined_symbols = dumpdata['defined_symbols'] + let b:nimrod_caas_enabled = g:nimrod_caas_enabled || index(dumpdata['defined_symbols'], 'forcecaas') != -1 for path in dumpdata['lib_paths'] if finddir(path) == path @@ -42,16 +42,24 @@ fun! s:UpdateNimLog() let g:nimrod_log = [] - match Search /^nimrod\ idetools.*/ + match Search /^nimrod\ .*/ endf -augroup NimLog +augroup NimrodVim au! au BufEnter log://nimrod call s:UpdateNimLog() + au QuitPre * :py nimTerminateAll() + au VimLeavePre * :py nimTerminateAll() augroup END command! NimLog :e log://nimrod +command! NimTerminateService + \ :exe printf("py nimTerminateService('%s')", b:nimrod_project_root) + +command! NimRestartService + \ :exe printf("py nimRestartService('%s')", b:nimrod_project_root) + fun! s:CurrentNimrodFile() let save_cur = getpos('.') call cursor(0, 0, 0) @@ -91,19 +99,26 @@ let g:nimrod_symbol_types = { \ } fun! NimExec(op) - let cmd = printf("idetools %s --track:\"%s,%d,%d\" \"%s\"", - \ a:op, expand('%:p'), line('.'), col('.')-1, s:CurrentNimrodFile()) + 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:CurrentNimrodFile()) + else + let cmd = printf("idetools %s --track:\"%s,%d,%d\" \"%s\"", + \ a:op, expand('%:p'), line('.'), col('.')-1, s:CurrentNimrodFile()) + endif if b:nimrod_caas_enabled - exe printf("py execNimCmd('%s', '%s', False)", b:nimrod_project_root, cmd) + exe printf("py nimExecCmd('%s', '%s', False)", b:nimrod_project_root, cmd) let output = l:py_res else - let syscmd = "nimrod " . cmd - call add(g:nimrod_log, syscmd) - let output = system(syscmd) + let output = system("nimrod " . cmd) endif - call add(g:nimrod_log, output) + call add(g:nimrod_log, "nimrod " . cmd . "\n" . output) return output endf @@ -113,6 +128,10 @@ fun! NimExecAsync(op, Handler) endf fun! NimComplete(findstart, base) + if b:nimrod_caas_enabled == 0 + return -1 + endif + if a:findstart if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' return -1 @@ -123,7 +142,7 @@ fun! NimComplete(findstart, base) let sugOut = NimExec("--suggest") for line in split(sugOut, '\n') let lineData = split(line, '\t') - if lineData[0] == "sug" + if len(lineData) > 0 && lineData[0] == "sug" let kind = get(g:nimrod_symbol_types, lineData[1], '') let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 } call add(result, c) @@ -137,11 +156,7 @@ if !exists("g:neocomplcache_omni_patterns") let g:neocomplcache_omni_patterns = {} endif -" let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' - -fun! StartNimrodThread() -endf - +let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' let g:nimrod_completion_callbacks = {} fun! NimrodAsyncCmdComplete(cmd, output) diff --git a/autoload/nimrod_vim.py b/autoload/nimrod_vim.py index 120b9e9..7a46b03 100644 --- a/autoload/nimrod_vim.py +++ b/autoload/nimrod_vim.py @@ -9,11 +9,6 @@ def command(self, x): vim = Vim() -def disable_sigint(): - # Ignore the SIGINT signal by setting the handler to the standard - # signal handler SIG_IGN. - signal.signal(signal.SIGINT, signal.SIG_IGN) - class NimrodThread(threading.Thread): def __init__(self, project_path): super(NimrodThread, self).__init__() @@ -26,7 +21,6 @@ def __init__(self, project_path): stdout = subprocess.PIPE, stderr = subprocess.STDOUT, universal_newlines = True, - preexec_fn = disable_sigint, bufsize = 1) def postNimCmd(self, msg, async = True): @@ -56,32 +50,49 @@ def run(self): break -def vimEscapeExpr(expr): +def nimVimEscape(expr): return expr.replace("\\", "\\\\").replace('"', "\\\"").replace("\n", "\\n") class NimrodVimThread(NimrodThread): def asyncOpComplete(self, msg, result): - cmd = "/usr/local/bin/mvim --remote-expr 'NimrodAsyncCmdComplete(1, \"" + vimEscapeExpr(result) + "\")'" + cmd = "/usr/local/bin/mvim --remote-expr 'NimrodAsyncCmdComplete(1, \"" + nimVimEscape(result) + "\")'" os.system (cmd) -projects = {} +NimProjects = {} + +def nimStartService(project): + target = NimrodVimThread(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) -log = open("/tmp/nim-log.txt", "w") +NimLog = open("/tmp/nim-log.txt", "w") -def execNimCmd(project, cmd, async = True): +def nimExecCmd(project, cmd, async = True): target = None - if projects.has_key(project): - target = projects[project] + if NimProjects.has_key(project): + target = NimProjects[project] else: - target = NimrodVimThread(project) - projects[project] = target - target.start() + target = nimStartService(project) result = target.postNimCmd(cmd, async) if result != None: - log.write(result) - log.flush() + NimLog.write(result) + NimLog.flush() if not async: - vim.command('let l:py_res = "' + vimEscapeExpr(result) + '"') + vim.command('let l:py_res = "' + nimVimEscape(result) + '"') +def nimTerminateAll(): + for thread in NimProjects.values(): + thread.postNimCmd("quit") + From 1d7ceef137a32699ca9c4787a2b07779d31b54e0 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Sun, 14 Jul 2013 22:22:00 +0200 Subject: [PATCH 29/98] Updates keyword list using nimrod's doc/keywords.txt. --- syntax/nimrod.vim | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index a4b4032..28a1939 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -32,19 +32,23 @@ syn region nimrodBrackets contained extend keepend matchgroup=Bold start=+ syn keyword nimrodKeyword addr and as asm atomic syn keyword nimrodKeyword bind block break syn keyword nimrodKeyword case cast const continue converter -syn keyword nimrodKeyword discard distinct div -syn keyword nimrodKeyword elif else enum except -syn keyword nimrodKeyword finally for from generic -syn keyword nimrodKeyword if implies import in include is isnot iterator +syn keyword nimrodKeyword discard distinct div do +syn keyword nimrodKeyword elif else end enum except export +syn keyword nimrodKeyword finally for from +syn keyword nimrodKeyword generic +syn keyword nimrodKeyword if import in include interface is isnot iterator syn keyword nimrodKeyword lambda let +syn keyword nimrodKeyword mixin mod syn keyword nimrodKeyword nil not notin syn keyword nimrodKeyword object of or out syn keyword nimrodKeyword proc method macro template nextgroup=nimrodFunction skipwhite +syn keyword nimrodKeyword ptr syn keyword nimrodKeyword raise ref return -syn keyword nimrodKeyword shl shr xom mod and +syn keyword nimrodKeyword shared shl shr static syn keyword nimrodKeyword try tuple type -syn keyword nimrodKeyword ptr var +syn keyword nimrodKeyword var syn keyword nimrodKeyword when while with without +syn keyword nimrodKeyword xor syn keyword nimrodKeyword yield syn match nimrodFunction "[a-zA-Z_][a-zA-Z0-9_]*" contained From 53bf9e840d758a61f843123b6d41e2adcafaa9e9 Mon Sep 17 00:00:00 2001 From: Davide D'Agostino Date: Tue, 30 Jul 2013 01:47:45 -0700 Subject: [PATCH 30/98] Added all ctypes --- syntax/nimrod.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index 28a1939..76af145 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -88,8 +88,8 @@ if nimrod_highlight_builtins == 1 syn keyword nimrodBuiltin int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 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 BiggestInt BiggestFloat cchar cschar cshort cint csize cuchar cushort + syn keyword nimrodBuiltin clong clonglong cfloat cdouble clongdouble cuint culong culonglong cchar 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 From 3d9f5fac0853141f9842ab9d17f7587dcb061671 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 6 May 2013 00:51:03 +0300 Subject: [PATCH 31/98] re-integrate with the latest version of syntastic --- autoload/nimrod.vim | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 518e014..38ea26e 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -201,10 +201,17 @@ fun! FindReferences_nimrod() endf " Syntastic syntax checking -fun! SyntaxCheckers_nimrod_GetLocList() +fun! SyntaxCheckers_nimrod_nimrod_GetLocList() let makeprg = 'nimrod check ' . s:CurrentNimrodFile() let errorformat = &errorformat return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endf +function! SyntaxCheckers_nimrod_nimrod_IsAvailable() + return executable("nimrod") +endfunction + +call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'nimrod', + \ 'name': 'nimrod'}) From bebdd7bb99c15b84a34123573ff78b2eda2f8c44 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sat, 24 Aug 2013 17:30:22 +0300 Subject: [PATCH 32/98] various auto-indenting improvements; fixes #10 --- autoload/nimrod.vim | 2 +- indent/nimrod.vim | 45 +++++++++++++++++++++++++++++---------------- 2 files changed, 30 insertions(+), 17 deletions(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 38ea26e..2782560 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -48,7 +48,7 @@ endf augroup NimrodVim au! au BufEnter log://nimrod call s:UpdateNimLog() - au QuitPre * :py nimTerminateAll() + " au QuitPre * :py nimTerminateAll() au VimLeavePre * :py nimTerminateAll() augroup END diff --git a/indent/nimrod.vim b/indent/nimrod.vim index d413f4e..280a1eb 100644 --- a/indent/nimrod.vim +++ b/indent/nimrod.vim @@ -16,6 +16,18 @@ if exists("*GetNimrodIndent") 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! GetNimrodIndent(lnum) " Search backwards for the previous non-empty line. let plnum = prevnonblank(a:lnum - 1) @@ -64,11 +76,23 @@ function! GetNimrodIndent(lnum) let col = col + 1 endwhile endif - + if pline =~ ':\s*$' - \ || pline =~ '=\s*$' - \ || pline =~ '\(type\|import\|const\|var\)\s*$' - \ || pline =~ '=\s*\(object\|enum\)' + "return s:FindStartLine(plnum, '(^\s*\(if\|when\|else\|elif\|case\|of\|try\|except\|finally\)\>)\|\') + &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\)\s*$' + \ || pline =~ '=\s*\(object\|enum\|tuple\|generic\)' return plindent + &sw endif @@ -101,18 +125,7 @@ function! GetNimrodIndent(lnum) " If the current line begins with a header keyword, dedent if getline(a:lnum) =~ '^\s*\(elif\|else\)\>' - - " Unless the previous line was a one-liner - "if getline(plnumstart) =~ '^\s*\(for\|if\|try\)\>' - "return plindent - "endif - - " Or the user has already dedented - if clindent <= plindent - &sw - return -1 - endif - - return plindent - &sw + return s:FindStartLine(a:lnum, '^\s*\(if\|when\|elif\|of\)') endif return -1 From f947b48cda8523be471047834e968ff8e9e9c2a9 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 25 Aug 2013 14:47:26 +0300 Subject: [PATCH 33/98] more auto-indenting improvements --- indent/nimrod.vim | 48 ++++++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 21 deletions(-) diff --git a/indent/nimrod.vim b/indent/nimrod.vim index 280a1eb..92ae499 100644 --- a/indent/nimrod.vim +++ b/indent/nimrod.vim @@ -43,6 +43,7 @@ function! GetNimrodIndent(lnum) endif let pline = getline(plnum) + let cline = getline(a:lnum) let pline_len = strlen(pline) let plindent = indent(plnum) let clindent = indent(a:lnum) @@ -77,6 +78,32 @@ function! GetNimrodIndent(lnum) 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\)\>)\|\') + &sw return s:FindStartLine(plnum, '^\s*\(if\|when\|else\|elif\|for\|while\|case\|of\|try\|except\|finally\)\>') + &sw @@ -107,27 +134,6 @@ function! GetNimrodIndent(lnum) return -1 endif - " If the current line begins with a keyword that lines up with "try" - if getline(a:lnum) =~ '^\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 getline(a:lnum) =~ '^\s*\(elif\|else\)\>' - return s:FindStartLine(a:lnum, '^\s*\(if\|when\|elif\|of\)') - endif - return -1 endfunction From d2f05bc1a66d41d33e59b2d2d7f06bb35bfb72fa Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Mon, 9 Dec 2013 23:45:56 +0200 Subject: [PATCH 34/98] fixes #17 --- autoload/nimrod.vim | 9 ++++++--- syntax/nimrod.vim | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 2782560..9d6e209 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -212,6 +212,9 @@ function! SyntaxCheckers_nimrod_nimrod_IsAvailable() return executable("nimrod") endfunction -call g:SyntasticRegistry.CreateAndRegisterChecker({ - \ 'filetype': 'nimrod', - \ 'name': 'nimrod'}) +if exists("g:SyntasticRegistry") + call g:SyntasticRegistry.CreateAndRegisterChecker({ + \ 'filetype': 'nimrod', + \ 'name': 'nimrod'}) +endif + diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index 76af145..0de7c6b 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -38,7 +38,7 @@ syn keyword nimrodKeyword finally for from syn keyword nimrodKeyword generic syn keyword nimrodKeyword if import in include interface is isnot iterator syn keyword nimrodKeyword lambda let -syn keyword nimrodKeyword mixin mod +syn keyword nimrodKeyword mixin using mod syn keyword nimrodKeyword nil not notin syn keyword nimrodKeyword object of or out syn keyword nimrodKeyword proc method macro template nextgroup=nimrodFunction skipwhite From f6bd6cfd251850dd3933be666f1b0a5a4c52c4a8 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Tue, 10 Dec 2013 01:36:15 +0200 Subject: [PATCH 35/98] basic QuickRun support; implements #6 --- autoload/nimrod.vim | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 9d6e209..cd71cfa 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -218,3 +218,11 @@ if exists("g:SyntasticRegistry") \ 'name': 'nimrod'}) endif +if !exists("g:quickrun_config") + let g:quickrun_config = {} +endif + +if !exists("g:quickrun_config.nimrod") + let g:quickrun_config.nimrod = { "exec": "nimrod c --run --verbosity:0 %S" } +endif + From 6de870a10a09e511d18cb9255dd7102b3e959597 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Tue, 10 Dec 2013 11:09:14 +0100 Subject: [PATCH 36/98] 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. --- autoload/nimrod.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index cd71cfa..3742651 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -202,7 +202,7 @@ endf " Syntastic syntax checking fun! SyntaxCheckers_nimrod_nimrod_GetLocList() - let makeprg = 'nimrod check ' . s:CurrentNimrodFile() + let makeprg = 'nimrod check --hints:off ' . s:CurrentNimrodFile() let errorformat = &errorformat return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) From bdcff60d77000d05ddec498108054dce18d838a3 Mon Sep 17 00:00:00 2001 From: flaviut Date: Mon, 3 Mar 2014 17:09:25 -0500 Subject: [PATCH 37/98] Added Vundle installation instructions Also changed section headings to `#`s in order to make deeper nesting possible --- README.markdown | 56 +++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 13 deletions(-) diff --git a/README.markdown b/README.markdown index c5bccb2..dbc11ba 100644 --- a/README.markdown +++ b/README.markdown @@ -1,5 +1,4 @@ -Nimrod language support for Vim -------------------------------- +#Nimrod language support for Vim This provides [Nimrod](http://nimrod-code.org) language support for Vim: @@ -13,15 +12,14 @@ 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 ------------- +#Installation +##Pathogen Installing `nimrod.vim` is easy but first you need to have the pathogen plugin installed. If you already have pathogen working then skip Step 1 and go to Step 2. -Step 1: Install pathogen.vim ----------------------------- +###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 @@ -36,8 +34,7 @@ Next you *need to add this* to your `~/.vimrc`: call pathogen#infect() -Step 2: Install nimrod.vim as a pathogen bundle ------------------------------------------------ +###Step 2: Install nimrod.vim as a pathogen bundle You now have pathogen installed and can put `nimrod.vim` into `~/.vim/bundle` like this: @@ -45,6 +42,41 @@ like this: cd ~/.vim/bundle git clone git://github.com/zah/nimrod.vim.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 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 nimrod.vim + +On the line after `Bundle 'gmarik/vundle'`, add `Bundle 'zah/nimrod.vim'`. +Save `~/.vimrc` and restart vim. Execute `:BundleInstall` and wait for nimrod.vim +to be installed. + +##Final Step Next you *need to add this* to your `~/.vimrc`: fun! JumpToDef() @@ -64,15 +96,13 @@ 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 nimrod 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 ----------------------------- + +#Other recomended Vim plugins * https://github.com/scrooloose/syntastic (copied bits from its readme) * https://github.com/Shougo/neocomplcache -If something goes wrong ------------------------ +#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 From ab0b173d0b6463f1f3f554961e2af44d2907c40b Mon Sep 17 00:00:00 2001 From: flaviut Date: Mon, 3 Mar 2014 17:12:57 -0500 Subject: [PATCH 38/98] Make readme more consistant Added text under instructions, added link to final step --- README.markdown | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index dbc11ba..4c7448e 100644 --- a/README.markdown +++ b/README.markdown @@ -14,10 +14,10 @@ modified python.vim (http://www.vim.org/scripts/script.php?script_id=790). #Installation +Installing `nimrod.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) + ##Pathogen -Installing `nimrod.vim` is easy but first you need to have the pathogen plugin -installed. If you already have pathogen working then skip Step 1 and go to -Step 2. ###Step 1: Install pathogen.vim @@ -53,7 +53,7 @@ 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 https://github.com/gmarik/Vundle.vim/blob/master/README.md +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 From b952e2bc23784235de3504789b704bd4c836ba49 Mon Sep 17 00:00:00 2001 From: flaviut Date: Wed, 5 Mar 2014 17:51:38 -0500 Subject: [PATCH 39/98] Reccomend Synastic --- README.markdown | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index 4c7448e..c702c80 100644 --- a/README.markdown +++ b/README.markdown @@ -15,7 +15,8 @@ modified python.vim (http://www.vim.org/scripts/script.php?script_id=790). #Installation Installing `nimrod.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) +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 @@ -41,6 +42,10 @@ like this: cd ~/.vim/bundle git clone git://github.com/zah/nimrod.vim.git + +You may also want to install synastic by calling + + git clone https://github.com/scrooloose/syntastic.git ##Vundle @@ -72,9 +77,9 @@ Modify your ~/.vimrc to get vundle running, lightly adapted from [Vundle's readm ###Step 2: Install nimrod.vim -On the line after `Bundle 'gmarik/vundle'`, add `Bundle 'zah/nimrod.vim'`. -Save `~/.vimrc` and restart vim. Execute `:BundleInstall` and wait for nimrod.vim -to be installed. +On the line after `Bundle 'gmarik/vundle'`, add `Bundle 'zah/nimrod.vim'`. You may also want +to add `Bundle 'scrooloose/syntastic'`. Save `~/.vimrc` and restart vim. Execute `:BundleInstall` +and wait for nimrod.vim to be installed. ##Final Step Next you *need to add this* to your `~/.vimrc`: From 02b735ae7cac21fabffab90cafacd927b61e4f37 Mon Sep 17 00:00:00 2001 From: flaviut Date: Wed, 5 Mar 2014 17:56:54 -0500 Subject: [PATCH 40/98] Make tabs automaticly turn into spaces --- syntax/nimrod.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index 0de7c6b..88f9c72 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -185,3 +185,4 @@ endif let b:current_syntax = "nimrod" +setlocal expandtab "Make sure that only spaces are used From e27dd52829c7df4a48c859fc6226bf81e441ab3e Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 6 Mar 2014 11:35:47 +0200 Subject: [PATCH 41/98] move expandtab to the ftplugin for more consistency --- ftplugin/nimrod.vim | 1 + syntax/nimrod.vim | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index 710b53e..8a38962 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -14,6 +14,7 @@ setlocal comments=:##,:# setlocal commentstring=#\ %s setlocal omnifunc=NimComplete setlocal suffixesadd=.nim +setlocal expandtab "Make sure that only spaces are used compiler nimrod diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index 88f9c72..0de7c6b 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -185,4 +185,3 @@ endif let b:current_syntax = "nimrod" -setlocal expandtab "Make sure that only spaces are used From b71a49f219bbdbd6806548a3e96c17ef75a766b2 Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Tue, 5 Aug 2014 18:32:23 +0200 Subject: [PATCH 42/98] Adds missing exceptions for highlighting. --- syntax/nimrod.vim | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/syntax/nimrod.vim b/syntax/nimrod.vim index 0de7c6b..2a47a2b 100644 --- a/syntax/nimrod.vim +++ b/syntax/nimrod.vim @@ -126,7 +126,8 @@ if nimrod_highlight_exceptions == 1 syn keyword nimrodException EInvalidObject EInvalidLibrary EInvalidKey syn keyword nimrodException EInvalidObjectConversion EFloatingPoint syn keyword nimrodException EFloatInvalidOp EFloatDivByZero EFloatOverflow - syn keyword nimrodException EFloatInexact EDeadThread + syn keyword nimrodException EFloatInexact EDeadThread EResourceExhausted + syn keyword nimrodException EFloatUnderflow endif if nimrod_highlight_space_errors == 1 From eecfe9b81fe702bcb445c34eb77af689f2d6a451 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 4 Sep 2014 22:44:36 +0300 Subject: [PATCH 43/98] Rename Nimrod to Nim --- autoload/nimrod.vim | 102 ++++++++++++++++++++--------------------- autoload/nimrod_vim.py | 12 ++--- compiler/nimrod.vim | 4 +- ftdetect/nimrod.vim | 2 +- ftplugin/nimrod.vim | 8 ++-- indent/nimrod.vim | 6 +-- 6 files changed, 67 insertions(+), 67 deletions(-) diff --git a/autoload/nimrod.vim b/autoload/nimrod.vim index 3742651..57e0bb1 100644 --- a/autoload/nimrod.vim +++ b/autoload/nimrod.vim @@ -1,25 +1,25 @@ -let g:nimrod_log = [] +let g:nim_log = [] let s:plugin_path = escape(expand(':p:h'), ' \') -if !exists("g:nimrod_caas_enabled") - let g:nimrod_caas_enabled = 1 +if !exists("g:nim_caas_enabled") + let g:nim_caas_enabled = 1 endif -if !executable('nimrod') - echoerr "the nimrod compiler must be in your system's PATH" +if !executable('nim') + echoerr "the Nim compiler must be in your system's PATH" endif -exe 'pyfile ' . fnameescape(s:plugin_path) . '/nimrod_vim.py' +exe 'pyfile ' . fnameescape(s:plugin_path) . '/nim_vim.py' -fun! nimrod#init() - let cmd = printf("nimrod --dump.format:json --verbosity:0 dump %s", s:CurrentNimrodFile()) +fun! nim#init() + let cmd = printf("nim --dump.format:json --verbosity:0 dump %s", s:CurrentNimFile()) let raw_dumpdata = system(cmd) if !v:shell_error let dumpdata = eval(substitute(raw_dumpdata, "\n", "", "g")) - let b:nimrod_project_root = dumpdata['project_path'] - let b:nimrod_defined_symbols = dumpdata['defined_symbols'] - let b:nimrod_caas_enabled = g:nimrod_caas_enabled || index(dumpdata['defined_symbols'], 'forcecaas') != -1 + 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 @@ -27,7 +27,7 @@ fun! nimrod#init() endif endfor else - let b:nimrod_caas_enabled = 0 + let b:nim_caas_enabled = 0 endif endf @@ -36,31 +36,31 @@ fun! s:UpdateNimLog() setlocal bufhidden=hide setlocal noswapfile - for entry in g:nimrod_log + for entry in g:nim_log call append(line('$'), split(entry, "\n")) endfor - let g:nimrod_log = [] + let g:nim_log = [] - match Search /^nimrod\ .*/ + match Search /^nim\ .*/ endf -augroup NimrodVim +augroup NimVim au! - au BufEnter log://nimrod call s:UpdateNimLog() + au BufEnter log://nim call s:UpdateNimLog() " au QuitPre * :py nimTerminateAll() au VimLeavePre * :py nimTerminateAll() augroup END -command! NimLog :e log://nimrod +command! NimLog :e log://nim command! NimTerminateService - \ :exe printf("py nimTerminateService('%s')", b:nimrod_project_root) + \ :exe printf("py nimTerminateService('%s')", b:nim_project_root) command! NimRestartService - \ :exe printf("py nimRestartService('%s')", b:nimrod_project_root) + \ :exe printf("py nimRestartService('%s')", b:nim_project_root) -fun! s:CurrentNimrodFile() +fun! s:CurrentNimFile() let save_cur = getpos('.') call cursor(0, 0, 0) @@ -78,7 +78,7 @@ fun! s:CurrentNimrodFile() return l:to_check endf -let g:nimrod_symbol_types = { +let g:nim_symbol_types = { \ 'skParam': 'v', \ 'skVar': 'v', \ 'skLet': 'v', @@ -105,20 +105,20 @@ fun! NimExec(op) silent! exe ":w " . tmp let cmd = printf("idetools %s --trackDirty:\"%s,%s,%d,%d\" \"%s\"", - \ a:op, tmp, expand('%:p'), line('.'), col('.')-1, s:CurrentNimrodFile()) + \ 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:CurrentNimrodFile()) + \ a:op, expand('%:p'), line('.'), col('.')-1, s:CurrentNimFile()) endif - if b:nimrod_caas_enabled - exe printf("py nimExecCmd('%s', '%s', False)", b:nimrod_project_root, cmd) + if b:nim_caas_enabled + exe printf("py nimExecCmd('%s', '%s', False)", b:nim_project_root, cmd) let output = l:py_res else - let output = system("nimrod " . cmd) + let output = system("nim " . cmd) endif - call add(g:nimrod_log, "nimrod " . cmd . "\n" . output) + call add(g:nim_log, "nim " . cmd . "\n" . output) return output endf @@ -128,7 +128,7 @@ fun! NimExecAsync(op, Handler) endf fun! NimComplete(findstart, base) - if b:nimrod_caas_enabled == 0 + if b:nim_caas_enabled == 0 return -1 endif @@ -143,7 +143,7 @@ fun! NimComplete(findstart, base) for line in split(sugOut, '\n') let lineData = split(line, '\t') if len(lineData) > 0 && lineData[0] == "sug" - let kind = get(g:nimrod_symbol_types, lineData[1], '') + let kind = get(g:nim_symbol_types, lineData[1], '') let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 } call add(result, c) endif @@ -156,25 +156,25 @@ if !exists("g:neocomplcache_omni_patterns") let g:neocomplcache_omni_patterns = {} endif -let g:neocomplcache_omni_patterns['nimrod'] = '[^. *\t]\.\w*' -let g:nimrod_completion_callbacks = {} +let g:neocomplcache_omni_patterns['nim'] = '[^. *\t]\.\w*' +let g:nim_completion_callbacks = {} -fun! NimrodAsyncCmdComplete(cmd, output) - call add(g:nimrod_log, a:output) - echom g:nimrod_completion_callbacks - if has_key(g:nimrod_completion_callbacks, a:cmd) - let Callback = get(g:nimrod_completion_callbacks, a:cmd) +fun! NimAsyncCmdComplete(cmd, output) + 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:nimrod_completion_callbacks, a:cmd) + " remove(g:nim_completion_callbacks, a:cmd) else echom "ERROR, Unknown Command: " . a:cmd endif return 1 endf -fun! GotoDefinition_nimrod_ready(def_output) +fun! GotoDefinition_nim_ready(def_output) if v:shell_error - echo "nimrod was unable to locate the definition. exit code: " . v:shell_error + echo "nim was unable to locate the definition. exit code: " . v:shell_error " echoerr a:def_output return 0 endif @@ -192,37 +192,37 @@ fun! GotoDefinition_nimrod_ready(def_output) return 1 endf -fun! GotoDefinition_nimrod() - call NimExecAsync("--def", function("GotoDefinition_nimrod_ready")) +fun! GotoDefinition_nim() + call NimExecAsync("--def", function("GotoDefinition_nim_ready")) endf -fun! FindReferences_nimrod() +fun! FindReferences_nim() setloclist() endf " Syntastic syntax checking -fun! SyntaxCheckers_nimrod_nimrod_GetLocList() - let makeprg = 'nimrod check --hints:off ' . s:CurrentNimrodFile() +fun! SyntaxCheckers_nim_nim_GetLocList() + let makeprg = 'nim check --hints:off ' . s:CurrentNimFile() let errorformat = &errorformat return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) endf -function! SyntaxCheckers_nimrod_nimrod_IsAvailable() - return executable("nimrod") +function! SyntaxCheckers_nim_nim_IsAvailable() + return executable("nim") endfunction if exists("g:SyntasticRegistry") call g:SyntasticRegistry.CreateAndRegisterChecker({ - \ 'filetype': 'nimrod', - \ 'name': 'nimrod'}) + \ 'filetype': 'nim', + \ 'name': 'nim'}) endif if !exists("g:quickrun_config") let g:quickrun_config = {} endif -if !exists("g:quickrun_config.nimrod") - let g:quickrun_config.nimrod = { "exec": "nimrod c --run --verbosity:0 %S" } +if !exists("g:quickrun_config.nim") + let g:quickrun_config.nim = { "exec": "nim c --run --verbosity:0 %S" } endif diff --git a/autoload/nimrod_vim.py b/autoload/nimrod_vim.py index 7a46b03..0c36fcf 100644 --- a/autoload/nimrod_vim.py +++ b/autoload/nimrod_vim.py @@ -9,13 +9,13 @@ def command(self, x): vim = Vim() -class NimrodThread(threading.Thread): +class NimThread(threading.Thread): def __init__(self, project_path): - super(NimrodThread, self).__init__() + super(NimThread, self).__init__() self.tasks = Queue.Queue() self.responses = Queue.Queue() self.nim = subprocess.Popen( - ["nimrod", "serve", "--server.type:stdin", project_path], + ["nim", "serve", "--server.type:stdin", project_path], cwd = os.path.dirname(project_path), stdin = subprocess.PIPE, stdout = subprocess.PIPE, @@ -53,15 +53,15 @@ def run(self): def nimVimEscape(expr): return expr.replace("\\", "\\\\").replace('"', "\\\"").replace("\n", "\\n") -class NimrodVimThread(NimrodThread): +class NimVimThread(NimThread): def asyncOpComplete(self, msg, result): - cmd = "/usr/local/bin/mvim --remote-expr 'NimrodAsyncCmdComplete(1, \"" + nimVimEscape(result) + "\")'" + cmd = "/usr/local/bin/mvim --remote-expr 'NimAsyncCmdComplete(1, \"" + nimVimEscape(result) + "\")'" os.system (cmd) NimProjects = {} def nimStartService(project): - target = NimrodVimThread(project) + target = NimVimThread(project) NimProjects[project] = target target.start() return target diff --git a/compiler/nimrod.vim b/compiler/nimrod.vim index 1219333..1db1fd8 100644 --- a/compiler/nimrod.vim +++ b/compiler/nimrod.vim @@ -2,7 +2,7 @@ if exists("current_compiler") finish endif -let current_compiler = "nimrod" +let current_compiler = "nim" if exists(":CompilerSet") != 2 " older Vim always used :setlocal command -nargs=* CompilerSet setlocal @@ -11,7 +11,7 @@ endif let s:cpo_save = &cpo set cpo-=C -CompilerSet makeprg=nimrod\ c\ $* +CompilerSet makeprg=nim\ c\ $* CompilerSet errorformat= \%-GHint:\ %m, diff --git a/ftdetect/nimrod.vim b/ftdetect/nimrod.vim index 04ea13e..20dbbe3 100644 --- a/ftdetect/nimrod.vim +++ b/ftdetect/nimrod.vim @@ -1,2 +1,2 @@ -au BufNewFile,BufRead *.nim set filetype=nimrod +au BufNewFile,BufRead *.nim set filetype=nim diff --git a/ftplugin/nimrod.vim b/ftplugin/nimrod.vim index 8a38962..5e7febf 100644 --- a/ftplugin/nimrod.vim +++ b/ftplugin/nimrod.vim @@ -1,13 +1,13 @@ -if exists("b:nimrod_loaded") +if exists("b:nim_loaded") finish endif -let b:nimrod_loaded = 1 +let b:nim_loaded = 1 let s:cpo_save = &cpo set cpo&vim -call nimrod#init() +call nim#init() setlocal formatoptions-=t formatoptions+=croql setlocal comments=:##,:# @@ -16,7 +16,7 @@ setlocal omnifunc=NimComplete setlocal suffixesadd=.nim setlocal expandtab "Make sure that only spaces are used -compiler nimrod +compiler nim let &cpo = s:cpo_save unlet s:cpo_save diff --git a/indent/nimrod.vim b/indent/nimrod.vim index 92ae499..06d6150 100644 --- a/indent/nimrod.vim +++ b/indent/nimrod.vim @@ -8,11 +8,11 @@ let b:did_indent = 1 setlocal nolisp " Make sure lisp indenting doesn't supersede us setlocal autoindent " indentexpr isn't much help otherwise -setlocal indentexpr=GetNimrodIndent(v:lnum) +setlocal indentexpr=GetNimIndent(v:lnum) setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif " Only define the function once. -if exists("*GetNimrodIndent") +if exists("*GetNimIndent") finish endif @@ -28,7 +28,7 @@ function! s:FindStartLine(fromln, pattern) return indent(lnum) endfunction -function! GetNimrodIndent(lnum) +function! GetNimIndent(lnum) " Search backwards for the previous non-empty line. let plnum = prevnonblank(a:lnum - 1) From 8d2db427b4a07a73dca7d80c61191c213f5e68a8 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 4 Sep 2014 22:47:42 +0300 Subject: [PATCH 44/98] more renames --- autoload/{nimrod.vim => nim.vim} | 0 autoload/{nimrod_vim.py => nim_vim.py} | 0 compiler/{nimrod.vim => nim.vim} | 0 ftdetect/{nimrod.vim => nim.vim} | 0 ftplugin/{nimrod.vim => nim.vim} | 0 indent/{nimrod.vim => nim.vim} | 0 syntax/{nimrod.vim => nim.vim} | 0 7 files changed, 0 insertions(+), 0 deletions(-) rename autoload/{nimrod.vim => nim.vim} (100%) rename autoload/{nimrod_vim.py => nim_vim.py} (100%) rename compiler/{nimrod.vim => nim.vim} (100%) rename ftdetect/{nimrod.vim => nim.vim} (100%) rename ftplugin/{nimrod.vim => nim.vim} (100%) rename indent/{nimrod.vim => nim.vim} (100%) rename syntax/{nimrod.vim => nim.vim} (100%) diff --git a/autoload/nimrod.vim b/autoload/nim.vim similarity index 100% rename from autoload/nimrod.vim rename to autoload/nim.vim diff --git a/autoload/nimrod_vim.py b/autoload/nim_vim.py similarity index 100% rename from autoload/nimrod_vim.py rename to autoload/nim_vim.py diff --git a/compiler/nimrod.vim b/compiler/nim.vim similarity index 100% rename from compiler/nimrod.vim rename to compiler/nim.vim diff --git a/ftdetect/nimrod.vim b/ftdetect/nim.vim similarity index 100% rename from ftdetect/nimrod.vim rename to ftdetect/nim.vim diff --git a/ftplugin/nimrod.vim b/ftplugin/nim.vim similarity index 100% rename from ftplugin/nimrod.vim rename to ftplugin/nim.vim diff --git a/indent/nimrod.vim b/indent/nim.vim similarity index 100% rename from indent/nimrod.vim rename to indent/nim.vim diff --git a/syntax/nimrod.vim b/syntax/nim.vim similarity index 100% rename from syntax/nimrod.vim rename to syntax/nim.vim From 05fdf7eac615a2bb0fa5870668fd65b6f284dd65 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 4 Sep 2014 22:53:02 +0300 Subject: [PATCH 45/98] some final Nimrod to Nim renames --- syntax/nim.vim | 262 ++++++++++++++++++++++++------------------------- 1 file changed, 131 insertions(+), 131 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 2a47a2b..263160e 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -7,182 +7,182 @@ elseif exists("b:current_syntax") endif " Keep user-supplied options -if !exists("nimrod_highlight_numbers") - let nimrod_highlight_numbers = 1 +if !exists("nim_highlight_numbers") + let nim_highlight_numbers = 1 endif -if !exists("nimrod_highlight_builtins") - let nimrod_highlight_builtins = 1 +if !exists("nim_highlight_builtins") + let nim_highlight_builtins = 1 endif -if !exists("nimrod_highlight_exceptions") - let nimrod_highlight_exceptions = 1 +if !exists("nim_highlight_exceptions") + let nim_highlight_exceptions = 1 endif -if !exists("nimrod_highlight_space_errors") - let nimrod_highlight_space_errors = 1 +if !exists("nim_highlight_space_errors") + let nim_highlight_space_errors = 1 endif -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 +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 endif -syn region nimrodBrackets contained extend keepend matchgroup=Bold start=+\(\\\)\@" - syn match nimrodNumber "\v<[0-9_]+(\'(i|I|f|F|u|U)(8|16|32|64))?>" - syn match nimrodNumber "\v\.[0-9_]+([eE][+-]=[0-9_]+)=>" - syn match nimrodNumber "\v<[0-9_]+(\.[0-9_]+)?([eE][+-]?[0-9_]+)?(\'(f|F)(32|64))?>" + syn match nimNumber "\v<0x\x+(\'(i|I|f|F|u|U)(8|16|32|64))?>" + syn match nimNumber "\v<[0-9_]+(\'(i|I|f|F|u|U)(8|16|32|64))?>" + syn match nimNumber "\v\.[0-9_]+([eE][+-]=[0-9_]+)=>" + syn match nimNumber "\v<[0-9_]+(\.[0-9_]+)?([eE][+-]?[0-9_]+)?(\'(f|F)(32|64))?>" endif -if nimrod_highlight_builtins == 1 +if nim_highlight_builtins == 1 " builtin functions, types and objects, not really part of the syntax - syn keyword nimrodBuiltin int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 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 csize cuchar cushort - syn keyword nimrodBuiltin clong clonglong cfloat cdouble clongdouble cuint culong culonglong cchar - 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 "\" - 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 + syn keyword nimBuiltin int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 float64 bool + syn keyword nimBuiltin char string cstring pointer range array openarray seq + syn keyword nimBuiltin set Byte Natural Positive TObject PObject Conversion TResult TAddress + 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 cstringArray TEndian PFloat32 PFloat64 PInt64 PInt32 + syn keyword nimBuiltin TGC_Strategy TFile TFileMode TFileHandle isMainModule + syn keyword nimBuiltin CompileDate CompileTime nimVersion nimMajor + syn keyword nimBuiltin nimMinor nimPatch cpuEndian hostOS hostCPU inf + syn keyword nimBuiltin neginf nan QuitSuccess QuitFailure dbgLineHook stdin + syn keyword nimBuiltin stdout stderr defined new high low sizeof succ pred + syn keyword nimBuiltin inc dec newSeq len incl excl card ord chr ze ze64 + syn keyword nimBuiltin toU8 toU16 toU32 abs min max add repr + syn match nimBuiltin "\" + syn keyword nimBuiltin toFloat toBiggestFloat toInt toBiggestInt addQuitProc + syn keyword nimBuiltin copy setLen newString zeroMem copyMem moveMem + syn keyword nimBuiltin equalMem alloc alloc0 realloc dealloc setLen assert + syn keyword nimBuiltin swap getRefcount getCurrentException Msg + syn keyword nimBuiltin getOccupiedMem getFreeMem getTotalMem isNil seqToPtr + syn keyword nimBuiltin find pop GC_disable GC_enable GC_fullCollect + syn keyword nimBuiltin GC_setStrategy GC_enableMarkAnd Sweep + 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 write readLine writeln writeln + syn keyword nimBuiltin getFileSize ReadBytes ReadChars readBuffer writeBytes + syn keyword nimBuiltin writeChars writeBuffer setFilePos getFilePos + syn keyword nimBuiltin fileHandle countdown countup items lines endif -if nimrod_highlight_exceptions == 1 +if nim_highlight_exceptions == 1 " 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 EInvalidLibrary EInvalidKey - syn keyword nimrodException EInvalidObjectConversion EFloatingPoint - syn keyword nimrodException EFloatInvalidOp EFloatDivByZero EFloatOverflow - syn keyword nimrodException EFloatInexact EDeadThread EResourceExhausted - syn keyword nimrodException EFloatUnderflow + 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 nimrod_highlight_space_errors == 1 +if nim_highlight_space_errors == 1 " trailing whitespace - syn match nimrodSpaceError display excludenl "\S\s\+$"ms=s+1 - " any tabs are illegal in nimrod - syn match nimrodSpaceError display "\t" + syn match nimSpaceError display excludenl "\S\s\+$"ms=s+1 + " any tabs are illegal in nim + syn match nimSpaceError display "\t" endif -syn sync match nimrodSync grouphere NONE "):$" +syn sync match nimSync grouphere NONE "):$" syn sync maxlines=200 syn sync minlines=2000 -if version >= 508 || !exists("did_nimrod_syn_inits") +if version >= 508 || !exists("did_nim_syn_inits") if version <= 508 - let did_nimrod_syn_inits = 1 + let did_nim_syn_inits = 1 command -nargs=+ HiLink hi link else command -nargs=+ HiLink hi def link endif " The default methods for highlighting. Can be overridden later - HiLink nimrodBrackets Operator - HiLink nimrodKeyword Keyword - HiLink nimrodFunction Function - HiLink nimrodConditional Conditional - HiLink nimrodRepeat Repeat - HiLink nimrodString String - HiLink nimrodRawString String - HiLink nimrodBoolean Boolean - HiLink nimrodEscape Special - HiLink nimrodOperator Operator - HiLink nimrodPreCondit PreCondit - HiLink nimrodComment Comment - HiLink nimrodTodo Todo - HiLink nimrodDecorator Define + HiLink nimBrackets Operator + HiLink nimKeyword Keyword + HiLink nimFunction Function + HiLink nimConditional Conditional + HiLink nimRepeat Repeat + HiLink nimString 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 - if nimrod_highlight_numbers == 1 - HiLink nimrodNumber Number + if nim_highlight_numbers == 1 + HiLink nimNumber Number endif - if nimrod_highlight_builtins == 1 - HiLink nimrodBuiltin Number + if nim_highlight_builtins == 1 + HiLink nimBuiltin Number endif - if nimrod_highlight_exceptions == 1 - HiLink nimrodException Exception + if nim_highlight_exceptions == 1 + HiLink nimException Exception endif - if nimrod_highlight_space_errors == 1 - HiLink nimrodSpaceError Error + if nim_highlight_space_errors == 1 + HiLink nimSpaceError Error endif delcommand HiLink endif -let b:current_syntax = "nimrod" +let b:current_syntax = "nim" From 14a9a9d3d8a991f01eee5379663e774d8728c5ed Mon Sep 17 00:00:00 2001 From: Benjamin Gorman <8076bgorman@gmail.com> Date: Fri, 2 Jan 2015 03:19:50 +0000 Subject: [PATCH 46/98] modify number matching regex to fix issue #26 --- syntax/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 263160e..948b78d 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -79,7 +79,7 @@ if nim_highlight_numbers == 1 " numbers (including longs and complex) syn match nimNumber "\v<0x\x+(\'(i|I|f|F|u|U)(8|16|32|64))?>" syn match nimNumber "\v<[0-9_]+(\'(i|I|f|F|u|U)(8|16|32|64))?>" - syn match nimNumber "\v\.[0-9_]+([eE][+-]=[0-9_]+)=>" + syn match nimNumber "\v[0-9]\.[0-9_]+([eE][+-]=[0-9_]+)=>" syn match nimNumber "\v<[0-9_]+(\.[0-9_]+)?([eE][+-]?[0-9_]+)?(\'(f|F)(32|64))?>" endif From 45b0bf9c1b8b0c0a2c183c9b74ffec877eba7a92 Mon Sep 17 00:00:00 2001 From: miyakogi Date: Sat, 24 Jan 2015 16:42:25 +0900 Subject: [PATCH 47/98] Add default configuration for neocomplete --- autoload/nim.vim | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index 57e0bb1..59fefce 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -155,8 +155,13 @@ 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) From 597cca20eb31dc55cd285f108b37ff5ca6256a69 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 10 May 2015 21:01:09 +0300 Subject: [PATCH 48/98] Force the Nim compiler to output full paths This fixes calling "nim check" from a directory outside of the project tree --- README.markdown | 4 ++-- autoload/nim.vim | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index c702c80..03040ec 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ -#Nimrod language support for Vim +#Nim language support for Vim -This provides [Nimrod](http://nimrod-code.org) language support for Vim: +This provides [Nim](http://nimrod-code.org) language support for Vim: * Syntax highlighting * Auto-indent diff --git a/autoload/nim.vim b/autoload/nim.vim index 57e0bb1..1fa110f 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -2,7 +2,7 @@ let g:nim_log = [] let s:plugin_path = escape(expand(':p:h'), ' \') if !exists("g:nim_caas_enabled") - let g:nim_caas_enabled = 1 + let g:nim_caas_enabled = 0 endif if !executable('nim') @@ -202,7 +202,7 @@ endf " Syntastic syntax checking fun! SyntaxCheckers_nim_nim_GetLocList() - let makeprg = 'nim check --hints:off ' . s:CurrentNimFile() + let makeprg = 'nim check --hints:off --listfullpaths ' . s:CurrentNimFile() let errorformat = &errorformat return SyntasticMake({ 'makeprg': makeprg, 'errorformat': errorformat }) From db7f06b431b5aaee1f9b0080024bfeee0714ef73 Mon Sep 17 00:00:00 2001 From: rhysd Date: Sat, 23 May 2015 17:52:11 +0900 Subject: [PATCH 49/98] Add highlight for special variable 'result' --- syntax/nim.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/syntax/nim.vim b/syntax/nim.vim index 948b78d..03c21ac 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -19,12 +19,16 @@ 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=+\(\\\)\@= 508 || !exists("did_nim_syn_inits") HiLink nimComment Comment HiLink nimTodo Todo HiLink nimDecorator Define + HiLink nimSpecialVar Identifier if nim_highlight_numbers == 1 HiLink nimNumber Number From 36fbc8a25137d6a47f087f70117ba28093924e5c Mon Sep 17 00:00:00 2001 From: patrick dw Date: Sat, 20 Jun 2015 12:12:14 -0500 Subject: [PATCH 50/98] Highlights new names from recent renamings --- syntax/nim.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/syntax/nim.vim b/syntax/nim.vim index 948b78d..d03fdef 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -113,6 +113,8 @@ if nim_highlight_builtins == 1 syn keyword nimBuiltin getFileSize ReadBytes ReadChars readBuffer writeBytes syn keyword nimBuiltin writeChars writeBuffer setFilePos getFilePos syn keyword nimBuiltin fileHandle countdown countup items lines + syn keyword nimBuiltin FileMode File RootObj FileHandle ByteAddress Endianness + syn keyword nimBuiltin GC_Strategy endif if nim_highlight_exceptions == 1 From 2edab5cbc4a4c99b1565e5101869e81cdc764a06 Mon Sep 17 00:00:00 2001 From: Federico Ceratto Date: Sat, 4 Jul 2015 22:11:46 +0100 Subject: [PATCH 51/98] Update Nim name and website --- README.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 03040ec..3e529c4 100644 --- a/README.markdown +++ b/README.markdown @@ -1,6 +1,6 @@ #Nim language support for Vim -This provides [Nim](http://nimrod-code.org) language support for Vim: +This provides [Nim](http://nim-lang.org) language support for Vim: * Syntax highlighting * Auto-indent @@ -14,7 +14,7 @@ modified python.vim (http://www.vim.org/scripts/script.php?script_id=790). #Installation -Installing `nimrod.vim` is easy but first you need to have either pathogen plugin or vundle +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. @@ -41,7 +41,7 @@ You now have pathogen installed and can put `nimrod.vim` into `~/.vim/bundle` like this: cd ~/.vim/bundle - git clone git://github.com/zah/nimrod.vim.git + git clone git://github.com/zah/nim.vim.git You may also want to install synastic by calling @@ -75,9 +75,9 @@ Modify your ~/.vimrc to get vundle running, lightly adapted from [Vundle's readm filetype plugin indent on " required -###Step 2: Install nimrod.vim +###Step 2: Install nim.vim -On the line after `Bundle 'gmarik/vundle'`, add `Bundle 'zah/nimrod.vim'`. You may also want +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 nimrod.vim to be installed. From 89f0a10aa3137a5a11e13b663b6b1f20388ea3e3 Mon Sep 17 00:00:00 2001 From: Roger Shi Date: Mon, 24 Aug 2015 15:50:07 +0800 Subject: [PATCH 52/98] add windows support when creating nim-log.txt --- autoload/nim_vim.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/autoload/nim_vim.py b/autoload/nim_vim.py index 0c36fcf..c90ac22 100644 --- a/autoload/nim_vim.py +++ b/autoload/nim_vim.py @@ -1,4 +1,4 @@ -import threading, Queue, subprocess, signal, os +import threading, Queue, subprocess, signal, os, platform, getpass try: import vim @@ -75,7 +75,12 @@ def nimRestartService(project): nimTerminateService(project) nimStartService(project) -NimLog = open("/tmp/nim-log.txt", "w") +NimLog = None +if platform.system() == 'Windows': + user = getpass.getuser() + NimLog = open("C:\\Users\\%s\\AppData\\Local\\Temp\\nim-log.txt" % (user,), "w") +else: + NimLog = open("/tmp/nim-log.txt", "w") def nimExecCmd(project, cmd, async = True): target = None From 5edd68793adea32dc2388280a997b350beb2d2b1 Mon Sep 17 00:00:00 2001 From: Tyler Anderson Date: Sun, 27 Dec 2015 23:55:28 -0800 Subject: [PATCH 53/98] 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. --- README.markdown | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.markdown b/README.markdown index 03040ec..5153518 100644 --- a/README.markdown +++ b/README.markdown @@ -14,7 +14,7 @@ modified python.vim (http://www.vim.org/scripts/script.php?script_id=790). #Installation -Installing `nimrod.vim` is easy but first you need to have either pathogen plugin or vundle +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. @@ -75,11 +75,11 @@ Modify your ~/.vimrc to get vundle running, lightly adapted from [Vundle's readm filetype plugin indent on " required -###Step 2: Install nimrod.vim +###Step 2: Install nim.vim -On the line after `Bundle 'gmarik/vundle'`, add `Bundle 'zah/nimrod.vim'`. You may also want +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 nimrod.vim to be installed. +and wait for nim.vim to be installed. ##Final Step Next you *need to add this* to your `~/.vimrc`: @@ -96,9 +96,9 @@ Next you *need to add this* to your `~/.vimrc`: nn :call JumpToDef() ino :call JumpToDef()i -The `JumpToDef` function hooks the `nimrod.vim` plugin to invoke the nimrod +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 nimrod compiler +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. @@ -112,8 +112,8 @@ requiring you to maintain a database file. 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://nimrod`` and a buffer will open with the log of -the plugin's invocations and nimrod's idetool answers. +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 From 91673015d487cdddea4cd03c5ea8511dccef20cf Mon Sep 17 00:00:00 2001 From: def Date: Fri, 29 Jan 2016 00:09:15 +0100 Subject: [PATCH 54/98] Update keywords and add new comment syntax --- syntax/nim.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 948b78d..7d92751 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -31,13 +31,13 @@ syn region nimBrackets contained extend keepend matchgroup=Bold start=+\(\ syn keyword nimKeyword addr and as asm atomic syn keyword nimKeyword bind block break -syn keyword nimKeyword case cast const continue converter -syn keyword nimKeyword discard distinct div do +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 finally for from func syn keyword nimKeyword generic syn keyword nimKeyword if import in include interface is isnot iterator -syn keyword nimKeyword lambda let +syn keyword nimKeyword let syn keyword nimKeyword mixin using mod syn keyword nimKeyword nil not notin syn keyword nimKeyword object of or out @@ -57,6 +57,7 @@ syn keyword nimRepeat for while syn keyword nimConditional if elif else case of 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 keyword nimTodo TODO FIXME XXX contained syn keyword nimBoolean true false From 1f62902041c81a7eb13a821d6d520257db3d4397 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 19 May 2016 19:27:38 +0300 Subject: [PATCH 55/98] proper indentation for concept definitions --- indent/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/nim.vim b/indent/nim.vim index 06d6150..4eca11c 100644 --- a/indent/nim.vim +++ b/indent/nim.vim @@ -119,7 +119,7 @@ function! GetNimIndent(lnum) endif if pline =~ '\(type\|import\|const\|var\)\s*$' - \ || pline =~ '=\s*\(object\|enum\|tuple\|generic\)' + \ || pline =~ '=\s*\(object\|enum\|tuple\|concept\)' return plindent + &sw endif From 55eaae0bb03dd8c7820b6608e07a43dd8f56c54f Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 19 May 2016 19:32:27 +0300 Subject: [PATCH 56/98] add a license --- LICENSE | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a54f69 --- /dev/null +++ b/LICENSE @@ -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. + From 10018be3678e1a890129ab9e93eeba01bf5e9120 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 19 May 2016 19:39:06 +0300 Subject: [PATCH 57/98] remove some obsolete system procs --- syntax/nim.vim | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 4101619..a9137b1 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -92,11 +92,9 @@ 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 bool syn keyword nimBuiltin char string cstring pointer range array openarray seq - syn keyword nimBuiltin set Byte Natural Positive TObject PObject Conversion TResult TAddress + 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 cstringArray TEndian PFloat32 PFloat64 PInt64 PInt32 - syn keyword nimBuiltin TGC_Strategy TFile TFileMode TFileHandle isMainModule syn keyword nimBuiltin CompileDate CompileTime nimVersion nimMajor syn keyword nimBuiltin nimMinor nimPatch cpuEndian hostOS hostCPU inf syn keyword nimBuiltin neginf nan QuitSuccess QuitFailure dbgLineHook stdin @@ -110,7 +108,7 @@ if nim_highlight_builtins == 1 syn keyword nimBuiltin swap getRefcount getCurrentException Msg syn keyword nimBuiltin getOccupiedMem getFreeMem getTotalMem isNil seqToPtr syn keyword nimBuiltin find pop GC_disable GC_enable GC_fullCollect - syn keyword nimBuiltin GC_setStrategy GC_enableMarkAnd Sweep + 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 @@ -119,7 +117,6 @@ if nim_highlight_builtins == 1 syn keyword nimBuiltin writeChars writeBuffer setFilePos getFilePos syn keyword nimBuiltin fileHandle countdown countup items lines syn keyword nimBuiltin FileMode File RootObj FileHandle ByteAddress Endianness - syn keyword nimBuiltin GC_Strategy endif if nim_highlight_exceptions == 1 From dcf25798f4a3f75e9538f9915959061edbff97cf Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 19 May 2016 19:50:46 +0300 Subject: [PATCH 58/98] 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 --- autoload/nim.vim | 4 ++-- autoload/nim_vim.py | 10 ---------- compiler/nim.vim | 2 +- ftdetect/nim.vim | 2 +- ftplugin/nim.vim | 4 ++++ 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index a92bb01..c24b12e 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -1,5 +1,5 @@ let g:nim_log = [] -let s:plugin_path = escape(expand(':p:h'), ' \') +let s:plugin_path = escape(expand(':p:h'), '\') if !exists("g:nim_caas_enabled") let g:nim_caas_enabled = 0 @@ -14,7 +14,7 @@ exe 'pyfile ' . fnameescape(s:plugin_path) . '/nim_vim.py' fun! nim#init() let cmd = printf("nim --dump.format:json --verbosity:0 dump %s", s:CurrentNimFile()) let raw_dumpdata = system(cmd) - if !v:shell_error + if !v:shell_error && expand("%:e") == "nim" let dumpdata = eval(substitute(raw_dumpdata, "\n", "", "g")) let b:nim_project_root = dumpdata['project_path'] diff --git a/autoload/nim_vim.py b/autoload/nim_vim.py index c90ac22..c72dc41 100644 --- a/autoload/nim_vim.py +++ b/autoload/nim_vim.py @@ -75,13 +75,6 @@ def nimRestartService(project): nimTerminateService(project) nimStartService(project) -NimLog = None -if platform.system() == 'Windows': - user = getpass.getuser() - NimLog = open("C:\\Users\\%s\\AppData\\Local\\Temp\\nim-log.txt" % (user,), "w") -else: - NimLog = open("/tmp/nim-log.txt", "w") - def nimExecCmd(project, cmd, async = True): target = None if NimProjects.has_key(project): @@ -90,9 +83,6 @@ def nimExecCmd(project, cmd, async = True): target = nimStartService(project) result = target.postNimCmd(cmd, async) - if result != None: - NimLog.write(result) - NimLog.flush() if not async: vim.command('let l:py_res = "' + nimVimEscape(result) + '"') diff --git a/compiler/nim.vim b/compiler/nim.vim index 1db1fd8..740c6c7 100644 --- a/compiler/nim.vim +++ b/compiler/nim.vim @@ -11,7 +11,7 @@ endif let s:cpo_save = &cpo set cpo-=C -CompilerSet makeprg=nim\ c\ $* +CompilerSet makeprg=nim\ c\ --verbosity:0\ $*\ %:p CompilerSet errorformat= \%-GHint:\ %m, diff --git a/ftdetect/nim.vim b/ftdetect/nim.vim index 20dbbe3..89e1e28 100644 --- a/ftdetect/nim.vim +++ b/ftdetect/nim.vim @@ -1,2 +1,2 @@ -au BufNewFile,BufRead *.nim set filetype=nim +au BufNewFile,BufRead *.nim,*.nims set filetype=nim diff --git a/ftplugin/nim.vim b/ftplugin/nim.vim index 5e7febf..c12a28d 100644 --- a/ftplugin/nim.vim +++ b/ftplugin/nim.vim @@ -16,6 +16,10 @@ setlocal omnifunc=NimComplete setlocal suffixesadd=.nim setlocal expandtab "Make sure that only spaces are used +setl tabstop=2 +setl softtabstop=2 +setl shiftwidth=2 + compiler nim let &cpo = s:cpo_save From 43c802b360197e82179be7276b96fceafa8d8a9e Mon Sep 17 00:00:00 2001 From: superfunc Date: Sun, 23 Jul 2017 09:05:18 -0700 Subject: [PATCH 59/98] Fix markdown formatting --- README.markdown | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/README.markdown b/README.markdown index c9a11c3..a0e36d9 100644 --- a/README.markdown +++ b/README.markdown @@ -1,4 +1,4 @@ -#Nim language support for Vim +# Nim language support for Vim This provides [Nim](http://nim-lang.org) language support for Vim: @@ -12,15 +12,15 @@ 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 +# 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 +## Pathogen -###Step 1: Install pathogen.vim +### 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 @@ -35,7 +35,7 @@ Next you *need to add this* to your `~/.vimrc`: call pathogen#infect() -###Step 2: Install nimrod.vim as a pathogen bundle +### Step 2: Install nimrod.vim as a pathogen bundle You now have pathogen installed and can put `nimrod.vim` into `~/.vim/bundle` like this: @@ -47,12 +47,12 @@ You may also want to install synastic by calling git clone https://github.com/scrooloose/syntastic.git -##Vundle +## Vundle Vundle is a more automatic way to install vim plugins that works by cloning the git reposotory. -###Step 1: Install Vundle +### Step 1: Install Vundle Add the vundle script to your vim: @@ -75,13 +75,13 @@ Modify your ~/.vimrc to get vundle running, lightly adapted from [Vundle's readm filetype plugin indent on " required -###Step 2: Install nim.vim +### 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 +## Final Step Next you *need to add this* to your `~/.vimrc`: fun! JumpToDef() @@ -102,12 +102,12 @@ 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 +# Other recomended Vim plugins * https://github.com/scrooloose/syntastic (copied bits from its readme) * https://github.com/Shougo/neocomplcache -#If something goes wrong +# 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 From 2b841ff6f25195453a5e25ccc4d91998f4ebeb18 Mon Sep 17 00:00:00 2001 From: nve3pd Date: Thu, 28 Sep 2017 21:30:32 +0900 Subject: [PATCH 60/98] corresponded to python3 --- autoload/nim.vim | 6 +++++- autoload/nim_vim.py | 8 +++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index c24b12e..cc2e4cd 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -9,7 +9,11 @@ if !executable('nim') echoerr "the Nim compiler must be in your system's PATH" endif -exe 'pyfile ' . fnameescape(s:plugin_path) . '/nim_vim.py' +if has("python3") + exe 'py3file ' . fnameescape(s:plugin_path) . '/nim_vim.py' +else + exe 'pyfile ' . fnameescape(s:plugin_path) . '/nim_vim.py' +endif fun! nim#init() let cmd = printf("nim --dump.format:json --verbosity:0 dump %s", s:CurrentNimFile()) diff --git a/autoload/nim_vim.py b/autoload/nim_vim.py index c72dc41..dde6e9f 100644 --- a/autoload/nim_vim.py +++ b/autoload/nim_vim.py @@ -1,4 +1,10 @@ -import threading, Queue, subprocess, signal, os, platform, getpass +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 From bb4f890a1569a56fb51ba8a3bebc69f6a6b3a57c Mon Sep 17 00:00:00 2001 From: Viacheslav Lotsmanov Date: Sat, 7 Oct 2017 03:28:37 +0500 Subject: [PATCH 61/98] added `writeLine` keyword `writeLn` is deprecated now --- syntax/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index a9137b1..c5cc0e9 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -112,7 +112,7 @@ if nim_highlight_builtins == 1 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 write readLine writeln writeln + syn keyword nimBuiltin FlushFile readfile readFile readline readLine write writeln writeLn writeline writeLine syn keyword nimBuiltin getFileSize ReadBytes ReadChars readBuffer writeBytes syn keyword nimBuiltin writeChars writeBuffer setFilePos getFilePos syn keyword nimBuiltin fileHandle countdown countup items lines From 22acd370faac6914aa2069e4ad6bafe8f673b7dd Mon Sep 17 00:00:00 2001 From: Viacheslav Lotsmanov Date: Sat, 7 Oct 2017 13:16:38 +0500 Subject: [PATCH 62/98] added `void` type keyword --- syntax/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index a9137b1..d02ed4e 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -90,7 +90,7 @@ 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 bool + syn keyword nimBuiltin int int8 int16 int32 int64 uint uint8 uint16 uint32 uint64 float float32 float64 bool void syn keyword nimBuiltin char string cstring pointer range array openarray seq syn keyword nimBuiltin set Byte Natural Positive Conversion syn keyword nimBuiltin BiggestInt BiggestFloat cchar cschar cshort cint csize cuchar cushort From 01f1f1e9eed20a942251e3e97558a9be4abe0c15 Mon Sep 17 00:00:00 2001 From: Viacheslav Lotsmanov Date: Sat, 7 Oct 2017 21:51:48 +0500 Subject: [PATCH 63/98] added `echo` keyword --- syntax/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index dbddcca..74eaa6a 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -112,7 +112,7 @@ if nim_highlight_builtins == 1 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 FlushFile readfile readFile readline readLine write writeln writeLn writeline writeLine echo syn keyword nimBuiltin getFileSize ReadBytes ReadChars readBuffer writeBytes syn keyword nimBuiltin writeChars writeBuffer setFilePos getFilePos syn keyword nimBuiltin fileHandle countdown countup items lines From df3c0ad89e60c14152830023a4ab93d213947389 Mon Sep 17 00:00:00 2001 From: Viacheslav Lotsmanov Date: Sat, 7 Oct 2017 22:08:41 +0500 Subject: [PATCH 64/98] more lower-case builtin keywords --- syntax/nim.vim | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index dbddcca..2a06dba 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -95,27 +95,28 @@ if nim_highlight_builtins == 1 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 CompileDate CompileTime nimVersion nimMajor - syn keyword nimBuiltin nimMinor nimPatch cpuEndian hostOS hostCPU inf - syn keyword nimBuiltin neginf nan QuitSuccess QuitFailure dbgLineHook stdin + 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 len incl excl card ord chr ze ze64 - syn keyword nimBuiltin toU8 toU16 toU32 abs min max add repr + 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 "\" - syn keyword nimBuiltin toFloat toBiggestFloat toInt toBiggestInt addQuitProc - syn keyword nimBuiltin copy setLen newString zeroMem copyMem moveMem - syn keyword nimBuiltin equalMem alloc alloc0 realloc dealloc setLen assert - syn keyword nimBuiltin swap getRefcount getCurrentException Msg - syn keyword nimBuiltin getOccupiedMem getFreeMem getTotalMem isNil seqToPtr + 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 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 ReadBytes ReadChars readBuffer writeBytes - syn keyword nimBuiltin writeChars writeBuffer setFilePos getFilePos - syn keyword nimBuiltin fileHandle countdown countup items lines + 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 From 1b094305a92405dffa32db78b6b6a05accf04a0c Mon Sep 17 00:00:00 2001 From: Viacheslav Lotsmanov Date: Sat, 7 Oct 2017 22:16:49 +0500 Subject: [PATCH 65/98] added keywords `chr` and `varargs` also `openArray` with uppercase --- syntax/nim.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index dbddcca..7612664 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -90,8 +90,8 @@ 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 bool void - syn keyword nimBuiltin char string cstring pointer range array openarray seq + 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 From 46b74a4c7526087659245b77465a0718a911e814 Mon Sep 17 00:00:00 2001 From: Tim Schumacher Date: Mon, 30 Oct 2017 20:11:33 +0100 Subject: [PATCH 66/98] No error when missing python, main features work --- autoload/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index cc2e4cd..0bfb1f7 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -11,7 +11,7 @@ endif if has("python3") exe 'py3file ' . fnameescape(s:plugin_path) . '/nim_vim.py' -else +elseif has("python") exe 'pyfile ' . fnameescape(s:plugin_path) . '/nim_vim.py' endif From 8167c50bd421c921b198001387e60d4728868010 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Wed, 29 Nov 2017 17:35:56 +0200 Subject: [PATCH 67/98] Add vtref and vtptr as keyworkds --- syntax/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 3703085..e6523d1 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -50,7 +50,7 @@ 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 +syn keyword nimKeyword var vtref vtptr syn keyword nimKeyword when while with without syn keyword nimKeyword xor syn keyword nimKeyword yield From 43de5bb9a1e6bdbbc15e7743e4d774591df653f0 Mon Sep 17 00:00:00 2001 From: erw7 Date: Fri, 2 Feb 2018 16:25:54 +0900 Subject: [PATCH 68/98] Fix numerical syntax --- syntax/nim.vim | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index e6523d1..1730c91 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -82,10 +82,11 @@ syn match nimEscapeError "\\x\x\=\X" display contained if nim_highlight_numbers == 1 " numbers (including longs and complex) - syn match nimNumber "\v<0x\x+(\'(i|I|f|F|u|U)(8|16|32|64))?>" - syn match nimNumber "\v<[0-9_]+(\'(i|I|f|F|u|U)(8|16|32|64))?>" - syn match nimNumber "\v[0-9]\.[0-9_]+([eE][+-]=[0-9_]+)=>" - syn match nimNumber "\v<[0-9_]+(\.[0-9_]+)?([eE][+-]?[0-9_]+)?(\'(f|F)(32|64))?>" + syn match nimNumber "\v<0[bB][01]%(_?[01])*%(\'%(%(i|I|u|U)%(8|16|32|64)|u|U|%(f|F)%(32|64|128)?|d|D))?>" + syn match nimNumber "\v<0[ocC]\o%(_?\o)*%(\'%(%(i|I|u|U)%(8|16|32|64)|u|U|%(f|F)%(32|64|128)?|d|D))?>" + syn match nimNumber "\v<0[xX]\x%(_?\x)*%(\'%(%(i|I|u|U)%(8|16|32|64)|u|U|%(f|F)%(32|64|128)?|d|D))?>" + syn match nimNumber "\v<\d%(_?\d)*%(%(\'%(%(i|I|u|U)%(8|16|32|64)|u|U)|%([eE][+-]?\d%(_?\d)*)?\'%(%(%(f|F)%(32|64|128)?|d|D))))?>" + syn match nimNumber "\v<\d%(_?\d)*\.\d%(_?\d)*%([eE][+-]?\d%(_?\d)*)?%(\'%(%(f|F)%(32|64|128)?|d|D))?>" endif if nim_highlight_builtins == 1 From c6c230b6fc4c65c7c73a8c5958389abb64bb2c8d Mon Sep 17 00:00:00 2001 From: erw7 Date: Sat, 10 Feb 2018 11:47:33 +0900 Subject: [PATCH 69/98] Change regular expression to more readable --- syntax/nim.vim | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 1730c91..600866f 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -82,11 +82,16 @@ syn match nimEscapeError "\\x\x\=\X" display contained if nim_highlight_numbers == 1 " numbers (including longs and complex) - syn match nimNumber "\v<0[bB][01]%(_?[01])*%(\'%(%(i|I|u|U)%(8|16|32|64)|u|U|%(f|F)%(32|64|128)?|d|D))?>" - syn match nimNumber "\v<0[ocC]\o%(_?\o)*%(\'%(%(i|I|u|U)%(8|16|32|64)|u|U|%(f|F)%(32|64|128)?|d|D))?>" - syn match nimNumber "\v<0[xX]\x%(_?\x)*%(\'%(%(i|I|u|U)%(8|16|32|64)|u|U|%(f|F)%(32|64|128)?|d|D))?>" - syn match nimNumber "\v<\d%(_?\d)*%(%(\'%(%(i|I|u|U)%(8|16|32|64)|u|U)|%([eE][+-]?\d%(_?\d)*)?\'%(%(%(f|F)%(32|64|128)?|d|D))))?>" - syn match nimNumber "\v<\d%(_?\d)*\.\d%(_?\d)*%([eE][+-]?\d%(_?\d)*)?%(\'%(%(f|F)%(32|64|128)?|d|D))?>" + 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 From 28c74af3a2ad75c5fca64da1faa02dd54aba93f6 Mon Sep 17 00:00:00 2001 From: erw7 Date: Wed, 31 Jan 2018 20:30:32 +0900 Subject: [PATCH 70/98] Fix completion * Fix position where the completion starts. * Change to remove filename from word. * Change to filter completions. --- autoload/nim.vim | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index 0bfb1f7..c52426f 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -140,16 +140,24 @@ fun! NimComplete(findstart, base) if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' return -1 endif - return col('.') + 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 kind = get(g:nim_symbol_types, lineData[1], '') - let c = { 'word': lineData[2], 'kind': kind, 'menu': lineData[3], 'dup': 1 } - call add(result, c) + 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 From e3806c600c64d14fc507d99c70d3c3fe28f5efb2 Mon Sep 17 00:00:00 2001 From: erw7 Date: Sat, 17 Feb 2018 16:10:55 +0900 Subject: [PATCH 71/98] Fix numerical syntax Fix an issue that is not highlighted when floating point suffix is omitted in cases like 1exp+10. --- syntax/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 600866f..60673b1 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -89,7 +89,7 @@ if nim_highlight_numbers == 1 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: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 From dfe55309a4961ac9143635e2c6b935214907315d Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Sun, 20 May 2018 16:57:12 +0100 Subject: [PATCH 72/98] 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`. --- compiler/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/nim.vim b/compiler/nim.vim index 740c6c7..6fd446b 100644 --- a/compiler/nim.vim +++ b/compiler/nim.vim @@ -11,7 +11,7 @@ endif let s:cpo_save = &cpo set cpo-=C -CompilerSet makeprg=nim\ c\ --verbosity:0\ $*\ %:p +CompilerSet makeprg=nim\ c\ --verbosity:0\ --listfullpaths\ $*\ %:p CompilerSet errorformat= \%-GHint:\ %m, From 1da465eedf2f5cc194a3c25532f46f4271d4a1bd Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Tue, 31 Jul 2018 16:37:35 +0100 Subject: [PATCH 73/98] 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. --- autoload/nim.vim | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index c52426f..5d6c5b7 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -52,8 +52,10 @@ endf augroup NimVim au! au BufEnter log://nim call s:UpdateNimLog() - " au QuitPre * :py nimTerminateAll() - au VimLeavePre * :py nimTerminateAll() + if has("python3") || has("python") + " au QuitPre * :py nimTerminateAll() + au VimLeavePre * :py nimTerminateAll() + endif augroup END command! NimLog :e log://nim From 089ea2ca195cf2e59da0ff37d756a31b67fd5f72 Mon Sep 17 00:00:00 2001 From: Siddhant Goel Date: Thu, 9 Aug 2018 08:47:51 +0200 Subject: [PATCH 74/98] Replace usage of reserved async keyword --- autoload/nim_vim.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/autoload/nim_vim.py b/autoload/nim_vim.py index dde6e9f..9a806c4 100644 --- a/autoload/nim_vim.py +++ b/autoload/nim_vim.py @@ -29,14 +29,14 @@ def __init__(self, project_path): universal_newlines = True, bufsize = 1) - def postNimCmd(self, msg, async = True): - self.tasks.put((msg, async)) - if not async: + 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() + (msg, async_) = self.tasks.get() if msg == "quit": self.nim.terminate() @@ -49,7 +49,7 @@ def run(self): line = self.nim.stdout.readline() result += line if line == "\n": - if not async: + if not async_: self.responses.put(result) else: self.asyncOpComplete(msg, result) @@ -81,16 +81,16 @@ def nimRestartService(project): nimTerminateService(project) nimStartService(project) -def nimExecCmd(project, cmd, async = True): +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) + result = target.postNimCmd(cmd, async_) - if not async: + if not async_: vim.command('let l:py_res = "' + nimVimEscape(result) + '"') def nimTerminateAll(): From 7d1211cc1588d8970e44435c612405f41ab5a36b Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Thu, 16 Aug 2018 18:09:37 +0300 Subject: [PATCH 75/98] nimble file support --- ftdetect/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ftdetect/nim.vim b/ftdetect/nim.vim index 89e1e28..152f6f5 100644 --- a/ftdetect/nim.vim +++ b/ftdetect/nim.vim @@ -1,2 +1,2 @@ -au BufNewFile,BufRead *.nim,*.nims set filetype=nim +au BufNewFile,BufRead *.nim,*.nims,*.nimble set filetype=nim From b0c4c6c7318866e5d74715885cb379aab70d2763 Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Wed, 19 Sep 2018 17:11:23 +0300 Subject: [PATCH 76/98] Enable folding --- ftplugin/nim.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ftplugin/nim.vim b/ftplugin/nim.vim index c12a28d..4cfad5e 100644 --- a/ftplugin/nim.vim +++ b/ftplugin/nim.vim @@ -15,6 +15,8 @@ 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 From f5473ff98b262d90205250e8dad5e9e51eb5f6bb Mon Sep 17 00:00:00 2001 From: Yuriy Glukhov Date: Wed, 12 Dec 2018 12:23:20 +0200 Subject: [PATCH 77/98] Fixed json parsing: true/false undefined --- autoload/nim.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload/nim.vim b/autoload/nim.vim index 5d6c5b7..c401c96 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -19,6 +19,8 @@ fun! nim#init() 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(substitute(raw_dumpdata, "\n", "", "g")) let b:nim_project_root = dumpdata['project_path'] From 358e2e013056af5ad09b3e2963e3390db8677680 Mon Sep 17 00:00:00 2001 From: nepeckman Date: Wed, 31 Oct 2018 18:17:06 -0400 Subject: [PATCH 78/98] Added func as a function keyword --- syntax/nim.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 60673b1..039ec4c 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -38,14 +38,14 @@ 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 func +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 method macro template nextgroup=nimFunction skipwhite +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 From f16af986a8bdfadffd81d33cec4e4e230ee61f86 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Sun, 16 Dec 2018 22:34:12 +0200 Subject: [PATCH 79/98] Regain compatibility with the latest syntastic release --- compiler/nim.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/nim.vim b/compiler/nim.vim index 6fd446b..c3cbe62 100644 --- a/compiler/nim.vim +++ b/compiler/nim.vim @@ -21,3 +21,5 @@ CompilerSet errorformat= let &cpo = s:cpo_save unlet s:cpo_save +let g:syntastic_nim_checkers = ['nim'] + From 21731384b8f0675e3d666e98dd6625508c30f3af Mon Sep 17 00:00:00 2001 From: erw7 Date: Sat, 3 Feb 2018 17:39:47 +0900 Subject: [PATCH 80/98] Remove quickrun settings --- autoload/nim.vim | 9 --------- 1 file changed, 9 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index c401c96..c1fdc9d 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -238,12 +238,3 @@ if exists("g:SyntasticRegistry") \ 'filetype': 'nim', \ 'name': 'nim'}) endif - -if !exists("g:quickrun_config") - let g:quickrun_config = {} -endif - -if !exists("g:quickrun_config.nim") - let g:quickrun_config.nim = { "exec": "nim c --run --verbosity:0 %S" } -endif - From 88f5e708a739fb26be6364ab2fabadf9fffb8d7b Mon Sep 17 00:00:00 2001 From: silvetie Date: Sat, 2 Mar 2019 22:53:41 +0900 Subject: [PATCH 81/98] Added the "let" keyword --- indent/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indent/nim.vim b/indent/nim.vim index 4eca11c..bd448fc 100644 --- a/indent/nim.vim +++ b/indent/nim.vim @@ -118,7 +118,7 @@ function! GetNimIndent(lnum) return plindent + &sw endif - if pline =~ '\(type\|import\|const\|var\)\s*$' + if pline =~ '\(type\|import\|const\|var\|let\)\s*$' \ || pline =~ '=\s*\(object\|enum\|tuple\|concept\)' return plindent + &sw endif From 413244f3c3572e12a6e0bbd7e55cf9cda021a8f1 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:10:05 +0900 Subject: [PATCH 82/98] Use pyx or pyxfile --- autoload/nim.vim | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index c1fdc9d..d9b78c6 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -9,10 +9,8 @@ if !executable('nim') echoerr "the Nim compiler must be in your system's PATH" endif -if has("python3") - exe 'py3file ' . fnameescape(s:plugin_path) . '/nim_vim.py' -elseif has("python") - exe 'pyfile ' . fnameescape(s:plugin_path) . '/nim_vim.py' +if has('pythonx') + exe 'pyxfile ' . fnameescape(s:plugin_path) . '/nim_vim.py' endif fun! nim#init() @@ -54,19 +52,19 @@ endf augroup NimVim au! au BufEnter log://nim call s:UpdateNimLog() - if has("python3") || has("python") - " au QuitPre * :py nimTerminateAll() - au VimLeavePre * :py nimTerminateAll() + if has("pythonx") + " au QuitPre * :pyx nimTerminateAll() + au VimLeavePre * :pyx nimTerminateAll() endif augroup END command! NimLog :e log://nim command! NimTerminateService - \ :exe printf("py nimTerminateService('%s')", b:nim_project_root) + \ :exe printf("pyx nimTerminateService('%s')", b:nim_project_root) command! NimRestartService - \ :exe printf("py nimRestartService('%s')", b:nim_project_root) + \ :exe printf("pyx nimRestartService('%s')", b:nim_project_root) fun! s:CurrentNimFile() let save_cur = getpos('.') @@ -120,7 +118,7 @@ fun! NimExec(op) endif if b:nim_caas_enabled - exe printf("py nimExecCmd('%s', '%s', False)", b:nim_project_root, cmd) + exe printf("pyx nimExecCmd('%s', '%s', False)", b:nim_project_root, cmd) let output = l:py_res else let output = system("nim " . cmd) From d37b22898530c8bfb0f2c3c97e6bec169eaf426f Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:18:49 +0900 Subject: [PATCH 83/98] vint: Use single quotes. --- autoload/nim.vim | 58 ++++++++++++++++++++++++------------------------ compiler/nim.vim | 6 ++--- ftdetect/nim.vim | 4 +++- ftplugin/nim.vim | 2 +- indent/nim.vim | 10 ++++----- syntax/nim.vim | 14 ++++++------ 6 files changed, 48 insertions(+), 46 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index d9b78c6..1f17037 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -1,7 +1,7 @@ let g:nim_log = [] let s:plugin_path = escape(expand(':p:h'), '\') -if !exists("g:nim_caas_enabled") +if !exists('g:nim_caas_enabled') let g:nim_caas_enabled = 0 endif @@ -14,12 +14,12 @@ if has('pythonx') endif fun! nim#init() - let cmd = printf("nim --dump.format:json --verbosity:0 dump %s", s:CurrentNimFile()) + 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" + 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(substitute(raw_dumpdata, "\n", "", "g")) + let dumpdata = eval(substitute(raw_dumpdata, "\n", '', 'g')) let b:nim_project_root = dumpdata['project_path'] let b:nim_defined_symbols = dumpdata['defined_symbols'] @@ -27,7 +27,7 @@ fun! nim#init() for path in dumpdata['lib_paths'] if finddir(path) == path - let &l:path = path . "," . &l:path + let &l:path = path . ',' . &l:path endif endfor else @@ -52,7 +52,7 @@ endf augroup NimVim au! au BufEnter log://nim call s:UpdateNimLog() - if has("pythonx") + if has('pythonx') " au QuitPre * :pyx nimTerminateAll() au VimLeavePre * :pyx nimTerminateAll() endif @@ -70,14 +70,14 @@ fun! s:CurrentNimFile() let save_cur = getpos('.') call cursor(0, 0, 0) - let PATTERN = "\\v^\\#\\s*included from \\zs.*\\ze" - let l = search(PATTERN, "n") + 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 + let l:to_check = expand('%:h') . '/' . f else - let l:to_check = expand("%") + let l:to_check = expand('%') endif call setpos('.', save_cur) @@ -105,15 +105,15 @@ let g:nim_symbol_types = { \ } fun! NimExec(op) - let isDirty = getbufvar(bufnr('%'), "&modified") + let isDirty = getbufvar(bufnr('%'), '&modified') if isDirty - let tmp = tempname() . bufname("%") . "_dirty.nim" - silent! exe ":w " . tmp + let tmp = tempname() . bufname('%') . '_dirty.nim' + silent! exe ':w ' . tmp - let cmd = printf("idetools %s --trackDirty:\"%s,%s,%d,%d\" \"%s\"", + 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\"", + let cmd = printf('idetools %s --track:"%s,%d,%d" "%s"', \ a:op, expand('%:p'), line('.'), col('.')-1, s:CurrentNimFile()) endif @@ -121,10 +121,10 @@ fun! NimExec(op) exe printf("pyx nimExecCmd('%s', '%s', False)", b:nim_project_root, cmd) let output = l:py_res else - let output = system("nim " . cmd) + let output = system('nim ' . cmd) endif - call add(g:nim_log, "nim " . cmd . "\n" . output) + call add(g:nim_log, 'nim ' . cmd . "\n" . output) return output endf @@ -139,7 +139,7 @@ fun! NimComplete(findstart, base) endif if a:findstart - if synIDattr(synIDtrans(synID(line("."),col("."),1)), "name") == 'Comment' + if synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name') == 'Comment' return -1 endif let line = getline('.') @@ -150,10 +150,10 @@ fun! NimComplete(findstart, base) return start else let result = [] - let sugOut = NimExec("--suggest") + let sugOut = NimExec('--suggest') for line in split(sugOut, '\n') let lineData = split(line, '\t') - if len(lineData) > 0 && lineData[0] == "sug" + 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], '') @@ -166,7 +166,7 @@ fun! NimComplete(findstart, base) endif endf -if !exists("g:neocomplcache_omni_patterns") +if !exists('g:neocomplcache_omni_patterns') let g:neocomplcache_omni_patterns = {} endif let g:neocomplcache_omni_patterns['nim'] = '[^. *\t]\.\w*' @@ -186,33 +186,33 @@ fun! NimAsyncCmdComplete(cmd, output) call Callback(a:output) " remove(g:nim_completion_callbacks, a:cmd) else - echom "ERROR, Unknown Command: " . a:cmd + echom 'ERROR, Unknown Command: ' . a:cmd endif return 1 endf fun! GotoDefinition_nim_ready(def_output) if v:shell_error - echo "nim was unable to locate the definition. exit code: " . 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" + 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) + exe printf('e +%d %s', line, file) return 1 endf fun! GotoDefinition_nim() - call NimExecAsync("--def", function("GotoDefinition_nim_ready")) + call NimExecAsync('--def', function('GotoDefinition_nim_ready')) endf fun! FindReferences_nim() @@ -228,10 +228,10 @@ fun! SyntaxCheckers_nim_nim_GetLocList() endf function! SyntaxCheckers_nim_nim_IsAvailable() - return executable("nim") + return executable('nim') endfunction -if exists("g:SyntasticRegistry") +if exists('g:SyntasticRegistry') call g:SyntasticRegistry.CreateAndRegisterChecker({ \ 'filetype': 'nim', \ 'name': 'nim'}) diff --git a/compiler/nim.vim b/compiler/nim.vim index c3cbe62..78bf48f 100644 --- a/compiler/nim.vim +++ b/compiler/nim.vim @@ -1,10 +1,10 @@ -if exists("current_compiler") +if exists('current_compiler') finish endif -let current_compiler = "nim" +let current_compiler = 'nim' -if exists(":CompilerSet") != 2 " older Vim always used :setlocal +if exists(':CompilerSet') != 2 " older Vim always used :setlocal command -nargs=* CompilerSet setlocal endif diff --git a/ftdetect/nim.vim b/ftdetect/nim.vim index 152f6f5..1c6eb20 100644 --- a/ftdetect/nim.vim +++ b/ftdetect/nim.vim @@ -1,2 +1,4 @@ -au BufNewFile,BufRead *.nim,*.nims,*.nimble set filetype=nim +augroup nim_vim + au BufNewFile,BufRead *.nim,*.nims,*.nimble set filetype=nim +augroup END diff --git a/ftplugin/nim.vim b/ftplugin/nim.vim index 4cfad5e..c77357d 100644 --- a/ftplugin/nim.vim +++ b/ftplugin/nim.vim @@ -1,4 +1,4 @@ -if exists("b:nim_loaded") +if exists('b:nim_loaded') finish endif diff --git a/indent/nim.vim b/indent/nim.vim index bd448fc..30be78d 100644 --- a/indent/nim.vim +++ b/indent/nim.vim @@ -1,5 +1,5 @@ " Only load this indent file when no other was loaded. -if exists("b:did_indent") +if exists('b:did_indent') finish endif let b:did_indent = 1 @@ -12,7 +12,7 @@ setlocal indentexpr=GetNimIndent(v:lnum) setlocal indentkeys=!^F,o,O,<:>,0),0],0},=elif " Only define the function once. -if exists("*GetNimIndent") +if exists('*GetNimIndent') finish endif @@ -38,7 +38,7 @@ function! GetNimIndent(lnum) 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$" + if has('syntax_items') && synIDattr(synID(a:lnum, 1, 1), 'name') =~ 'String$' return -1 endif @@ -54,12 +54,12 @@ function! GetNimIndent(lnum) " 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$" + 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$" + if synIDattr(synID(plnum, col, 1), 'name') =~ 'Comment$' let max = col else let min = col + 1 diff --git a/syntax/nim.vim b/syntax/nim.vim index 039ec4c..008d32f 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -2,28 +2,28 @@ " For version 6.x: Quit when a syntax file was already loaded if version < 600 syntax clear -elseif exists("b:current_syntax") +elseif exists('b:current_syntax') finish endif " Keep user-supplied options -if !exists("nim_highlight_numbers") +if !exists('nim_highlight_numbers') let nim_highlight_numbers = 1 endif -if !exists("nim_highlight_builtins") +if !exists('nim_highlight_builtins') let nim_highlight_builtins = 1 endif -if !exists("nim_highlight_exceptions") +if !exists('nim_highlight_exceptions') let nim_highlight_exceptions = 1 endif -if !exists("nim_highlight_space_errors") +if !exists('nim_highlight_space_errors') let nim_highlight_space_errors = 1 endif -if !exists("nim_highlight_special_vars") +if !exists('nim_highlight_special_vars') let nim_highlight_special_vars = 1 endif -if exists("nim_highlight_all") +if exists('nim_highlight_all') let nim_highlight_numbers = 1 let nim_highlight_builtins = 1 let nim_highlight_exceptions = 1 From 5cff46c7d57ee89afd3995a7d637259a0a183054 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:19:22 +0900 Subject: [PATCH 84/98] vint: Use v:version --- syntax/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 008d32f..07fb487 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -1,6 +1,6 @@ " For version 5.x: Clear all syntax items " For version 6.x: Quit when a syntax file was already loaded -if version < 600 +if v:version < 600 syntax clear elseif exists('b:current_syntax') finish From 7cead42bb1a5e7f576ddc1900e03b2bae0b0a309 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:20:36 +0900 Subject: [PATCH 85/98] vint: Use =~# --- indent/nim.vim | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/indent/nim.vim b/indent/nim.vim index 30be78d..c71367d 100644 --- a/indent/nim.vim +++ b/indent/nim.vim @@ -38,7 +38,7 @@ function! GetNimIndent(lnum) 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$' + if has('syntax_items') && synIDattr(synID(a:lnum, 1, 1), 'name') =~# 'String$' return -1 endif @@ -54,12 +54,12 @@ function! GetNimIndent(lnum) " 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$' + 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$' + if synIDattr(synID(plnum, col, 1), 'name') =~# 'Comment$' let max = col else let min = col + 1 @@ -78,16 +78,16 @@ function! GetNimIndent(lnum) endwhile endif - if cline =~ '^\s*\(if\|when\|for\|while\|case\|of\|try\)\>' + 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\)\>' + if cline =~# '^\s*\(except\|finally\)\>' let lnum = a:lnum - 1 while lnum >= 1 - if getline(lnum) =~ '^\s*\(try\|except\)\>' + if getline(lnum) =~# '^\s*\(try\|except\)\>' let ind = indent(lnum) if ind >= clindent return -1 " indent is already less than this @@ -100,31 +100,31 @@ function! GetNimIndent(lnum) endif " If the current line begins with a header keyword, dedent - if cline =~ '^\s*\(elif\|else\)\>' + if cline =~# '^\s*\(elif\|else\)\>' return s:FindStartLine(a:lnum, '^\s*\(if\|when\|elif\|of\)') endif - if pline =~ ':\s*$' + if pline =~# ':\s*$' "return s:FindStartLine(plnum, '(^\s*\(if\|when\|else\|elif\|case\|of\|try\|except\|finally\)\>)\|\') + &sw return s:FindStartLine(plnum, '^\s*\(if\|when\|else\|elif\|for\|while\|case\|of\|try\|except\|finally\)\>') + &sw endif - if pline =~ '=\s*$' + 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\)[^:]*$' + 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\)' + 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\)\>' + 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 From cdccc96c56dceb33cb3d463dd78e3b1eaf09ca7f Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:22:33 +0900 Subject: [PATCH 86/98] vint: Use abort attributes --- autoload/nim.vim | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index 1f17037..1a05a00 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -13,7 +13,7 @@ if has('pythonx') exe 'pyxfile ' . fnameescape(s:plugin_path) . '/nim_vim.py' endif -fun! nim#init() +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' @@ -35,7 +35,7 @@ fun! nim#init() endif endf -fun! s:UpdateNimLog() +fun! s:UpdateNimLog() abort setlocal buftype=nofile setlocal bufhidden=hide setlocal noswapfile @@ -66,7 +66,7 @@ command! NimTerminateService command! NimRestartService \ :exe printf("pyx nimRestartService('%s')", b:nim_project_root) -fun! s:CurrentNimFile() +fun! s:CurrentNimFile() abort let save_cur = getpos('.') call cursor(0, 0, 0) @@ -104,7 +104,7 @@ let g:nim_symbol_types = { \ 'skEnumField': 'v', \ } -fun! NimExec(op) +fun! NimExec(op) abort let isDirty = getbufvar(bufnr('%'), '&modified') if isDirty let tmp = tempname() . bufname('%') . '_dirty.nim' @@ -128,12 +128,12 @@ fun! NimExec(op) return output endf -fun! NimExecAsync(op, Handler) +fun! NimExecAsync(op, Handler) abort let result = NimExec(a:op) call a:Handler(result) endf -fun! NimComplete(findstart, base) +fun! NimComplete(findstart, base) abort if b:nim_caas_enabled == 0 return -1 endif @@ -178,7 +178,7 @@ let g:neocomplete#sources#omni#input_patterns['nim'] = '[^. *\t]\.\w*' let g:nim_completion_callbacks = {} -fun! NimAsyncCmdComplete(cmd, output) +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) @@ -191,7 +191,7 @@ fun! NimAsyncCmdComplete(cmd, output) return 1 endf -fun! GotoDefinition_nim_ready(def_output) +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 @@ -211,23 +211,23 @@ fun! GotoDefinition_nim_ready(def_output) return 1 endf -fun! GotoDefinition_nim() +fun! GotoDefinition_nim() abort call NimExecAsync('--def', function('GotoDefinition_nim_ready')) endf -fun! FindReferences_nim() +fun! FindReferences_nim() abort setloclist() endf " Syntastic syntax checking -fun! SyntaxCheckers_nim_nim_GetLocList() +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() +function! SyntaxCheckers_nim_nim_IsAvailable() abort return executable('nim') endfunction From e88782bda730bddfd9943934c3308c381930b519 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:23:00 +0900 Subject: [PATCH 87/98] vint: setloclist() is not a command or function --- autoload/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index 1a05a00..53cfaa0 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -216,7 +216,7 @@ fun! GotoDefinition_nim() abort endf fun! FindReferences_nim() abort - setloclist() + "setloclist() endf " Syntastic syntax checking From dc109e5a20156d8479e2175572bb18268352e8dd Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:23:53 +0900 Subject: [PATCH 88/98] vint: Use ==# --- autoload/nim.vim | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index 53cfaa0..5098d72 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -16,7 +16,7 @@ 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' + 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(substitute(raw_dumpdata, "\n", '', 'g')) @@ -26,7 +26,7 @@ fun! nim#init() abort 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 + if finddir(path) ==# path let &l:path = path . ',' . &l:path endif endfor @@ -134,12 +134,12 @@ fun! NimExecAsync(op, Handler) abort endf fun! NimComplete(findstart, base) abort - if b:nim_caas_enabled == 0 + if b:nim_caas_enabled ==# 0 return -1 endif if a:findstart - if synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name') == 'Comment' + if synIDattr(synIDtrans(synID(line('.'),col('.'),1)), 'name') ==# 'Comment' return -1 endif let line = getline('.') @@ -153,7 +153,7 @@ fun! NimComplete(findstart, base) abort let sugOut = NimExec('--suggest') for line in split(sugOut, '\n') let lineData = split(line, '\t') - if len(lineData) > 0 && lineData[0] == 'sug' + 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], '') From 711af55cb50be2c9163d7a9f80055afa86afeb1a Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:24:43 +0900 Subject: [PATCH 89/98] vint: Use get(l:, 'py_res', '') --- autoload/nim.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index 5098d72..3b2e2ce 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -119,7 +119,7 @@ fun! NimExec(op) abort if b:nim_caas_enabled exe printf("pyx nimExecCmd('%s', '%s', False)", b:nim_project_root, cmd) - let output = l:py_res + let output = get(l:, 'py_res', '') else let output = system('nim ' . cmd) endif From 74ed699e823b1123fb15f865d2366cef9332c911 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:25:11 +0900 Subject: [PATCH 90/98] vint: Use v:version --- syntax/nim.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index 07fb487..cb1c9de 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -156,8 +156,8 @@ syn sync match nimSync grouphere NONE "):$" syn sync maxlines=200 syn sync minlines=2000 -if version >= 508 || !exists("did_nim_syn_inits") - if version <= 508 +if v:version >= 508 || !exists("did_nim_syn_inits") + if v:version <= 508 let did_nim_syn_inits = 1 command -nargs=+ HiLink hi link else From 7a8737a4532239c06116ebde0329d8156f3d3b55 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Fri, 16 Oct 2020 11:25:38 +0900 Subject: [PATCH 91/98] vint: Use single quotes --- syntax/nim.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syntax/nim.vim b/syntax/nim.vim index cb1c9de..7489ee1 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -156,7 +156,7 @@ 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 || !exists('did_nim_syn_inits') if v:version <= 508 let did_nim_syn_inits = 1 command -nargs=+ HiLink hi link @@ -200,5 +200,5 @@ if v:version >= 508 || !exists("did_nim_syn_inits") delcommand HiLink endif -let b:current_syntax = "nim" +let b:current_syntax = 'nim' From cfcd9bf0952f9307eddcafb9c68b82a6f5c0c531 Mon Sep 17 00:00:00 2001 From: HIDE810 <48782538+HIDE810@users.noreply.github.com> Date: Thu, 11 Nov 2021 23:22:37 +0900 Subject: [PATCH 92/98] Update to recommended URL --- README.markdown | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.markdown b/README.markdown index a0e36d9..8870177 100644 --- a/README.markdown +++ b/README.markdown @@ -27,9 +27,8 @@ First I'll show you how to install tpope's 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 + mkdir -p ~/.vim/autoload ~/.vim/bundle && \ + curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim Next you *need to add this* to your `~/.vimrc`: @@ -41,7 +40,7 @@ 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 + git clone https://github.com/zah/nim.vim.git You may also want to install synastic by calling From e8c647f456860adba1ee67c8a9e3f28c6f561a75 Mon Sep 17 00:00:00 2001 From: Josias Date: Thu, 16 Jul 2020 19:12:50 +0200 Subject: [PATCH 93/98] Change Nimrod name to Nim (again?) This updates all references to nimrod and nimrod.vim to simply Nim. As it appears #53 was supposed to do. --- README.markdown | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.markdown b/README.markdown index 8870177..40f3804 100644 --- a/README.markdown +++ b/README.markdown @@ -24,7 +24,7 @@ It is also recommened that you use the [syntastic](https://github.com/scrooloose 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 +install `nim.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 && \ @@ -34,9 +34,9 @@ Next you *need to add this* to your `~/.vimrc`: call pathogen#infect() -### Step 2: Install nimrod.vim as a pathogen bundle +### Step 2: Install nim.vim as a pathogen bundle -You now have pathogen installed and can put `nimrod.vim` into `~/.vim/bundle` +You now have pathogen installed and can put `nim.vim` into `~/.vim/bundle` like this: cd ~/.vim/bundle @@ -98,7 +98,7 @@ Next you *need to add this* to your `~/.vimrc`: 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 +instead of ctags, so it works on any nim file which is compilable without requiring you to maintain a database file. # Other recomended Vim plugins @@ -116,5 +116,5 @@ 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 +generating so you can prepare a test case for either this plugin or the nim compiler. From f02ed8cc035065d73123876cdfa16fe9cdd3a489 Mon Sep 17 00:00:00 2001 From: "Felipe S. S. Schneider" Date: Thu, 24 Jun 2021 16:24:17 -0300 Subject: [PATCH 94/98] Explain how to use with vim-plug --- README.markdown | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/README.markdown b/README.markdown index 40f3804..a63fc8b 100644 --- a/README.markdown +++ b/README.markdown @@ -14,9 +14,10 @@ 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. +Installing `nim.vim` is easy but first you need to have a plugin manager such +as pathogen, vundle or vim-plug installed. +If you already have one working then skip to the [final step](README.markdown#final-step). +It is also recommended that you use the [syntastic](https://github.com/scrooloose/syntastic) plugin for best results. ## Pathogen @@ -80,6 +81,29 @@ On the line after `Bundle 'gmarik/vundle'`, add `Bundle 'zah/nim.vim'`. You may to add `Bundle 'scrooloose/syntastic'`. Save `~/.vimrc` and restart vim. Execute `:BundleInstall` and wait for nim.vim to be installed. +## vim-plug + +[vim-plug](https://github.com/junegunn/vim-plug) is a minimalist Vim plugin manager. + +### Step 1: Install vim-plug + +Install vim-plug so that it loads automatically at launch: + + $ curl -fLo ~/.vim/autoload/plug.vim --create-dirs \ + https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim + +### Step 2: Add `nim.vim` to your list of plugins + +Modify your `~/.vimrc` to add the `nim.vim` plugin to the list of plugins: + + " ... + call plug#begin('~/.vim/plugged') + " ... + Plug 'zah/nim.vim' + call plug#end() + +Execute `:PlugInstall` and wait for `nim.vim` to be installed. + ## Final Step Next you *need to add this* to your `~/.vimrc`: From 7ce76770902301a4dae18989190fe19bfc1e98b2 Mon Sep 17 00:00:00 2001 From: bkerin Date: Thu, 11 Nov 2021 05:48:49 -0900 Subject: [PATCH 95/98] Use cursor() to get to correct column (#75) --- autoload/nim.vim | 2 ++ 1 file changed, 2 insertions(+) diff --git a/autoload/nim.vim b/autoload/nim.vim index 3b2e2ce..bbdd93d 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -207,7 +207,9 @@ fun! GotoDefinition_nim_ready(def_output) abort let defBits = split(rawDef, '\t') let file = defBits[4] let line = defBits[5] + let column = defBits[6] exe printf('e +%d %s', line, file) + call cursor(line, column + 1) return 1 endf From dce4bab907d89e56d78530af5dcca313767f659f Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 11 Nov 2021 16:53:59 +0200 Subject: [PATCH 96/98] Use json_decode --- autoload/nim.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/nim.vim b/autoload/nim.vim index bbdd93d..4d6f29c 100644 --- a/autoload/nim.vim +++ b/autoload/nim.vim @@ -19,8 +19,8 @@ fun! nim#init() abort 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(substitute(raw_dumpdata, "\n", '', 'g')) - + let dumpdata = json_decode(raw_dumpdata) + 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 From 9f9855496149ab998aa23d9c81db038686595805 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 11 Nov 2021 16:59:36 +0200 Subject: [PATCH 97/98] Syntax highlight typedesc, typed, untyped, expr and stmt --- syntax/nim.vim | 1 + 1 file changed, 1 insertion(+) diff --git a/syntax/nim.vim b/syntax/nim.vim index 7489ee1..7534a67 100644 --- a/syntax/nim.vim +++ b/syntax/nim.vim @@ -112,6 +112,7 @@ if nim_highlight_builtins == 1 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 typedesc typed untyped stmt expr 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 From a15714fea392b0f06ff2b282921a68c7033e39a2 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 11 Nov 2021 17:06:31 +0200 Subject: [PATCH 98/98] proper name for the README --- README.markdown => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README.markdown => README.md (100%) diff --git a/README.markdown b/README.md similarity index 100% rename from README.markdown rename to README.md