Tamas Kovacs avatar Tamas Kovacs committed 806fe91

Use swank's :indentation-update info for special indentation

Comments (0)

Files changed (5)

 Script versions
 --------------------------------------------------------------------------------
 
-0.8.3: Added top/bottom/left/right directions to g:slimv_repl_split, added :Lisp (and an equivalent :Eval) command with completion, added g:slimv_leader and g:paredit_leader options, added g:slimv_echolines to echo only the first few lines of the form being evaluated, added fuzzy completion and option g:slimv_simple_compl (by Philipp Marek), indent macros with &body argument by two spaces when connected to swank, default for Set-Package is current package (thanks to Philipp Marek), bugfixes: REPL output ordering problems, problem with inserting Space into visual block, blinking when g:slimv_repl_syntax is on, entering incomplete form in REPL command line, close form when inside comment, string, or with mixed ([. 
+0.8.3: Added top/bottom/left/right directions to g:slimv_repl_split, added :Lisp (and an equivalent :Eval) command with completion, added g:slimv_leader and g:paredit_leader options, added g:slimv_echolines to echo only the first few lines of the form being evaluated, added fuzzy completion and option g:slimv_simple_compl (by Philipp Marek), indent macros with &body argument by two spaces when connected to swank (thanks to Philipp Marek and Andreas Fredriksson), special indentation for flet, labels and macrolet, default for Set-Package is current package (thanks to Philipp Marek), bugfixes: REPL output ordering problems, problem with inserting Space into visual block, blinking when g:slimv_repl_syntax is on, entering incomplete form in REPL command line, close form when inside comment, string, or with mixed ([. 
 
 0.8.2: Added Paredit and g:lisp_rainbow support for Scheme files, added SWANK support for MIT Scheme on Linux, added frame call information to SLDB (thanks to Philipp Marek), check for unbalanced form before evaluation, reconnect SWANK server in Connect-Server if already connected (thanks to Philipp Marek), select current form instead of top level form in Macroexpand, bugfixes: Paredit handling of escaped matched characters (e.g. \"), cursor positioning problems when debugger activated, print prompt after Describe.
 
-*slimv.txt*                    Slimv                 Last Change: 14 May 2011
+*slimv.txt*                    Slimv                 Last Change: 17 May 2011
 
 Slimv                                                                  *slimv*
                                Version 0.8.3
        ftplugin/lisp/slimv-lisp.vim
        ftplugin/scheme/slimv-scheme.vim
        indent/clojure.vim
+       indent/lisp.vim
        plugin/paredit.vim
        slime/*
        swank-clojure/*
 The indentation is also done via the default lisp.vim indent plugin, or an
 optionally installed Clojure indent plugin, just like for the syntax
 highlighting.
+When using the SWANK client and it is connected to the server, then indentation
+information is fetched from the SWANK server. This allows special indentation
+methods, e.g. when the given macro has an &body argument then it is indented
+by 2 spaces (instead of indenting the second argument below the first one).
+
 There are some built-in Vim reindentation commands that may come very handy
 when editing Lisp files. One can define a custom key mapping for any of them,
 such mappings are not defined by Slimv.
 
-    :set autoindent         Copy indent from current line when starting
-                            a new line.
-
     =                       Reindent selection, after a text has been selected.
 
     ==                      Reindent current line.
 
     99[(v%=                 Select top level form and reindent it.
 
+    gg=G                    Reindent whole file.
+
 
 3. Parenthesis handling
 
        - Added g:slimv_echolines to echo only the first few lines of the
          form being evaluated.
        - Added fuzzy completion and option g:slimv_simple_compl (by Philipp Marek).
-       - Indent macros with &body argument by two spaces when connected to swank.
+       - Indent macros with &body argument by two spaces when connected to swank
+         (thanks to Philipp Marek and Andreas Fredriksson).
+       - Special indentation for flet, labels, macrolet.
        - Default for Set-Package is current package (thanks to Philipp Marek).
        - Bugfix: REPL output ordering problems.
        - Bugfix: problem with inserting Space into visual block.
 
 Also thanks to Vlad Hanciuta, Marcin Fatyga, Dmitry Petukhov,
 Daniel Solano G�mez, Brian Kropf, Len Weincier, Andreas Salwasser,
-Jon Thacker, Andrew Hills, Jerome Baum, John Obbele for additional notes and
-contributions.
+Jon Thacker, Andrew Hills, Jerome Baum, John Obbele, Andreas Fredriksson
+for additional notes and contributions.
 
 Last but not least many thanks to my wife Andrea (for the Italians out there:
 hey, this is a female name in Hungary :) for her support and patience.
-*swank.txt*                    Slimv                 Last Change: 10 May 2011
+*swank.txt*                    Slimv                 Last Change: 17 May 2011
 
 SWANK client for Slimv                                    *swank* *slimv-swank*
                                Version 0.8.3
   :emacs-interrupt
   :emacs-pong
   :emacs-return-string
+  :indentation-update
   swank:compile-file-for-emacs
   swank:compile-string-for-emacs
   swank:connection-info

ftplugin/slimv.vim

 " slimv.vim:    The Superior Lisp Interaction Mode for VIM
 " Version:      0.8.3
-" Last Change:  15 May 2011
+" Last Change:  17 May 2011
 " Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 " License:      This file is placed in the public domain.
 "               No warranty, express or implied.
 
 let s:repl_name = g:slimv_repl_dir . g:slimv_repl_file    " Name of the REPL buffer inside Vim
 let s:prompt = ''                                         " Lisp prompt in the last line
+let s:indent = ''                                         " Most recent indentation info
 let s:last_update = 0                                     " The last update time for the REPL buffer
 let s:last_size = 0                                       " The last size of the REPL buffer
 let s:save_updatetime = &updatetime                       " The original value for 'updatetime'
             " Found opening paren in the previous line, let's find out the function name
             let func = matchstr( line, '\<\k*\>', c )
             if func != '' && g:slimv_swank && s:swank_connected
-                " Ask function argument list from SWANK
-                let arglist = SlimvCommandGetResponse( ':operator-arglist', 'python swank_op_arglist("' . func . '")' )
-                if arglist != '' && match( arglist, '\c&body' ) >= 0
+                let s:indent = ''
+                silent execute 'python get_indent_info("' . func . '")'
+                if s:indent >= '0' && s:indent <= '9'
                     " Function has &body argument, so indent by 2 spaces from the opening '('
                     return c + 1
                 endif

ftplugin/swank.py

 # SWANK client for Slimv
 # swank.py:     SWANK client code for slimv.vim plugin
 # Version:      0.8.3
-# Last Change:  16 May 2011
+# Last Change:  17 May 2011
 # Maintainer:   Tamas Kovacs <kovisoft at gmail dot com>
 # License:      This file is placed in the public domain.
 #               No warranty, express or implied.
 
                 elif message == ':indentation-update':
                     for el in r[1]:
-                        indent_info[ unquote(el[0]) ] = int( el[2] )
+                        indent_info[ unquote(el[0]) ] = el[2]
 
                 elif message == ':new-package':
                     package = unquote( r[1] )
         return requote(pkg)
 
 def get_indent_info(name):
+    indent = ''
     if name in indent_info:
-        return indent_info[name]
-    else:
-        return 0
+        indent = indent_info[name]
+    vc = ":let s:indent='" + indent + "'"
+    vim.command(vc)
 
 ###############################################################################
 # Various SWANK messages
 ###############################################################################
 
 def swank_connection_info():
+    indent_info.clear()
     swank_rex(':connection-info', '(swank:connection-info)', 'nil', 't')
 
 def swank_create_repl():
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.