Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

Add setting for removing file extension from filepath completion. #184

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/nvim-completion-manager.txt
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,11 @@ g:cm_completeopt
The value of 'completeopt' when NCM is active.
Default: "menu,menuone,noinsert,noselect"

*g:cm_filepath_strip_extension*
g:cm_filepath_strip_extension
Strip file extension when completing filepaths.
Default: 0

==============================================================================
5. API *NCM-API*

Expand Down
2 changes: 2 additions & 0 deletions plugin/cm.vim
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ let g:cm_refresh_length = get(g:, 'cm_refresh_length', get(g:, 'cm_refresh_defau

let g:cm_completeopt=get(g:,'cm_completeopt','menu,menuone,noinsert,noselect')

let g:cm_filepath_strip_extension = get(g:,'cm_filepath_strip_extension', 0)

au User CmSetup if exists('g:did_plugin_ultisnips') | call cm#sources#ultisnips#init() | endif
au User CmSetup if exists('g:loaded_neosnippet') | call cm#sources#neosnippet#init() | endif
au User CmSetup if exists('g:snipMateSources') | call cm#sources#snipmate#init() | endif
Expand Down
6 changes: 6 additions & 0 deletions pythonx/cm_sources/cm_filepath.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Source(Base):

def __init__(self, nvim):
super(Source, self).__init__(nvim)
self._strip_extension = self.nvim.vars['cm_filepath_strip_extension']

def cm_refresh(self, info, ctx):

Expand Down Expand Up @@ -73,6 +74,11 @@ def cm_refresh(self, info, ctx):
seen.add(p)
word = os.path.basename(p)
menu = '~' + label
if self._strip_extension:
[fname, ext] = os.path.splitext(word)
word = fname
if ext:
menu += ' [' + ext[1:] + ']'
if expanded:
menu += '~ ' + p
matches.append(dict(word=word, icase=1, menu=menu, dup=1))
Expand Down