Skip to content

Clojure syntax highlighting for Vim and Neovim.

License

Notifications You must be signed in to change notification settings

vito/bass.vim

 
 

Repository files navigation

work in progress - expect broken promises until this notice is removed!

Bass.vim

Bass syntax highlighting for Vim and Neovim.

Provides syntax highlighting and LSP configuration.

Installation

Plug 'vito/bass.vim'

Language server

A bass_lsp Lua library is provided to configure Bass with Neovim's lspconfig. Just add this somewhere in your vim config:

require'bass_lsp'.setup()

Tree-sitter

A Bass Tree-sitter grammar is available in addition to the old-fashioned syntax/bass.vim. Until it is merged into the official Neovim Tree-sitter repository, you'll need to load it like so:

require'bass_ts'.setup()

Then, run :TSInstall bass.

Configuration

Folding

Setting g:bass_fold to 1 will enable the folding of Bass code. Any list, vector or map that extends over more than one line can be folded using the standard Vim fold commands.

(Note that this option will not work with scripts that redefine the bracket regions, such as rainbow parenphesis plugins.)

Indent options

Bass indentation differs somewhat from traditional Lisps, due in part to the use of square and curly brackets, and otherwise by community convention. These conventions are not universally followed, so the Bass indent script offers a few configuration options.

(If the current Vim does not include searchpairpos(), the indent script falls back to normal 'lisp' indenting, and the following options are ignored.)

g:bass_maxlines

Sets maximum scan distance of searchpairpos(). Larger values trade performance for correctness when dealing with very long forms. A value of 0 will scan without limits. The default is 300.

g:bass_fuzzy_indent, g:bass_fuzzy_indent_patterns, g:bass_fuzzy_indent_blacklist

The 'lispwords' option is a list of comma-separated words that mark special forms whose subforms should be indented with two spaces.

For example:

(defn bad []
      "Incorrect indentation")

(defn good []
  "Correct indentation")

If you would like to specify 'lispwords' with a pattern instead, you can use the fuzzy indent feature:

" Default
let g:bass_fuzzy_indent = 1
let g:bass_fuzzy_indent_patterns = ['^with', '^def', '^let']
let g:bass_fuzzy_indent_blacklist = ['-fn$', '\v^with-%(meta|out-str|loading-context)$']

g:bass_fuzzy_indent_patterns and g:bass_fuzzy_indent_blacklist are lists of patterns that will be matched against the unqualified symbol at the head of a list. This means that a pattern like "^foo" will match all these candidates: foobar, my.ns/foobar, and #'foobar.

Each candidate word is tested for special treatment in this order:

  1. Return true if word is literally in 'lispwords'
  2. Return false if word matches a pattern in g:bass_fuzzy_indent_blacklist
  3. Return true if word matches a pattern in g:bass_fuzzy_indent_patterns
  4. Return false and indent normally otherwise

g:bass_special_indent_words

Some forms in Bass are indented such that every subform is indented by only two spaces, regardless of 'lispwords'. If you have a custom construct that should be indented in this idiosyncratic fashion, you can add your symbols to the default list below.

" Default
let g:bass_special_indent_words = 'deftype,defrecord,reify,proxy,extend-type,extend-protocol,letfn'

g:bass_align_multiline_strings

Align subsequent lines in multi-line strings to the column after the opening quote, instead of the same column.

For example:

(def default
  "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
  eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
  enim ad minim veniam, quis nostrud exercitation ullamco laboris
  nisi ut aliquip ex ea commodo consequat.")

(def aligned
  "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
   eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut
   enim ad minim veniam, quis nostrud exercitation ullamco laboris
   nisi ut aliquip ex ea commodo consequat.")

g:bass_align_subforms

By default, parenthesized compound forms that look like function calls and whose head subform is on its own line have subsequent subforms indented by two spaces relative to the opening paren:

(foo
  bar
  baz)

Setting this option to 1 changes this behaviour so that all subforms are aligned to the same column, emulating the default behaviour of clojure-mode.el:

(foo
 bar
 baz)

Contribute

Pull requests are welcome! A healthy CONTRIBUTING.md file will be written once I figure out how to contribute to this myself. Until then, wing it and open issues if you have any questions. Thanks!

Acknowledgements

Bass.vim stands on the shoulders of Clojure.vim which has its own history and acknowledgements.

License

Bass.vim is forked from Clojure.vim and retains the same Vim License.

  • Copyright © 2021, Alex Suraci suraci.alex@gmail.com
  • Copyright © 2020–2021, The clojure-vim contributors.
  • Copyright © 2013–2018, Sung Pae.
  • Copyright © 2008–2012, Meikel Brandmeyer.
  • Copyright © 2007–2008, Toralf Wittner.

See LICENSE for more details.

About

Clojure syntax highlighting for Vim and Neovim.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Vim Script 76.7%
  • Scheme 14.4%
  • Go 4.6%
  • Lua 3.1%
  • Makefile 1.2%