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

Cannot get completion to work #307

Closed
iexos opened this issue May 23, 2023 · 11 comments
Closed

Cannot get completion to work #307

iexos opened this issue May 23, 2023 · 11 comments

Comments

@iexos
Copy link

iexos commented May 23, 2023

Description

I want to use the completion to find pages and cannot get it to work. I boiled it down to the absolut minimum, what am I missing?

  • vim -u ~/junkyard/init.vim ~/junkyard/index.md
  • start typing tes (or [tes or [x](tes,...) and press C-X C-O
  • expecting completion for test.md but nothing happens

Notes

  • :WikiPages, <cr> and other functionality works as expected
  • C-X C-O works for e.g. python with this init.vim
  • :verbose set omnifunc?: omnifunc=wiki#complete#omnicomplete Last set from ~/.local/share/nvim/plugged/wiki.vim/autoload/wiki/buffer.vim line 11

Minimal working example

Files:

$ ls ~/junkyard/wiki
index.md  test.md

neovim: NVIM v0.9.0

minimal init.vim:

let &rtp  = '~/.local/share/nvim/plugged/wiki.vim,' . &rtp
let g:wiki_root = '~/junkyard/wiki'
@lervag
Copy link
Owner

lervag commented May 24, 2023

I want to use the completion to find pages and cannot get it to work. I boiled it down to the absolut minimum, what am I missing?

Thanks, this is a very good minimal example! Here are some adjustments to simplify:

  • Create test folder:

    mkdir ~/test
    cd ~/test
    touch {index,foo,bar}.md
  • Create test.vim:

    let &rtp  = '~/.local/share/nvim/plugged/wiki.vim,' . &rtp
  • Use nvim --clean -u test.vim index.md to start neovim

  • Type [test]( then <c-x><c-o> and it should complete as expected. This works on my end.

The main change here is that we removed the global g:wiki_journal. I believe it is not really relevant here. Does the above work for you?

@iexos
Copy link
Author

iexos commented May 25, 2023

Thank you for the instructions! No, I just get

-- Omni completion (^O^N^P) Pattern not found

Here is the output of :CheckHealth with this invocation if its any help:


==============================================================================
nvim: require("nvim.health").check()

Configuration ~
- OK no issues found

Runtime ~
- OK $VIMRUNTIME: /usr/share/nvim/runtime

Performance ~
- OK Build type: Release

Remote Plugins ~
- OK Up to date

terminal ~
- key_backspace (kbs) terminfo entry: `key_backspace=^H`
- key_dc (kdch1) terminfo entry: `key_dc=\E[3~`
- $VTE_VERSION="7201"
- $TERM_PROGRAM="tmux"
- $COLORTERM="truecolor"

tmux ~
- OK escape-time: 1
- OK focus-events: on
- $TERM: screen-256color

==============================================================================
provider: health#provider#check

Clipboard (optional) ~
- OK Clipboard tool found: wl-copy

Python 3 provider (optional) ~
- `g:python3_host_prog` is not set.  Searching for python3 in the environment.
- Executable: /usr/bin/python3
- Python version: 3.11.3
- pynvim version: 0.4.3
- OK Latest pynvim is installed.

Python virtualenv ~
- OK no $VIRTUAL_ENV

Ruby provider (optional) ~
- Ruby: ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c5) [x86_64-linux]
- WARNING `neovim-ruby-host` not found.
  - ADVICE:
    - Run `gem install neovim` to ensure the neovim RubyGem is installed.
    - Run `gem environment` to ensure the gem bin directory is in $PATH.
    - If you are using rvm/rbenv/chruby, try "rehashing".
    - See :help |g:ruby_host_prog| for non-standard gem installations.
    - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim

Node.js provider (optional) ~
- Node.js: v20.2.0
- WARNING Missing "neovim" npm (or yarn, pnpm) package.
  - ADVICE:
    - Run in shell: npm install -g neovim
    - Run in shell (if you use yarn): yarn global add neovim
    - Run in shell (if you use pnpm): pnpm install -g neovim
    - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim

Perl provider (optional) ~
- WARNING "Neovim::Ext" cpan module is not installed
  - ADVICE:
    - See :help |provider-perl| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim

==============================================================================
vim.lsp: require("vim.lsp.health").check()

- LSP log level : WARN
- Log path: /home/xxx/.local/state/nvim/lsp.log
- Log size: 1865 KB

vim.lsp: Active Clients ~
- No active clients

==============================================================================
vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14

@lervag
Copy link
Owner

lervag commented May 26, 2023

Thank you for the instructions! No, I just get

-- Omni completion (^O^N^P) Pattern not found

That's strange. Which OS are you on? Which version of wiki.vim? If you are not on the latest version, then please update.

After following the steps outlined in my previuos comment, please do this and report the output:

cd ~/test
pwd   # does your $HOME have strange characters?
ls -l # or tree if you have it
cat test.vim
cat index.md

Next, do nvim --clean -u test.vim index.md and report the output of:

  • :echo b:wiki
  • :echo &omnifunc

@iexos
Copy link
Author

iexos commented May 28, 2023

I'm on a current Arch Linux

$ cd ~/.local/share/nvim/plugged/wiki.vim
$ git rev-parse HEAD
f9769a61bfb70ba0801b79174ed7f2f4d31fdf83
$ cd ~/test
$ pwd
/home/holger/test
$ ls -l
-rw-r--r-- 1 holger holger  0 May 25 09:39 bar.md
-rw-r--r-- 1 holger holger  0 May 25 09:39 foo.md
-rw-r--r-- 1 holger holger  0 May 25 09:39 index.md
-rw-r--r-- 1 holger holger 59 May 25 09:39 test.vim
$ nvim --clean -u test.vim index.md
$$ :echo b:wiki
{'root': '/home/holger/test', 'in_journal': 0, 'index_name': 'index', 'extension': 'md'}
$$ :echo &omnifunc
wiki#complete#omnicomplete

@lervag
Copy link
Owner

lervag commented May 28, 2023

Please also cat test.vim.

@lervag
Copy link
Owner

lervag commented May 28, 2023

But, it seems things look correct. I want to see cat test.vim just to be 100% sure there is no surprise misunderstanding.

The next step is to continue the steps earlier defined steps. After nvim --clean -u test.vim index.md, write [text here]( and then <c-x><c-o> - does it still say "Pattern not found"? (I assume it does, since we did not change anything yet.)

Now, perhaps can we do some simple print debugging together. Let's start here:

let l:cnum = match(a:line, '\](\zs[^)]\{-}$')
if l:cnum < 0 | return -1 | endif

Add a line unsilent echom "DEBUG HERE" l:cnum before line 139; repeat the test. What is the output? You might need to do :messages to see the message after you get "Pattern not found".

I would expect l:cnum to be a positive number. If it is, then the next position we want to inspect is here:

let l:candidates = self.is_anchor
\ ? self.complete_anchor(a:regex)
\ : self.complete_page(a:regex)
return map(l:candidates, "{'word': v:val, 'menu': '[wiki]'}")

@iexos
Copy link
Author

iexos commented May 29, 2023

Ok, I debugged a bit further and found that fd tries to be smart by reading the .gitignore in my home dir which excludes everything but a few versioned config files. Simply replacing fd with fd -I makes completion work.

https://github.com/lervag/wiki.vim/blob/f9769a61bfb70ba0801b79174ed7f2f4d31fdf83/autoload/wiki/complete.vim#LL117C8-L117C8

@lervag
Copy link
Owner

lervag commented May 29, 2023

Oh, I did not think of that. Thanks! I'll push an update immediately!

lervag added a commit that referenced this issue May 29, 2023
@lervag
Copy link
Owner

lervag commented May 29, 2023

Let me know if this fixes it for you. If not, feel free to reopen!

@lervag lervag closed this as completed May 29, 2023
@iexos
Copy link
Author

iexos commented May 29, 2023

Fix works, thank you!

@lervag
Copy link
Owner

lervag commented May 29, 2023

Great, glad to hear it! Thanks for digging in and noticing the issue!

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

No branches or pull requests

2 participants