Skip to content

An additional source for nvim-cmp to autocomplete clojure libraries and its versions

License

Notifications You must be signed in to change notification settings

k13gomez/cmp-clojure-deps

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cmp-clojure-deps

This is an additional source for nvim-cmp, it allows you to autocomplete clojure library versions. The source is only active if you're in a deps.edn file.

cmp-clojure-demo

Requirements

It needs the Neovim plugin nvim-cmp and tools-deps-helper command line tool compiled and in your path. The tools-deps-helper tool has been linked as a submodule but it needs to be compiled and copied somewhere in your path.

Installation

For vim-plug:

Plug 'nvim-lua/plenary.nvim'
Plug 'k13gomez/cmp-clojure-deps'

For packer:

use {
  'k13gomez/cmp-clojure-deps',
  requires = {
    'nvim-lua/plenary.nvim'
  }
}

For lazy.nvim:

{
  "k13gomez/cmp-clojure-deps",
  dependencies = { 'nvim-lua/plenary.nvim' },
  ft = "json",
  config = function()
    require('cmp-clojure-deps').setup({})
  end
}

Run the setup function and add the source

require('cmp-clojure-deps').setup({})

cmp.setup({
  ...,
  sources = {
    { name = 'clojure-tools-deps' },
    ...
  },
  sorting = {
    -- tweak sorting as needed, these are reasonable settings
    comparators = {
      compare.exact,
      compare.score,
      compare.order, -- this is recommended for correct sorting
      compare.offset,
      compare.recently_used,
      compare.locality,
      compare.kind,
      compare.sort_text,
      compare.length
    }
  },
  ...
})

(in Vimscript, make sure to add lua << EOF before and EOF after the lua code)

The setup function accepts an options table which defaults to:

{
  ignore = {},
  only_semantic_versions = false,
  only_latest_version = false
}
  • ignore (table): Allows you to filter out all versions which match one of its entries, e.g. ignore = { 'beta', 'rc' }.
  • only_semantic_versions (Boolean): If true, will filter out all versions which don't follow the major.minor.patch schema.
  • only_latest_version (Boolean): If true, will only show latest release version.

Limitations

The versions are not correctly sorted unless you configure the nvim-cmp compare.order sorter.

About

An additional source for nvim-cmp to autocomplete clojure libraries and its versions

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Lua 100.0%