Giter Site home page Giter Site logo

cmp-zsh's Introduction

cmp-zsh

Zsh completion source for nvim-cmp

Requirements

zmodload zsh/zpty

Installation

Plug 'hrsh7th/nvim-cmp'
Plug 'tamago324/cmp-zsh'
Plug 'Shougo/deol.nvim'      " recommended to use together.

lua << EOF
require'cmp'.setup {
  -- ...
  sources = {
    { name = 'zsh' }
  }
}
EOF

Configuration

It saves compdump file in $CMP_ZSH_CACHE_DIR or $XDG_CACHE_HOME or $HOME/.cache directory.

In order to show completions defined in your zshrc you can setup cmp zsh like this. Note: This feature is experimental. If you enable it and don't get any results try disabling it.

require'cmp_zsh'.setup {
  zshrc = true, -- Source the zshrc (adding all custom completions). default: false
  filetypes = { "deoledit", "zsh" } -- Filetypes to enable cmp_zsh source. default: {"*"}
}

Alternatively you can use this trick (if sourcing your zshrc is very slow): Add the directory of the complete function to $FPATH in ~/.zshenv.

# completions
if [ -d $HOME/.zsh/comp ]; then
    export FPATH="$HOME/.zsh/comp:$FPATH"
fi

Credit

License

MIT

cmp-zsh's People

Contributors

jandamm avatar tamago324 avatar yuys13 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

cmp-zsh's Issues

How to set `cmp-zsh` completion source for `:!` commands (`nvim-cmp` stuff)?

I have wrote this issue to vimstackexchange but got no help.

I have next setup for nvim-cmp cmdline : completion:

cmp.setup.cmdline(':', {
	mapping = cmp.mapping.preset.cmdline(),
	sources = cmp.config.sources({
		-- { name = 'path' },
		{ name = 'zsh' },
	}, {
		{
			name = 'cmdline',
			option = {
				ignore_cmds = { 'Man', '!' }
			}
		}
	})
})

It uses zsh completion for paths and ! command, and cmdline completion for
vim : stuff.

How it started: I have been using path and cmdline completion at the start of my journey, but I quickly found out that when I try to :!mv ~/Downdloads/file with spaces.txt ./file.txt I get no space escaping (file\ with\ spaces.txt) from path. So I added the cmp-zsh plugin. In the current setup with zsh completion source I have next problems:

  • When I am writing some : commands I get the zsh and path completion. I want to get only path
  • When I am writing some :!<command> commands, I get no completion for <command> because no shell commands start from !.

SO there is the question: How to make the zsh source be accessible only within :!<command> ... and disable path for :? As You may have noticed, I have already disabled cmdline for :! commands.

The :h nvim-cmp does not contain definition for :! mode. Actually, it says:

*cmp.setup.cmdline* (cmdtype: string, config: cmp.ConfigSchema)
 Setup cmdline configuration for the specific type of command.
 See |getcmdtype()|.
 NOTE: nvim-cmp does not support the `=` command type.

So, there is the getcmdtype() definition:

getcmdtype()						*getcmdtype()*
  	Return the current command-line type. Possible return values
  	are:
  	    :	normal Ex command
  	    >	debug mode command |debug-mode|
  	    /	forward search command
  	    ?	backward search command
  	    @	|input()| command
  	    -	|:insert| or |:append| command
  	    =	|i_CTRL-R_=|
  	Only works when editing the command line, thus requires use of
  	|c_CTRL-\_e| or |c_CTRL-R_=| or an expression mapping.
  	Returns an empty string otherwise.
  	Also see |getcmdpos()|, |setcmdpos()| and |getcmdline()|.

It looks like there is no :! mode. Then how I can solve the

SO there is the question: How to make the zsh source be accessible only within :!<command> ... and disable path for :?

problem...?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.