Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buffer source doesn't work #335

Closed
sainnhe opened this issue Jan 13, 2019 · 12 comments
Closed

Buffer source doesn't work #335

sainnhe opened this issue Jan 13, 2019 · 12 comments

Comments

@sainnhe
Copy link

sainnhe commented Jan 13, 2019

Demo

This is how coc behaves:

coc

And this is how ncm2 behaves:

ncm2

What I expect: complete buffer words like ncm2

My config

init.vim

call plug#begin('~/.cache/vim/plugins')

if g:VIM_Snippets ==# 'ultisnips'
    Plug 'SirVer/ultisnips'
    Plug 'honza/vim-snippets'
elseif g:VIM_Snippets ==# 'neosnippet'
    Plug 'Shougo/neosnippet.vim'
    Plug 'Shougo/neosnippet-snippets'
    Plug 'honza/vim-snippets'
elseif g:VIM_Snippets ==# 'coc-snippets'
    Plug 'SirVer/ultisnips'
    Plug 'honza/vim-snippets'
endif

Plug 'Shougo/neco-vim' | Plug 'neoclide/coc-neco'
Plug 'Shougo/neoinclude.vim' | Plug 'jsfaint/coc-neoinclude'
Plug 'neoclide/coc.nvim', {'do': 'proxychains yarn install'}
Plug 'iamcco/coc-action-source.nvim'

call plug#end()

    "{{{coc-init
    if g:VIM_Snippets ==# 'ultisnips'
        let g:Coc_Snippet = 'coc-ultisnips'
    elseif g:VIM_Snippets ==# 'coc-snippets'
        let g:Coc_Snippet = 'coc-snippets'
    endif
    call coc#add_extension(
                \   'coc-dictionary', 'coc-word', 'coc-emoji',
                \   g:Coc_Snippet, 'coc-tag',
                \   'coc-html', 'coc-css',
                \   'coc-emmet', 'coc-pyls', 'coc-rls',
                \   'coc-jest', 'coc-json'
                \   )
    "}}}
    "{{{coc-settings
    augroup CocAu
        autocmd!
        autocmd CursorHoldI,CursorMovedI * call CocAction('showSignatureHelp')
        autocmd User CocJumpPlaceholder call CocActionAsync('showSignatureHelp')
        autocmd InsertEnter * call CocMapping()
    augroup END
    set completeopt=noinsert,noselect,menuone
    highlight CocErrorHighlight ctermfg=Gray guifg=#8d8d8d
    "}}}
    "{{{coc-mappings
    if g:VIM_Snippets ==# 'coc-snippets'
        let g:UltiSnipsJumpForwardTrigger       = '<A-z>``````j'
        let g:UltiSnipsJumpBackwardTrigger      = '<A-z>``````k'
    endif
    function! CocMapping()
        inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
        inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<C-n>"
        inoremap <expr> <C-j> pumvisible() ? "\<C-y>" : "\<C-j>"
        inoremap <expr> <up> pumvisible() ? "\<Space>\<Backspace>\<up>" : "\<up>"
        inoremap <expr> <down> pumvisible() ? "\<Space>\<Backspace>\<down>" : "\<down>"
        inoremap <expr> <left> pumvisible() ? "\<Space>\<Backspace>\<left>" : "\<left>"
        inoremap <expr> <right> pumvisible() ? "\<Space>\<Backspace>\<right>" : "\<right>"
        inoremap <expr> <CR> pumvisible() ? "\<Space>\<Backspace>\<CR>" : "\<CR>"
        inoremap <expr> <C-z> pumvisible() ? "\<C-e>" : "<C-z>"
    endfunction
    "}}}

coc-settings.json

{
    "coc.preferences.snippetIndicator": "\ue796",
    "coc.preferences.minTriggerInputLength": 1,
    "coc.preferences.diagnostic.errorSign": "\uf65b",
    "coc.preferences.diagnostic.warningSign": "\uf421",
    "coc.preferences.diagnostic.infoSign": "",
    "coc.preferences.diagnostic.hintSign": "",
    "coc.preferences.diagnostic.displayByAle": true,
    "$schema": "./data/schema.json",
    "coc.preferences.autoTrigger": "always",
    "coc.preferences.snippets.enable": true,
    "coc.preferences.colorSupport": true,
    "coc.preferences.hoverTarget": "preview",
    "coc.preferences.maxColorCount": 1000,
    "coc.preferences.triggerAfterInsertEnter": false,
    "coc.preferences.acceptSuggestionOnCommitCharacter": false,
    "coc.preferences.triggerSignatureHelp": true,
    "coc.preferences.timeout": 2000,
    "coc.preferences.noselect": true,
    "coc.preferences.formatOnType": false,
    "coc.preferences.parseKeywordsLimitLines": 5000,
    "coc.preferences.hyphenAsKeyword": true,
    "coc.preferences.jumpCommand": "edit",
    "coc.preferences.diagnostic.locationlist": true,
    "coc.preferences.diagnostic.enable": true,
    "coc.preferences.diagnostic.level": "hint",
    "coc.preferences.diagnostic.enableMessage": true,
    "coc.preferences.diagnostic.highlightOffset": 1000,
    "coc.preferences.diagnostic.signOffset": 1000,
    "coc.preferences.codeLens.enable": true,
    "coc.preferences.codeLens.separator": "",
    "coc.source.emmet.priority": 1,
    "coc.source.ultisnips.priority": 2,
    "coc.source.snippets.priority": 2,
    "coc.source.around.priority": 10,
    "coc.source.buffer.priority": 11,
    "coc.source.file.priority": 12,
    "coc.source.dictionary.priority": 20,
    "coc.source.word.priority": 21,
    "coc.source.emoji.priority": 22,
    "coc.source.around.enable": true,
    "coc.source.around.shortcut": "A",
    "coc.source.buffer.enable": true,
    "coc.source.buffer.shortcut": "B",
    "coc.source.buffer.ignoreGitignore": true,
    "coc.source.file.enable": true,
    "coc.source.file.shortcut": "F",
    "coc.source.file.triggerCharacters": ["/"],
    "coc.source.file.trimSameExts": [".ts", ".js"],
    "coc.source.file.ignoreHidden": true,
    "coc.source.file.ignorePatterns": [],
    "coc.source.dictionary.enable": true,
    "coc.source.dictionary.shortcut": "D",
    "coc.source.dictionary.filetypes": ["markdown"],
    "coc.source.word.enable": true,
    "coc.source.word.shortcut": "W",
    "coc.source.word.filetypes": ["markdown"],
    "coc.source.emoji.enable": true,
    "coc.source.emoji.shortcut": "E",
    "coc.source.emoji.filetypes": ["markdown"],
    "coc.source.ultisnips.enable": true,
    "coc.source.ultisnips.shortcut": "S",
    "coc.source.snippets.enable": true,
    "coc.source.snippets.shortcut": "S",
    "coc.source.snippets.extends": {
        "cpp": ["c"],
        "javascriptreact": ["javascript"],
        "typescript": ["javascript"]
    },
    "coc.source.snippets.ultisnips.enable": true,
    "coc.source.snippets.ultisnips.pythonVersion": 3,
    "coc.source.snippets.ultisnips.directories": ["UltiSnips"],
    "coc.source.snippets.loadFromExtensions": true,
    "coc.source.emmet.showExpandedAbbreviation": true,
    "coc.source.emmet.showAbbreviationSuggestions": true,
    "coc.source.emmet.includeLanguages": {"vue-html": "html", "javascript": "javascriptreact"},
    "http.proxy": "",
    "http.proxyStrictSSL": true,
    "languageserver": {
        "clangd": {
            "command": "ccls",
            "filetypes": ["c", "cpp", "objc", "objcpp"],
            "initializationOptions": {
                "cacheDirectory": "/tmp/ccls"
            }
        },
        "bash": {
            "command": "bash-language-server",
            "filetypes": ["sh"],
            "args": ["start"]
        },
        "MPLS": {
            "command": "dotnet",
            "args": ["exec", "/home/sainnhe/.cache/python-language-server/output/bin/Release/Microsoft.Python.LanguageServer.dll"],
            "filetypes": ["python"],
            "initializationOptions": {
                "interpreter": {
                    "properties": {
                        "InterpreterPath": "/bin/python3",
                        "UseDefaultDatabase": true,
                        "Version": "3.7.1"
                    }
                }
            }
        }
    }
}
@chemzqm
Copy link
Member

chemzqm commented Jan 13, 2019

Can't reproduce, looks like your around source is disabled, consider checkout the log: https://github.com/neoclide/coc.nvim/wiki/Debug-coc.nvim#using-logger-module

@chemzqm chemzqm closed this as completed Jan 13, 2019
@sainnhe
Copy link
Author

sainnhe commented Jan 13, 2019

here is the log
coc-nvim.log

but I still have no idea what is going on, I have already enabled around source

    "coc.source.around.enable": true,

@chemzqm
Copy link
Member

chemzqm commented Jan 13, 2019

There's no line contains around, it could be disabled by use vim function like coc#config.
Try coc.nvim with minimal vimrc.

@sainnhe
Copy link
Author

sainnhe commented Jan 13, 2019

I've tried a minimal vimrc provided by README.md, but it dosen't work still.

And meanwhile, I find that the around source works intermittently. it works in some situations, but fails sometimes.

But the buffer source doesn't work all the time.

Maybe this is not a common problem, I'm trying to get ncm2-coc to work, hope this would solve my problem.

@chemzqm
Copy link
Member

chemzqm commented Jan 13, 2019

Coc doesn't generate keywords for git ignored files and none empty filetype.
Also check your iskeywords option.

@sainnhe
Copy link
Author

sainnhe commented Jan 13, 2019

OK, I find the reason.
That's because I create a "dotfiles" repo which is located in $HOME, and exclude all files

~/.git/info/exclude

*

and then use git add -f to add some dotfiles. So coc only works when edit those dotfiles.
Dotfiles - ArchWiki

Is there any option to force coc to generate keywords for git ignored files in a certain repo?

@chemzqm
Copy link
Member

chemzqm commented Jan 13, 2019

I've made coc generate words for ignored files, you can use "coc.source.buffer.ignoreGitignore" to toggle those words in completion.

@sainnhe
Copy link
Author

sainnhe commented Jan 14, 2019

Thanks for your work, but unfortunately, it still doesn't work.
I have already upgraded coc to latest version, and tried to toggle

"coc.source.buffer.ignoreGitignore": true,
"coc.source.buffer.ignoreGitignore": false,

But both around and buffer source still don't work when I edit git ignored files.
Personally, I thought there should be a "coc.source.around.ignoreGitignore" option to toggle around source in completion, because around source still seems to be disabled when edit git ignored files.

@chemzqm
Copy link
Member

chemzqm commented Jan 14, 2019

No need for "coc.source.around.ignoreGitignore", it always return words of current buffer.
I think you didn't compile code from master branch, you have to not use tag:* in Plug command.

@sainnhe
Copy link
Author

sainnhe commented Jan 14, 2019

It works, thanks!

@Pablo1107
Copy link

Coc doesn't generate keywords for git ignored files and none empty filetype.
Also check your iskeywords option.

@chemzqm Sorry to necrobump this issue, is there a way to configure coc so it does not ignore none empty filetype? I imagine this was added for performance sake, but if I type some keyword on another file I want to reference it on the current one if I have both buffers opened.

@chemzqm
Copy link
Member

chemzqm commented Jun 2, 2020

@Pablo1107 no, it sucks, you can simply invoke <C-n> for keywords completion of vim, it even works without any plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants