clojure plugin for neovim

README.md

clojure.nvim #

Clojure syntax highlighting and indentation for Neovim, based on Tree-sitter.

requires tree-sitter cli installed and whatever else i guess.

features #

this is a classic vim filetype plugin that sets filetypes, iskeyword, configures syntax highlighting, and other lil features. it's a wip tho

syntax highlighting #

this is done with tree-sitter. when the plugin first loads, it uses the tree-sitter cli to compile the tree-sitter-clojure grammar, and then neovim loads it automatically to use for all clojure files.

indentation #

idk yet. vim's indentexpr system is weird, nvim-treesitter's indentation system is also kind of weird, i gotta figuret this one out quick.

commands #

following up on my coc.nvim plugin coc-clojure, this borrows all of the keymap and command features from coc.nvim style to native vim.lsp style.

every refactoring command listed on the refactoring page is available. they are provided with the CljLsp prefix:

  • CljLspAddMissingImport
  • CljLspAddMissingLibspec
  • CljLspAddRequireSuggestion
  • CljLspBackward
  • CljLspBackwardBarf
  • CljLspBackwardSelect
  • CljLspBackwardSlurp
  • CljLspChangeColl
  • CljLspChangeCollection
  • CljLspCleanNs
  • CljLspCreateFunction
  • CljLspCreateTest
  • CljLspCursorInfo
  • CljLspCycleColl
  • CljLspCyclePrivacy
  • CljLspDemoteFn
  • CljLspDestructureKeys
  • CljLspDocs
  • CljLspDragBackward
  • CljLspDragForward
  • CljLspDragParamBackward
  • CljLspDragParamForward
  • CljLspExpandLet
  • CljLspExtractFunction
  • CljLspExtractToDef
  • CljLspForward
  • CljLspForwardBarf
  • CljLspForwardSelect
  • CljLspForwardSlurp
  • CljLspGetInAll
  • CljLspGetInLess
  • CljLspGetInMore
  • CljLspGetInNone
  • CljLspInlineSymbol
  • CljLspIntroduceLet
  • CljLspKillSexp
  • CljLspMoveCollEntryDown
  • CljLspMoveCollEntryUp
  • CljLspMoveForm
  • CljLspMoveToLet
  • CljLspProjectTree
  • CljLspPromoteFn
  • CljLspRaiseSexp
  • CljLspReplaceReferAllWithAlias
  • CljLspReplaceReferAllWithRefer
  • CljLspResolveMacroAs
  • CljLspRestructureKeys
  • CljLspServerInfo
  • CljLspSortClauses
  • CljLspSortMap
  • CljLspSuppressDiagnostic
  • CljLspTestTree
  • CljLspThreadFirst
  • CljLspThreadFirstAll
  • CljLspThreadLast
  • CljLspThreadLastAll
  • CljLspUnwindAll
  • CljLspUnwindThread

keymaps #

all of the above are also given <leader>cl[SHORTCUT] keymaps as defined by the clojure-lsp website.

installation #

idk use vim.pack.add() and then call require('clojure-nvim').setup().

has a dependency on text-case.nvim, so if you install this, you gotta install (and setup) that one too.

settings #

pass in a table, it'll be deep merged with the defaults. dashes are used because this plugin is written in fennel and dashes are better than underscores.

here's the defaults:

{
  compile = true,
  register = true,
  lsp = {
    enable = true,
    ["register-keymaps"] = true,
    ["register-commands"] = true,
    -- this is passed unchanged to vim.lsp.config, so you can add what you want
    config = {
      cmd = {"clojure-lsp"},
      filetypes = {"clojure"},
      root_markers = {"project.clj", "deps.edn", "build.boot", "shadow-cljs.edn", "bb.edn", ".git"},
    },
  },
}

license #

Original code is copyright © Noah Bogart under the Mozilla Public License version 2.0.

Vendored code is copied under their original licenses, as laid out in the licenses/ folder.