From dcf25798f4a3f75e9538f9915959061edbff97cf Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 19 May 2016 19:50:46 +0300 Subject: [PATCH] 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