Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/David-Kunz/cmp-npm
An additional source for nvim-cmp to autocomplete packages and its versions
https://github.com/David-Kunz/cmp-npm
lua neovim nvim-cmp plugin
Last synced: about 2 months ago
JSON representation
An additional source for nvim-cmp to autocomplete packages and its versions
- Host: GitHub
- URL: https://github.com/David-Kunz/cmp-npm
- Owner: David-Kunz
- License: unlicense
- Created: 2021-10-24T13:15:02.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-07-02T02:41:05.000Z (6 months ago)
- Last Synced: 2024-11-10T09:34:12.406Z (about 2 months ago)
- Topics: lua, neovim, nvim-cmp, plugin
- Language: Lua
- Homepage:
- Size: 24.4 KB
- Stars: 113
- Watchers: 3
- Forks: 10
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmp-npm
This is an additional source for [nvim-cmp](https://github.com/hrsh7th/nvim-cmp), it allows you to
autocomplete [npm](https://npmjs.com/) packages and its versions.
The source is only active if you're in a `package.json` file.![demo-cmp-npm](https://user-images.githubusercontent.com/1009936/138598207-4855e5b5-1a88-4b02-b43a-c67143527f82.gif)
## Requirements
It needs the Neovim plugin [nvim-cmp](https://github.com/hrsh7th/nvim-cmp) and the [npm](https://npmjs.com/) command line tool.
## Installation
For [vim-plug](https://github.com/junegunn/vim-plug):
```
Plug 'nvim-lua/plenary.nvim'
Plug 'David-Kunz/cmp-npm'
```
For [packer](https://github.com/wbthomason/packer.nvim):
```
use {
'David-Kunz/cmp-npm',
requires = {
'nvim-lua/plenary.nvim'
}
}
```For [lazy.nvim](https://github.com/folke/lazy.nvim):
```
{
"David-Kunz/cmp-npm",
dependencies = { 'nvim-lua/plenary.nvim' },
ft = "json",
config = function()
require('cmp-npm').setup({})
end
}
```Run the `setup` function and add the source
```lua
require('cmp-npm').setup({})
cmp.setup({
...,
sources = {
{ name = 'npm', keyword_length = 4 },
...
}
})
```
(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:
```lua
{
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 (depends on `nvim-cmp`'s sorting algorithm).