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.
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.
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): Iftrue
, will filter out all versions which don't follow themajor.minor.patch
schema.only_latest_version
(Boolean): Iftrue
, will only show latest release version.
The versions are not correctly sorted unless you configure the nvim-cmp compare.order
sorter.